mtp: Rename link_no to nr, add a name like for the other commands
This commit is contained in:
parent
6c0b2e570c
commit
5a34c7f6f8
|
@ -95,6 +95,8 @@ struct mtp_link_set {
|
||||||
*/
|
*/
|
||||||
struct mtp_link {
|
struct mtp_link {
|
||||||
struct llist_head entry;
|
struct llist_head entry;
|
||||||
|
int nr;
|
||||||
|
char *name;
|
||||||
|
|
||||||
int pcap_fd;
|
int pcap_fd;
|
||||||
struct mtp_link_set *set;
|
struct mtp_link_set *set;
|
||||||
|
@ -109,7 +111,6 @@ struct mtp_link {
|
||||||
int blocked;
|
int blocked;
|
||||||
|
|
||||||
int first_sls;
|
int first_sls;
|
||||||
int link_no;
|
|
||||||
int sltm_pending;
|
int sltm_pending;
|
||||||
int was_up;
|
int was_up;
|
||||||
|
|
||||||
|
|
|
@ -116,31 +116,31 @@ static int udp_read_cb(struct bsc_fd *fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hdr->data_type == UDP_DATA_RETR_COMPL || hdr->data_type == UDP_DATA_RETR_IMPOS) {
|
if (hdr->data_type == UDP_DATA_RETR_COMPL || hdr->data_type == UDP_DATA_RETR_IMPOS) {
|
||||||
LOGP(DINP, LOGL_ERROR, "Link retrieval done on %s/%d.\n",
|
LOGP(DINP, LOGL_ERROR, "Link retrieval done on %d/%s of %d/%s.\n",
|
||||||
link->set->name, link->link_no);
|
link->nr, link->name, link->set->nr, link->set->name);
|
||||||
mtp_link_failure(link);
|
mtp_link_failure(link);
|
||||||
goto exit;
|
goto exit;
|
||||||
} else if (hdr->data_type == UDP_DATA_LINK_UP) {
|
} else if (hdr->data_type == UDP_DATA_LINK_UP) {
|
||||||
LOGP(DINP, LOGL_NOTICE, "Link of %s/%d is up.\n",
|
LOGP(DINP, LOGL_NOTICE, "Link of %d/%s of %d/%s is up.\n",
|
||||||
link->set->name, link->link_no);
|
link->nr, link->name, link->set->nr, link->set->name);
|
||||||
mtp_link_up(link);
|
mtp_link_up(link);
|
||||||
goto exit;
|
goto exit;
|
||||||
} else if (hdr->data_type == UDP_DATA_LINK_DOWN) {
|
} else if (hdr->data_type == UDP_DATA_LINK_DOWN) {
|
||||||
LOGP(DINP, LOGL_NOTICE, "Link of %s/%d is down.\n",
|
LOGP(DINP, LOGL_NOTICE, "Link of %d/%s of %d/%s is down.\n",
|
||||||
link->set->name, link->link_no);
|
link->nr, link->name, link->set->nr, link->set->name);
|
||||||
mtp_link_failure(link);
|
mtp_link_failure(link);
|
||||||
goto exit;
|
goto exit;
|
||||||
} else if (hdr->data_type > UDP_DATA_MSU_PRIO_3) {
|
} else if (hdr->data_type > UDP_DATA_MSU_PRIO_3) {
|
||||||
LOGP(DINP, LOGL_ERROR, "Link failue on %s/%d.\n",
|
LOGP(DINP, LOGL_ERROR, "Link failue on %d/%s of %d/%s.\n",
|
||||||
link->set->name, link->link_no);
|
link->nr, link->name, link->set->nr, link->set->name);
|
||||||
mtp_link_failure(link);
|
mtp_link_failure(link);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* throw away data as the link is down */
|
/* throw away data as the link is down */
|
||||||
if (link->set->available == 0) {
|
if (link->set->available == 0) {
|
||||||
LOGP(DINP, LOGL_ERROR, "Link %s/%d is down. Not forwarding.\n",
|
LOGP(DINP, LOGL_ERROR, "Link %d/%s of %d/%s is down. Not forwarding.\n",
|
||||||
link->set->name, link->link_no);
|
link->nr, link->name, link->set->nr, link->set->name);
|
||||||
rc = 0;
|
rc = 0;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -148,16 +148,19 @@ static int udp_read_cb(struct bsc_fd *fd)
|
||||||
length = ntohl(hdr->data_length);
|
length = ntohl(hdr->data_length);
|
||||||
if (length + sizeof(*hdr) > (unsigned int) rc) {
|
if (length + sizeof(*hdr) > (unsigned int) rc) {
|
||||||
LOGP(DINP, LOGL_ERROR,
|
LOGP(DINP, LOGL_ERROR,
|
||||||
"The MSU payload does not fit: %u + %u > %d on %s/%d.\n",
|
"The MSU payload does not fit: %u + %u > %d on link %d/%s of %d/%s.\n",
|
||||||
length, sizeof(*hdr), rc, link->set->name, link->link_no);
|
length, sizeof(*hdr), rc,
|
||||||
|
link->nr, link->name, link->set->nr, link->set->name);
|
||||||
|
rc = 0;
|
||||||
rc = -1;
|
rc = -1;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg->l2h = msgb_put(msg, length);
|
msg->l2h = msgb_put(msg, length);
|
||||||
|
|
||||||
LOGP(DINP, LOGL_DEBUG, "MSU data on: %s/%d data %s.\n",
|
LOGP(DINP, LOGL_DEBUG, "MSU data on link %d/%s of %d/%s data %s.\n",
|
||||||
link->set->name, link->link_no, hexdump(msg->data, msg->len));
|
link->nr, link->name, link->set->nr, link->set->name,
|
||||||
|
hexdump(msg->data, msg->len));
|
||||||
mtp_handle_pcap(link, NET_IN, msg->l2h, msgb_l2len(msg));
|
mtp_handle_pcap(link, NET_IN, msg->l2h, msgb_l2len(msg));
|
||||||
mtp_link_set_data(link, msg);
|
mtp_link_set_data(link, msg);
|
||||||
|
|
||||||
|
@ -211,8 +214,8 @@ static int udp_link_write(struct mtp_link *link, struct msgb *msg)
|
||||||
msg->cb[0] = ulnk->link_index;
|
msg->cb[0] = ulnk->link_index;
|
||||||
|
|
||||||
if (write_queue_enqueue(&ulnk->data->write_queue, msg) != 0) {
|
if (write_queue_enqueue(&ulnk->data->write_queue, msg) != 0) {
|
||||||
LOGP(DINP, LOGL_ERROR, "Failed to enqueue msg on %s/%d.\n",
|
LOGP(DINP, LOGL_ERROR, "Failed to enqueue msg on link %d/%s of %d/%s.\n",
|
||||||
link->set->name, link->link_no);
|
link->nr, link->name, link->set->nr, link->set->name);
|
||||||
msgb_free(msg);
|
msgb_free(msg);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -322,8 +325,9 @@ void snmp_mtp_callback(struct snmp_mtp_session *session,
|
||||||
link = ulink->base;
|
link = ulink->base;
|
||||||
|
|
||||||
if (res == SNMP_STATUS_TIMEOUT && !link->blocked) {
|
if (res == SNMP_STATUS_TIMEOUT && !link->blocked) {
|
||||||
LOGP(DINP, LOGL_ERROR, "Failed to restart link: %s/%d\n",
|
LOGP(DINP, LOGL_ERROR,
|
||||||
link->set->name, link->link_no);
|
"Failed to restart link %d/%s of linkset %d/%s\n",
|
||||||
|
link->nr, link->name, link->set->nr, link->set->name);
|
||||||
udp_link_reset(link);
|
udp_link_reset(link);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -343,12 +347,15 @@ void snmp_mtp_callback(struct snmp_mtp_session *session,
|
||||||
link->link_activate.data = ulink;
|
link->link_activate.data = ulink;
|
||||||
bsc_schedule_timer(&link->link_activate, ulink->reset_timeout, 0);
|
bsc_schedule_timer(&link->link_activate, ulink->reset_timeout, 0);
|
||||||
LOGP(DINP, LOGL_NOTICE,
|
LOGP(DINP, LOGL_NOTICE,
|
||||||
"Will bring up link %s/%d in %d seconds.\n",
|
"Will bring up link %d/%s of linkset %d/%s in %d seconds.\n",
|
||||||
link->set->name, link->link_no, ulink->reset_timeout);
|
link->nr, link->name,
|
||||||
|
link->set->nr, link->set->name,
|
||||||
|
ulink->reset_timeout);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOGP(DINP, LOGL_ERROR, "Unknown event %d on %s/%d.\n",
|
LOGP(DINP, LOGL_ERROR,
|
||||||
area, link->set->name, link->link_no);
|
"Unknown event %d on %d/%s of linkset %d/%s.\n",
|
||||||
|
area, link->nr, link->name, link->set->nr, link->set->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,8 +64,9 @@ void mtp_link_up(struct mtp_link *link)
|
||||||
int one_up;
|
int one_up;
|
||||||
|
|
||||||
if (link->blocked) {
|
if (link->blocked) {
|
||||||
LOGP(DINP, LOGL_ERROR, "Ignoring link up on blocked link %s/%d.\n",
|
LOGP(DINP, LOGL_ERROR,
|
||||||
link->set->name, link->link_no);
|
"Ignoring link up on blocked link %d/%s of linkset %d/%s.\n",
|
||||||
|
link->nr, link->name, link->set->nr, link->set->name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -434,8 +434,9 @@ int mtp_link_set_data(struct mtp_link *link, struct msgb *msg)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!link->set->running) {
|
if (!link->set->running) {
|
||||||
LOGP(DINP, LOGL_ERROR, "Link is not running. Call mtp_link_reset first: %s/%d\n",
|
LOGP(DINP, LOGL_ERROR,
|
||||||
link->set->name, link->link_no);
|
"Link %d/%s of Linkse %d/%s is not running. Call mtp_link_reset first.\n",
|
||||||
|
link->nr, link->name, link->set->nr, link->set->name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ static struct msgb *mtp_create_sltm(struct mtp_link *link)
|
||||||
|
|
||||||
hdr = (struct mtp_level_3_hdr *) msg->l2h;
|
hdr = (struct mtp_level_3_hdr *) msg->l2h;
|
||||||
hdr->ser_ind = MTP_SI_MNT_REG_MSG;
|
hdr->ser_ind = MTP_SI_MNT_REG_MSG;
|
||||||
hdr->addr = MTP_ADDR(link->link_no % 16, link->set->dpc, link->set->opc);
|
hdr->addr = MTP_ADDR(link->nr % 16, link->set->dpc, link->set->opc);
|
||||||
|
|
||||||
mng = (struct mtp_level_3_mng *) msgb_put(msg, sizeof(*mng));
|
mng = (struct mtp_level_3_mng *) msgb_put(msg, sizeof(*mng));
|
||||||
mng->cmn.h0 = MTP_TST_MSG_GRP;
|
mng->cmn.h0 = MTP_TST_MSG_GRP;
|
||||||
|
@ -63,8 +63,8 @@ static void mtp_send_sltm(struct mtp_link *link)
|
||||||
link->sltm_pending = 1;
|
link->sltm_pending = 1;
|
||||||
msg = mtp_create_sltm(link);
|
msg = mtp_create_sltm(link);
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
LOGP(DINP, LOGL_ERROR, "Failed to allocate SLTM on %s/%d.\n",
|
LOGP(DINP, LOGL_ERROR, "Failed to allocate SLTM on link %d/%s of %d/%s.\n",
|
||||||
link->set->name, link->link_no);
|
link->nr, link->name, link->set->nr, link->set->name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,15 +79,15 @@ static void mtp_sltm_t1_timeout(void *_link)
|
||||||
|
|
||||||
if (link->slta_misses == 0) {
|
if (link->slta_misses == 0) {
|
||||||
LOGP(DINP, LOGL_ERROR,
|
LOGP(DINP, LOGL_ERROR,
|
||||||
"No SLTM response on link %s/%d.\n",
|
"No SLTM response on link %d/%s of %d/%s.\n",
|
||||||
link->set->name, link->link_no);
|
link->nr, link->name, link->set->nr, link->set->name);
|
||||||
++link->slta_misses;
|
++link->slta_misses;
|
||||||
mtp_send_sltm(link);
|
mtp_send_sltm(link);
|
||||||
bsc_schedule_timer(&link->t1_timer, MTP_T1);
|
bsc_schedule_timer(&link->t1_timer, MTP_T1);
|
||||||
} else {
|
} else {
|
||||||
LOGP(DINP, LOGL_ERROR,
|
LOGP(DINP, LOGL_ERROR,
|
||||||
"Two missing SLTAs on link %s/%d.\n",
|
"Two missing SLTAs on link %d/%s of %d/%s.\n",
|
||||||
link->set->name, link->link_no);
|
link->nr, link->name, link->set->nr, link->set->name);
|
||||||
bsc_del_timer(&link->t2_timer);
|
bsc_del_timer(&link->t2_timer);
|
||||||
mtp_link_failure(link);
|
mtp_link_failure(link);
|
||||||
}
|
}
|
||||||
|
@ -99,8 +99,8 @@ static void mtp_sltm_t2_timeout(void *_link)
|
||||||
|
|
||||||
if (!link->set->running) {
|
if (!link->set->running) {
|
||||||
LOGP(DINP, LOGL_INFO,
|
LOGP(DINP, LOGL_INFO,
|
||||||
"The linkset is not active. Stopping the link test on %s/%d.\n",
|
"The linkset is not active. Stopping link test on %d/%s of %d/%s.\n",
|
||||||
link->set->name, link->link_no);
|
link->nr, link->name, link->set->nr, link->set->name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,8 +110,8 @@ static void mtp_sltm_t2_timeout(void *_link)
|
||||||
bsc_schedule_timer(&link->t1_timer, MTP_T1);
|
bsc_schedule_timer(&link->t1_timer, MTP_T1);
|
||||||
|
|
||||||
if (link->set->sltm_once && link->was_up)
|
if (link->set->sltm_once && link->was_up)
|
||||||
LOGP(DINP, LOGL_INFO, "Not sending SLTM again as configured on %s/%d.\n",
|
LOGP(DINP, LOGL_INFO, "Not sending SLTM again on link %d/%s of %d/%s.\n",
|
||||||
link->set->name, link->link_no);
|
link->nr, link->name, link->set->nr, link->set->name);
|
||||||
else
|
else
|
||||||
bsc_schedule_timer(&link->t2_timer, MTP_T2);
|
bsc_schedule_timer(&link->t2_timer, MTP_T2);
|
||||||
}
|
}
|
||||||
|
@ -158,13 +158,13 @@ int mtp_link_slta(struct mtp_link *link, uint16_t l3_len,
|
||||||
void mtp_link_failure(struct mtp_link *link)
|
void mtp_link_failure(struct mtp_link *link)
|
||||||
{
|
{
|
||||||
if (link->blocked) {
|
if (link->blocked) {
|
||||||
LOGP(DINP, LOGL_ERROR, "Ignoring failure on blocked link %s/%d.\n",
|
LOGP(DINP, LOGL_ERROR, "Ignoring failure on blocked link %d/%s on %d/%s.\n",
|
||||||
link->set->name, link->link_no);
|
link->nr, link->name, link->set->nr, link->set->name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGP(DINP, LOGL_ERROR, "Link %s/%d has failed, going to reset it.\n",
|
LOGP(DINP, LOGL_ERROR, "Link %d/%s of %d/%s has failed, going to reset it.\n",
|
||||||
link->set->name, link->link_no);
|
link->nr, link->name, link->set->nr, link->set->name);
|
||||||
rate_ctr_inc(&link->ctrg->ctr[MTP_LNK_ERROR]);
|
rate_ctr_inc(&link->ctrg->ctr[MTP_LNK_ERROR]);
|
||||||
link->reset(link);
|
link->reset(link);
|
||||||
}
|
}
|
||||||
|
@ -185,15 +185,15 @@ void mtp_link_unblock(struct mtp_link *link)
|
||||||
|
|
||||||
static int dummy_arg1(struct mtp_link *link)
|
static int dummy_arg1(struct mtp_link *link)
|
||||||
{
|
{
|
||||||
LOGP(DINP, LOGL_ERROR, "The link %d of linkset %d/%s is not typed.\n",
|
LOGP(DINP, LOGL_ERROR, "The link %d/%s of linkset %d/%s is not typed.\n",
|
||||||
link->link_no, link->set->nr, link->set->name);
|
link->nr, link->name, link->set->nr, link->set->name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dummy_arg2(struct mtp_link *link, struct msgb *msg)
|
static int dummy_arg2(struct mtp_link *link, struct msgb *msg)
|
||||||
{
|
{
|
||||||
LOGP(DINP, LOGL_ERROR, "The link %d of linkset %d/%s is not typed.\n",
|
LOGP(DINP, LOGL_ERROR, "The link %d/%s of linkset %d/%s is not typed.\n",
|
||||||
link->link_no, link->set->nr, link->set->name);
|
link->nr, link->name, link->set->nr, link->set->name);
|
||||||
msgb_free(msg);
|
msgb_free(msg);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -208,9 +208,9 @@ struct mtp_link *mtp_link_alloc(struct mtp_link_set *set)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
link->link_no = set->nr_links++;
|
link->nr = set->nr_links++;
|
||||||
link->ctrg = rate_ctr_group_alloc(link,
|
link->ctrg = rate_ctr_group_alloc(link,
|
||||||
mtp_link_rate_ctr_desc(), link->link_no);
|
mtp_link_rate_ctr_desc(), link->nr);
|
||||||
if (!link->ctrg) {
|
if (!link->ctrg) {
|
||||||
LOGP(DINP, LOGL_ERROR, "Failed to allocate rate_ctr.\n");
|
LOGP(DINP, LOGL_ERROR, "Failed to allocate rate_ctr.\n");
|
||||||
talloc_free(link);
|
talloc_free(link);
|
||||||
|
@ -244,7 +244,7 @@ struct mtp_link *mtp_link_num(struct mtp_link_set *set, int num)
|
||||||
struct mtp_link *link;
|
struct mtp_link *link;
|
||||||
|
|
||||||
llist_for_each_entry(link, &set->links, entry)
|
llist_for_each_entry(link, &set->links, entry)
|
||||||
if (link->link_no == num)
|
if (link->nr == num)
|
||||||
return link;
|
return link;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -332,7 +332,7 @@ static void dump_stats(struct vty *vty, struct mtp_link_set *set)
|
||||||
vty_out_rate_ctr_group(vty, " ", set->ctrg);
|
vty_out_rate_ctr_group(vty, " ", set->ctrg);
|
||||||
|
|
||||||
llist_for_each_entry(link, &set->links, entry) {
|
llist_for_each_entry(link, &set->links, entry) {
|
||||||
vty_out(vty, " Link %d%s", link->link_no, VTY_NEWLINE);
|
vty_out(vty, " Link %d%s", link->nr, VTY_NEWLINE);
|
||||||
vty_out_rate_ctr_group(vty, " ", link->ctrg);
|
vty_out_rate_ctr_group(vty, " ", link->ctrg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -367,10 +367,10 @@ static void dump_state(struct vty *vty, struct mtp_link_set *set)
|
||||||
llist_for_each_entry(link, &set->links, entry) {
|
llist_for_each_entry(link, &set->links, entry) {
|
||||||
if (link->blocked)
|
if (link->blocked)
|
||||||
vty_out(vty, " Link %d is blocked.%s",
|
vty_out(vty, " Link %d is blocked.%s",
|
||||||
link->link_no, VTY_NEWLINE);
|
link->nr, VTY_NEWLINE);
|
||||||
else
|
else
|
||||||
vty_out(vty, " Link %d is %s.%s",
|
vty_out(vty, " Link %d is %s.%s",
|
||||||
link->link_no,
|
link->nr,
|
||||||
link->available == 0 ? "not available" : "available",
|
link->available == 0 ? "not available" : "available",
|
||||||
VTY_NEWLINE);
|
VTY_NEWLINE);
|
||||||
}
|
}
|
||||||
|
@ -435,7 +435,7 @@ DEFUN(show_slc, show_slc_cmd,
|
||||||
for (i = 0; i < ARRAY_SIZE(set->slc); ++i) {
|
for (i = 0; i < ARRAY_SIZE(set->slc); ++i) {
|
||||||
if (set->slc[i])
|
if (set->slc[i])
|
||||||
vty_out(vty, " SLC[%.2d] is on link %d.%s",
|
vty_out(vty, " SLC[%.2d] is on link %d.%s",
|
||||||
i, set->slc[i]->link_no, VTY_NEWLINE);
|
i, set->slc[i]->nr, VTY_NEWLINE);
|
||||||
else
|
else
|
||||||
vty_out(vty, " SLC[%d] is down.%s",
|
vty_out(vty, " SLC[%d] is down.%s",
|
||||||
i, VTY_NEWLINE);
|
i, VTY_NEWLINE);
|
||||||
|
|
Reference in New Issue