diff options
| author | Mark Stapp <mjs@voltanet.io> | 2020-10-21 13:56:26 -0400 |
|---|---|---|
| committer | Mark Stapp <mjs@voltanet.io> | 2020-10-22 13:37:25 -0400 |
| commit | 96b663a381c2e90fa663d69fce4e40f0be698e58 (patch) | |
| tree | 061e8297387581dcb5e730f405bf9a5596a58dc1 /ospfd/ospf_spf.c | |
| parent | 84de5a245a3eb17619588a535b9f408ce802a8c9 (diff) | |
ospfd: replace inet_ntoa
Stop using inet_ntoa, use %pI4 etc or inet_ntop instead
Signed-off-by: Mark Stapp <mjs@voltanet.io>
Diffstat (limited to 'ospfd/ospf_spf.c')
| -rw-r--r-- | ospfd/ospf_spf.c | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/ospfd/ospf_spf.c b/ospfd/ospf_spf.c index f5e393a13c..b53719a402 100644 --- a/ospfd/ospf_spf.c +++ b/ospfd/ospf_spf.c @@ -200,10 +200,10 @@ static struct vertex *ospf_vertex_new(struct ospf_area *area, listnode_add(area->spf_vertex_list, new); if (IS_DEBUG_OSPF_EVENT) - zlog_debug("%s: Created %s vertex %s", __func__, + zlog_debug("%s: Created %s vertex %pI4", __func__, new->type == OSPF_VERTEX_ROUTER ? "Router" : "Network", - inet_ntoa(new->lsa->id)); + &new->lsa->id); return new; } @@ -213,9 +213,9 @@ static void ospf_vertex_free(void *data) struct vertex *v = data; if (IS_DEBUG_OSPF_EVENT) - zlog_debug("%s: Free %s vertex %s", __func__, + zlog_debug("%s: Free %s vertex %pI4", __func__, v->type == OSPF_VERTEX_ROUTER ? "Router" : "Network", - inet_ntoa(v->lsa->id)); + &v->lsa->id); if (v->children) list_delete(&v->children); @@ -234,9 +234,9 @@ static void ospf_vertex_dump(const char *msg, struct vertex *v, if (!IS_DEBUG_OSPF_EVENT) return; - zlog_debug("%s %s vertex %s distance %u flags %u", msg, + zlog_debug("%s %s vertex %pI4 distance %u flags %u", msg, v->type == OSPF_VERTEX_ROUTER ? "Router" : "Network", - inet_ntoa(v->lsa->id), v->distance, (unsigned int)v->flags); + &v->lsa->id, v->distance, (unsigned int)v->flags); if (print_parents) { struct listnode *node; @@ -247,8 +247,8 @@ static void ospf_vertex_dump(const char *msg, struct vertex *v, if (vp) { zlog_debug( - "parent %s backlink %d nexthop %s lsa pos %d", - inet_ntoa(vp->parent->lsa->id), + "parent %pI4 backlink %d nexthop %s lsa pos %d", + &vp->parent->lsa->id, vp->backlink, inet_ntop(AF_INET, &vp->nexthop->router, buf1, BUFSIZ), @@ -826,9 +826,9 @@ static void ospf_spf_next(struct vertex *v, struct ospf_area *area, } if (IS_DEBUG_OSPF_EVENT) - zlog_debug("%s: Next vertex of %s vertex %s", __func__, + zlog_debug("%s: Next vertex of %s vertex %pI4", __func__, v->type == OSPF_VERTEX_ROUTER ? "Router" : "Network", - inet_ntoa(v->lsa->id)); + &v->lsa->id); p = ((uint8_t *)v->lsa) + OSPF_LSA_HEADER_SIZE + 4; lim = ((uint8_t *)v->lsa) + ntohs(v->lsa->length); @@ -868,20 +868,20 @@ static void ospf_spf_next(struct vertex *v, struct ospf_area *area, if (type == LSA_LINK_TYPE_VIRTUALLINK && IS_DEBUG_OSPF_EVENT) zlog_debug( - "looking up LSA through VL: %s", - inet_ntoa(l->link_id)); + "looking up LSA through VL: %pI4", + &l->link_id); w_lsa = ospf_lsa_lookup(area->ospf, area, OSPF_ROUTER_LSA, l->link_id, l->link_id); if (w_lsa && IS_DEBUG_OSPF_EVENT) - zlog_debug("found Router LSA %s", - inet_ntoa(l->link_id)); + zlog_debug("found Router LSA %pI4", + &l->link_id); break; case LSA_LINK_TYPE_TRANSIT: if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "Looking up Network LSA, ID: %s", - inet_ntoa(l->link_id)); + "Looking up Network LSA, ID: %pI4", + &l->link_id); w_lsa = ospf_lsa_lookup_by_id( area, OSPF_NETWORK_LSA, l->link_id); if (w_lsa && IS_DEBUG_OSPF_EVENT) @@ -904,8 +904,8 @@ static void ospf_spf_next(struct vertex *v, struct ospf_area *area, w_lsa = ospf_lsa_lookup_by_id(area, OSPF_ROUTER_LSA, *r); if (w_lsa && IS_DEBUG_OSPF_EVENT) - zlog_debug("found Router LSA %s", - inet_ntoa(w_lsa->data->id)); + zlog_debug("found Router LSA %pI4", + &w_lsa->data->id); /* step (d) below */ distance = v->distance; @@ -1003,20 +1003,21 @@ static void ospf_spf_dump(struct vertex *v, int i) if (v->type == OSPF_VERTEX_ROUTER) { if (IS_DEBUG_OSPF_EVENT) - zlog_debug("SPF Result: %d [R] %s", i, - inet_ntoa(v->lsa->id)); + zlog_debug("SPF Result: %d [R] %pI4", i, + &v->lsa->id); } else { struct network_lsa *lsa = (struct network_lsa *)v->lsa; if (IS_DEBUG_OSPF_EVENT) - zlog_debug("SPF Result: %d [N] %s/%d", i, - inet_ntoa(v->lsa->id), + zlog_debug("SPF Result: %d [N] %pI4/%d", i, + &v->lsa->id, ip_masklen(lsa->mask)); } if (IS_DEBUG_OSPF_EVENT) for (ALL_LIST_ELEMENTS_RO(v->parents, nnode, parent)) { - zlog_debug(" nexthop %p %s %d", (void *)parent->nexthop, - inet_ntoa(parent->nexthop->router), + zlog_debug(" nexthop %p %pI4 %d", + (void *)parent->nexthop, + &parent->nexthop->router, parent->nexthop->lsa_pos); } @@ -1033,17 +1034,17 @@ void ospf_spf_print(struct vty *vty, struct vertex *v, int i) struct vertex_parent *parent; if (v->type == OSPF_VERTEX_ROUTER) { - vty_out(vty, "SPF Result: depth %d [R] %s\n", i, - inet_ntoa(v->lsa->id)); + vty_out(vty, "SPF Result: depth %d [R] %pI4\n", i, + &v->lsa->id); } else { struct network_lsa *lsa = (struct network_lsa *)v->lsa; - vty_out(vty, "SPF Result: depth %d [N] %s/%d\n", i, - inet_ntoa(v->lsa->id), ip_masklen(lsa->mask)); + vty_out(vty, "SPF Result: depth %d [N] %pI4/%d\n", i, + &v->lsa->id, ip_masklen(lsa->mask)); } for (ALL_LIST_ELEMENTS_RO(v->parents, nnode, parent)) { - vty_out(vty, " nexthop %s lsa pos %d\n", - inet_ntoa(parent->nexthop->router), + vty_out(vty, " nexthop %pI4 lsa pos %d\n", + &parent->nexthop->router, parent->nexthop->lsa_pos); } @@ -1061,8 +1062,8 @@ static void ospf_spf_process_stubs(struct ospf_area *area, struct vertex *v, struct vertex *child; if (IS_DEBUG_OSPF_EVENT) - zlog_debug("ospf_process_stub():processing stubs for area %s", - inet_ntoa(area->area_id)); + zlog_debug("ospf_process_stub():processing stubs for area %pI4", + &area->area_id); if (v->type == OSPF_VERTEX_ROUTER) { uint8_t *p; @@ -1073,8 +1074,8 @@ static void ospf_spf_process_stubs(struct ospf_area *area, struct vertex *v, if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_process_stubs():processing router LSA, id: %s", - inet_ntoa(v->lsa->id)); + "ospf_process_stubs():processing router LSA, id: %pI4", + &v->lsa->id); router_lsa = (struct router_lsa *)v->lsa; @@ -1211,8 +1212,8 @@ ospf_rtrs_print (struct route_table *rtrs) else { if (IS_DEBUG_OSPF_EVENT) - zlog_debug (" via %s, %s\r", - inet_ntoa (path->nexthop), + zlog_debug (" via %pI4, %s\r", + &path->nexthop, ifindex2ifname (path->ifindex), VRF_DEFAULT); } } @@ -1233,8 +1234,8 @@ void ospf_spf_calculate(struct ospf_area *area, struct ospf_lsa *root_lsa, if (IS_DEBUG_OSPF_EVENT) { zlog_debug("ospf_spf_calculate: Start"); - zlog_debug("ospf_spf_calculate: running Dijkstra for area %s", - inet_ntoa(area->area_id)); + zlog_debug("ospf_spf_calculate: running Dijkstra for area %pI4", + &area->area_id); } /* @@ -1245,8 +1246,8 @@ void ospf_spf_calculate(struct ospf_area *area, struct ospf_lsa *root_lsa, if (!root_lsa) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_spf_calculate: Skip area %s's calculation due to empty root LSA", - inet_ntoa(area->area_id)); + "ospf_spf_calculate: Skip area %pI4's calculation due to empty root LSA", + &area->area_id); return; } @@ -1444,20 +1445,19 @@ static int ospf_spf_calculate_schedule_worker(struct thread *thread) rbuf[0] = '\0'; if (spf_reason_flags) { if (spf_reason_flags & SPF_FLAG_ROUTER_LSA_INSTALL) - strncat(rbuf, "R, ", sizeof(rbuf) - strlen(rbuf) - 1); + strlcat(rbuf, "R, ", sizeof(rbuf)); if (spf_reason_flags & SPF_FLAG_NETWORK_LSA_INSTALL) - strncat(rbuf, "N, ", sizeof(rbuf) - strlen(rbuf) - 1); + strlcat(rbuf, "N, ", sizeof(rbuf)); if (spf_reason_flags & SPF_FLAG_SUMMARY_LSA_INSTALL) - strncat(rbuf, "S, ", sizeof(rbuf) - strlen(rbuf) - 1); + strlcat(rbuf, "S, ", sizeof(rbuf)); if (spf_reason_flags & SPF_FLAG_ASBR_SUMMARY_LSA_INSTALL) - strncat(rbuf, "AS, ", sizeof(rbuf) - strlen(rbuf) - 1); + strlcat(rbuf, "AS, ", sizeof(rbuf)); if (spf_reason_flags & SPF_FLAG_ABR_STATUS_CHANGE) - strncat(rbuf, "ABR, ", sizeof(rbuf) - strlen(rbuf) - 1); + strlcat(rbuf, "ABR, ", sizeof(rbuf)); if (spf_reason_flags & SPF_FLAG_ASBR_STATUS_CHANGE) - strncat(rbuf, "ASBR, ", - sizeof(rbuf) - strlen(rbuf) - 1); + strlcat(rbuf, "ASBR, ", sizeof(rbuf)); if (spf_reason_flags & SPF_FLAG_MAXAGE) - strncat(rbuf, "M, ", sizeof(rbuf) - strlen(rbuf) - 1); + strlcat(rbuf, "M, ", sizeof(rbuf)); size_t rbuflen = strlen(rbuf); if (rbuflen >= 2) |
