From: Donald Sharp Date: Wed, 10 Mar 2021 01:00:45 +0000 (-0500) Subject: ospfd: Convert to using proper string formatting X-Git-Tag: base_8.0~299^2~4 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=c067e23e547425d779fa362674befe82db558a48;p=mirror%2Ffrr.git ospfd: Convert to using proper string formatting Signed-off-by: Donald Sharp --- diff --git a/ospfd/ospf_flood.c b/ospfd/ospf_flood.c index 5f74984c66..caba03c1b5 100644 --- a/ospfd/ospf_flood.c +++ b/ospfd/ospf_flood.c @@ -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; } } diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index 343e406f28..0fd4803c79 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -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); diff --git a/ospfd/ospf_spf.c b/ospfd/ospf_spf.c index 82acd0829c..6cd6a47098 100644 --- a/ospfd/ospf_spf.c +++ b/ospfd/ospf_spf.c @@ -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; } }