Merge pull request #11869 from sri-mohan1/sri-isis-dbg1

isisd: changes for code maintainability
This commit is contained in:
Donatas Abraitis 2022-08-29 13:43:11 +03:00 committed by GitHub
commit ad70aa810e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 34 deletions

View File

@ -860,13 +860,13 @@ void isis_adj_build_neigh_list(struct list *adjdb, struct list *list)
struct listnode *node; struct listnode *node;
if (!list) { if (!list) {
zlog_warn("isis_adj_build_neigh_list(): NULL list"); zlog_warn("%s: NULL list", __func__);
return; return;
} }
for (ALL_LIST_ELEMENTS_RO(adjdb, node, adj)) { for (ALL_LIST_ELEMENTS_RO(adjdb, node, adj)) {
if (!adj) { if (!adj) {
zlog_warn("isis_adj_build_neigh_list(): NULL adj"); zlog_warn("%s: NULL adj", __func__);
return; return;
} }
@ -883,18 +883,18 @@ void isis_adj_build_up_list(struct list *adjdb, struct list *list)
struct listnode *node; struct listnode *node;
if (adjdb == NULL) { if (adjdb == NULL) {
zlog_warn("isis_adj_build_up_list(): adjacency DB is empty"); zlog_warn("%s: adjacency DB is empty", __func__);
return; return;
} }
if (!list) { if (!list) {
zlog_warn("isis_adj_build_up_list(): NULL list"); zlog_warn("%s: NULL list", __func__);
return; return;
} }
for (ALL_LIST_ELEMENTS_RO(adjdb, node, adj)) { for (ALL_LIST_ELEMENTS_RO(adjdb, node, adj)) {
if (!adj) { if (!adj) {
zlog_warn("isis_adj_build_up_list(): NULL adj"); zlog_warn("%s: NULL adj", __func__);
return; return;
} }

View File

@ -165,7 +165,7 @@ static int open_bpf_dev(struct isis_circuit *circuit)
bpf_prog.bf_len = 8; bpf_prog.bf_len = 8;
bpf_prog.bf_insns = &(llcfilter[0]); bpf_prog.bf_insns = &(llcfilter[0]);
if (ioctl(fd, BIOCSETF, (caddr_t)&bpf_prog) < 0) { if (ioctl(fd, BIOCSETF, (caddr_t)&bpf_prog) < 0) {
zlog_warn("open_bpf_dev(): failed to install filter: %s", zlog_warn("%s: failed to install filter: %s", __func__,
safe_strerror(errno)); safe_strerror(errno));
return ISIS_WARNING; return ISIS_WARNING;
} }
@ -198,7 +198,7 @@ int isis_sock_init(struct isis_circuit *circuit)
circuit->tx = isis_send_pdu_bcast; circuit->tx = isis_send_pdu_bcast;
circuit->rx = isis_recv_pdu_bcast; circuit->rx = isis_recv_pdu_bcast;
} else { } else {
zlog_warn("isis_sock_init(): unknown circuit type"); zlog_warn("%s: unknown circuit type", __func__);
retval = ISIS_WARNING; retval = ISIS_WARNING;
break; break;
} }
@ -223,8 +223,8 @@ int isis_recv_pdu_bcast(struct isis_circuit *circuit, uint8_t *ssnpa)
bytesread = read(circuit->fd, readbuff, readblen); bytesread = read(circuit->fd, readbuff, readblen);
} }
if (bytesread < 0) { if (bytesread < 0) {
zlog_warn("isis_recv_pdu_bcast(): read() failed: %s", zlog_warn("%s: read() failed: %s", __func__,
safe_strerror(errno)); safe_strerror(errno));
return ISIS_WARNING; return ISIS_WARNING;
} }
@ -267,8 +267,9 @@ int isis_send_pdu_bcast(struct isis_circuit *circuit, int level)
buflen = stream_get_endp(circuit->snd_stream) + LLC_LEN + ETHER_HDR_LEN; buflen = stream_get_endp(circuit->snd_stream) + LLC_LEN + ETHER_HDR_LEN;
if (buflen > sizeof(sock_buff)) { if (buflen > sizeof(sock_buff)) {
zlog_warn( zlog_warn(
"isis_send_pdu_bcast: sock_buff size %zu is less than output pdu size %zu on circuit %s", "%s: sock_buff size %zu is less than output pdu size %zu on circuit %s",
sizeof(sock_buff), buflen, circuit->interface->name); __func__, sizeof(sock_buff), buflen,
circuit->interface->name);
return ISIS_WARNING; return ISIS_WARNING;
} }

View File

@ -513,7 +513,7 @@ void isis_circuit_if_add(struct isis_circuit *circuit, struct interface *ifp)
} else { } else {
/* It's normal in case of loopback etc. */ /* It's normal in case of loopback etc. */
if (IS_DEBUG_EVENTS) if (IS_DEBUG_EVENTS)
zlog_debug("isis_circuit_if_add: unsupported media"); zlog_debug("%s: unsupported media", __func__);
circuit->circ_type = CIRCUIT_T_UNKNOWN; circuit->circ_type = CIRCUIT_T_UNKNOWN;
} }
@ -678,10 +678,10 @@ int isis_circuit_up(struct isis_circuit *circuit)
} }
#ifdef EXTREME_DEGUG #ifdef EXTREME_DEGUG
if (IS_DEBUG_EVENTS) if (IS_DEBUG_EVENTS)
zlog_debug( zlog_debug("%s: if_id %d, isomtu %d snpa %s", __func__,
"isis_circuit_if_add: if_id %d, isomtu %d snpa %s", circuit->interface->ifindex,
circuit->interface->ifindex, ISO_MTU(circuit), ISO_MTU(circuit),
snpa_print(circuit->u.bc.snpa)); snpa_print(circuit->u.bc.snpa));
#endif /* EXTREME_DEBUG */ #endif /* EXTREME_DEBUG */
circuit->u.bc.adjdb[0] = list_new(); circuit->u.bc.adjdb[0] = list_new();

View File

@ -336,9 +336,8 @@ static int open_dlpi_dev(struct isis_circuit *circuit)
/* Double check the DLPI style */ /* Double check the DLPI style */
if (dia->dl_provider_style != DL_STYLE2) { if (dia->dl_provider_style != DL_STYLE2) {
zlog_warn( zlog_warn("%s: interface %s: %s is not style 2",
"open_dlpi_dev(): interface %s: %s is not style 2", __func__, circuit->interface->name, devpath);
circuit->interface->name, devpath);
close(fd); close(fd);
return ISIS_WARNING; return ISIS_WARNING;
} }
@ -355,9 +354,8 @@ static int open_dlpi_dev(struct isis_circuit *circuit)
} else { } else {
/* Double check the DLPI style */ /* Double check the DLPI style */
if (dia->dl_provider_style != DL_STYLE1) { if (dia->dl_provider_style != DL_STYLE1) {
zlog_warn( zlog_warn("%s: interface %s: %s is not style 1",
"open_dlpi_dev(): interface %s: %s is not style 1", __func__, circuit->interface->name, devpath);
circuit->interface->name, devpath);
close(fd); close(fd);
return ISIS_WARNING; return ISIS_WARNING;
} }
@ -404,9 +402,8 @@ static int open_dlpi_dev(struct isis_circuit *circuit)
* so we need to be careful and use DL_PHYS_ADDR_REQ instead. * so we need to be careful and use DL_PHYS_ADDR_REQ instead.
*/ */
if (dlpiaddr(fd, circuit->u.bc.snpa) == -1) { if (dlpiaddr(fd, circuit->u.bc.snpa) == -1) {
zlog_warn( zlog_warn("%s: interface %s: unable to get MAC address",
"open_dlpi_dev(): interface %s: unable to get MAC address", __func__, circuit->interface->name);
circuit->interface->name);
close(fd); close(fd);
return ISIS_WARNING; return ISIS_WARNING;
} }
@ -479,7 +476,7 @@ int isis_sock_init(struct isis_circuit *circuit)
circuit->tx = isis_send_pdu_bcast; circuit->tx = isis_send_pdu_bcast;
circuit->rx = isis_recv_pdu_bcast; circuit->rx = isis_recv_pdu_bcast;
} else { } else {
zlog_warn("isis_sock_init(): unknown circuit type"); zlog_warn("%s: unknown circuit type", __func__);
retval = ISIS_WARNING; retval = ISIS_WARNING;
break; break;
} }
@ -511,7 +508,7 @@ int isis_recv_pdu_bcast(struct isis_circuit *circuit, uint8_t *ssnpa)
retv = getmsg(circuit->fd, &ctlbuf, &databuf, &flags); retv = getmsg(circuit->fd, &ctlbuf, &databuf, &flags);
if (retv < 0) { if (retv < 0) {
zlog_warn("isis_recv_pdu_bcast: getmsg failed: %s", zlog_warn("%s: getmsg failed: %s", __func__,
safe_strerror(errno)); safe_strerror(errno));
return ISIS_WARNING; return ISIS_WARNING;
} }
@ -561,8 +558,9 @@ int isis_send_pdu_bcast(struct isis_circuit *circuit, int level)
buflen = stream_get_endp(circuit->snd_stream) + LLC_LEN; buflen = stream_get_endp(circuit->snd_stream) + LLC_LEN;
if ((size_t)buflen > sizeof(sock_buff)) { if ((size_t)buflen > sizeof(sock_buff)) {
zlog_warn( zlog_warn(
"isis_send_pdu_bcast: sock_buff size %zu is less than output pdu size %d on circuit %s", "%s: sock_buff size %zu is less than output pdu size %d on circuit %s",
sizeof(sock_buff), buflen, circuit->interface->name); __func__, sizeof(sock_buff), buflen,
circuit->interface->name);
return ISIS_WARNING; return ISIS_WARNING;
} }

View File

@ -80,7 +80,8 @@ void isis_run_dr(struct thread *thread)
} }
if (circuit->u.bc.run_dr_elect[level - 1]) if (circuit->u.bc.run_dr_elect[level - 1])
zlog_warn("isis_run_dr(): run_dr_elect already set for l%d", level); zlog_warn("%s: run_dr_elect already set for l%d", __func__,
level);
circuit->u.bc.t_run_dr[level - 1] = NULL; circuit->u.bc.t_run_dr[level - 1] = NULL;
circuit->u.bc.run_dr_elect[level - 1] = 1; circuit->u.bc.run_dr_elect[level - 1] = 1;
@ -126,7 +127,7 @@ int isis_dr_elect(struct isis_circuit *circuit, int level)
adjdb = circuit->u.bc.adjdb[level - 1]; adjdb = circuit->u.bc.adjdb[level - 1];
if (!adjdb) { if (!adjdb) {
zlog_warn("isis_dr_elect() adjdb == NULL"); zlog_warn("%s adjdb == NULL", __func__);
list_delete(&list); list_delete(&list);
return ISIS_WARNING; return ISIS_WARNING;
} }
@ -155,7 +156,8 @@ int isis_dr_elect(struct isis_circuit *circuit, int level)
} }
if (cmp_res == 0) if (cmp_res == 0)
zlog_warn( zlog_warn(
"isis_dr_elect(): multiple adjacencies with same SNPA"); "%s: multiple adjacencies with same SNPA",
__func__);
} else { } else {
adj_dr = adj; adj_dr = adj;
} }
@ -218,7 +220,7 @@ int isis_dr_resign(struct isis_circuit *circuit, int level)
uint8_t id[ISIS_SYS_ID_LEN + 2]; uint8_t id[ISIS_SYS_ID_LEN + 2];
if (IS_DEBUG_EVENTS) if (IS_DEBUG_EVENTS)
zlog_debug("isis_dr_resign l%d", level); zlog_debug("%s l%d", __func__, level);
circuit->u.bc.is_dr[level - 1] = 0; circuit->u.bc.is_dr[level - 1] = 0;
circuit->u.bc.run_dr_elect[level - 1] = 0; circuit->u.bc.run_dr_elect[level - 1] = 0;
@ -266,7 +268,7 @@ int isis_dr_commence(struct isis_circuit *circuit, int level)
uint8_t old_dr[ISIS_SYS_ID_LEN + 2]; uint8_t old_dr[ISIS_SYS_ID_LEN + 2];
if (IS_DEBUG_EVENTS) if (IS_DEBUG_EVENTS)
zlog_debug("isis_dr_commence l%d", level); zlog_debug("%s l%d", __func__, level);
/* Lets keep a pause in DR election */ /* Lets keep a pause in DR election */
circuit->u.bc.run_dr_elect[level - 1] = 0; circuit->u.bc.run_dr_elect[level - 1] = 0;