ospfd: Convert to using proper string formatting

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2021-03-09 20:00:45 -05:00
parent c0d72166ee
commit c067e23e54
3 changed files with 34 additions and 88 deletions

View File

@ -537,11 +537,9 @@ static int ospf_flood_through_interface(struct ospf_interface *oi,
if (!CHECK_FLAG(onbr->options, OSPF_OPTION_O)) {
if (IS_DEBUG_OSPF(lsa, LSA_FLOODING))
zlog_debug(
"%s: Skipping neighbor %s via %s -- Not Opaque-capable.",
"%s: Skipping neighbor %s via %pI4 -- Not Opaque-capable.",
__func__, IF_NAME(oi),
inet_ntop(AF_INET,
&onbr->router_id, buf,
sizeof(buf)));
&onbr->router_id);
continue;
}
}
@ -557,11 +555,9 @@ static int ospf_flood_through_interface(struct ospf_interface *oi,
&onbr->router_id)) {
if (IS_DEBUG_OSPF(lsa, LSA_FLOODING))
zlog_debug(
"%s: Skipping neighbor %s via %s -- inbr == onbr.",
"%s: Skipping neighbor %s via %pI4 -- inbr == onbr.",
__func__, IF_NAME(oi),
inet_ntop(AF_INET,
&inbr->router_id, buf,
sizeof(buf)));
&inbr->router_id);
continue;
}
} else {
@ -573,11 +569,9 @@ static int ospf_flood_through_interface(struct ospf_interface *oi,
&onbr->router_id)) {
if (IS_DEBUG_OSPF(lsa, LSA_FLOODING))
zlog_debug(
"%s: Skipping neighbor %s via %s -- lsah->adv_router == onbr.",
"%s: Skipping neighbor %s via %pI4 -- lsah->adv_router == onbr.",
__func__, IF_NAME(oi),
inet_ntop(AF_INET,
&onbr->router_id, buf,
sizeof(buf)));
&onbr->router_id);
continue;
}
}

View File

@ -1881,20 +1881,10 @@ static void ospf_ls_upd(struct ospf *ospf, struct ip *iph,
struct ospf_lsa *ls_ret, *current;
int ret = 1;
if (IS_DEBUG_OSPF_NSSA) {
char buf1[INET_ADDRSTRLEN];
char buf2[INET_ADDRSTRLEN];
char buf3[INET_ADDRSTRLEN];
zlog_debug("LSA Type-%d from %s, ID: %s, ADV: %s",
lsa->data->type,
inet_ntop(AF_INET, &ospfh->router_id, buf1,
INET_ADDRSTRLEN),
inet_ntop(AF_INET, &lsa->data->id, buf2,
INET_ADDRSTRLEN),
inet_ntop(AF_INET, &lsa->data->adv_router,
buf3, INET_ADDRSTRLEN));
}
if (IS_DEBUG_OSPF_NSSA)
zlog_debug("LSA Type-%d from %pI4, ID: %pI4, ADV: %pI4",
lsa->data->type, &ospfh->router_id,
&lsa->data->id, &lsa->data->adv_router);
listnode_delete(lsas,
lsa); /* We don't need it in list anymore */
@ -1940,19 +1930,11 @@ static void ospf_ls_upd(struct ospf *ospf, struct ip *iph,
if (lsa->data->type == OSPF_ROUTER_LSA)
if (!IPV4_ADDR_SAME(&lsa->data->id,
&lsa->data->adv_router)) {
char buf1[INET_ADDRSTRLEN];
char buf2[INET_ADDRSTRLEN];
char buf3[INET_ADDRSTRLEN];
flog_err(EC_OSPF_ROUTER_LSA_MISMATCH,
"Incoming Router-LSA from %s with Adv-ID[%s] != LS-ID[%s]",
inet_ntop(AF_INET, &ospfh->router_id,
buf1, INET_ADDRSTRLEN),
inet_ntop(AF_INET, &lsa->data->id,
buf2, INET_ADDRSTRLEN),
inet_ntop(AF_INET,
&lsa->data->adv_router, buf3,
INET_ADDRSTRLEN));
flog_err(
EC_OSPF_ROUTER_LSA_MISMATCH,
"Incoming Router-LSA from %pI4 with Adv-ID[%pI4] != LS-ID[%pI4]",
&ospfh->router_id, &lsa->data->id,
&lsa->data->adv_router);
flog_err(
EC_OSPF_DOMAIN_CORRUPT,
"OSPF domain compromised by attack or corruption. Verify correct operation of -ALL- OSPF routers.");
@ -3045,17 +3027,11 @@ static enum ospf_read_return_enum ospf_read_helper(struct ospf *ospf)
/* If incoming interface is passive one, ignore it. */
if (oi && OSPF_IF_PASSIVE_STATUS(oi) == OSPF_IF_PASSIVE) {
char buf[3][INET_ADDRSTRLEN];
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
"ignoring packet from router %s sent to %s, received on a passive interface, %s",
inet_ntop(AF_INET, &ospfh->router_id, buf[0],
sizeof(buf[0])),
inet_ntop(AF_INET, &iph->ip_dst, buf[1],
sizeof(buf[1])),
inet_ntop(AF_INET, &oi->address->u.prefix4,
buf[2], sizeof(buf[2])));
"ignoring packet from router %pI4 sent to %pI4, received on a passive interface, %pI4",
&ospfh->router_id, &iph->ip_dst,
&oi->address->u.prefix4);
if (iph->ip_dst.s_addr == htonl(OSPF_ALLSPFROUTERS)) {
/* Try to fix multicast membership.
@ -3097,16 +3073,11 @@ static enum ospf_read_return_enum ospf_read_helper(struct ospf *ospf)
&iph->ip_src, ifp->name);
return OSPF_READ_CONTINUE;
} else if (oi->state == ISM_Down) {
char buf[2][INET_ADDRSTRLEN];
flog_warn(
EC_OSPF_PACKET,
"Ignoring packet from %s to %s received on interface that is down [%s]; interface flags are %s",
inet_ntop(AF_INET, &iph->ip_src, buf[0],
sizeof(buf[0])),
inet_ntop(AF_INET, &iph->ip_dst, buf[1],
sizeof(buf[1])),
ifp->name, if_flag_dump(ifp->flags));
"Ignoring packet from %pI4 to %pI4 received on interface that is down [%s]; interface flags are %s",
&iph->ip_src, &iph->ip_dst, ifp->name,
if_flag_dump(ifp->flags));
/* Fix multicast memberships? */
if (iph->ip_dst.s_addr == htonl(OSPF_ALLSPFROUTERS))
OI_MEMBER_JOINED(oi, MEMBER_ALLROUTERS);

View File

@ -251,15 +251,11 @@ static void ospf_vertex_dump(const char *msg, struct vertex *v,
struct vertex_parent *vp;
for (ALL_LIST_ELEMENTS_RO(v->parents, node, vp)) {
char buf1[BUFSIZ];
if (vp) {
zlog_debug(
"parent %pI4 backlink %d nexthop %s lsa pos %d",
&vp->parent->lsa->id,
vp->backlink,
inet_ntop(AF_INET, &vp->nexthop->router,
buf1, BUFSIZ),
"parent %pI4 backlink %d nexthop %pI4 lsa pos %d",
&vp->parent->lsa->id, vp->backlink,
&vp->nexthop->router,
vp->nexthop->lsa_pos);
}
}
@ -707,14 +703,9 @@ static void ospf_spf_add_parent(struct vertex *v, struct vertex *w,
else
w->distance = distance;
if (IS_DEBUG_OSPF_EVENT) {
char buf[2][INET_ADDRSTRLEN];
zlog_debug(
"%s: Adding %s as parent of %s", __func__,
inet_ntop(AF_INET, &v->lsa->id, buf[0], sizeof(buf[0])),
inet_ntop(AF_INET, &w->lsa->id, buf[1],
sizeof(buf[1])));
}
if (IS_DEBUG_OSPF_EVENT)
zlog_debug("%s: Adding %pI4 as parent of %pI4", __func__,
&v->lsa->id, &w->lsa->id);
/*
* Adding parent for a new, better path: flush existing parents from W.
@ -805,8 +796,6 @@ static unsigned int ospf_nexthop_calculation(struct ospf_area *area,
struct vertex_nexthop *nh, *lnh;
struct vertex_parent *vp;
unsigned int added = 0;
char buf1[BUFSIZ];
char buf2[BUFSIZ];
if (IS_DEBUG_OSPF_EVENT) {
zlog_debug("ospf_nexthop_calculation(): Start");
@ -828,14 +817,11 @@ static unsigned int ospf_nexthop_calculation(struct ospf_area *area,
/* we *must* be supplied with the link data */
assert(l != NULL);
if (IS_DEBUG_OSPF_EVENT) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
"%s: considering link type:%d link_id:%s link_data:%s",
__func__, l->m[0].type,
inet_ntop(AF_INET, &l->link_id, buf1, BUFSIZ),
inet_ntop(AF_INET, &l->link_data, buf2,
BUFSIZ));
}
"%s: considering link type:%d link_id:%pI4 link_data:%pI4",
__func__, l->m[0].type, &l->link_id,
&l->link_data);
if (w->type == OSPF_VERTEX_ROUTER) {
/*
@ -852,15 +838,10 @@ static unsigned int ospf_nexthop_calculation(struct ospf_area *area,
lsa_pos);
if (!oi) {
zlog_debug(
"%s: OI not found in LSA: lsa_pos: %d link_id:%s link_data:%s",
"%s: OI not found in LSA: lsa_pos: %d link_id:%pI4 link_data:%pI4",
__func__, lsa_pos,
inet_ntop(AF_INET,
&l->link_id,
buf1, BUFSIZ),
inet_ntop(AF_INET,
&l->link_data,
buf2,
BUFSIZ));
&l->link_id,
&l->link_data);
return 0;
}
}