From 96b663a381c2e90fa663d69fce4e40f0be698e58 Mon Sep 17 00:00:00 2001 From: Mark Stapp Date: Wed, 21 Oct 2020 13:56:26 -0400 Subject: [PATCH] ospfd: replace inet_ntoa Stop using inet_ntoa, use %pI4 etc or inet_ntop instead Signed-off-by: Mark Stapp --- ospfd/ospf_abr.c | 149 +++++++-------- ospfd/ospf_apiserver.c | 48 ++--- ospfd/ospf_asbr.c | 13 +- ospfd/ospf_ase.c | 21 +-- ospfd/ospf_bfd.c | 16 +- ospfd/ospf_dump.c | 36 ++-- ospfd/ospf_dump_api.c | 4 +- ospfd/ospf_ext.c | 18 +- ospfd/ospf_flood.c | 50 ++--- ospfd/ospf_gr_helper.c | 32 ++-- ospfd/ospf_ia.c | 9 +- ospfd/ospf_interface.c | 34 ++-- ospfd/ospf_ism.c | 8 +- ospfd/ospf_lsa.c | 170 +++++++++-------- ospfd/ospf_neighbor.c | 17 +- ospfd/ospf_network.c | 36 ++-- ospfd/ospf_nsm.c | 36 ++-- ospfd/ospf_opaque.c | 20 +- ospfd/ospf_packet.c | 282 ++++++++++++++-------------- ospfd/ospf_ri.c | 51 ++--- ospfd/ospf_route.c | 47 +++-- ospfd/ospf_snmp.c | 8 +- ospfd/ospf_spf.c | 96 +++++----- ospfd/ospf_sr.c | 58 +++--- ospfd/ospf_te.c | 78 ++++---- ospfd/ospf_vty.c | 409 +++++++++++++++++++++++------------------ ospfd/ospf_zebra.c | 25 ++- ospfd/ospfd.c | 24 +-- 28 files changed, 920 insertions(+), 875 deletions(-) diff --git a/ospfd/ospf_abr.c b/ospfd/ospf_abr.c index 28afee31a3..634418ec5a 100644 --- a/ospfd/ospf_abr.c +++ b/ospfd/ospf_abr.c @@ -331,6 +331,7 @@ static int ospf_abr_nssa_am_elected(struct ospf_area *area) struct ospf_lsa *lsa; struct router_lsa *rlsa; struct in_addr *best = NULL; + char buf[PREFIX_STRLEN]; LSDB_LOOP (ROUTER_LSDB(area), rn, lsa) { /* sanity checks */ @@ -348,8 +349,8 @@ static int ospf_abr_nssa_am_elected(struct ospf_area *area) if (IS_ROUTER_LSA_NT(rlsa)) { if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_abr_nssa_am_elected: router %s asserts Nt", - inet_ntoa(lsa->data->id)); + "ospf_abr_nssa_am_elected: router %pI4 asserts Nt", + &lsa->data->id); return 0; } @@ -363,7 +364,8 @@ static int ospf_abr_nssa_am_elected(struct ospf_area *area) if (IS_DEBUG_OSPF_NSSA) zlog_debug( "ospf_abr_nssa_am_elected: best electable ABR is: %s", - (best) ? inet_ntoa(*best) : ""); + (best) ? inet_ntop(AF_INET, best, buf, sizeof(buf)) : + ""); if (best == NULL) return 1; @@ -390,8 +392,8 @@ static void ospf_abr_nssa_check_status(struct ospf *ospf) if (IS_DEBUG_OSPF(nssa, NSSA)) zlog_debug( - "ospf_abr_nssa_check_status: checking area %s", - inet_ntoa(area->area_id)); + "ospf_abr_nssa_check_status: checking area %pI4", + &area->area_id); if (!IS_OSPF_ABR(area->ospf)) { if (IS_DEBUG_OSPF(nssa, NSSA)) @@ -615,15 +617,15 @@ static int ospf_abr_translate_nssa(struct ospf_area *area, struct ospf_lsa *lsa) if (!CHECK_FLAG(lsa->data->options, OSPF_OPTION_NP)) { if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_abr_translate_nssa(): LSA Id %s, P-bit off, NO Translation", - inet_ntoa(lsa->data->id)); + "ospf_abr_translate_nssa(): LSA Id %pI4, P-bit off, NO Translation", + &lsa->data->id); return 1; } if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_abr_translate_nssa(): LSA Id %s, TRANSLATING 7 to 5", - inet_ntoa(lsa->data->id)); + "ospf_abr_translate_nssa(): LSA Id %pI4, TRANSLATING 7 to 5", + &lsa->data->id); ext7 = (struct as_external_lsa *)(lsa->data); p.prefix = lsa->data->id; @@ -632,8 +634,8 @@ static int ospf_abr_translate_nssa(struct ospf_area *area, struct ospf_lsa *lsa) if (ext7->e[0].fwd_addr.s_addr == OSPF_DEFAULT_DESTINATION) { if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_abr_translate_nssa(): LSA Id %s, Forward address is 0, NO Translation", - inet_ntoa(lsa->data->id)); + "ospf_abr_translate_nssa(): LSA Id %pI4, Forward address is 0, NO Translation", + &lsa->data->id); return 1; } @@ -646,8 +648,8 @@ static int ospf_abr_translate_nssa(struct ospf_area *area, struct ospf_lsa *lsa) UNSET_FLAG(old->flags, OSPF_LSA_APPROVED); if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_abr_translate_nssa(): remove old translated LSA id %s", - inet_ntoa(old->data->id)); + "ospf_abr_translate_nssa(): remove old translated LSA id %pI4", + &old->data->id); } /* if type-7 is removed and type-5 does not exist, do not * originate */ @@ -657,16 +659,16 @@ static int ospf_abr_translate_nssa(struct ospf_area *area, struct ospf_lsa *lsa) if (old && CHECK_FLAG(old->flags, OSPF_LSA_APPROVED)) { if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_abr_translate_nssa(): found old translated LSA Id %s, refreshing", - inet_ntoa(old->data->id)); + "ospf_abr_translate_nssa(): found old translated LSA Id %pI4, refreshing", + &old->data->id); /* refresh */ new = ospf_translated_nssa_refresh(area->ospf, lsa, old); if (!new) { if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_abr_translate_nssa(): could not refresh translated LSA Id %s", - inet_ntoa(old->data->id)); + "ospf_abr_translate_nssa(): could not refresh translated LSA Id %pI4", + &old->data->id); } } else { /* no existing external route for this LSA Id @@ -676,8 +678,8 @@ static int ospf_abr_translate_nssa(struct ospf_area *area, struct ospf_lsa *lsa) if (ospf_translated_nssa_originate(area->ospf, lsa) == NULL) { if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_abr_translate_nssa(): Could not translate Type-7 for %s to Type-5", - inet_ntoa(lsa->data->id)); + "ospf_abr_translate_nssa(): Could not translate Type-7 for %pI4 to Type-5", + &lsa->data->id); return 1; } } @@ -741,9 +743,9 @@ void ospf_abr_announce_network_to_area(struct prefix_ipv4 *p, uint32_t cost, if (!lsa) { flog_warn(EC_OSPF_LSA_MISSING, - "%s: Could not refresh %pFX to %s", + "%s: Could not refresh %pFX to %pI4", __func__, (struct prefix *)p, - inet_ntoa(area->area_id)); + &area->area_id); return; } @@ -759,9 +761,9 @@ void ospf_abr_announce_network_to_area(struct prefix_ipv4 *p, uint32_t cost, if (!lsa) { flog_warn(EC_OSPF_LSA_MISSING, - "%s: Could not originate %pFX to %s", + "%s: Could not originate %pFX to %pi4", __func__, (struct prefix *)p, - inet_ntoa(area->area_id)); + &area->area_id); return; } @@ -854,8 +856,8 @@ static void ospf_abr_announce_network(struct ospf *ospf, struct prefix_ipv4 *p, for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_network(): looking at area %s", - inet_ntoa(area->area_id)); + "ospf_abr_announce_network(): looking at area %pI4", + &area->area_id); if (IPV4_ADDR_SAME(& or->u.std.area_id, &area->area_id)) continue; @@ -883,8 +885,8 @@ static void ospf_abr_announce_network(struct ospf *ospf, struct prefix_ipv4 *p, && area->no_summary) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_network(): area %s is stub and no_summary", - inet_ntoa(area->area_id)); + "ospf_abr_announce_network(): area %pI4 is stub and no_summary", + &area->area_id); continue; } @@ -962,8 +964,8 @@ static void ospf_abr_process_nssa_translates(struct ospf *ospf) if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_abr_process_nssa_translates(): looking at area %s", - inet_ntoa(area->area_id)); + "ospf_abr_process_nssa_translates(): looking at area %pI4", + &area->area_id); LSDB_LOOP (NSSA_LSDB(area), rn, lsa) ospf_abr_translate_nssa(area, lsa); @@ -991,15 +993,15 @@ static void ospf_abr_process_network_rt(struct ospf *ospf, or->u.std.area_id))) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_process_network_rt(): area %s no longer exists", - inet_ntoa(or->u.std.area_id)); + "ospf_abr_process_network_rt(): area %pI4 no longer exists", + &or->u.std.area_id); continue; } if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_process_network_rt(): this is a route to %s/%d", - inet_ntoa(rn->p.u.prefix4), rn->p.prefixlen); + "ospf_abr_process_network_rt(): this is a route to %pFX", + &rn->p); if (or->path_type >= OSPF_PATH_TYPE1_EXTERNAL) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( @@ -1113,9 +1115,9 @@ static void ospf_abr_announce_rtr_to_area(struct prefix_ipv4 *p, uint32_t cost, lsa = ospf_summary_asbr_lsa_originate(p, cost, area); if (!lsa) { flog_warn(EC_OSPF_LSA_MISSING, - "%s: Could not refresh/originate %pFX to %s", + "%s: Could not refresh/originate %pFX to %pI4", __func__, (struct prefix *)p, - inet_ntoa(area->area_id)); + &area->area_id); return; } @@ -1149,8 +1151,8 @@ static void ospf_abr_announce_rtr(struct ospf *ospf, struct prefix_ipv4 *p, for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_rtr(): looking at area %s", - inet_ntoa(area->area_id)); + "ospf_abr_announce_rtr(): looking at area %pI4", + &area->area_id); if (IPV4_ADDR_SAME(& or->u.std.area_id, &area->area_id)) continue; @@ -1162,24 +1164,24 @@ static void ospf_abr_announce_rtr(struct ospf *ospf, struct prefix_ipv4 *p, if (or->u.std.external_routing == OSPF_AREA_NSSA) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_rtr(): do not generate LSA Type-4 %s from NSSA", - inet_ntoa(p->prefix)); + "ospf_abr_announce_rtr(): do not generate LSA Type-4 %pI4 from NSSA", + &p->prefix); continue; } if (area->external_routing != OSPF_AREA_DEFAULT) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_rtr(): area %s doesn't support external routing", - inet_ntoa(area->area_id)); + "ospf_abr_announce_rtr(): area %pI4 doesn't support external routing", + &area->area_id); continue; } if (or->path_type == OSPF_PATH_INTER_AREA) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_rtr(): this is inter-area route to %s", - inet_ntoa(p->prefix)); + "ospf_abr_announce_rtr(): this is inter-area route to %pI4", + &p->prefix); if (!OSPF_IS_AREA_BACKBONE(area)) ospf_abr_announce_rtr_to_area(p, or->cost, area); @@ -1188,8 +1190,8 @@ static void ospf_abr_announce_rtr(struct ospf *ospf, struct prefix_ipv4 *p, if (or->path_type == OSPF_PATH_INTRA_AREA) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_rtr(): this is intra-area route to %s", - inet_ntoa(p->prefix)); + "ospf_abr_announce_rtr(): this is intra-area route to %pI4", + &p->prefix); ospf_abr_announce_rtr_to_area(p, or->cost, area); } } @@ -1220,16 +1222,16 @@ static void ospf_abr_process_router_rt(struct ospf *ospf, if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_process_router_rt(): this is a route to %s", - inet_ntoa(rn->p.u.prefix4)); + "ospf_abr_process_router_rt(): this is a route to %pI4", + &rn->p.u.prefix4); for (ALL_LIST_ELEMENTS(l, node, nnode, or)) { if (!ospf_area_lookup_by_area_id(ospf, or->u.std.area_id)) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_process_router_rt(): area %s no longer exists", - inet_ntoa(or->u.std.area_id)); + "ospf_abr_process_router_rt(): area %pI4 no longer exists", + &or->u.std.area_id); continue; } @@ -1310,8 +1312,8 @@ ospf_abr_unapprove_translates(struct ospf *ospf) /* For NSSA Translations */ UNSET_FLAG(lsa->flags, OSPF_LSA_APPROVED); if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_abr_unapprove_translates(): approved unset on link id %s", - inet_ntoa(lsa->data->id)); + "ospf_abr_unapprove_translates(): approved unset on link id %pI4", + &lsa->data->id); } if (IS_DEBUG_OSPF_NSSA) @@ -1331,14 +1333,14 @@ static void ospf_abr_unapprove_summaries(struct ospf *ospf) for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_unapprove_summaries(): considering area %s", - inet_ntoa(area->area_id)); + "ospf_abr_unapprove_summaries(): considering area %pI4", + &area->area_id); LSDB_LOOP (SUMMARY_LSDB(area), rn, lsa) if (ospf_lsa_is_self_originated(ospf, lsa)) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_unapprove_summaries(): approved unset on summary link id %s", - inet_ntoa(lsa->data->id)); + "ospf_abr_unapprove_summaries(): approved unset on summary link id %pI4", + &lsa->data->id); UNSET_FLAG(lsa->flags, OSPF_LSA_APPROVED); } @@ -1346,8 +1348,8 @@ static void ospf_abr_unapprove_summaries(struct ospf *ospf) if (ospf_lsa_is_self_originated(ospf, lsa)) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_unapprove_summaries(): approved unset on asbr-summary link id %s", - inet_ntoa(lsa->data->id)); + "ospf_abr_unapprove_summaries(): approved unset on asbr-summary link id %pI4", + &lsa->data->id); UNSET_FLAG(lsa->flags, OSPF_LSA_APPROVED); } } @@ -1392,8 +1394,8 @@ static void ospf_abr_announce_aggregates(struct ospf *ospf) for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_aggregates(): looking at area %s", - inet_ntoa(area->area_id)); + "ospf_abr_announce_aggregates(): looking at area %pI4", + &area->area_id); for (rn = route_top(area->ranges); rn; rn = route_next(rn)) if ((range = rn->info)) { @@ -1411,9 +1413,8 @@ static void ospf_abr_announce_aggregates(struct ospf *ospf) if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_aggregates(): this is range: %s/%d", - inet_ntoa(p.u.prefix4), - p.prefixlen); + "ospf_abr_announce_aggregates(): this is range: %pFX", + &p); if (CHECK_FLAG(range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) { @@ -1482,8 +1483,8 @@ ospf_abr_send_nssa_aggregates(struct ospf *ospf) /* temporarily turned off */ if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_abr_send_nssa_aggregates(): looking at area %s", - inet_ntoa(area->area_id)); + "ospf_abr_send_nssa_aggregates(): looking at area %pI4", + &area->area_id); for (rn = route_top(area->ranges); rn; rn = route_next(rn)) { if (rn->info == NULL) @@ -1505,8 +1506,8 @@ ospf_abr_send_nssa_aggregates(struct ospf *ospf) /* temporarily turned off */ if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_abr_send_nssa_aggregates(): this is range: %s/%d", - inet_ntoa(p.prefix), p.prefixlen); + "ospf_abr_send_nssa_aggregates(): this is range: %pFX", + &p); if (CHECK_FLAG(range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) { @@ -1553,8 +1554,8 @@ static void ospf_abr_announce_stub_defaults(struct ospf *ospf) for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_stub_defaults(): looking at area %s", - inet_ntoa(area->area_id)); + "ospf_abr_announce_stub_defaults(): looking at area %pI4", + &area->area_id); if ((area->external_routing != OSPF_AREA_STUB) && (area->external_routing != OSPF_AREA_NSSA)) @@ -1565,8 +1566,8 @@ static void ospf_abr_announce_stub_defaults(struct ospf *ospf) if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_stub_defaults(): announcing 0.0.0.0/0 to area %s", - inet_ntoa(area->area_id)); + "ospf_abr_announce_stub_defaults(): announcing 0.0.0.0/0 to area %pI4", + &area->area_id); ospf_abr_announce_network_to_area(&p, area->default_cost, area); } @@ -1580,8 +1581,8 @@ static int ospf_abr_remove_unapproved_translates_apply(struct ospf *ospf, if (CHECK_FLAG(lsa->flags, OSPF_LSA_LOCAL_XLT) && !CHECK_FLAG(lsa->flags, OSPF_LSA_APPROVED)) { zlog_info( - "ospf_abr_remove_unapproved_translates(): removing unapproved translates, ID: %s", - inet_ntoa(lsa->data->id)); + "ospf_abr_remove_unapproved_translates(): removing unapproved translates, ID: %pI4", + &lsa->data->id); /* FLUSH THROUGHOUT AS */ ospf_lsa_flush_as(ospf, lsa); @@ -1621,8 +1622,8 @@ static void ospf_abr_remove_unapproved_summaries(struct ospf *ospf) for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_remove_unapproved_summaries(): looking at area %s", - inet_ntoa(area->area_id)); + "ospf_abr_remove_unapproved_summaries(): looking at area %pI4", + &area->area_id); LSDB_LOOP (SUMMARY_LSDB(area), rn, lsa) if (ospf_lsa_is_self_originated(ospf, lsa)) diff --git a/ospfd/ospf_apiserver.c b/ospfd/ospf_apiserver.c index 73ce606504..9d3493e910 100644 --- a/ospfd/ospf_apiserver.c +++ b/ospfd/ospf_apiserver.c @@ -387,8 +387,8 @@ int ospf_apiserver_read(struct thread *thread) apiserv->t_sync_read = NULL; if (IS_DEBUG_OSPF_EVENT) - zlog_debug("API: ospf_apiserver_read: Peer: %s/%u", - inet_ntoa(apiserv->peer_sync.sin_addr), + zlog_debug("API: ospf_apiserver_read: Peer: %pI4/%u", + &apiserv->peer_sync.sin_addr, ntohs(apiserv->peer_sync.sin_port)); } #ifdef USE_ASYNC_READ @@ -397,8 +397,8 @@ int ospf_apiserver_read(struct thread *thread) apiserv->t_async_read = NULL; if (IS_DEBUG_OSPF_EVENT) - zlog_debug("API: ospf_apiserver_read: Peer: %s/%u", - inet_ntoa(apiserv->peer_async.sin_addr), + zlog_debug("API: ospf_apiserver_read: Peer: %pI4/%u", + &apiserv->peer_async.sin_addr, ntohs(apiserv->peer_async.sin_port)); } #endif /* USE_ASYNC_READ */ @@ -455,8 +455,8 @@ int ospf_apiserver_sync_write(struct thread *thread) } if (IS_DEBUG_OSPF_EVENT) - zlog_debug("API: ospf_apiserver_sync_write: Peer: %s/%u", - inet_ntoa(apiserv->peer_sync.sin_addr), + zlog_debug("API: ospf_apiserver_sync_write: Peer: %pI4/%u", + &apiserv->peer_sync.sin_addr, ntohs(apiserv->peer_sync.sin_port)); /* Check whether there is really a message in the fifo. */ @@ -519,8 +519,8 @@ int ospf_apiserver_async_write(struct thread *thread) } if (IS_DEBUG_OSPF_EVENT) - zlog_debug("API: ospf_apiserver_async_write: Peer: %s/%u", - inet_ntoa(apiserv->peer_async.sin_addr), + zlog_debug("API: ospf_apiserver_async_write: Peer: %pI4/%u", + &apiserv->peer_async.sin_addr, ntohs(apiserv->peer_async.sin_port)); /* Check whether there is really a message in the fifo. */ @@ -645,8 +645,8 @@ int ospf_apiserver_accept(struct thread *thread) } if (IS_DEBUG_OSPF_EVENT) - zlog_debug("API: ospf_apiserver_accept: New peer: %s/%u", - inet_ntoa(peer_sync.sin_addr), + zlog_debug("API: ospf_apiserver_accept: New peer: %pI4/%u", + &peer_sync.sin_addr, ntohs(peer_sync.sin_port)); /* Create new socket for asynchronous messages. */ @@ -657,8 +657,8 @@ int ospf_apiserver_accept(struct thread *thread) */ if (ntohs(peer_async.sin_port) == ospf_apiserver_getport()) { zlog_warn( - "API: ospf_apiserver_accept: Peer(%s/%u): Invalid async port number?", - inet_ntoa(peer_async.sin_addr), + "API: ospf_apiserver_accept: Peer(%pI4/%u): Invalid async port number?", + &peer_async.sin_addr, ntohs(peer_async.sin_port)); close(new_sync_sock); return -1; @@ -1409,8 +1409,8 @@ struct ospf_lsa *ospf_apiserver_opaque_lsa_new(struct ospf_area *area, options |= OSPF_OPTION_O; /* Don't forget to set option bit */ if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) { - zlog_debug("LSA[Type%d:%s]: Creating an Opaque-LSA instance", - protolsa->type, inet_ntoa(protolsa->id)); + zlog_debug("LSA[Type%d:%pI4]: Creating an Opaque-LSA instance", + protolsa->type, &protolsa->id); } /* Set opaque-LSA header fields. */ @@ -1510,8 +1510,8 @@ int ospf_apiserver_handle_originate_request(struct ospf_apiserver *apiserv, case OSPF_OPAQUE_LINK_LSA: oi = ospf_apiserver_if_lookup_by_addr(omsg->ifaddr); if (!oi) { - zlog_warn("apiserver_originate: unknown interface %s", - inet_ntoa(omsg->ifaddr)); + zlog_warn("apiserver_originate: unknown interface %pI4", + &omsg->ifaddr); rc = OSPF_API_NOSUCHINTERFACE; goto out; } @@ -1521,8 +1521,8 @@ int ospf_apiserver_handle_originate_request(struct ospf_apiserver *apiserv, case OSPF_OPAQUE_AREA_LSA: area = ospf_area_lookup_by_area_id(ospf, omsg->area_id); if (!area) { - zlog_warn("apiserver_originate: unknown area %s", - inet_ntoa(omsg->area_id)); + zlog_warn("apiserver_originate: unknown area %pI4", + &omsg->area_id); rc = OSPF_API_NOSUCHAREA; goto out; } @@ -1791,8 +1791,8 @@ struct ospf_lsa *ospf_apiserver_lsa_refresher(struct ospf_lsa *lsa) /* Debug logging. */ if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) { - zlog_debug("LSA[Type%d:%s]: Refresh Opaque LSA", - new->data->type, inet_ntoa(new->data->id)); + zlog_debug("LSA[Type%d:%pI4]: Refresh Opaque LSA", + new->data->type, &new->data->id); ospf_lsa_header_dump(new->data); } @@ -1829,8 +1829,8 @@ int ospf_apiserver_handle_delete_request(struct ospf_apiserver *apiserv, case OSPF_OPAQUE_AREA_LSA: area = ospf_area_lookup_by_area_id(ospf, dmsg->area_id); if (!area) { - zlog_warn("ospf_apiserver_lsa_delete: unknown area %s", - inet_ntoa(dmsg->area_id)); + zlog_warn("ospf_apiserver_lsa_delete: unknown area %pI4", + &dmsg->area_id); rc = OSPF_API_NOSUCHAREA; goto out; } @@ -1872,8 +1872,8 @@ int ospf_apiserver_handle_delete_request(struct ospf_apiserver *apiserv, old = ospf_lsa_lookup(ospf, area, dmsg->lsa_type, id, ospf->router_id); if (!old) { zlog_warn( - "ospf_apiserver_lsa_delete: LSA[Type%d:%s] not in LSDB", - dmsg->lsa_type, inet_ntoa(id)); + "ospf_apiserver_lsa_delete: LSA[Type%d:%pI4] not in LSDB", + dmsg->lsa_type, &id); rc = OSPF_API_NOSUCHLSA; goto out; } diff --git a/ospfd/ospf_asbr.c b/ospfd/ospf_asbr.c index b64ec981be..fac85c9dca 100644 --- a/ospfd/ospf_asbr.c +++ b/ospfd/ospf_asbr.c @@ -131,13 +131,12 @@ ospf_external_info_add(struct ospf *ospf, uint8_t type, unsigned short instance, } inet_ntop(AF_INET, (void *)&nexthop.s_addr, inetbuf, - INET6_BUFSIZ); + sizeof(inetbuf)); if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) zlog_debug( - "Redistribute[%s][%d][%u]: %s/%d discarding old info with NH %s.", + "Redistribute[%s][%d][%u]: %pFX discarding old info with NH %s.", ospf_redist_string(type), instance, - ospf->vrf_id, inet_ntoa(p.prefix), - p.prefixlen, inetbuf); + ospf->vrf_id, &p, inetbuf); XFREE(MTYPE_OSPF_EXTERNAL_INFO, rn->info); } @@ -155,11 +154,11 @@ ospf_external_info_add(struct ospf *ospf, uint8_t type, unsigned short instance, if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) { inet_ntop(AF_INET, (void *)&nexthop.s_addr, inetbuf, - INET6_BUFSIZ); + sizeof(inetbuf)); zlog_debug( - "Redistribute[%s][%u]: %s/%d external info created, with NH %s", + "Redistribute[%s][%u]: %pFX external info created, with NH %s", ospf_redist_string(type), ospf->vrf_id, - inet_ntoa(p.prefix), p.prefixlen, inetbuf); + &p, inetbuf); } return new; } diff --git a/ospfd/ospf_ase.c b/ospfd/ospf_ase.c index d2a30477b0..3606efc76f 100644 --- a/ospfd/ospf_ase.c +++ b/ospfd/ospf_ase.c @@ -179,8 +179,8 @@ ospf_ase_calculate_asbr_route (struct ospf *ospf, if (asbr_route == NULL) { if (IS_DEBUG_OSPF (lsa, LSA)) - zlog_debug ("ospf_ase_calculate(): Route to ASBR %s not found", - inet_ntoa (asbr.prefix)); + zlog_debug ("ospf_ase_calculate(): Route to ASBR %pI4 not found", + &asbr.prefix); return NULL; } @@ -283,7 +283,6 @@ int ospf_ase_calculate_route(struct ospf *ospf, struct ospf_lsa *lsa) struct prefix_ipv4 asbr, p; struct route_node *rn; struct ospf_route *new, * or ; - char buf1[INET_ADDRSTRLEN]; int ret; assert(lsa); @@ -301,11 +300,10 @@ int ospf_ase_calculate_route(struct ospf *ospf, struct ospf_lsa *lsa) } if (IS_DEBUG_OSPF(lsa, LSA)) { - snprintf(buf1, sizeof(buf1), "%s", - inet_ntoa(al->header.adv_router)); zlog_debug( - "Route[External]: Calculate AS-external-LSA to %s/%d adv_router %s", - inet_ntoa(al->header.id), ip_masklen(al->mask), buf1); + "Route[External]: Calculate AS-external-LSA to %pI4/%d adv_router %pI4", + &al->header.id, ip_masklen(al->mask), + &al->header.adv_router); } /* (1) If the cost specified by the LSA is LSInfinity, or if the @@ -457,9 +455,8 @@ int ospf_ase_calculate_route(struct ospf *ospf, struct ospf_lsa *lsa) if (!rn || (or = rn->info) == NULL) { if (IS_DEBUG_OSPF(lsa, LSA)) - zlog_debug("Route[External]: Adding a new route %s/%d with paths %u", - inet_ntoa(p.prefix), p.prefixlen, - listcount(asbr_route->paths)); + zlog_debug("Route[External]: Adding a new route %pFX with paths %u", + &p, listcount(asbr_route->paths)); ospf_route_add(ospf->new_external_route, &p, new, asbr_route); @@ -658,8 +655,8 @@ static int ospf_ase_calculate_timer(struct thread *t) for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) { if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_ase_calculate_timer(): looking at area %s", - inet_ntoa(area->area_id)); + "ospf_ase_calculate_timer(): looking at area %pI4", + &area->area_id); if (area->external_routing == OSPF_AREA_NSSA) LSDB_LOOP (NSSA_LSDB(area), rn, lsa) diff --git a/ospfd/ospf_bfd.c b/ospfd/ospf_bfd.c index 46ad94c3de..4640720952 100644 --- a/ospfd/ospf_bfd.c +++ b/ospfd/ospf_bfd.c @@ -76,9 +76,9 @@ static void ospf_bfd_reg_dereg_nbr(struct ospf_neighbor *nbr, int command) bfd_info = (struct bfd_info *)params->bfd_info; if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE)) - zlog_debug("%s nbr (%s) with BFD. OSPF vrf %s", + zlog_debug("%s nbr (%pI4) with BFD. OSPF vrf %s", bfd_get_command_dbg_str(command), - inet_ntoa(nbr->src), + &nbr->src, ospf_vrf_id_to_name(oi->ospf->vrf_id)); cbit = CHECK_FLAG(bfd_info->flags, BFD_FLAG_BFD_CBIT_ON); @@ -180,8 +180,8 @@ static int ospf_bfd_nbr_replay(ZAPI_CALLBACK_ARGS) continue; if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE)) - zlog_debug("Replaying nbr (%s) to BFD", - inet_ntoa(nbr->src)); + zlog_debug("Replaying nbr (%pI4) to BFD", + &nbr->src); ospf_bfd_reg_dereg_nbr(nbr, ZEBRA_BFD_DEST_UPDATE); @@ -266,18 +266,18 @@ static int ospf_bfd_interface_dest_update(ZAPI_CALLBACK_ARGS) if ((status == BFD_STATUS_DOWN) && (old_status == BFD_STATUS_UP)) { if (IS_DEBUG_OSPF(nsm, NSM_EVENTS)) - zlog_debug("NSM[%s:%s]: BFD Down", + zlog_debug("NSM[%s:%pI4]: BFD Down", IF_NAME(nbr->oi), - inet_ntoa(nbr->address.u.prefix4)); + &nbr->address.u.prefix4); OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_InactivityTimer); } if ((status == BFD_STATUS_UP) && (old_status == BFD_STATUS_DOWN)) { if (IS_DEBUG_OSPF(nsm, NSM_EVENTS)) - zlog_debug("NSM[%s:%s]: BFD Up", + zlog_debug("NSM[%s:%pI4]: BFD Up", IF_NAME(nbr->oi), - inet_ntoa(nbr->address.u.prefix4)); + &nbr->address.u.prefix4); } } diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c index 7fd1b5c64e..ba045e0418 100644 --- a/ospfd/ospf_dump.c +++ b/ospfd/ospf_dump.c @@ -242,20 +242,20 @@ static void ospf_packet_hello_dump(struct stream *s, uint16_t length) hello = (struct ospf_hello *)stream_pnt(s); zlog_debug("Hello"); - zlog_debug(" NetworkMask %s", inet_ntoa(hello->network_mask)); + zlog_debug(" NetworkMask %pI4", &hello->network_mask); zlog_debug(" HelloInterval %d", ntohs(hello->hello_interval)); zlog_debug(" Options %d (%s)", hello->options, ospf_options_dump(hello->options)); zlog_debug(" RtrPriority %d", hello->priority); zlog_debug(" RtrDeadInterval %ld", (unsigned long)ntohl(hello->dead_interval)); - zlog_debug(" DRouter %s", inet_ntoa(hello->d_router)); - zlog_debug(" BDRouter %s", inet_ntoa(hello->bd_router)); + zlog_debug(" DRouter %pI4", &hello->d_router); + zlog_debug(" BDRouter %pI4", &hello->bd_router); length -= OSPF_HEADER_SIZE + OSPF_HELLO_MIN_SIZE; zlog_debug(" # Neighbors %d", length / 4); for (i = 0; length > 0; i++, length -= sizeof(struct in_addr)) - zlog_debug(" Neighbor %s", inet_ntoa(hello->neighbors[i])); + zlog_debug(" Neighbor %pI4", &hello->neighbors[i]); } static char *ospf_dd_flags_dump(uint8_t flags, char *buf, size_t size) @@ -292,9 +292,9 @@ static void ospf_router_lsa_dump(struct stream *s, uint16_t length) len = ntohs(rl->header.length) - OSPF_LSA_HEADER_SIZE - 4; for (i = 0; len > 0; i++) { - zlog_debug(" Link ID %s", inet_ntoa(rl->link[i].link_id)); - zlog_debug(" Link Data %s", - inet_ntoa(rl->link[i].link_data)); + zlog_debug(" Link ID %pI4", &rl->link[i].link_id); + zlog_debug(" Link Data %pI4", + &rl->link[i].link_data); zlog_debug(" Type %d", (uint8_t)rl->link[i].type); zlog_debug(" TOS %d", (uint8_t)rl->link[i].tos); zlog_debug(" metric %d", ntohs(rl->link[i].metric)); @@ -317,11 +317,11 @@ static void ospf_network_lsa_dump(struct stream *s, uint16_t length) zlog_debug ("Network-LSA size %d", ntohs (nl->header.length) - OSPF_LSA_HEADER_SIZE); */ - zlog_debug(" Network Mask %s", inet_ntoa(nl->mask)); + zlog_debug(" Network Mask %pI4", &nl->mask); zlog_debug(" # Attached Routers %d", cnt); for (i = 0; i < cnt; i++) - zlog_debug(" Attached Router %s", - inet_ntoa(nl->routers[i])); + zlog_debug(" Attached Router %pI4", + &nl->routers[i]); } static void ospf_summary_lsa_dump(struct stream *s, uint16_t length) @@ -333,7 +333,7 @@ static void ospf_summary_lsa_dump(struct stream *s, uint16_t length) sl = (struct summary_lsa *)stream_pnt(s); zlog_debug(" Summary-LSA"); - zlog_debug(" Network Mask %s", inet_ntoa(sl->mask)); + zlog_debug(" Network Mask %pI4", &sl->mask); size = ntohs(sl->header.length) - OSPF_LSA_HEADER_SIZE - 4; for (i = 0; size > 0; size -= 4, i++) @@ -349,15 +349,15 @@ static void ospf_as_external_lsa_dump(struct stream *s, uint16_t length) al = (struct as_external_lsa *)stream_pnt(s); zlog_debug(" %s", ospf_lsa_type_msg[al->header.type].str); - zlog_debug(" Network Mask %s", inet_ntoa(al->mask)); + zlog_debug(" Network Mask %pI4", &al->mask); size = ntohs(al->header.length) - OSPF_LSA_HEADER_SIZE - 4; for (i = 0; size > 0; size -= 12, i++) { zlog_debug(" bit %s TOS=%d metric %d", IS_EXTERNAL_METRIC(al->e[i].tos) ? "E" : "-", al->e[i].tos & 0x7f, GET_METRIC(al->e[i].metric)); - zlog_debug(" Forwarding address %s", - inet_ntoa(al->e[i].fwd_addr)); + zlog_debug(" Forwarding address %pI4", + &al->e[i].fwd_addr); zlog_debug(" External Route Tag %" ROUTE_TAG_PRI, al->e[i].route_tag); } @@ -427,8 +427,8 @@ static void ospf_packet_ls_req_dump(struct stream *s, uint16_t length) adv_router.s_addr = stream_get_ipv4(s); zlog_debug(" LS type %d", ls_type); - zlog_debug(" Link State ID %s", inet_ntoa(ls_id)); - zlog_debug(" Advertising Router %s", inet_ntoa(adv_router)); + zlog_debug(" Link State ID %pI4", &ls_id); + zlog_debug(" Advertising Router %pI4", &adv_router); } stream_set_getp(s, sp); @@ -519,8 +519,8 @@ static void ospf_header_dump(struct ospf_header *ospfh) zlog_debug(" Type %d (%s)", ospfh->type, lookup_msg(ospf_packet_type_str, ospfh->type, NULL)); zlog_debug(" Packet Len %d", ntohs(ospfh->length)); - zlog_debug(" Router ID %s", inet_ntoa(ospfh->router_id)); - zlog_debug(" Area ID %s", inet_ntoa(ospfh->area_id)); + zlog_debug(" Router ID %pI4", &ospfh->router_id); + zlog_debug(" Area ID %pI4", &ospfh->area_id); zlog_debug(" Checksum 0x%x", ntohs(ospfh->checksum)); zlog_debug(" AuType %s", lookup_msg(ospf_auth_type_str, auth_type, NULL)); diff --git a/ospfd/ospf_dump_api.c b/ospfd/ospf_dump_api.c index e24936a473..4b68b006e2 100644 --- a/ospfd/ospf_dump_api.c +++ b/ospfd/ospf_dump_api.c @@ -127,8 +127,8 @@ void ospf_lsa_header_dump(struct lsa_header *lsah) ospf_options_dump(lsah->options)); zlog_debug(" LS type %d (%s)", lsah->type, (lsah->type ? lsah_type : "unknown type")); - zlog_debug(" Link State ID %s", inet_ntoa(lsah->id)); - zlog_debug(" Advertising Router %s", inet_ntoa(lsah->adv_router)); + zlog_debug(" Link State ID %pI4", &lsah->id); + zlog_debug(" Advertising Router %pI4", &lsah->adv_router); zlog_debug(" LS sequence number 0x%lx", (unsigned long)ntohl(lsah->ls_seqnum)); zlog_debug(" LS checksum 0x%x", ntohs(lsah->checksum)); diff --git a/ospfd/ospf_ext.c b/ospfd/ospf_ext.c index 90dc108c0e..104248694d 100644 --- a/ospfd/ospf_ext.c +++ b/ospfd/ospf_ext.c @@ -1716,8 +1716,8 @@ static uint16_t show_vty_ext_link_rmt_itf_addr(struct vty *vty, top = (struct ext_subtlv_rmt_itf_addr *)tlvh; vty_out(vty, - " Remote Interface Address Sub-TLV: Length %u\n Address: %s\n", - ntohs(top->header.length), inet_ntoa(top->value)); + " Remote Interface Address Sub-TLV: Length %u\n Address: %pI4\n", + ntohs(top->header.length), &top->value); return TLV_SIZE(tlvh); } @@ -1748,9 +1748,9 @@ static uint16_t show_vty_ext_link_lan_adj_sid(struct vty *vty, (struct ext_subtlv_lan_adj_sid *)tlvh; vty_out(vty, - " LAN-Adj-SID Sub-TLV: Length %u\n\tFlags: 0x%x\n\tMT-ID:0x%x\n\tWeight: 0x%x\n\tNeighbor ID: %s\n\t%s: %u\n", + " LAN-Adj-SID Sub-TLV: Length %u\n\tFlags: 0x%x\n\tMT-ID:0x%x\n\tWeight: 0x%x\n\tNeighbor ID: %pI4\n\t%s: %u\n", ntohs(top->header.length), top->flags, top->mtid, top->weight, - inet_ntoa(top->neighbor_id), + &top->neighbor_id, CHECK_FLAG(top->flags, EXT_SUBTLV_LINK_ADJ_SID_VFLG) ? "Label" : "Index", CHECK_FLAG(top->flags, EXT_SUBTLV_LINK_ADJ_SID_VFLG) @@ -1778,10 +1778,10 @@ static uint16_t show_vty_link_info(struct vty *vty, struct tlv_header *ext) vty_out(vty, " Extended Link TLV: Length %u\n Link Type: 0x%x\n" - " Link ID: %s\n", + " Link ID: %pI4\n", ntohs(top->header.length), top->link_type, - inet_ntoa(top->link_id)); - vty_out(vty, " Link data: %s\n", inet_ntoa(top->link_data)); + &top->link_id); + vty_out(vty, " Link data: %pI4\n", &top->link_data); tlvh = (struct tlv_header *)((char *)(ext) + TLV_HDR_SIZE + EXT_TLV_LINK_SIZE); @@ -1858,9 +1858,9 @@ static uint16_t show_vty_pref_info(struct vty *vty, struct tlv_header *ext) vty_out(vty, " Extended Prefix TLV: Length %u\n\tRoute Type: %u\n" - "\tAddress Family: 0x%x\n\tFlags: 0x%x\n\tAddress: %s/%u\n", + "\tAddress Family: 0x%x\n\tFlags: 0x%x\n\tAddress: %pI4/%u\n", ntohs(top->header.length), top->route_type, top->af, top->flags, - inet_ntoa(top->address), top->pref_length); + &top->address, top->pref_length); tlvh = (struct tlv_header *)((char *)(ext) + TLV_HDR_SIZE + EXT_TLV_PREFIX_SIZE); diff --git a/ospfd/ospf_flood.c b/ospfd/ospf_flood.c index 7d461d4587..0f43553c01 100644 --- a/ospfd/ospf_flood.c +++ b/ospfd/ospf_flood.c @@ -157,9 +157,9 @@ static void ospf_process_self_originated_lsa(struct ospf *ospf, if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "%s:LSA[Type%d:%s]: Process self-originated LSA seq 0x%x", + "%s:LSA[Type%d:%pI4]: Process self-originated LSA seq 0x%x", ospf_get_name(ospf), new->data->type, - inet_ntoa(new->data->id), ntohl(new->data->ls_seqnum)); + &new->data->id, ntohl(new->data->ls_seqnum)); /* If we're here, we installed a self-originated LSA that we received from a neighbor, i.e. it's more recent. We must see whether we want @@ -276,8 +276,8 @@ int ospf_flood(struct ospf *ospf, struct ospf_neighbor *nbr, if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "%s:LSA[Flooding]: start, NBR %s (%s), cur(%p), New-LSA[%s]", - ospf_get_name(ospf), inet_ntoa(nbr->router_id), + "%s:LSA[Flooding]: start, NBR %pI4 (%s), cur(%p), New-LSA[%s]", + ospf_get_name(ospf), &nbr->router_id, lookup_msg(ospf_nsm_state_msg, nbr->state, NULL), (void *)current, dump_lsa_key(new)); @@ -345,9 +345,9 @@ int ospf_flood(struct ospf *ospf, struct ospf_neighbor *nbr, /* Handling Max age grace LSA.*/ if (IS_DEBUG_OSPF_GR_HELPER) zlog_debug( - "%s, Received a maxage GRACE-LSA from router %s", + "%s, Received a maxage GRACE-LSA from router %pI4", __PRETTY_FUNCTION__, - inet_ntoa(new->data->adv_router)); + &new->data->adv_router); if (current) { ospf_process_maxage_grace_lsa(ospf, new, nbr); @@ -361,9 +361,9 @@ int ospf_flood(struct ospf *ospf, struct ospf_neighbor *nbr, } else { if (IS_DEBUG_OSPF_GR_HELPER) zlog_debug( - "%s, Received a GRACE-LSA from router %s", + "%s, Received a GRACE-LSA from router %pI4", __PRETTY_FUNCTION__, - inet_ntoa(new->data->adv_router)); + &new->data->adv_router); if (ospf_process_grace_lsa(ospf, new, nbr) == OSPF_GR_NOT_HELPER) { @@ -412,11 +412,15 @@ static int ospf_flood_through_interface(struct ospf_interface *oi, struct ospf_neighbor *onbr; struct route_node *rn; int retx_flag; + char buf[PREFIX_STRLEN]; if (IS_DEBUG_OSPF_EVENT) zlog_debug( "%s:ospf_flood_through_interface(): considering int %s, INBR(%s), LSA[%s] AGE %u", - ospf_get_name(oi->ospf), IF_NAME(oi), inbr ? inet_ntoa(inbr->router_id) : "NULL", + ospf_get_name(oi->ospf), IF_NAME(oi), + inbr ? + inet_ntop(AF_INET, &inbr->router_id, buf, sizeof(buf)) : + "NULL", dump_lsa_key(lsa), ntohs(lsa->data->ls_age)); if (!ospf_if_is_enable(oi)) @@ -437,8 +441,8 @@ static int ospf_flood_through_interface(struct ospf_interface *oi, onbr = rn->info; if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_flood_through_interface(): considering nbr %s(%s) (%s)", - inet_ntoa(onbr->router_id), + "ospf_flood_through_interface(): considering nbr %pI4(%s) (%s)", + &onbr->router_id, ospf_get_name(oi->ospf), lookup_msg(ospf_nsm_state_msg, onbr->state, NULL)); @@ -773,9 +777,9 @@ void ospf_ls_request_add(struct ospf_neighbor *nbr, struct ospf_lsa *lsa) * the common function "ospf_lsdb_add()" -- endo. */ if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) - zlog_debug("RqstL(%lu)++, NBR(%s(%s)), LSA[%s]", + zlog_debug("RqstL(%lu)++, NBR(%pI4(%s)), LSA[%s]", ospf_ls_request_count(nbr), - inet_ntoa(nbr->router_id), + &nbr->router_id, ospf_get_name(nbr->oi->ospf), dump_lsa_key(lsa)); ospf_lsdb_add(&nbr->ls_req, lsa); @@ -800,9 +804,9 @@ void ospf_ls_request_delete(struct ospf_neighbor *nbr, struct ospf_lsa *lsa) } if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) /* -- endo. */ - zlog_debug("RqstL(%lu)--, NBR(%s(%s)), LSA[%s]", + zlog_debug("RqstL(%lu)--, NBR(%pI4(%s)), LSA[%s]", ospf_ls_request_count(nbr), - inet_ntoa(nbr->router_id), + &nbr->router_id, ospf_get_name(nbr->oi->ospf), dump_lsa_key(lsa)); ospf_lsdb_delete(&nbr->ls_req, lsa); @@ -862,9 +866,9 @@ void ospf_ls_retransmit_add(struct ospf_neighbor *nbr, struct ospf_lsa *lsa) if (old) { old->retransmit_counter--; if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) - zlog_debug("RXmtL(%lu)--, NBR(%s(%s)), LSA[%s]", + zlog_debug("RXmtL(%lu)--, NBR(%pI4(%s)), LSA[%s]", ospf_ls_retransmit_count(nbr), - inet_ntoa(nbr->router_id), + &nbr->router_id, ospf_get_name(nbr->oi->ospf), dump_lsa_key(old)); ospf_lsdb_delete(&nbr->ls_rxmt, old); @@ -879,9 +883,9 @@ void ospf_ls_retransmit_add(struct ospf_neighbor *nbr, struct ospf_lsa *lsa) * the common function "ospf_lsdb_add()" -- endo. */ if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) - zlog_debug("RXmtL(%lu)++, NBR(%s(%s)), LSA[%s]", + zlog_debug("RXmtL(%lu)++, NBR(%pI4(%s)), LSA[%s]", ospf_ls_retransmit_count(nbr), - inet_ntoa(nbr->router_id), + &nbr->router_id, ospf_get_name(nbr->oi->ospf), dump_lsa_key(lsa)); ospf_lsdb_add(&nbr->ls_rxmt, lsa); @@ -894,9 +898,9 @@ void ospf_ls_retransmit_delete(struct ospf_neighbor *nbr, struct ospf_lsa *lsa) if (ospf_ls_retransmit_lookup(nbr, lsa)) { lsa->retransmit_counter--; if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) /* -- endo. */ - zlog_debug("RXmtL(%lu)--, NBR(%s(%s)), LSA[%s]", + zlog_debug("RXmtL(%lu)--, NBR(%pI4(%s)), LSA[%s]", ospf_ls_retransmit_count(nbr), - inet_ntoa(nbr->router_id), + &nbr->router_id, ospf_get_name(nbr->oi->ospf), dump_lsa_key(lsa)); ospf_lsdb_delete(&nbr->ls_rxmt, lsa); @@ -984,8 +988,8 @@ void ospf_lsa_flush_area(struct ospf_lsa *lsa, struct ospf_area *area) retransmissions */ lsa->data->ls_age = htons(OSPF_LSA_MAXAGE); if (IS_DEBUG_OSPF_EVENT) - zlog_debug("%s: MAXAGE set to LSA %s", __func__, - inet_ntoa(lsa->data->id)); + zlog_debug("%s: MAXAGE set to LSA %pI4", __func__, + &lsa->data->id); monotime(&lsa->tv_recv); lsa->tv_orig = lsa->tv_recv; ospf_flood_through_area(area, NULL, lsa); diff --git a/ospfd/ospf_gr_helper.c b/ospfd/ospf_gr_helper.c index 616013fb9e..9c029a49ba 100644 --- a/ospfd/ospf_gr_helper.c +++ b/ospfd/ospf_gr_helper.c @@ -377,8 +377,8 @@ int ospf_process_grace_lsa(struct ospf *ospf, struct ospf_lsa *lsa, if (IS_DEBUG_OSPF_GR_HELPER) zlog_debug( - "%s, Grace LSA received from %s, grace interval:%u, restartreason :%s", - __PRETTY_FUNCTION__, inet_ntoa(restart_addr), + "%s, Grace LSA received from %pI4, grace interval:%u, restartreason :%s", + __PRETTY_FUNCTION__, &restart_addr, grace_interval, ospf_restart_reason2str(restart_reason)); @@ -392,9 +392,9 @@ int ospf_process_grace_lsa(struct ospf *ospf, struct ospf_lsa *lsa, if (!restarter) { if (IS_DEBUG_OSPF_GR_HELPER) zlog_debug( - "%s, Restarter is not a nbr(%s) for this router.", + "%s, Restarter is not a nbr(%pI4) for this router.", __PRETTY_FUNCTION__, - inet_ntoa(restart_addr)); + &restart_addr); return OSPF_GR_NOT_HELPER; } } else @@ -425,8 +425,8 @@ int ospf_process_grace_lsa(struct ospf *ospf, struct ospf_lsa *lsa, if (!IS_NBR_STATE_FULL(restarter)) { if (IS_DEBUG_OSPF_GR_HELPER) zlog_debug( - "%s, This Neighbour %s is not in FULL state.", - __PRETTY_FUNCTION__, inet_ntoa(restarter->src)); + "%s, This Neighbour %pI4 is not in FULL state.", + __PRETTY_FUNCTION__, &restarter->src); restarter->gr_helper_info.rejected_reason = OSPF_HELPER_NOT_A_VALID_NEIGHBOUR; return OSPF_GR_NOT_HELPER; @@ -501,8 +501,8 @@ int ospf_process_grace_lsa(struct ospf *ospf, struct ospf_lsa *lsa, } else { if (IS_DEBUG_OSPF_GR_HELPER) zlog_debug( - "%s, This Router becomes a HELPER for the neighbour %s", - __PRETTY_FUNCTION__, inet_ntoa(restarter->src)); + "%s, This Router becomes a HELPER for the neighbour %pI4", + __PRETTY_FUNCTION__, &restarter->src); } /* Became a Helper to the RESTART neighbour. @@ -606,8 +606,8 @@ void ospf_helper_handle_topo_chg(struct ospf *ospf, struct ospf_lsa *lsa) if (IS_DEBUG_OSPF_GR_HELPER) zlog_debug( - "%s, Topo change detected due to lsa LSID:%s type:%d", - __PRETTY_FUNCTION__, inet_ntoa(lsa->data->id), + "%s, Topo change detected due to lsa LSID:%pI4 type:%d", + __PRETTY_FUNCTION__, &lsa->data->id, lsa->data->type); lsa->to_be_acknowledged = OSPF_GR_TRUE; @@ -670,8 +670,8 @@ void ospf_gr_helper_exit(struct ospf_neighbor *nbr, return; if (IS_DEBUG_OSPF_GR_HELPER) - zlog_debug("%s, Exiting from HELPER support to %s, due to %s", - __PRETTY_FUNCTION__, inet_ntoa(nbr->src), + zlog_debug("%s, Exiting from HELPER support to %pI4, due to %s", + __PRETTY_FUNCTION__, &nbr->src, ospf_exit_reason2str(reason)); /* Reset helper status*/ @@ -758,8 +758,8 @@ void ospf_process_maxage_grace_lsa(struct ospf *ospf, struct ospf_lsa *lsa, } if (IS_DEBUG_OSPF_GR_HELPER) - zlog_debug("%s, GraceLSA received for neighbour %s.", - __PRETTY_FUNCTION__, inet_ntoa(restartAddr)); + zlog_debug("%s, GraceLSA received for neighbour %pI4", + __PRETTY_FUNCTION__, &restartAddr); /* In case of broadcast links, if RESTARTER is DR_OTHER, * grace LSA might be received from DR, so fetching the @@ -1066,8 +1066,8 @@ static void show_ospf_grace_lsa_info(struct vty *vty, struct ospf_lsa *lsa) restartAddr = (struct grace_tlv_restart_addr *)tlvh; sum += TLV_SIZE(tlvh); - vty_out(vty, " Restarter address:%s\n", - inet_ntoa(restartAddr->addr)); + vty_out(vty, " Restarter address:%pI4\n", + &restartAddr->addr); break; default: vty_out(vty, " Unknown TLV type %d\n", diff --git a/ospfd/ospf_ia.c b/ospfd/ospf_ia.c index 7d6a19524a..f805899b81 100644 --- a/ospfd/ospf_ia.c +++ b/ospfd/ospf_ia.c @@ -130,6 +130,7 @@ static void ospf_ia_router_route(struct ospf *ospf, struct route_table *rtrs, if (IS_DEBUG_OSPF_EVENT) zlog_debug("ospf_ia_router_route(): considering %pFX", p); + /* Find a route to the same dest */ rn = route_node_get(rtrs, (struct prefix *)p); @@ -201,8 +202,8 @@ static int process_summary_lsa(struct ospf_area *area, struct route_table *rt, sl = (struct summary_lsa *)lsa->data; if (IS_DEBUG_OSPF_EVENT) - zlog_debug("process_summary_lsa(): LS ID: %s", - inet_ntoa(sl->header.id)); + zlog_debug("process_summary_lsa(): LS ID: %pI4", + &sl->header.id); metric = GET_METRIC(sl->metric); @@ -523,8 +524,8 @@ static int process_transit_summary_lsa(struct ospf_area *area, sl = (struct summary_lsa *)lsa->data; if (IS_DEBUG_OSPF_EVENT) - zlog_debug("process_transit_summaries(): LS ID: %s", - inet_ntoa(lsa->data->id)); + zlog_debug("process_transit_summaries(): LS ID: %pI4", + &lsa->data->id); metric = GET_METRIC(sl->metric); if (metric == OSPF_LS_INFINITY) { diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c index 3d2c28b1e4..6e34740166 100644 --- a/ospfd/ospf_interface.c +++ b/ospfd/ospf_interface.c @@ -977,17 +977,17 @@ struct ospf_vl_data *ospf_vl_lookup(struct ospf *ospf, struct ospf_area *area, struct listnode *node; if (IS_DEBUG_OSPF_EVENT) { - zlog_debug("%s: Looking for %s", __func__, inet_ntoa(vl_peer)); + zlog_debug("%s: Looking for %pI4", __func__, &vl_peer); if (area) - zlog_debug("%s: in area %s", __func__, - inet_ntoa(area->area_id)); + zlog_debug("%s: in area %pI4", __func__, + &area->area_id); } for (ALL_LIST_ELEMENTS_RO(ospf->vlinks, node, vl_data)) { if (IS_DEBUG_OSPF_EVENT) - zlog_debug("%s: VL %s, peer %s", __func__, + zlog_debug("%s: VL %s, peer %pI4", __func__, vl_data->vl_oi->ifp->name, - inet_ntoa(vl_data->vl_peer)); + &vl_data->vl_peer); if (area && !IPV4_ADDR_SAME(&vl_data->vl_area_id, &area->area_id)) @@ -1109,9 +1109,9 @@ static int ospf_vl_set_params(struct ospf_area *area, } if (IS_DEBUG_OSPF_EVENT) - zlog_debug("%s: %s peer address: %s, cost: %d,%schanged", + zlog_debug("%s: %s peer address: %pI4, cost: %d,%schanged", __func__, vl_data->vl_oi->ifp->name, - inet_ntoa(vl_data->peer_addr), voi->output_cost, + &vl_data->peer_addr, voi->output_cost, (changed ? " " : " un")); return changed; @@ -1128,19 +1128,19 @@ void ospf_vl_up_check(struct ospf_area *area, struct in_addr rid, if (IS_DEBUG_OSPF_EVENT) { zlog_debug("ospf_vl_up_check(): Start"); - zlog_debug("ospf_vl_up_check(): Router ID is %s", - inet_ntoa(rid)); - zlog_debug("ospf_vl_up_check(): Area is %s", - inet_ntoa(area->area_id)); + zlog_debug("ospf_vl_up_check(): Router ID is %pI4", + &rid); + zlog_debug("ospf_vl_up_check(): Area is %pI4", + &area->area_id); } for (ALL_LIST_ELEMENTS_RO(ospf->vlinks, node, vl_data)) { if (IS_DEBUG_OSPF_EVENT) { - zlog_debug("%s: considering VL, %s in area %s", + zlog_debug("%s: considering VL, %s in area %pI4", __func__, vl_data->vl_oi->ifp->name, - inet_ntoa(vl_data->vl_area_id)); - zlog_debug("%s: peer ID: %s", __func__, - inet_ntoa(vl_data->vl_peer)); + &vl_data->vl_area_id); + zlog_debug("%s: peer ID: %pI4", __func__, + &vl_data->vl_peer); } if (IPV4_ADDR_SAME(&vl_data->vl_peer, &rid) @@ -1198,8 +1198,8 @@ int ospf_full_virtual_nbrs(struct ospf_area *area) { if (IS_DEBUG_OSPF_EVENT) { zlog_debug( - "counting fully adjacent virtual neighbors in area %s", - inet_ntoa(area->area_id)); + "counting fully adjacent virtual neighbors in area %pI4", + &area->area_id); zlog_debug("there are %d of them", area->full_vls); } diff --git a/ospfd/ospf_ism.c b/ospfd/ospf_ism.c index e9faa415fe..36e97f8779 100644 --- a/ospfd/ospf_ism.c +++ b/ospfd/ospf_ism.c @@ -223,8 +223,8 @@ int ospf_dr_election(struct ospf_interface *oi) new_state = ospf_ism_state(oi); - zlog_debug("DR-Election[1st]: Backup %s", inet_ntoa(BDR(oi))); - zlog_debug("DR-Election[1st]: DR %s", inet_ntoa(DR(oi))); + zlog_debug("DR-Election[1st]: Backup %pI4", &BDR(oi)); + zlog_debug("DR-Election[1st]: DR %pI4", &DR(oi)); if (new_state != old_state && !(new_state == ISM_DROther && old_state < ISM_DROther)) { @@ -233,8 +233,8 @@ int ospf_dr_election(struct ospf_interface *oi) new_state = ospf_ism_state(oi); - zlog_debug("DR-Election[2nd]: Backup %s", inet_ntoa(BDR(oi))); - zlog_debug("DR-Election[2nd]: DR %s", inet_ntoa(DR(oi))); + zlog_debug("DR-Election[2nd]: Backup %pI4", &BDR(oi)); + zlog_debug("DR-Election[2nd]: DR %pI4", &DR(oi)); } list_delete(&el_list); diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index 2f72642bce..297a796397 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -98,8 +98,8 @@ int ospf_lsa_refresh_delay(struct ospf_lsa *lsa) if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) zlog_debug( - "LSA[Type%d:%s]: Refresh timer delay %d seconds", - lsa->data->type, inet_ntoa(lsa->data->id), + "LSA[Type%d:%pI4]: Refresh timer delay %d seconds", + lsa->data->type, &lsa->data->id, delay); assert(delay > 0); @@ -281,8 +281,8 @@ struct lsa_header *ospf_lsa_data_dup(struct lsa_header *lsah) void ospf_lsa_data_free(struct lsa_header *lsah) { if (IS_DEBUG_OSPF(lsa, LSA)) - zlog_debug("LSA[Type%d:%s]: data freed %p", lsah->type, - inet_ntoa(lsah->id), (void *)lsah); + zlog_debug("LSA[Type%d:%pI4]: data freed %p", lsah->type, + &lsah->id, (void *)lsah); XFREE(MTYPE_OSPF_LSA_DATA, lsah); } @@ -297,8 +297,8 @@ const char *dump_lsa_key(struct ospf_lsa *lsa) if (lsa != NULL && (lsah = lsa->data) != NULL) { char id[INET_ADDRSTRLEN], ar[INET_ADDRSTRLEN]; - strlcpy(id, inet_ntoa(lsah->id), sizeof(id)); - strlcpy(ar, inet_ntoa(lsah->adv_router), sizeof(ar)); + inet_ntop(AF_INET, &lsah->id, id, sizeof(id)); + inet_ntop(AF_INET, &lsah->adv_router, ar, sizeof(ar)); snprintf(buf, sizeof(buf), "Type%d,id(%s),ar(%s)", lsah->type, id, ar); @@ -628,10 +628,8 @@ static int lsa_link_ptomp_set(struct stream **s, struct ospf_interface *oi) cost); if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) zlog_debug( - "PointToMultipoint: set link to %s", - inet_ntoa( - oi->address->u - .prefix4)); + "PointToMultipoint: set link to %pI4", + &oi->address->u.prefix4); } return links; @@ -837,8 +835,8 @@ static struct ospf_lsa *ospf_router_lsa_originate(struct ospf_area *area) ospf_flood_through_area(area, NULL, new); if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) { - zlog_debug("LSA[Type%d:%s]: Originate router-LSA %p", - new->data->type, inet_ntoa(new->data->id), + zlog_debug("LSA[Type%d:%pI4]: Originate router-LSA %p", + new->data->type, &new->data->id, (void *)new); ospf_lsa_header_dump(new->data); } @@ -876,8 +874,8 @@ static struct ospf_lsa *ospf_router_lsa_refresh(struct ospf_lsa *lsa) /* Debug logging. */ if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) { - zlog_debug("LSA[Type%d:%s]: router-LSA refresh", - new->data->type, inet_ntoa(new->data->id)); + zlog_debug("LSA[Type%d:%pI4]: router-LSA refresh", + new->data->type, &new->data->id); ospf_lsa_header_dump(new->data); } @@ -929,9 +927,9 @@ int ospf_router_lsa_update(struct ospf *ospf) else if (!IPV4_ADDR_SAME(&lsa->data->id, &ospf->router_id)) { if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) zlog_debug( - "LSA[Type%d:%s]: Refresh router-LSA for Area %s", + "LSA[Type%d:%pI4]: Refresh router-LSA for Area %s", lsa->data->type, - inet_ntoa(lsa->data->id), area_str); + &lsa->data->id, area_str); ospf_refresher_unregister_lsa(ospf, lsa); ospf_lsa_flush_area(lsa, area); ospf_lsa_unlock(&area->router_lsa_self); @@ -1059,8 +1057,8 @@ void ospf_network_lsa_update(struct ospf_interface *oi) ospf_flood_through_area(oi->area, NULL, new); if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) { - zlog_debug("LSA[Type%d:%s]: Originate network-LSA %p", - new->data->type, inet_ntoa(new->data->id), + zlog_debug("LSA[Type%d:%pI4]: Originate network-LSA %p", + new->data->type, &new->data->id, (void *)new); ospf_lsa_header_dump(new->data); } @@ -1082,8 +1080,8 @@ static struct ospf_lsa *ospf_network_lsa_refresh(struct ospf_lsa *lsa) if (oi == NULL) { if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) { zlog_debug( - "LSA[Type%d:%s]: network-LSA refresh: no oi found, ick, ignoring.", - lsa->data->type, inet_ntoa(lsa->data->id)); + "LSA[Type%d:%pI4]: network-LSA refresh: no oi found, ick, ignoring.", + lsa->data->type, &lsa->data->id); ospf_lsa_header_dump(lsa->data); } return NULL; @@ -1112,8 +1110,8 @@ static struct ospf_lsa *ospf_network_lsa_refresh(struct ospf_lsa *lsa) ospf_flood_through_area(area, NULL, new); if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) { - zlog_debug("LSA[Type%d:%s]: network-LSA refresh", - new->data->type, inet_ntoa(new->data->id)); + zlog_debug("LSA[Type%d:%pI4]: network-LSA refresh", + new->data->type, &new->data->id); ospf_lsa_header_dump(new->data); } @@ -1231,8 +1229,8 @@ struct ospf_lsa *ospf_summary_lsa_originate(struct prefix_ipv4 *p, ospf_flood_through_area(area, NULL, new); if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) { - zlog_debug("LSA[Type%d:%s]: Originate summary-LSA %p", - new->data->type, inet_ntoa(new->data->id), + zlog_debug("LSA[Type%d:%pI4]: Originate summary-LSA %p", + new->data->type, &new->data->id, (void *)new); ospf_lsa_header_dump(new->data); } @@ -1267,8 +1265,8 @@ static struct ospf_lsa *ospf_summary_lsa_refresh(struct ospf *ospf, /* Debug logging. */ if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) { - zlog_debug("LSA[Type%d:%s]: summary-LSA refresh", - new->data->type, inet_ntoa(new->data->id)); + zlog_debug("LSA[Type%d:%pI4]: summary-LSA refresh", + new->data->type, &new->data->id); ospf_lsa_header_dump(new->data); } @@ -1374,8 +1372,8 @@ struct ospf_lsa *ospf_summary_asbr_lsa_originate(struct prefix_ipv4 *p, ospf_flood_through_area(area, NULL, new); if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) { - zlog_debug("LSA[Type%d:%s]: Originate summary-ASBR-LSA %p", - new->data->type, inet_ntoa(new->data->id), + zlog_debug("LSA[Type%d:%pI4]: Originate summary-ASBR-LSA %p", + new->data->type, &new->data->id, (void *)new); ospf_lsa_header_dump(new->data); } @@ -1408,8 +1406,8 @@ static struct ospf_lsa *ospf_summary_asbr_lsa_refresh(struct ospf *ospf, ospf_flood_through_area(new->area, NULL, new); if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) { - zlog_debug("LSA[Type%d:%s]: summary-ASBR-LSA refresh", - new->data->type, inet_ntoa(new->data->id)); + zlog_debug("LSA[Type%d:%pI4]: summary-ASBR-LSA refresh", + new->data->type, &new->data->id); ospf_lsa_header_dump(new->data); } @@ -1758,8 +1756,8 @@ static struct ospf_lsa *ospf_lsa_translated_nssa_new(struct ospf *ospf, == NULL) { if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_nssa_translate_originate(): Could not originate Translated Type-5 for %s", - inet_ntoa(ei.p.prefix)); + "ospf_nssa_translate_originate(): Could not originate Translated Type-5 for %pI4", + &ei.p.prefix); return NULL; } @@ -1792,8 +1790,8 @@ struct ospf_lsa *ospf_translated_nssa_originate(struct ospf *ospf, if ((new = ospf_lsa_translated_nssa_new(ospf, type7)) == NULL) { if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_translated_nssa_originate(): Could not translate Type-7, Id %s, to Type-5", - inet_ntoa(type7->data->id)); + "ospf_translated_nssa_originate(): Could not translate Type-7, Id %pI4, to Type-5", + &type7->data->id); return NULL; } @@ -1802,8 +1800,8 @@ struct ospf_lsa *ospf_translated_nssa_originate(struct ospf *ospf, if ((new = ospf_lsa_install(ospf, NULL, new)) == NULL) { flog_warn( EC_OSPF_LSA_INSTALL_FAILURE, - "ospf_lsa_translated_nssa_originate(): Could not install LSA id %s", - inet_ntoa(type7->data->id)); + "ospf_lsa_translated_nssa_originate(): Could not install LSA id %pI4", + &type7->data->id); return NULL; } @@ -1812,8 +1810,8 @@ struct ospf_lsa *ospf_translated_nssa_originate(struct ospf *ospf, "ospf_translated_nssa_originate(): translated Type 7, installed:"); ospf_lsa_header_dump(new->data); zlog_debug(" Network mask: %d", ip_masklen(extnew->mask)); - zlog_debug(" Forward addr: %s", - inet_ntoa(extnew->e[0].fwd_addr)); + zlog_debug(" Forward addr: %pI4", + &extnew->e[0].fwd_addr); } ospf->lsa_originate_count++; @@ -1878,8 +1876,8 @@ struct ospf_lsa *ospf_translated_nssa_refresh(struct ospf *ospf, if (!type7) { if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_translated_nssa_refresh(): no Type-7 found for Type-5 LSA Id %s", - inet_ntoa(type5->data->id)); + "ospf_translated_nssa_refresh(): no Type-7 found for Type-5 LSA Id %pI4", + &type5->data->id); return NULL; } @@ -1887,8 +1885,8 @@ struct ospf_lsa *ospf_translated_nssa_refresh(struct ospf *ospf, if (type5 == NULL || !CHECK_FLAG(type5->flags, OSPF_LSA_LOCAL_XLT)) { if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_translated_nssa_refresh(): No translated Type-5 found for Type-7 with Id %s", - inet_ntoa(type7->data->id)); + "ospf_translated_nssa_refresh(): No translated Type-5 found for Type-7 with Id %pI4", + &type7->data->id); return NULL; } @@ -1899,16 +1897,16 @@ struct ospf_lsa *ospf_translated_nssa_refresh(struct ospf *ospf, if ((new = ospf_lsa_translated_nssa_new(ospf, type7)) == NULL) { if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_translated_nssa_refresh(): Could not translate Type-7 for %s to Type-5", - inet_ntoa(type7->data->id)); + "ospf_translated_nssa_refresh(): Could not translate Type-7 for %pI4 to Type-5", + &type7->data->id); return NULL; } if (!(new = ospf_lsa_install(ospf, NULL, new))) { flog_warn( EC_OSPF_LSA_INSTALL_FAILURE, - "ospf_translated_nssa_refresh(): Could not install translated LSA, Id %s", - inet_ntoa(type7->data->id)); + "ospf_translated_nssa_refresh(): Could not install translated LSA, Id %pI4", + &type7->data->id); return NULL; } @@ -1987,8 +1985,8 @@ struct ospf_lsa *ospf_external_lsa_originate(struct ospf *ospf, if ((new = ospf_external_lsa_new(ospf, ei, NULL)) == NULL) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "LSA[Type5:%s]: Could not originate AS-external-LSA", - inet_ntoa(ei->p.prefix)); + "LSA[Type5:%pI4]: Could not originate AS-external-LSA", + &ei->p.prefix); return NULL; } @@ -2010,8 +2008,8 @@ struct ospf_lsa *ospf_external_lsa_originate(struct ospf *ospf, /* Debug logging. */ if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) { - zlog_debug("LSA[Type%d:%s]: Originate AS-external-LSA %p", - new->data->type, inet_ntoa(new->data->id), + zlog_debug("LSA[Type%d:%pI4]: Originate AS-external-LSA %p", + new->data->type, &new->data->id, (void *)new); ospf_lsa_header_dump(new->data); } @@ -2254,8 +2252,8 @@ struct ospf_lsa *ospf_external_lsa_refresh(struct ospf *ospf, if (!ospf_redistribute_check(ospf, ei, &changed)) { if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) zlog_debug( - "LSA[Type%d:%s]: Could not be refreshed, redist check fail", - lsa->data->type, inet_ntoa(lsa->data->id)); + "LSA[Type%d:%pI4]: Could not be refreshed, redist check fail", + lsa->data->type, &lsa->data->id); ospf_external_lsa_flush(ospf, ei->type, &ei->p, ei->ifindex /*, ei->nexthop */); return NULL; @@ -2264,8 +2262,8 @@ struct ospf_lsa *ospf_external_lsa_refresh(struct ospf *ospf, if (!changed && !force) { if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) zlog_debug( - "LSA[Type%d:%s]: Not refreshed, not changed/forced", - lsa->data->type, inet_ntoa(lsa->data->id)); + "LSA[Type%d:%pI4]: Not refreshed, not changed/forced", + lsa->data->type, &lsa->data->id); return NULL; } @@ -2279,8 +2277,8 @@ struct ospf_lsa *ospf_external_lsa_refresh(struct ospf *ospf, if (new == NULL) { if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) - zlog_debug("LSA[Type%d:%s]: Could not be refreshed", - lsa->data->type, inet_ntoa(lsa->data->id)); + zlog_debug("LSA[Type%d:%pI4]: Could not be refreshed", + lsa->data->type, &lsa->data->id); return NULL; } @@ -2305,8 +2303,8 @@ struct ospf_lsa *ospf_external_lsa_refresh(struct ospf *ospf, /* Debug logging. */ if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) { - zlog_debug("LSA[Type%d:%s]: AS-external-LSA refresh", - new->data->type, inet_ntoa(new->data->id)); + zlog_debug("LSA[Type%d:%pI4]: AS-external-LSA refresh", + new->data->type, &new->data->id); ospf_lsa_header_dump(new->data); } @@ -2681,8 +2679,6 @@ struct ospf_lsa *ospf_lsa_install(struct ospf *ospf, struct ospf_interface *oi, /* Debug logs. */ if (IS_DEBUG_OSPF(lsa, LSA_INSTALL)) { - char area_str[INET_ADDRSTRLEN]; - switch (lsa->data->type) { case OSPF_AS_EXTERNAL_LSA: case OSPF_OPAQUE_AS_LSA: @@ -2692,13 +2688,11 @@ struct ospf_lsa *ospf_lsa_install(struct ospf *ospf, struct ospf_interface *oi, new->data->type, NULL)); break; default: - strlcpy(area_str, inet_ntoa(new->area->area_id), - sizeof(area_str)); - zlog_debug("LSA[%s]: Install %s to Area %s", + zlog_debug("LSA[%s]: Install %s to Area %pI4", dump_lsa_key(new), lookup_msg(ospf_lsa_type_msg, new->data->type, NULL), - area_str); + &new->area->area_id); break; } } @@ -2709,8 +2703,8 @@ struct ospf_lsa *ospf_lsa_install(struct ospf *ospf, struct ospf_interface *oi, */ if (IS_LSA_MAXAGE(new)) { if (IS_DEBUG_OSPF(lsa, LSA_INSTALL)) - zlog_debug("LSA[Type%d:%s]: Install LSA 0x%p, MaxAge", - new->data->type, inet_ntoa(new->data->id), + zlog_debug("LSA[Type%d:%pI4]: Install LSA 0x%p, MaxAge", + new->data->type, &new->data->id, (void *)lsa); ospf_lsa_maxage(ospf, lsa); } @@ -2786,16 +2780,16 @@ static int ospf_maxage_lsa_remover(struct thread *thread) if (IS_LSA_SELF(lsa)) if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) zlog_debug( - "LSA[Type%d:%s]: LSA 0x%lx is self-originated: ", + "LSA[Type%d:%pI4]: LSA 0x%lx is self-originated: ", lsa->data->type, - inet_ntoa(lsa->data->id), + &lsa->data->id, (unsigned long)lsa); if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) zlog_debug( - "LSA[Type%d:%s]: MaxAge LSA removed from list", + "LSA[Type%d:%pI4]: MaxAge LSA removed from list", lsa->data->type, - inet_ntoa(lsa->data->id)); + &lsa->data->id); if (CHECK_FLAG(lsa->flags, OSPF_LSA_PREMATURE_AGE)) { if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) @@ -2812,9 +2806,9 @@ static int ospf_maxage_lsa_remover(struct thread *thread) } else { if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) zlog_debug( - "%s: LSA[Type%d:%s]: No associated LSDB!", + "%s: LSA[Type%d:%pI4]: No associated LSDB!", __func__, lsa->data->type, - inet_ntoa(lsa->data->id)); + &lsa->data->id); } } @@ -2871,8 +2865,8 @@ void ospf_lsa_maxage(struct ospf *ospf, struct ospf_lsa *lsa) if (CHECK_FLAG(lsa->flags, OSPF_LSA_IN_MAXAGE)) { if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) zlog_debug( - "LSA[Type%d:%s]: %p already exists on MaxAge LSA list", - lsa->data->type, inet_ntoa(lsa->data->id), + "LSA[Type%d:%pI4]: %p already exists on MaxAge LSA list", + lsa->data->type, &lsa->data->id, (void *)lsa); return; } @@ -3107,8 +3101,8 @@ struct ospf_lsa *ospf_lsa_lookup_by_header(struct ospf_area *area, if (match == NULL) if (IS_DEBUG_OSPF(lsa, LSA) == OSPF_DEBUG_LSA) - zlog_debug("LSA[Type%d:%s]: Lookup by header, NO MATCH", - lsah->type, inet_ntoa(lsah->id)); + zlog_debug("LSA[Type%d:%pI4]: Lookup by header, NO MATCH", + lsah->type, &lsah->id); return match; } @@ -3204,8 +3198,8 @@ int ospf_lsa_flush_schedule(struct ospf *ospf, struct ospf_lsa *lsa) if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "LSA[Type%d:%s]: Schedule self-originated LSA to FLUSH", - lsa->data->type, inet_ntoa(lsa->data->id)); + "LSA[Type%d:%pI4]: Schedule self-originated LSA to FLUSH", + lsa->data->type, &lsa->data->id); /* Force given lsa's age to MaxAge. */ lsa->data->ls_age = htons(OSPF_LSA_MAXAGE); @@ -3242,9 +3236,9 @@ void ospf_flush_self_originated_lsas_now(struct ospf *ospf) if ((lsa = area->router_lsa_self) != NULL) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "LSA[Type%d:%s]: Schedule self-originated LSA to FLUSH", + "LSA[Type%d:%pI4]: Schedule self-originated LSA to FLUSH", lsa->data->type, - inet_ntoa(lsa->data->id)); + &lsa->data->id); ospf_refresher_unregister_lsa(ospf, lsa); ospf_lsa_flush_area(lsa, area); @@ -3257,9 +3251,9 @@ void ospf_flush_self_originated_lsas_now(struct ospf *ospf) && oi->state == ISM_DR && oi->full_nbrs > 0) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "LSA[Type%d:%s]: Schedule self-originated LSA to FLUSH", + "LSA[Type%d:%pI4]: Schedule self-originated LSA to FLUSH", lsa->data->type, - inet_ntoa(lsa->data->id)); + &lsa->data->id); ospf_refresher_unregister_lsa( ospf, oi->network_lsa_self); @@ -3527,8 +3521,8 @@ void ospf_refresher_register_lsa(struct ospf *ospf, struct ospf_lsa *lsa) if (IS_DEBUG_OSPF(lsa, LSA_REFRESH)) zlog_debug( - "LSA[Refresh:Type%d:%s]: age %d, added to index %d", - lsa->data->type, inet_ntoa(lsa->data->id), + "LSA[Refresh:Type%d:%pI4]: age %d, added to index %d", + lsa->data->type, &lsa->data->id, LS_AGE(lsa), index); if (!ospf->lsa_refresh_queue.qs[index]) @@ -3540,8 +3534,8 @@ void ospf_refresher_register_lsa(struct ospf *ospf, struct ospf_lsa *lsa) if (IS_DEBUG_OSPF(lsa, LSA_REFRESH)) zlog_debug( - "LSA[Refresh:Type%d:%s]: ospf_refresher_register_lsa(): setting refresh_list on lsa %p (slod %d)", - lsa->data->type, inet_ntoa(lsa->data->id), + "LSA[Refresh:Type%d:%pI4]: ospf_refresher_register_lsa(): setting refresh_list on lsa %p (slod %d)", + lsa->data->type, &lsa->data->id, (void *)lsa, index); } } @@ -3612,9 +3606,9 @@ int ospf_lsa_refresh_walker(struct thread *t) lsa)) { if (IS_DEBUG_OSPF(lsa, LSA_REFRESH)) zlog_debug( - "LSA[Refresh:Type%d:%s]: ospf_lsa_refresh_walker(): refresh lsa %p (slot %d)", + "LSA[Refresh:Type%d:%pI4]: ospf_lsa_refresh_walker(): refresh lsa %p (slot %d)", lsa->data->type, - inet_ntoa(lsa->data->id), + &lsa->data->id, (void *)lsa, i); assert(lsa->lock > 0); diff --git a/ospfd/ospf_neighbor.c b/ospfd/ospf_neighbor.c index 52ee21473d..2fa43923ab 100644 --- a/ospfd/ospf_neighbor.c +++ b/ospfd/ospf_neighbor.c @@ -184,8 +184,8 @@ void ospf_nbr_delete(struct ospf_neighbor *nbr) rn->info = NULL; route_unlock_node(rn); } else - zlog_info("Can't find neighbor %s in the interface %s", - inet_ntoa(nbr->src), IF_NAME(oi)); + zlog_info("Can't find neighbor %pI4 in the interface %s", + &nbr->src, IF_NAME(oi)); route_unlock_node(rn); } else { @@ -284,9 +284,8 @@ void ospf_nbr_add_self(struct ospf_interface *oi, struct in_addr router_id) /* There is already pseudo neighbor. */ if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "router_id %s already present in neighbor table. node refcount %u", - inet_ntoa(router_id), - route_node_get_lock_count(rn)); + "router_id %pI4 already present in neighbor table. node refcount %u", + &router_id, route_node_get_lock_count(rn)); route_unlock_node(rn); } else rn->info = oi->nbr_self; @@ -402,8 +401,8 @@ void ospf_renegotiate_optional_capabilities(struct ospf *top) if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "Renegotiate optional capabilities with neighbor(%s)", - inet_ntoa(nbr->router_id)); + "Renegotiate optional capabilities with neighbor(%pI4)", + &nbr->router_id); OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_SeqNumberMismatch); } @@ -460,8 +459,8 @@ static struct ospf_neighbor *ospf_nbr_add(struct ospf_interface *oi, nbr->crypt_seqnum = ospfh->u.crypt.crypt_seqnum; if (IS_DEBUG_OSPF_EVENT) - zlog_debug("NSM[%s:%s]: start", IF_NAME(oi), - inet_ntoa(nbr->router_id)); + zlog_debug("NSM[%s:%pI4]: start", IF_NAME(oi), + &nbr->router_id); return nbr; } diff --git a/ospfd/ospf_network.c b/ospfd/ospf_network.c index 28aec41eba..00fbdc21a1 100644 --- a/ospfd/ospf_network.c +++ b/ospfd/ospf_network.c @@ -53,14 +53,14 @@ int ospf_if_add_allspfrouters(struct ospf *top, struct prefix *p, if (ret < 0) flog_err( EC_LIB_SOCKET, - "can't setsockopt IP_ADD_MEMBERSHIP (fd %d, addr %s, ifindex %u, AllSPFRouters): %s; perhaps a kernel limit on # of multicast group memberships has been exceeded?", - top->fd, inet_ntoa(p->u.prefix4), ifindex, + "can't setsockopt IP_ADD_MEMBERSHIP (fd %d, addr %pI4, ifindex %u, AllSPFRouters): %s; perhaps a kernel limit on # of multicast group memberships has been exceeded?", + top->fd, &p->u.prefix4, ifindex, safe_strerror(errno)); else { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "interface %s [%u] join AllSPFRouters Multicast group.", - inet_ntoa(p->u.prefix4), ifindex); + "interface %pI4 [%u] join AllSPFRouters Multicast group.", + &p->u.prefix4, ifindex); } return ret; @@ -76,14 +76,14 @@ int ospf_if_drop_allspfrouters(struct ospf *top, struct prefix *p, ifindex); if (ret < 0) flog_err(EC_LIB_SOCKET, - "can't setsockopt IP_DROP_MEMBERSHIP (fd %d, addr %s, ifindex %u, AllSPFRouters): %s", - top->fd, inet_ntoa(p->u.prefix4), ifindex, + "can't setsockopt IP_DROP_MEMBERSHIP (fd %d, addr %pI4, ifindex %u, AllSPFRouters): %s", + top->fd, &p->u.prefix4, ifindex, safe_strerror(errno)); else { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "interface %s [%u] leave AllSPFRouters Multicast group.", - inet_ntoa(p->u.prefix4), ifindex); + "interface %pI4 [%u] leave AllSPFRouters Multicast group.", + &p->u.prefix4, ifindex); } return ret; @@ -101,13 +101,13 @@ int ospf_if_add_alldrouters(struct ospf *top, struct prefix *p, if (ret < 0) flog_err( EC_LIB_SOCKET, - "can't setsockopt IP_ADD_MEMBERSHIP (fd %d, addr %s, ifindex %u, AllDRouters): %s; perhaps a kernel limit on # of multicast group memberships has been exceeded?", - top->fd, inet_ntoa(p->u.prefix4), ifindex, + "can't setsockopt IP_ADD_MEMBERSHIP (fd %d, addr %pI4, ifindex %u, AllDRouters): %s; perhaps a kernel limit on # of multicast group memberships has been exceeded?", + top->fd, &p->u.prefix4, ifindex, safe_strerror(errno)); else zlog_debug( - "interface %s [%u] join AllDRouters Multicast group.", - inet_ntoa(p->u.prefix4), ifindex); + "interface %pI4 [%u] join AllDRouters Multicast group.", + &p->u.prefix4, ifindex); return ret; } @@ -122,13 +122,13 @@ int ospf_if_drop_alldrouters(struct ospf *top, struct prefix *p, ifindex); if (ret < 0) flog_err(EC_LIB_SOCKET, - "can't setsockopt IP_DROP_MEMBERSHIP (fd %d, addr %s, ifindex %u, AllDRouters): %s", - top->fd, inet_ntoa(p->u.prefix4), ifindex, + "can't setsockopt IP_DROP_MEMBERSHIP (fd %d, addr %pI4, ifindex %u, AllDRouters): %s", + top->fd, &p->u.prefix4, ifindex, safe_strerror(errno)); else zlog_debug( - "interface %s [%u] leave AllDRouters Multicast group.", - inet_ntoa(p->u.prefix4), ifindex); + "interface %pI4 [%u] leave AllDRouters Multicast group.", + &p->u.prefix4, ifindex); return ret; } @@ -161,8 +161,8 @@ int ospf_if_ipmulticast(struct ospf *top, struct prefix *p, ifindex_t ifindex) ret = setsockopt_ipv4_multicast_if(top->fd, p->u.prefix4, ifindex); if (ret < 0) flog_err(EC_LIB_SOCKET, - "can't setsockopt IP_MULTICAST_IF(fd %d, addr %s, ifindex %u): %s", - top->fd, inet_ntoa(p->u.prefix4), ifindex, + "can't setsockopt IP_MULTICAST_IF(fd %d, addr %pI4, ifindex %u): %s", + top->fd, &p->u.prefix4, ifindex, safe_strerror(errno)); #endif diff --git a/ospfd/ospf_nsm.c b/ospfd/ospf_nsm.c index 2931831826..26e7855e8c 100644 --- a/ospfd/ospf_nsm.c +++ b/ospfd/ospf_nsm.c @@ -66,8 +66,8 @@ static int ospf_inactivity_timer(struct thread *thread) nbr->t_inactivity = NULL; if (IS_DEBUG_OSPF(nsm, NSM_TIMERS)) - zlog_debug("NSM[%s:%s:%s]: Timer (Inactivity timer expire)", - IF_NAME(nbr->oi), inet_ntoa(nbr->router_id), + zlog_debug("NSM[%s:%pI4:%s]: Timer (Inactivity timer expire)", + IF_NAME(nbr->oi), &nbr->router_id, ospf_get_name(nbr->oi->ospf)); /* Dont trigger NSM_InactivityTimer event , if the current @@ -91,8 +91,8 @@ static int ospf_db_desc_timer(struct thread *thread) nbr->t_db_desc = NULL; if (IS_DEBUG_OSPF(nsm, NSM_TIMERS)) - zlog_debug("NSM[%s:%s:%s]: Timer (DD Retransmit timer expire)", - IF_NAME(nbr->oi), inet_ntoa(nbr->src), + zlog_debug("NSM[%s:%pI4:%s]: Timer (DD Retransmit timer expire)", + IF_NAME(nbr->oi), &nbr->src, ospf_get_name(nbr->oi->ospf)); /* resent last send DD packet. */ @@ -398,9 +398,9 @@ static int nsm_kill_nbr(struct ospf_neighbor *nbr) if (IS_DEBUG_OSPF(nsm, NSM_EVENTS)) zlog_debug( - "NSM[%s:%s:%s]: Down (PollIntervalTimer scheduled)", + "NSM[%s:%pI4:%s]: Down (PollIntervalTimer scheduled)", IF_NAME(nbr->oi), - inet_ntoa(nbr->address.u.prefix4), + &nbr->address.u.prefix4, ospf_get_name(nbr->oi->ospf)); } @@ -597,8 +597,8 @@ static void nsm_notice_state_change(struct ospf_neighbor *nbr, int next_state, { /* Logging change of status. */ if (IS_DEBUG_OSPF(nsm, NSM_STATUS)) - zlog_debug("NSM[%s:%s:%s]: State change %s -> %s (%s)", - IF_NAME(nbr->oi), inet_ntoa(nbr->router_id), + zlog_debug("NSM[%s:%pI4:%s]: State change %s -> %s (%s)", + IF_NAME(nbr->oi), &nbr->router_id, ospf_get_name(nbr->oi->ospf), lookup_msg(ospf_nsm_state_msg, nbr->state, NULL), lookup_msg(ospf_nsm_state_msg, next_state, NULL), @@ -608,8 +608,8 @@ static void nsm_notice_state_change(struct ospf_neighbor *nbr, int next_state, if (CHECK_FLAG(nbr->oi->ospf->config, OSPF_LOG_ADJACENCY_CHANGES) && (CHECK_FLAG(nbr->oi->ospf->config, OSPF_LOG_ADJACENCY_DETAIL) || (next_state == NSM_Full) || (next_state < nbr->state))) - zlog_notice("AdjChg: Nbr %s(%s) on %s: %s -> %s (%s)", - inet_ntoa(nbr->router_id), + zlog_notice("AdjChg: Nbr %pI4(%s) on %s: %s -> %s (%s)", + &nbr->router_id, ospf_get_name(nbr->oi->ospf), IF_NAME(nbr->oi), lookup_msg(ospf_nsm_state_msg, nbr->state, NULL), lookup_msg(ospf_nsm_state_msg, next_state, NULL), @@ -691,8 +691,8 @@ static void nsm_change_state(struct ospf_neighbor *nbr, int state) if (CHECK_FLAG(oi->ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) zlog_info( - "%s:[%s:%s], %s -> %s): scheduling new router-LSA origination", - __func__, inet_ntoa(nbr->router_id), + "%s:[%pI4:%s], %s -> %s): scheduling new router-LSA origination", + __func__, &nbr->router_id, ospf_get_name(oi->ospf), lookup_msg(ospf_nsm_state_msg, old_state, NULL), lookup_msg(ospf_nsm_state_msg, state, NULL)); @@ -749,10 +749,10 @@ static void nsm_change_state(struct ospf_neighbor *nbr, int state) OSPF_DD_FLAG_I | OSPF_DD_FLAG_M | OSPF_DD_FLAG_MS; if (CHECK_FLAG(oi->ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) zlog_info( - "%s: Initializing [DD]: %s with seqnum:%x , flags:%x", + "%s: Initializing [DD]: %pI4 with seqnum:%x , flags:%x", (oi->ospf->name) ? oi->ospf->name : VRF_DEFAULT_NAME, - inet_ntoa(nbr->router_id), nbr->dd_seqnum, + &nbr->router_id, nbr->dd_seqnum, nbr->dd_flags); ospf_db_desc_send(nbr); } @@ -777,8 +777,8 @@ int ospf_nsm_event(struct thread *thread) event = THREAD_VAL(thread); if (IS_DEBUG_OSPF(nsm, NSM_EVENTS)) - zlog_debug("NSM[%s:%s:%s]: %s (%s)", IF_NAME(nbr->oi), - inet_ntoa(nbr->router_id), + zlog_debug("NSM[%s:%pI4:%s]: %s (%s)", IF_NAME(nbr->oi), + &nbr->router_id, ospf_get_name(nbr->oi->ospf), lookup_msg(ospf_nsm_state_msg, nbr->state, NULL), ospf_nsm_event_str[event]); @@ -802,8 +802,8 @@ int ospf_nsm_event(struct thread *thread) */ flog_err( EC_OSPF_FSM_INVALID_STATE, - "NSM[%s:%s:%s]: %s (%s): Warning: action tried to change next_state to %s", - IF_NAME(nbr->oi), inet_ntoa(nbr->router_id), + "NSM[%s:%pI4:%s]: %s (%s): Warning: action tried to change next_state to %s", + IF_NAME(nbr->oi), &nbr->router_id, ospf_get_name(nbr->oi->ospf), lookup_msg(ospf_nsm_state_msg, nbr->state, NULL), diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c index 061ada5b16..5ba61b3184 100644 --- a/ospfd/ospf_opaque.c +++ b/ospfd/ospf_opaque.c @@ -1469,8 +1469,8 @@ static int ospf_opaque_type10_lsa_originate(struct thread *t) if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "Timer[Type10-LSA]: Originate Opaque-LSAs for Area %s", - inet_ntoa(area->area_id)); + "Timer[Type10-LSA]: Originate Opaque-LSAs for Area %pI4", + &area->area_id); rc = opaque_lsa_originate_callback(ospf_opaque_type10_funclist, area); @@ -1626,8 +1626,8 @@ struct ospf_lsa *ospf_opaque_lsa_refresh(struct ospf_lsa *lsa) * LSA from the routing domain. */ if (IS_DEBUG_OSPF_EVENT) - zlog_debug("LSA[Type%d:%s]: Flush stray Opaque-LSA", - lsa->data->type, inet_ntoa(lsa->data->id)); + zlog_debug("LSA[Type%d:%pI4]: Flush stray Opaque-LSA", + lsa->data->type, &lsa->data->id); lsa->data->ls_age = htons(OSPF_LSA_MAXAGE); ospf_lsa_flush(ospf, lsa); @@ -1701,8 +1701,8 @@ void ospf_opaque_lsa_reoriginate_schedule(void *lsa_type_dependent, if ((top = area->ospf) == NULL) { flog_warn( EC_OSPF_LSA, - "ospf_opaque_lsa_reoriginate_schedule: AREA(%s) -> TOP?", - inet_ntoa(area->area_id)); + "ospf_opaque_lsa_reoriginate_schedule: AREA(%pI4) -> TOP?", + &area->area_id); goto out; } if (!list_isempty(ospf_opaque_type10_funclist) @@ -1710,8 +1710,8 @@ void ospf_opaque_lsa_reoriginate_schedule(void *lsa_type_dependent, && area->t_opaque_lsa_self != NULL) { flog_warn( EC_OSPF_LSA, - "Type-10 Opaque-LSA (opaque_type=%u): Common origination for AREA(%s) has already started", - opaque_type, inet_ntoa(area->area_id)); + "Type-10 Opaque-LSA (opaque_type=%u): Common origination for AREA(%pI4) has already started", + opaque_type, &area->area_id); goto out; } func = ospf_opaque_type10_lsa_reoriginate_timer; @@ -1927,8 +1927,8 @@ static int ospf_opaque_type10_lsa_reoriginate_timer(struct thread *t) if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "Timer[Type10-LSA]: Re-originate Opaque-LSAs (opaque-type=%u) for Area %s", - oipt->opaque_type, inet_ntoa(area->area_id)); + "Timer[Type10-LSA]: Re-originate Opaque-LSAs (opaque-type=%u) for Area %pI4", + oipt->opaque_type, &area->area_id); rc = (*functab->lsa_originator)(area); out: diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index 160982a238..8cb0062ea4 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -606,15 +606,15 @@ static void ospf_write_frags(int fd, struct ospf_packet *op, struct ip *iph, if (ret < 0) flog_err( EC_LIB_SOCKET, - "*** ospf_write_frags: sendmsg failed to %s, id %d, off %d, len %d, mtu %u failed with %s", - inet_ntoa(iph->ip_dst), iph->ip_id, iph->ip_off, + "*** ospf_write_frags: sendmsg failed to %pI4, id %d, off %d, len %d, mtu %u failed with %s", + &iph->ip_dst, iph->ip_id, iph->ip_off, iph->ip_len, mtu, safe_strerror(errno)); if (IS_DEBUG_OSPF_PACKET(type - 1, SEND)) { zlog_debug( - "ospf_write_frags: sent id %d, off %d, len %d to %s", + "ospf_write_frags: sent id %d, off %d, len %d to %pI4", iph->ip_id, iph->ip_off, iph->ip_len, - inet_ntoa(iph->ip_dst)); + &iph->ip_dst); } iph->ip_off += offset; @@ -659,8 +659,8 @@ static int ospf_write(struct thread *thread) if (ospf->fd < 0 || ospf->oi_running == 0) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_write failed to send, fd %d, instance %u" - ,ospf->fd, ospf->oi_running); + "ospf_write failed to send, fd %d, instance %u", + ospf->fd, ospf->oi_running); return -1; } @@ -799,15 +799,15 @@ static int ospf_write(struct thread *thread) sockopt_iphdrincl_swab_systoh(&iph); if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_write to %s, id %d, off %d, len %d, interface %s, mtu %u:", - inet_ntoa(iph.ip_dst), iph.ip_id, iph.ip_off, + "ospf_write to %pI4, id %d, off %d, len %d, interface %s, mtu %u:", + &iph.ip_dst, iph.ip_id, iph.ip_off, iph.ip_len, oi->ifp->name, oi->ifp->mtu); if (ret < 0) flog_err( EC_LIB_SOCKET, - "*** sendmsg in ospf_write failed to %s, id %d, off %d, len %d, interface %s, mtu %u: %s", - inet_ntoa(iph.ip_dst), iph.ip_id, iph.ip_off, + "*** sendmsg in ospf_write failed to %pI4, id %d, off %d, len %d, interface %s, mtu %u: %s", + &iph.ip_dst, iph.ip_id, iph.ip_off, iph.ip_len, oi->ifp->name, oi->ifp->mtu, safe_strerror(errno)); @@ -820,9 +820,9 @@ static int ospf_write(struct thread *thread) ospf_packet_dump(op->s); } - zlog_debug("%s sent to [%s] via [%s].", + zlog_debug("%s sent to [%pI4] via [%s].", lookup_msg(ospf_packet_type_str, type, NULL), - inet_ntoa(op->dst), IF_NAME(oi)); + &op->dst, IF_NAME(oi)); if (IS_DEBUG_OSPF_PACKET(type - 1, DETAIL)) zlog_debug( @@ -896,10 +896,10 @@ static void ospf_hello(struct ip *iph, struct ospf_header *ospfh, if (IPV4_ADDR_SAME(&ospfh->router_id, &oi->ospf->router_id)) { if (IS_DEBUG_OSPF_PACKET(ospfh->type - 1, RECV)) { zlog_debug( - "ospf_header[%s/%s]: selforiginated, dropping.", + "ospf_header[%s/%pI4]: selforiginated, dropping.", lookup_msg(ospf_packet_type_str, ospfh->type, NULL), - inet_ntoa(iph->ip_src)); + &iph->ip_src); } return; } @@ -916,8 +916,8 @@ static void ospf_hello(struct ip *iph, struct ospf_header *ospfh, if (oi->address->prefixlen != p.prefixlen) { flog_warn( EC_OSPF_PACKET, - "Packet %s [Hello:RECV]: NetworkMask mismatch on %s (configured prefix length is %d, but hello packet indicates %d).", - inet_ntoa(ospfh->router_id), IF_NAME(oi), + "Packet %pI4 [Hello:RECV]: NetworkMask mismatch on %s (configured prefix length is %d, but hello packet indicates %d).", + &ospfh->router_id, IF_NAME(oi), (int)oi->address->prefixlen, (int)p.prefixlen); return; } @@ -925,8 +925,8 @@ static void ospf_hello(struct ip *iph, struct ospf_header *ospfh, /* Compare Router Dead Interval. */ if (OSPF_IF_PARAM(oi, v_wait) != ntohl(hello->dead_interval)) { flog_warn(EC_OSPF_PACKET, - "Packet %s [Hello:RECV]: RouterDeadInterval mismatch (expected %u, but received %u).", - inet_ntoa(ospfh->router_id), + "Packet %pI4 [Hello:RECV]: RouterDeadInterval mismatch (expected %u, but received %u).", + &ospfh->router_id, OSPF_IF_PARAM(oi, v_wait), ntohl(hello->dead_interval)); return; @@ -938,8 +938,8 @@ static void ospf_hello(struct ip *iph, struct ospf_header *ospfh, != ntohs(hello->hello_interval)) { flog_warn( EC_OSPF_PACKET, - "Packet %s [Hello:RECV]: HelloInterval mismatch (expected %u, but received %u).", - inet_ntoa(ospfh->router_id), + "Packet %pI4 [Hello:RECV]: HelloInterval mismatch (expected %u, but received %u).", + &ospfh->router_id, OSPF_IF_PARAM(oi, v_hello), ntohs(hello->hello_interval)); return; @@ -947,8 +947,8 @@ static void ospf_hello(struct ip *iph, struct ospf_header *ospfh, } if (IS_DEBUG_OSPF_EVENT) - zlog_debug("Packet %s [Hello:RECV]: Options %s vrf %s", - inet_ntoa(ospfh->router_id), + zlog_debug("Packet %pI4 [Hello:RECV]: Options %s vrf %s", + &ospfh->router_id, ospf_options_dump(hello->options), ospf_vrf_id_to_name(oi->ospf->vrf_id)); @@ -962,8 +962,8 @@ static void ospf_hello(struct ip *iph, struct ospf_header *ospfh, * relationship. */ flog_warn(EC_OSPF_PACKET, - "Packet %s [Hello:RECV]: T-bit on, drop it.", - inet_ntoa(ospfh->router_id)); + "Packet %pI4 [Hello:RECV]: T-bit on, drop it.", + &ospfh->router_id); return; } #endif /* REJECT_IF_TBIT_ON */ @@ -975,8 +975,8 @@ static void ospf_hello(struct ip *iph, struct ospf_header *ospfh, * the bit should be set in DD packet only. */ flog_warn(EC_OSPF_PACKET, - "Packet %s [Hello:RECV]: O-bit abuse?", - inet_ntoa(ospfh->router_id)); + "Packet %pI4 [Hello:RECV]: O-bit abuse?", + &ospfh->router_id); #ifdef STRICT_OBIT_USAGE_CHECK return; /* Reject this packet. */ #else /* STRICT_OBIT_USAGE_CHECK */ @@ -993,14 +993,14 @@ static void ospf_hello(struct ip *iph, struct ospf_header *ospfh, && !CHECK_FLAG(hello->options, OSPF_OPTION_E))) { flog_warn( EC_OSPF_PACKET, - "NSSA-Packet-%s[Hello:RECV]: my options: %x, his options %x", - inet_ntoa(ospfh->router_id), OPTIONS(oi), + "NSSA-Packet-%pI4[Hello:RECV]: my options: %x, his options %x", + &ospfh->router_id, OPTIONS(oi), hello->options); return; } if (IS_DEBUG_OSPF_NSSA) - zlog_debug("NSSA-Hello:RECV:Packet from %s:", - inet_ntoa(ospfh->router_id)); + zlog_debug("NSSA-Hello:RECV:Packet from %pI4:", + &ospfh->router_id); } else /* The setting of the E-bit found in the Hello Packet's Options field must match this area's ExternalRoutingCapability A @@ -1011,8 +1011,8 @@ static void ospf_hello(struct ip *iph, struct ospf_header *ospfh, != CHECK_FLAG(hello->options, OSPF_OPTION_E)) { flog_warn( EC_OSPF_PACKET, - "Packet %s [Hello:RECV]: my options: %x, his options %x", - inet_ntoa(ospfh->router_id), OPTIONS(oi), + "Packet %pI4 [Hello:RECV]: my options: %x, his options %x", + &ospfh->router_id, OPTIONS(oi), hello->options); return; } @@ -1147,8 +1147,8 @@ static void ospf_db_desc_proc(struct stream *s, struct ospf_interface *oi, if (IS_OPAQUE_LSA(lsah->type) && !CHECK_FLAG(nbr->options, OSPF_OPTION_O)) { flog_warn(EC_OSPF_PACKET, - "LSA[Type%d:%s]: Opaque capability mismatch?", - lsah->type, inet_ntoa(lsah->id)); + "LSA[Type%d:%pI4]: Opaque capability mismatch?", + lsah->type, &lsah->id); OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_SeqNumberMismatch); return; } @@ -1162,8 +1162,8 @@ static void ospf_db_desc_proc(struct stream *s, struct ospf_interface *oi, if (oi->area->external_routing == OSPF_AREA_STUB) { flog_warn( EC_OSPF_PACKET, - "Packet [DD:RECV]: LSA[Type%d:%s] from %s area.", - lsah->type, inet_ntoa(lsah->id), + "Packet [DD:RECV]: LSA[Type%d:%pI4] from %s area.", + lsah->type, &lsah->id, (oi->area->external_routing == OSPF_AREA_STUB) ? "STUB" @@ -1218,8 +1218,8 @@ static void ospf_db_desc_proc(struct stream *s, struct ospf_interface *oi, */ if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "Packet [DD:RECV]: LSA received Type %d, ID %s is not recent.", - lsah->type, inet_ntoa(lsah->id)); + "Packet [DD:RECV]: LSA received Type %d, ID %pI4 is not recent.", + lsah->type, &lsah->id); ospf_lsa_discard(new); } } @@ -1287,8 +1287,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, nbr = ospf_nbr_lookup(oi, iph, ospfh); if (nbr == NULL) { - flog_warn(EC_OSPF_PACKET, "Packet[DD]: Unknown Neighbor %s", - inet_ntoa(ospfh->router_id)); + flog_warn(EC_OSPF_PACKET, "Packet[DD]: Unknown Neighbor %pI4", + &ospfh->router_id); return; } @@ -1297,8 +1297,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, && (ntohs(dd->mtu) > oi->ifp->mtu)) { flog_warn( EC_OSPF_PACKET, - "Packet[DD]: Neighbor %s MTU %u is larger than [%s]'s MTU %u", - inet_ntoa(nbr->router_id), ntohs(dd->mtu), IF_NAME(oi), + "Packet[DD]: Neighbor %pI4 MTU %u is larger than [%s]'s MTU %u", + &nbr->router_id, ntohs(dd->mtu), IF_NAME(oi), oi->ifp->mtu); return; } @@ -1324,8 +1324,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, && (!CHECK_FLAG(dd->options, OSPF_OPTION_NP))) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "Packet[DD]: Neighbour %s: Has NSSA capability, sends with N bit clear in DD options", - inet_ntoa(nbr->router_id)); + "Packet[DD]: Neighbour %pI4: Has NSSA capability, sends with N bit clear in DD options", + &nbr->router_id); SET_FLAG(dd->options, OSPF_OPTION_NP); } @@ -1335,8 +1335,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, * In Hello protocol, optional capability must have checked * to prevent this T-bit enabled router be my neighbor. */ - flog_warn(EC_OSPF_PACKET, "Packet[DD]: Neighbor %s: T-bit on?", - inet_ntoa(nbr->router_id)); + flog_warn(EC_OSPF_PACKET, "Packet[DD]: Neighbor %pI4: T-bit on?", + &nbr->router_id); return; } #endif /* REJECT_IF_TBIT_ON */ @@ -1356,9 +1356,9 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, if (CHECK_FLAG(oi->ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) zlog_info( - "%s:Packet[DD]: Neighbor %s state is %s, seq_num:0x%x, local:0x%x", + "%s:Packet[DD]: Neighbor %pI4 state is %s, seq_num:0x%x, local:0x%x", (oi->ospf->name) ? oi->ospf->name : VRF_DEFAULT_NAME, - inet_ntoa(nbr->router_id), + &nbr->router_id, lookup_msg(ospf_nsm_state_msg, nbr->state, NULL), ntohl(dd->dd_seqnum), nbr->dd_seqnum); @@ -1369,8 +1369,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, case NSM_TwoWay: if (CHECK_FLAG(oi->ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) zlog_info( - "Packet[DD]: Neighbor %s state is %s, packet discarded.", - inet_ntoa(nbr->router_id), + "Packet[DD]: Neighbor %pI4 state is %s, packet discarded.", + &nbr->router_id, lookup_msg(ospf_nsm_state_msg, nbr->state, NULL)); break; @@ -1392,8 +1392,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, if (CHECK_FLAG(oi->ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) zlog_info( - "Packet[DD]: Neighbor %s Negotiation done (Slave).", - inet_ntoa(nbr->router_id)); + "Packet[DD]: Neighbor %pI4 Negotiation done (Slave).", + &nbr->router_id); nbr->dd_seqnum = ntohl(dd->dd_seqnum); @@ -1406,8 +1406,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, if (CHECK_FLAG(oi->ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) zlog_info( - "Packet[DD]: Neighbor %s: Initial DBD from Slave, ignoring.", - inet_ntoa(nbr->router_id)); + "Packet[DD]: Neighbor %pI4: Initial DBD from Slave, ignoring.", + &nbr->router_id); break; } } @@ -1417,14 +1417,14 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, && IPV4_ADDR_CMP(&nbr->router_id, &oi->ospf->router_id) < 0) { zlog_info( - "Packet[DD]: Neighbor %s Negotiation done (Master).", - inet_ntoa(nbr->router_id)); + "Packet[DD]: Neighbor %pI4 Negotiation done (Master).", + &nbr->router_id); /* Reset I, leaving MS */ UNSET_FLAG(nbr->dd_flags, OSPF_DD_FLAG_I); } else { flog_warn(EC_OSPF_PACKET, - "Packet[DD]: Neighbor %s Negotiation fails.", - inet_ntoa(nbr->router_id)); + "Packet[DD]: Neighbor %pI4 Negotiation fails.", + &nbr->router_id); break; } @@ -1434,8 +1434,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, if (CHECK_FLAG(oi->ospf->config, OSPF_OPAQUE_CAPABLE)) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "Neighbor[%s] is %sOpaque-capable.", - inet_ntoa(nbr->router_id), + "Neighbor[%pI4] is %sOpaque-capable.", + &nbr->router_id, CHECK_FLAG(nbr->options, OSPF_OPTION_O) ? "" : "NOT "); @@ -1445,8 +1445,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, &nbr->address.u.prefix4)) { flog_warn( EC_OSPF_PACKET, - "DR-neighbor[%s] is NOT opaque-capable; Opaque-LSAs cannot be reliably advertised in this network.", - inet_ntoa(nbr->router_id)); + "DR-neighbor[%pI4] is NOT opaque-capable; Opaque-LSAs cannot be reliably advertised in this network.", + &nbr->router_id); /* This situation is undesirable, but not a real * error. */ } @@ -1462,15 +1462,15 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, if (IS_SET_DD_MS(nbr->dd_flags)) /* Master: discard duplicated DD packet. */ zlog_info( - "Packet[DD] (Master): Neighbor %s packet duplicated.", - inet_ntoa(nbr->router_id)); + "Packet[DD] (Master): Neighbor %pI4 packet duplicated.", + &nbr->router_id); else /* Slave: cause to retransmit the last Database Description. */ { zlog_info( - "Packet[DD] [Slave]: Neighbor %s packet duplicated.", - inet_ntoa(nbr->router_id)); + "Packet[DD] [Slave]: Neighbor %pI4 packet duplicated.", + &nbr->router_id); ospf_db_desc_resend(nbr); } break; @@ -1481,8 +1481,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, if (IS_SET_DD_MS(dd->flags) != IS_SET_DD_MS(nbr->last_recv.flags)) { flog_warn(EC_OSPF_PACKET, - "Packet[DD]: Neighbor %s MS-bit mismatch.", - inet_ntoa(nbr->router_id)); + "Packet[DD]: Neighbor %pI4 MS-bit mismatch.", + &nbr->router_id); OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_SeqNumberMismatch); if (IS_DEBUG_OSPF_EVENT) zlog_debug( @@ -1493,8 +1493,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, /* Check initialize bit is set. */ if (IS_SET_DD_I(dd->flags)) { - zlog_info("Packet[DD]: Neighbor %s I-bit set.", - inet_ntoa(nbr->router_id)); + zlog_info("Packet[DD]: Neighbor %pI4 I-bit set.", + &nbr->router_id); OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_SeqNumberMismatch); break; } @@ -1502,8 +1502,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, /* Check DD Options. */ if (dd->options != nbr->options) { flog_warn(EC_OSPF_PACKET, - "Packet[DD]: Neighbor %s options mismatch.", - inet_ntoa(nbr->router_id)); + "Packet[DD]: Neighbor %pI4 options mismatch.", + &nbr->router_id); OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_SeqNumberMismatch); break; } @@ -1515,8 +1515,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, && ntohl(dd->dd_seqnum) != nbr->dd_seqnum + 1)) { flog_warn( EC_OSPF_PACKET, - "Packet[DD]: Neighbor %s sequence number mismatch.", - inet_ntoa(nbr->router_id)); + "Packet[DD]: Neighbor %pI4 sequence number mismatch.", + &nbr->router_id); OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_SeqNumberMismatch); break; } @@ -1530,8 +1530,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, if (IS_SET_DD_MS(nbr->dd_flags)) { /* Master should discard duplicate DD packet. */ zlog_info( - "Packet[DD]: Neighbor %s duplicated, packet discarded.", - inet_ntoa(nbr->router_id)); + "Packet[DD]: Neighbor %pI4 duplicated, packet discarded.", + &nbr->router_id); break; } else { if (monotime_since(&nbr->last_send_ts, NULL) @@ -1564,8 +1564,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, break; default: flog_warn(EC_OSPF_PACKET, - "Packet[DD]: Neighbor %s NSM illegal status %u.", - inet_ntoa(nbr->router_id), nbr->state); + "Packet[DD]: Neighbor %pI4 NSM illegal status %u.", + &nbr->router_id, nbr->state); break; } } @@ -1591,8 +1591,8 @@ static void ospf_ls_req(struct ip *iph, struct ospf_header *ospfh, nbr = ospf_nbr_lookup(oi, iph, ospfh); if (nbr == NULL) { flog_warn(EC_OSPF_PACKET, - "Link State Request: Unknown Neighbor %s.", - inet_ntoa(ospfh->router_id)); + "Link State Request: Unknown Neighbor %pI4", + &ospfh->router_id); return; } @@ -1604,8 +1604,8 @@ static void ospf_ls_req(struct ip *iph, struct ospf_header *ospfh, && nbr->state != NSM_Full) { flog_warn( EC_OSPF_PACKET, - "Link State Request received from %s: Neighbor state is %s, packet discarded.", - inet_ntoa(ospfh->router_id), + "Link State Request received from %pI4: Neighbor state is %s, packet discarded.", + &ospfh->router_id, lookup_msg(ospf_nsm_state_msg, nbr->state, NULL)); return; } @@ -1712,10 +1712,10 @@ static struct list *ospf_ls_upd_list_lsa(struct ospf_neighbor *nbr, * other */ flog_warn( EC_OSPF_PACKET, - "Link State Update: LSA checksum error %x/%x, ID=%s from: nbr %s, router ID %s, adv router %s", - sum, lsah->checksum, inet_ntoa(lsah->id), - inet_ntoa(nbr->src), inet_ntoa(nbr->router_id), - inet_ntoa(lsah->adv_router)); + "Link State Update: LSA checksum error %x/%x, ID=%pI4 from: nbr %pI4, router ID %pI4, adv router %pI4", + sum, lsah->checksum, &lsah->id, + &nbr->src, &nbr->router_id, + &lsah->adv_router); continue; } @@ -1747,8 +1747,8 @@ static struct list *ospf_ls_upd_list_lsa(struct ospf_neighbor *nbr, * only. */ flog_warn(EC_OSPF_PACKET, - "LSA[Type%d:%s]: O-bit abuse?", - lsah->type, inet_ntoa(lsah->id)); + "LSA[Type%d:%pI4]: O-bit abuse?", + lsah->type, &lsah->id); continue; } #endif /* STRICT_OBIT_USAGE_CHECK */ @@ -1760,15 +1760,15 @@ static struct list *ospf_ls_upd_list_lsa(struct ospf_neighbor *nbr, != OSPF_AREA_DEFAULT) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "LSA[Type%d:%s]: We are a stub, don't take this LSA.", + "LSA[Type%d:%pI4]: We are a stub, don't take this LSA.", lsah->type, - inet_ntoa(lsah->id)); + &lsah->id); continue; } } else if (IS_OPAQUE_LSA(lsah->type)) { flog_warn(EC_OSPF_PACKET, - "LSA[Type%d:%s]: Opaque capability mismatch?", - lsah->type, inet_ntoa(lsah->id)); + "LSA[Type%d:%pI4]: Opaque capability mismatch?", + lsah->type, &lsah->id); continue; } @@ -1796,8 +1796,8 @@ static struct list *ospf_ls_upd_list_lsa(struct ospf_neighbor *nbr, if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "LSA[Type%d:%s]: %p new LSA created with Link State Update", - lsa->data->type, inet_ntoa(lsa->data->id), + "LSA[Type%d:%pI4]: %p new LSA created with Link State Update", + lsa->data->type, &lsa->data->id, (void *)lsa); listnode_add(lsas, lsa); } @@ -1838,8 +1838,8 @@ static void ospf_ls_upd(struct ospf *ospf, struct ip *iph, nbr = ospf_nbr_lookup(oi, iph, ospfh); if (nbr == NULL) { flog_warn(EC_OSPF_PACKET, - "Link State Update: Unknown Neighbor %s on int: %s", - inet_ntoa(ospfh->router_id), IF_NAME(oi)); + "Link State Update: Unknown Neighbor %pI4 on int: %s", + &ospfh->router_id, IF_NAME(oi)); return; } @@ -1850,8 +1850,8 @@ static void ospf_ls_upd(struct ospf *ospf, struct ip *iph, if (nbr->state < NSM_Exchange) { if (IS_DEBUG_OSPF(nsm, NSM_EVENTS)) zlog_debug( - "Link State Update: Neighbor[%s] state %s is less than Exchange", - inet_ntoa(ospfh->router_id), + "Link State Update: Neighbor[%pI4] state %s is less than Exchange", + &ospfh->router_id, lookup_msg(ospf_nsm_state_msg, nbr->state, NULL)); return; @@ -2241,8 +2241,8 @@ static void ospf_ls_ack(struct ip *iph, struct ospf_header *ospfh, nbr = ospf_nbr_lookup(oi, iph, ospfh); if (nbr == NULL) { flog_warn(EC_OSPF_PACKET, - "Link State Acknowledgment: Unknown Neighbor %s.", - inet_ntoa(ospfh->router_id)); + "Link State Acknowledgment: Unknown Neighbor %pI4", + &ospfh->router_id); return; } @@ -2252,8 +2252,8 @@ static void ospf_ls_ack(struct ip *iph, struct ospf_header *ospfh, if (nbr->state < NSM_Exchange) { if (IS_DEBUG_OSPF(nsm, NSM_EVENTS)) zlog_debug( - "Link State Acknowledgment: Neighbor[%s] state %s is less than Exchange", - inet_ntoa(ospfh->router_id), + "Link State Acknowledgment: Neighbor[%pI4] state %s is less than Exchange", + &ospfh->router_id, lookup_msg(ospf_nsm_state_msg, nbr->state, NULL)); return; @@ -2485,9 +2485,9 @@ static int ospf_check_auth(struct ospf_interface *oi, struct ospf_header *ospfh) if (IS_DEBUG_OSPF_PACKET(ospfh->type - 1, RECV)) flog_warn( EC_OSPF_PACKET, - "interface %s: Null auth OK, but checksum error, Router-ID %s", + "interface %s: Null auth OK, but checksum error, Router-ID %pI4", IF_NAME(oi), - inet_ntoa(ospfh->router_id)); + &ospfh->router_id); return 0; } return 1; @@ -2515,9 +2515,9 @@ static int ospf_check_auth(struct ospf_interface *oi, struct ospf_header *ospfh) if (IS_DEBUG_OSPF_PACKET(ospfh->type - 1, RECV)) flog_warn( EC_OSPF_PACKET, - "interface %s: Simple auth OK, checksum error, Router-ID %s", + "interface %s: Simple auth OK, checksum error, Router-ID %pI4", IF_NAME(oi), - inet_ntoa(ospfh->router_id)); + &ospfh->router_id); return 0; } return 1; @@ -2916,8 +2916,8 @@ static int ospf_verify_header(struct stream *ibuf, struct ospf_interface *oi, /* Check Area ID. */ if (!ospf_check_area_id(oi, ospfh)) { flog_warn(EC_OSPF_PACKET, - "interface %s: ospf_read invalid Area ID %s.", - IF_NAME(oi), inet_ntoa(ospfh->area_id)); + "interface %s: ospf_read invalid Area ID %pI4", + IF_NAME(oi), &ospfh->area_id); return -1; } @@ -2925,8 +2925,8 @@ static int ospf_verify_header(struct stream *ibuf, struct ospf_interface *oi, if (!ospf_check_network_mask(oi, iph->ip_src)) { flog_warn( EC_OSPF_PACKET, - "interface %s: ospf_read network address is not same [%s]", - IF_NAME(oi), inet_ntoa(iph->ip_src)); + "interface %s: ospf_read network address is not same [%pI4]", + IF_NAME(oi), &iph->ip_src); return -1; } @@ -2984,8 +2984,8 @@ static enum ospf_read_return_enum ospf_read_helper(struct ospf *ospf) if (ifp == NULL) { if (IS_DEBUG_OSPF_PACKET(0, RECV)) zlog_debug( - "%s: Unable to determine incoming interface from: %s(%s)", - __func__, inet_ntoa(iph->ip_src), + "%s: Unable to determine incoming interface from: %pI4(%s)", + __func__, &iph->ip_src, ospf_get_name(ospf)); return OSPF_READ_CONTINUE; } @@ -2995,8 +2995,8 @@ static enum ospf_read_return_enum ospf_read_helper(struct ospf *ospf) if (ospf_if_lookup_by_local_addr(ospf, NULL, iph->ip_src)) { if (IS_DEBUG_OSPF_PACKET(0, RECV)) { zlog_debug( - "ospf_read[%s]: Dropping self-originated packet", - inet_ntoa(iph->ip_src)); + "ospf_read[%pI4]: Dropping self-originated packet", + &iph->ip_src); } return OSPF_READ_CONTINUE; } @@ -3074,8 +3074,8 @@ static enum ospf_read_return_enum ospf_read_helper(struct ospf *ospf) == NULL) { if (!ospf->instance && IS_DEBUG_OSPF_EVENT) zlog_debug( - "Packet from [%s] received on link %s but no ospf_interface", - inet_ntoa(iph->ip_src), ifp->name); + "Packet from [%pI4] received on link %s but no ospf_interface", + &iph->ip_src, ifp->name); return OSPF_READ_CONTINUE; } } @@ -3087,8 +3087,8 @@ static enum ospf_read_return_enum ospf_read_helper(struct ospf *ospf) else if (oi->ifp != ifp) { if (IS_DEBUG_OSPF_EVENT) flog_warn(EC_OSPF_PACKET, - "Packet from [%s] received on wrong link %s", - inet_ntoa(iph->ip_src), ifp->name); + "Packet from [%pI4] received on wrong link %s", + &iph->ip_src, ifp->name); return OSPF_READ_CONTINUE; } else if (oi->state == ISM_Down) { char buf[2][INET_ADDRSTRLEN]; @@ -3122,8 +3122,8 @@ static enum ospf_read_return_enum ospf_read_helper(struct ospf *ospf) && (oi->state != ISM_DR && oi->state != ISM_Backup)) { flog_warn( EC_OSPF_PACKET, - "Dropping packet for AllDRouters from [%s] via [%s] (ISM: %s)", - inet_ntoa(iph->ip_src), IF_NAME(oi), + "Dropping packet for AllDRouters from [%pI4] via [%s] (ISM: %s)", + &iph->ip_src, IF_NAME(oi), lookup_msg(ospf_ism_state_msg, oi->state, NULL)); /* Try to fix multicast membership. */ SET_FLAG(oi->multicast_memberships, MEMBER_DROUTERS); @@ -3136,8 +3136,8 @@ static enum ospf_read_return_enum ospf_read_helper(struct ospf *ospf) if (ret < 0) { if (IS_DEBUG_OSPF_PACKET(0, RECV)) zlog_debug( - "ospf_read[%s]: Header check failed, dropping.", - inet_ntoa(iph->ip_src)); + "ospf_read[%pI4]: Header check failed, dropping.", + &iph->ip_src); return OSPF_READ_CONTINUE; } @@ -3149,11 +3149,11 @@ static enum ospf_read_return_enum ospf_read_helper(struct ospf *ospf) ospf_packet_dump(ibuf); } - zlog_debug("%s received from [%s] via [%s]", + zlog_debug("%s received from [%pI4] via [%s]", lookup_msg(ospf_packet_type_str, ospfh->type, NULL), - inet_ntoa(ospfh->router_id), IF_NAME(oi)); - zlog_debug(" src [%s],", inet_ntoa(iph->ip_src)); - zlog_debug(" dst [%s]", inet_ntoa(iph->ip_dst)); + &ospfh->router_id, IF_NAME(oi)); + zlog_debug(" src [%pI4],", &iph->ip_src); + zlog_debug(" dst [%pI4]", &iph->ip_dst); if (IS_DEBUG_OSPF_PACKET(ospfh->type - 1, DETAIL)) zlog_debug( @@ -3736,8 +3736,8 @@ int ospf_poll_timer(struct thread *thread) nbr_nbma->t_poll = NULL; if (IS_DEBUG_OSPF(nsm, NSM_TIMERS)) - zlog_debug("NSM[%s:%s]: Timer (Poll timer expire)", - IF_NAME(nbr_nbma->oi), inet_ntoa(nbr_nbma->addr)); + zlog_debug("NSM[%s:%pI4]: Timer (Poll timer expire)", + IF_NAME(nbr_nbma->oi), &nbr_nbma->addr); ospf_poll_send(nbr_nbma); @@ -3757,8 +3757,8 @@ int ospf_hello_reply_timer(struct thread *thread) nbr->t_hello_reply = NULL; if (IS_DEBUG_OSPF(nsm, NSM_TIMERS)) - zlog_debug("NSM[%s:%s]: Timer (hello-reply timer expire)", - IF_NAME(nbr->oi), inet_ntoa(nbr->router_id)); + zlog_debug("NSM[%s:%pI4]: Timer (hello-reply timer expire)", + IF_NAME(nbr->oi), &nbr->router_id); ospf_hello_send_sub(nbr->oi, nbr->address.u.prefix4.s_addr); @@ -3875,9 +3875,9 @@ void ospf_db_desc_send(struct ospf_neighbor *nbr) monotime(&nbr->last_send_ts); if (CHECK_FLAG(oi->ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) zlog_info( - "%s:Packet[DD]: %s DB Desc send with seqnum:%x , flags:%x", + "%s:Packet[DD]: %pI4 DB Desc send with seqnum:%x , flags:%x", (oi->ospf->name) ? oi->ospf->name : VRF_DEFAULT_NAME, - inet_ntoa(nbr->router_id), nbr->dd_seqnum, + &nbr->router_id, nbr->dd_seqnum, nbr->dd_flags); } @@ -3895,9 +3895,9 @@ void ospf_db_desc_resend(struct ospf_neighbor *nbr) OSPF_ISM_WRITE_ON(oi->ospf); if (CHECK_FLAG(oi->ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) zlog_info( - "%s:Packet[DD]: %s DB Desc resend with seqnum:%x , flags:%x", + "%s:Packet[DD]: %pI4 DB Desc resend with seqnum:%x , flags:%x", (oi->ospf->name) ? oi->ospf->name : VRF_DEFAULT_NAME, - inet_ntoa(nbr->router_id), nbr->dd_seqnum, + &nbr->router_id, nbr->dd_seqnum, nbr->dd_flags); } @@ -3992,10 +3992,10 @@ static struct ospf_packet *ospf_ls_upd_packet_new(struct list *update, if (IS_DEBUG_OSPF_PACKET(0, SEND)) zlog_debug( - "ospf_ls_upd_packet_new: oversized LSA id:%s, %d bytes originated by %s, will be fragmented!", - inet_ntoa(lsa->data->id), + "ospf_ls_upd_packet_new: oversized LSA id:%pI4, %d bytes originated by %pI4, will be fragmented!", + &lsa->data->id, ntohs(lsa->data->length), - inet_ntoa(lsa->data->adv_router)); + &lsa->data->adv_router); /* * Allocate just enough to fit this LSA only, to avoid including @@ -4010,8 +4010,8 @@ static struct ospf_packet *ospf_ls_upd_packet_new(struct list *update, if (size > OSPF_MAX_PACKET_SIZE) { flog_warn(EC_OSPF_LARGE_LSA, - "ospf_ls_upd_packet_new: oversized LSA id:%s too big, %d bytes, packet size %ld, dropping it completely. OSPF routing is broken!", - inet_ntoa(lsa->data->id), ntohs(lsa->data->length), + "ospf_ls_upd_packet_new: oversized LSA id:%pI4 too big, %d bytes, packet size %ld, dropping it completely. OSPF routing is broken!", + &lsa->data->id, ntohs(lsa->data->length), (long int)size); list_delete_node(update, ln); return NULL; @@ -4043,8 +4043,8 @@ static void ospf_ls_upd_queue_send(struct ospf_interface *oi, uint16_t length = OSPF_HEADER_SIZE; if (IS_DEBUG_OSPF_EVENT) - zlog_debug("listcount = %d, [%s]dst %s", listcount(update), - IF_NAME(oi), inet_ntoa(addr)); + zlog_debug("listcount = %d, [%s]dst %pI4", listcount(update), + IF_NAME(oi), &addr); /* Check that we have really something to process */ if (listcount(update) == 0) diff --git a/ospfd/ospf_ri.c b/ospfd/ospf_ri.c index fc9c8f6be6..3145d16161 100644 --- a/ospfd/ospf_ri.c +++ b/ospfd/ospf_ri.c @@ -544,8 +544,8 @@ static void initialize_params(struct ospf_router_info *ori) if (!list_isempty(OspfRI.area_info)) list_delete_all_node(OspfRI.area_info); for (ALL_LIST_ELEMENTS(top->areas, node, nnode, area)) { - zlog_debug("RI (%s): Add area %s to Router Information", - __func__, inet_ntoa(area->area_id)); + zlog_debug("RI (%s): Add area %pI4 to Router Information", + __func__, &area->area_id); new = XCALLOC(MTYPE_OSPF_ROUTER_INFO, sizeof(struct ospf_ri_area_info)); new->area = area; @@ -795,8 +795,8 @@ static struct ospf_lsa *ospf_router_info_lsa_new(struct ospf_area *area) if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) zlog_debug( - "LSA[Type%d:%s]: Create an Opaque-LSA/ROUTER INFORMATION instance", - lsa_type, inet_ntoa(lsa_id)); + "LSA[Type%d:%pI4]: Create an Opaque-LSA/ROUTER INFORMATION instance", + lsa_type, &lsa_id); top = ospf_lookup_by_vrf_id(VRF_DEFAULT); @@ -874,8 +874,8 @@ static int ospf_router_info_lsa_originate_as(void *arg) if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) { zlog_debug( - "LSA[Type%d:%s]: Originate Opaque-LSA/ROUTER INFORMATION", - new->data->type, inet_ntoa(new->data->id)); + "LSA[Type%d:%pI4]: Originate Opaque-LSA/ROUTER INFORMATION", + new->data->type, &new->data->id); ospf_lsa_header_dump(new->data); } @@ -943,8 +943,8 @@ static int ospf_router_info_lsa_originate_area(void *arg) if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) { zlog_debug( - "LSA[Type%d:%s]: Originate Opaque-LSA/ROUTER INFORMATION", - new->data->type, inet_ntoa(new->data->id)); + "LSA[Type%d:%pI4]: Originate Opaque-LSA/ROUTER INFORMATION", + new->data->type, &new->data->id); ospf_lsa_header_dump(new->data); } @@ -1094,8 +1094,8 @@ static struct ospf_lsa *ospf_router_info_lsa_refresh(struct ospf_lsa *lsa) /* Debug logging. */ if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) { zlog_debug( - "LSA[Type%d:%s]: Refresh Opaque-LSA/ROUTER INFORMATION", - new->data->type, inet_ntoa(new->data->id)); + "LSA[Type%d:%pI4]: Refresh Opaque-LSA/ROUTER INFORMATION", + new->data->type, &new->data->id); ospf_lsa_header_dump(new->data); } @@ -1247,11 +1247,11 @@ static uint16_t show_vty_pce_subtlv_address(struct vty *vty, if (ntohs(top->address.type) == PCE_ADDRESS_TYPE_IPV4) { if (vty != NULL) - vty_out(vty, " PCE Address: %s\n", - inet_ntoa(top->address.value)); + vty_out(vty, " PCE Address: %pI4\n", + &top->address.value); else - zlog_debug(" PCE Address: %s", - inet_ntoa(top->address.value)); + zlog_debug(" PCE Address: %pI4", + &top->address.value); } else { /* TODO: Add support to IPv6 with inet_ntop() */ if (vty != NULL) @@ -1288,9 +1288,9 @@ static uint16_t show_vty_pce_subtlv_domain(struct vty *vty, if (ntohs(top->type) == PCE_DOMAIN_TYPE_AREA) { tmp.s_addr = top->value; if (vty != NULL) - vty_out(vty, " PCE domain Area: %s\n", inet_ntoa(tmp)); + vty_out(vty, " PCE domain Area: %pI4\n", &tmp); else - zlog_debug(" PCE domain Area: %s", inet_ntoa(tmp)); + zlog_debug(" PCE domain Area: %pI4", &tmp); } else { if (vty != NULL) vty_out(vty, " PCE domain AS: %d\n", @@ -1312,10 +1312,10 @@ static uint16_t show_vty_pce_subtlv_neighbor(struct vty *vty, if (ntohs(top->type) == PCE_DOMAIN_TYPE_AREA) { tmp.s_addr = top->value; if (vty != NULL) - vty_out(vty, " PCE neighbor Area: %s\n", - inet_ntoa(tmp)); + vty_out(vty, " PCE neighbor Area: %pI4\n", + &tmp); else - zlog_debug(" PCE neighbor Area: %s", inet_ntoa(tmp)); + zlog_debug(" PCE neighbor Area: %pI4", &tmp); } else { if (vty != NULL) vty_out(vty, " PCE neighbor AS: %d\n", @@ -1543,8 +1543,8 @@ static void ospf_router_info_config_write_router(struct vty *vty) if (OspfRI.pce_info.enabled) { if (pce->pce_address.header.type != 0) - vty_out(vty, " pce address %s\n", - inet_ntoa(pce->pce_address.address.value)); + vty_out(vty, " pce address %pI4\n", + &pce->pce_address.address.value); if (pce->pce_cap_flag.header.type != 0) vty_out(vty, " pce flag 0x%x\n", @@ -1554,8 +1554,8 @@ static void ospf_router_info_config_write_router(struct vty *vty) if (domain->header.type != 0) { if (domain->type == PCE_DOMAIN_TYPE_AREA) { tmp.s_addr = domain->value; - vty_out(vty, " pce domain area %s\n", - inet_ntoa(tmp)); + vty_out(vty, " pce domain area %pI4\n", + &tmp); } else { vty_out(vty, " pce domain as %d\n", ntohl(domain->value)); @@ -1567,8 +1567,9 @@ static void ospf_router_info_config_write_router(struct vty *vty) if (neighbor->header.type != 0) { if (neighbor->type == PCE_DOMAIN_TYPE_AREA) { tmp.s_addr = neighbor->value; - vty_out(vty, " pce neighbor area %s\n", - inet_ntoa(tmp)); + vty_out(vty, + " pce neighbor area %pI4\n", + &tmp); } else { vty_out(vty, " pce neighbor as %d\n", ntohl(neighbor->value)); diff --git a/ospfd/ospf_route.c b/ospfd/ospf_route.c index e3e6f68a82..bcf563a5ba 100644 --- a/ospfd/ospf_route.c +++ b/ospfd/ospf_route.c @@ -307,8 +307,8 @@ void ospf_intra_add_router(struct route_table *rt, struct vertex *v, lsa = (struct router_lsa *)v->lsa; if (IS_DEBUG_OSPF_EVENT) - zlog_debug("ospf_intra_add_router: LS ID: %s", - inet_ntoa(lsa->header.id)); + zlog_debug("ospf_intra_add_router: LS ID: %pI4", + &lsa->header.id); if (!OSPF_IS_AREA_BACKBONE(area)) ospf_vl_up_check(area, lsa->header.id, v); @@ -364,8 +364,7 @@ void ospf_intra_add_router(struct route_table *rt, struct vertex *v, apply_mask_ipv4(&p); if (IS_DEBUG_OSPF_EVENT) - zlog_debug("ospf_intra_add_router: talking about %s/%d", - inet_ntoa(p.prefix), p.prefixlen); + zlog_debug("ospf_intra_add_router: talking about %pFX", &p); rn = route_node_get(rt, (struct prefix *)&p); @@ -467,8 +466,8 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link, apply_mask_ipv4(&p); if (IS_DEBUG_OSPF_EVENT) - zlog_debug("ospf_intra_add_stub(): processing route to %s/%d", - inet_ntoa(p.prefix), p.prefixlen); + zlog_debug("ospf_intra_add_stub(): processing route to %pFX", + &p); /* (1) Calculate the distance D of stub network from the root. D is equal to the distance from the root to the router vertex @@ -488,8 +487,8 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link, if (parent_is_root && link->link_data.s_addr == 0xffffffff && ospf_if_lookup_by_local_addr(area->ospf, NULL, link->link_id)) { if (IS_DEBUG_OSPF_EVENT) - zlog_debug("%s: ignoring host route %s/32 to self.", - __func__, inet_ntoa(link->link_id)); + zlog_debug("%s: ignoring host route %pI4/32 to self.", + __func__, &link->link_id); return; } @@ -653,8 +652,8 @@ void ospf_route_table_dump(struct route_table *rt) or->cost); for (ALL_LIST_ELEMENTS_RO(or->paths, pnode, path)) - zlog_debug(" -> %s", - inet_ntoa(path->nexthop)); + zlog_debug(" -> %pI4", + &path->nexthop); } else zlog_debug("R %-18pI4 %-15pI4 %s %d", &rn->p.u.prefix4, @@ -682,11 +681,12 @@ void ospf_route_table_print(struct vty *vty, struct route_table *rt) or->cost); for (ALL_LIST_ELEMENTS_RO(or->paths, pnode, path)) - vty_out(vty, " -> %s\n", - path->nexthop.s_addr != 0 - ? inet_ntoa( - path->nexthop) - : "directly connected"); + if (path->nexthop.s_addr != 0) + vty_out(vty, " -> %pI4\n", + &path->nexthop); + else + vty_out(vty, " -> %s\n", + "directly connected"); } else vty_out(vty, "R %-18pI4 %-15pI4 %s %d\n", &rn->p.u.prefix4, & or->u.std.area_id, @@ -896,9 +896,8 @@ void ospf_prune_unreachable_networks(struct route_table *rt) or = rn->info; if (listcount(or->paths) == 0) { if (IS_DEBUG_OSPF_EVENT) - zlog_debug("Pruning route to %s/%d", - inet_ntoa(rn->p.u.prefix4), - rn->p.prefixlen); + zlog_debug("Pruning route to %pFX", + &rn->p); ospf_route_free(or); rn->info = NULL; @@ -926,11 +925,11 @@ void ospf_prune_unreachable_routers(struct route_table *rtrs) for (ALL_LIST_ELEMENTS(paths, node, nnode, or)) { if (listcount(or->paths) == 0) { if (IS_DEBUG_OSPF_EVENT) { - zlog_debug("Pruning route to rtr %s", - inet_ntoa(rn->p.u.prefix4)); + zlog_debug("Pruning route to rtr %pI4", + &rn->p.u.prefix4); zlog_debug( - " via area %s", - inet_ntoa(or->u.std.area_id)); + " via area %pI4", + &or->u.std.area_id); } listnode_delete(paths, or); @@ -940,8 +939,8 @@ void ospf_prune_unreachable_routers(struct route_table *rtrs) if (listcount(paths) == 0) { if (IS_DEBUG_OSPF_EVENT) - zlog_debug("Pruning router node %s", - inet_ntoa(rn->p.u.prefix4)); + zlog_debug("Pruning router node %pI4", + &rn->p.u.prefix4); list_delete(&paths); rn->info = NULL; diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c index 8e5cb5bb36..033046da0a 100644 --- a/ospfd/ospf_snmp.c +++ b/ospfd/ospf_snmp.c @@ -2455,8 +2455,8 @@ static void ospfTrapNbrStateChange(struct ospf_neighbor *on) ospf_nbr_state_message(on, msgbuf, sizeof(msgbuf)); if (IS_DEBUG_OSPF_EVENT) - zlog_info("%s: trap sent: %s now %s", __func__, - inet_ntoa(on->address.u.prefix4), msgbuf); + zlog_info("%s: trap sent: %pI4 now %s", __func__, + &on->address.u.prefix4, msgbuf); oid_copy_addr(index, &(on->address.u.prefix4), IN_ADDR_SIZE); index[IN_ADDR_SIZE] = 0; @@ -2513,8 +2513,8 @@ static void ospfTrapIfStateChange(struct ospf_interface *oi) oid index[sizeof(oid) * (IN_ADDR_SIZE + 1)]; if (IS_DEBUG_OSPF_EVENT) - zlog_info("%s: trap sent: %s now %s", __func__, - inet_ntoa(oi->address->u.prefix4), + zlog_info("%s: trap sent: %pI4 now %s", __func__, + &oi->address->u.prefix4, lookup_msg(ospf_ism_state_msg, oi->state, NULL)); oid_copy_addr(index, &(oi->address->u.prefix4), IN_ADDR_SIZE); 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) diff --git a/ospfd/ospf_sr.c b/ospfd/ospf_sr.c index 64d7b39acd..4e32732c86 100644 --- a/ospfd/ospf_sr.c +++ b/ospfd/ospf_sr.c @@ -1947,10 +1947,8 @@ void ospf_sr_config_write_router(struct vty *vty) for (ALL_LIST_ELEMENTS_RO(OspfSR.self->ext_prefix, node, srp)) { vty_out(vty, - " segment-routing prefix %s/%u " - "index %u", - inet_ntoa(srp->prefv4.prefix), - srp->prefv4.prefixlen, srp->sid); + " segment-routing prefix %pFX index %u", + &srp->prefv4, srp->sid); if (CHECK_FLAG(srp->flags, EXT_SUBTLV_PREFIX_SID_EFLG)) vty_out(vty, " explicit-null\n"); @@ -2449,8 +2447,8 @@ DEFUN (sr_prefix_sid, new->instance = ospf_ext_schedule_prefix_index( ifp, new->sid, &new->prefv4, new->flags); if (new->instance == 0) { - vty_out(vty, "Unable to set index %u for prefix %s/%u\n", index, - inet_ntoa(p.u.prefix4), p.prefixlen); + vty_out(vty, "Unable to set index %u for prefix %pFX\n", + index, &p); return CMD_WARNING; } @@ -2572,6 +2570,7 @@ static void show_sr_prefix(struct sbuf *sbuf, struct json_object *json, char pref[19]; char sid[22]; char op[32]; + char buf[PREFIX_STRLEN]; int indent = 0; snprintfrr(pref, 19, "%pFX", (struct prefix *)&srp->prefv4); @@ -2598,15 +2597,18 @@ static void show_sr_prefix(struct sbuf *sbuf, struct json_object *json, srp->nhlfe.label_out); json_object_string_add(json_obj, "interface", itf ? itf->name : "-"); - json_object_string_add(json_obj, "nexthop", - inet_ntoa(srp->nhlfe.nexthop)); + json_object_string_add( + json_obj, "nexthop", + inet_ntop(AF_INET, &srp->nhlfe.nexthop, + buf, sizeof(buf))); json_object_array_add(json_route, json_obj); } else { sbuf_push(sbuf, 0, "%20s %9s %15s\n", sr_op2str(op, 32, srp->label_in, srp->nhlfe.label_out), itf ? itf->name : "-", - inet_ntoa(srp->nhlfe.nexthop)); + inet_ntop(AF_INET, &srp->nhlfe.nexthop, + buf, sizeof(buf))); } return; } @@ -2633,15 +2635,18 @@ static void show_sr_prefix(struct sbuf *sbuf, struct json_object *json, path->srni.label_out); json_object_string_add(json_obj, "interface", itf ? itf->name : "-"); - json_object_string_add(json_obj, "nexthop", - inet_ntoa(path->nexthop)); + json_object_string_add( + json_obj, "nexthop", + inet_ntop(AF_INET, &path->nexthop, + buf, sizeof(buf))); json_object_array_add(json_route, json_obj); } else { sbuf_push(sbuf, indent, "%20s %9s %15s\n", sr_op2str(op, 32, srp->label_in, path->srni.label_out), itf ? itf->name : "-", - inet_ntoa(path->nexthop)); + inet_ntop(AF_INET, &path->nexthop, buf, + sizeof(buf))); /* Offset to align information for ECMP */ indent = 43; } @@ -2660,6 +2665,7 @@ static void show_sr_node(struct vty *vty, struct json_object *json, char pref[19]; char sid[22]; char op[32]; + char buf[PREFIX_STRLEN]; uint32_t upper; json_object *json_node = NULL, *json_algo, *json_obj; json_object *json_prefix = NULL, *json_link = NULL; @@ -2673,7 +2679,8 @@ static void show_sr_node(struct vty *vty, struct json_object *json, if (json) { json_node = json_object_new_object(); json_object_string_add(json_node, "routerID", - inet_ntoa(srn->adv_router)); + inet_ntop(AF_INET, &srn->adv_router, + buf, sizeof(buf))); json_object_int_add(json_node, "srgbSize", srn->srgb.range_size); json_object_int_add(json_node, "srgbLabel", @@ -2700,7 +2707,7 @@ static void show_sr_node(struct vty *vty, struct json_object *json, if (srn->msd != 0) json_object_int_add(json_node, "nodeMsd", srn->msd); } else { - sbuf_push(&sbuf, 0, "SR-Node: %s", inet_ntoa(srn->adv_router)); + sbuf_push(&sbuf, 0, "SR-Node: %pI4", &srn->adv_router); upper = srn->srgb.lower_bound + srn->srgb.range_size - 1; sbuf_push(&sbuf, 0, "\tSRGB: [%u/%u]", srn->srgb.lower_bound, upper); @@ -2764,7 +2771,8 @@ static void show_sr_node(struct vty *vty, struct json_object *json, itf ? itf->name : "-"); json_object_string_add( json_obj, "nexthop", - inet_ntoa(srl->nhlfe[0].nexthop)); + inet_ntop(AF_INET, &srl->nhlfe[0].nexthop, + buf, sizeof(buf))); json_object_array_add(json_link, json_obj); /* Backup Link */ json_obj = json_object_new_object(); @@ -2779,7 +2787,8 @@ static void show_sr_node(struct vty *vty, struct json_object *json, itf ? itf->name : "-"); json_object_string_add( json_obj, "nexthop", - inet_ntoa(srl->nhlfe[1].nexthop)); + inet_ntop(AF_INET, &srl->nhlfe[1].nexthop, + buf, sizeof(buf))); json_object_array_add(json_link, json_obj); } else { sbuf_push(&sbuf, 0, "%18s %21s %20s %9s %15s\n", @@ -2787,14 +2796,16 @@ static void show_sr_node(struct vty *vty, struct json_object *json, sr_op2str(op, 32, srl->nhlfe[0].label_in, srl->nhlfe[0].label_out), itf ? itf->name : "-", - inet_ntoa(srl->nhlfe[0].nexthop)); + inet_ntop(AF_INET, &srl->nhlfe[0].nexthop, + buf, sizeof(buf))); snprintf(sid, 22, "SR Adj. (lbl %u)", srl->sid[1]); sbuf_push(&sbuf, 0, "%18s %21s %20s %9s %15s\n", pref, sid, sr_op2str(op, 32, srl->nhlfe[1].label_in, srl->nhlfe[1].label_out), itf ? itf->name : "-", - inet_ntoa(srl->nhlfe[1].nexthop)); + inet_ntop(AF_INET, &srl->nhlfe[1].nexthop, + buf, sizeof(buf))); } } if (json) @@ -2837,6 +2848,7 @@ DEFUN (show_ip_opsf_srdb, int idx = 0; struct in_addr rid; struct sr_node *srn; + char buf[PREFIX_STRLEN]; bool uj = use_json(argc, argv); json_object *json = NULL, *json_node_array = NULL; @@ -2848,13 +2860,15 @@ DEFUN (show_ip_opsf_srdb, if (uj) { json = json_object_new_object(); json_node_array = json_object_new_array(); - json_object_string_add(json, "srdbID", - inet_ntoa(OspfSR.self->adv_router)); + json_object_string_add( + json, "srdbID", + inet_ntop(AF_INET, &OspfSR.self->adv_router, + buf, sizeof(buf))); json_object_object_add(json, "srNodes", json_node_array); } else { vty_out(vty, - "\n\t\tOSPF Segment Routing database for ID %s\n\n", - inet_ntoa(OspfSR.self->adv_router)); + "\n\t\tOSPF Segment Routing database for ID %pI4\n\n", + &OspfSR.self->adv_router); } if (argv_find(argv, argc, "self-originate", &idx)) { diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c index 1009c7577e..e3c554c530 100644 --- a/ospfd/ospf_te.c +++ b/ospfd/ospf_te.c @@ -1043,8 +1043,8 @@ static void ospf_mpls_te_nsm_change(struct ospf_neighbor *nbr, int old_state) if (IS_DEBUG_OSPF_TE) zlog_debug( - "MPLS-TE (%s): Add Link-ID %s for interface %s ", - __func__, inet_ntoa(lp->link_id.value), oi->ifp->name); + "MPLS-TE (%s): Add Link-ID %pI4 for interface %s ", + __func__, &lp->link_id.value, oi->ifp->name); /* Try to Schedule LSA */ if (OspfMplsTE.enabled) { @@ -1187,8 +1187,8 @@ static struct ospf_lsa *ospf_mpls_te_lsa_new(struct ospf *ospf, if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) zlog_debug( - "LSA[Type%d:%s]: Create an Opaque-LSA/MPLS-TE instance", - lsa_type, inet_ntoa(lsa_id)); + "LSA[Type%d:%pI4]: Create an Opaque-LSA/MPLS-TE instance", + lsa_type, &lsa_id); /* Set opaque-LSA body fields. */ ospf_mpls_te_lsa_body_set(s, lp); @@ -1243,11 +1243,9 @@ static int ospf_mpls_te_lsa_originate1(struct ospf_area *area, ospf_flood_through_area(area, NULL /*nbr*/, new); if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) { - char area_id[INET_ADDRSTRLEN]; - strlcpy(area_id, inet_ntoa(area->area_id), sizeof(area_id)); zlog_debug( - "LSA[Type%d:%s]: Originate Opaque-LSA/MPLS-TE: Area(%s), Link(%s)", - new->data->type, inet_ntoa(new->data->id), area_id, + "LSA[Type%d:%pI4]: Originate Opaque-LSA/MPLS-TE: Area(%pI4), Link(%s)", + new->data->type, &new->data->id, &area->area_id, lp->ifp->name); ospf_lsa_header_dump(new->data); } @@ -1302,8 +1300,8 @@ static int ospf_mpls_te_lsa_originate_area(void *arg) /* Ok, let's try to originate an LSA for this area and Link. */ if (IS_DEBUG_OSPF_TE) zlog_debug( - "MPLS-TE(ospf_mpls_te_lsa_originate_area) Let's finally reoriginate the LSA %d through the Area %s for Link %s", - lp->instance, inet_ntoa(area->area_id), + "MPLS-TE(ospf_mpls_te_lsa_originate_area) Let's finally reoriginate the LSA %d through the Area %pI4 for Link %s", + lp->instance, &area->area_id, lp->ifp ? lp->ifp->name : "?"); if (ospf_mpls_te_lsa_originate1(area, lp) != 0) return rc; @@ -1347,8 +1345,8 @@ static int ospf_mpls_te_lsa_originate2(struct ospf *top, if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) { zlog_debug( - "LSA[Type%d:%s]: Originate Opaque-LSA/MPLS-TE Inter-AS", - new->data->type, inet_ntoa(new->data->id)); + "LSA[Type%d:%pI4]: Originate Opaque-LSA/MPLS-TE Inter-AS", + new->data->type, &new->data->id); ospf_lsa_header_dump(new->data); } @@ -1490,8 +1488,8 @@ static struct ospf_lsa *ospf_mpls_te_lsa_refresh(struct ospf_lsa *lsa) /* Debug logging. */ if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) { - zlog_debug("LSA[Type%d:%s]: Refresh Opaque-LSA/MPLS-TE", - new->data->type, inet_ntoa(new->data->id)); + zlog_debug("LSA[Type%d:%pI4]: Refresh Opaque-LSA/MPLS-TE", + new->data->type, &new->data->id); ospf_lsa_header_dump(new->data); } @@ -1593,9 +1591,9 @@ static uint16_t show_vty_router_addr(struct vty *vty, struct tlv_header *tlvh) struct te_tlv_router_addr *top = (struct te_tlv_router_addr *)tlvh; if (vty != NULL) - vty_out(vty, " Router-Address: %s\n", inet_ntoa(top->value)); + vty_out(vty, " Router-Address: %pI4\n", &top->value); else - zlog_debug(" Router-Address: %s", inet_ntoa(top->value)); + zlog_debug(" Router-Address: %pI4", &top->value); return TLV_SIZE(tlvh); } @@ -1648,9 +1646,9 @@ static uint16_t show_vty_link_subtlv_link_id(struct vty *vty, top = (struct te_link_subtlv_link_id *)tlvh; if (vty != NULL) - vty_out(vty, " Link-ID: %s\n", inet_ntoa(top->value)); + vty_out(vty, " Link-ID: %pI4\n", &top->value); else - zlog_debug(" Link-ID: %s", inet_ntoa(top->value)); + zlog_debug(" Link-ID: %pI4", &top->value); return TLV_SIZE(tlvh); } @@ -1671,11 +1669,9 @@ static uint16_t show_vty_link_subtlv_lclif_ipaddr(struct vty *vty, for (i = 0; i < n; i++) { if (vty != NULL) - vty_out(vty, " #%d: %s\n", i, - inet_ntoa(top->value[i])); + vty_out(vty, " #%d: %pI4\n", i, &top->value[i]); else - zlog_debug(" #%d: %s", i, - inet_ntoa(top->value[i])); + zlog_debug(" #%d: %pI4", i, &top->value[i]); } return TLV_SIZE(tlvh); } @@ -1695,11 +1691,9 @@ static uint16_t show_vty_link_subtlv_rmtif_ipaddr(struct vty *vty, for (i = 0; i < n; i++) { if (vty != NULL) - vty_out(vty, " #%d: %s\n", i, - inet_ntoa(top->value[i])); + vty_out(vty, " #%d: %pI4\n", i, &top->value[i]); else - zlog_debug(" #%d: %s", i, - inet_ntoa(top->value[i])); + zlog_debug(" #%d: %pI4", i, &top->value[i]); } return TLV_SIZE(tlvh); } @@ -1811,15 +1805,15 @@ static uint16_t show_vty_link_subtlv_lrrid(struct vty *vty, top = (struct te_link_subtlv_lrrid *)tlvh; if (vty != NULL) { - vty_out(vty, " Local TE Router ID: %s\n", - inet_ntoa(top->local)); - vty_out(vty, " Remote TE Router ID: %s\n", - inet_ntoa(top->remote)); + vty_out(vty, " Local TE Router ID: %pI4\n", + &top->local); + vty_out(vty, " Remote TE Router ID: %pI4\n", + &top->remote); } else { - zlog_debug(" Local TE Router ID: %s", - inet_ntoa(top->local)); - zlog_debug(" Remote TE Router ID: %s", - inet_ntoa(top->remote)); + zlog_debug(" Local TE Router ID: %pI4", + &top->local); + zlog_debug(" Remote TE Router ID: %pI4", + &top->remote); } return TLV_SIZE(tlvh); @@ -1855,11 +1849,11 @@ static uint16_t show_vty_link_subtlv_rip(struct vty *vty, top = (struct te_link_subtlv_rip *)tlvh; if (vty != NULL) - vty_out(vty, " Inter-AS TE Remote ASBR IP address: %s\n", - inet_ntoa(top->value)); + vty_out(vty, " Inter-AS TE Remote ASBR IP address: %pI4\n", + &top->value); else - zlog_debug(" Inter-AS TE Remote ASBR IP address: %s", - inet_ntoa(top->value)); + zlog_debug(" Inter-AS TE Remote ASBR IP address: %pI4", + &top->value); return TLV_SIZE(tlvh); } @@ -2160,15 +2154,15 @@ static void ospf_mpls_te_config_write_router(struct vty *vty) if (OspfMplsTE.enabled) { vty_out(vty, " mpls-te on\n"); - vty_out(vty, " mpls-te router-address %s\n", - inet_ntoa(OspfMplsTE.router_addr.value)); + vty_out(vty, " mpls-te router-address %pI4\n", + &OspfMplsTE.router_addr.value); } if (OspfMplsTE.inter_as == AS) vty_out(vty, " mpls-te inter-as as\n"); if (OspfMplsTE.inter_as == Area) - vty_out(vty, " mpls-te inter-as area %s \n", - inet_ntoa(OspfMplsTE.interas_areaid)); + vty_out(vty, " mpls-te inter-as area %pI4 \n", + &OspfMplsTE.interas_areaid); return; } diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 870c9dd0a8..bef9490efc 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -34,6 +34,7 @@ #include "zclient.h" #include #include "defaults.h" +#include "lib/printfrr.h" #include "ospfd/ospfd.h" #include "ospfd/ospf_asbr.h" @@ -921,7 +922,7 @@ ospf_find_vl_data(struct ospf *ospf, struct ospf_vl_config_data *vl_config) if (area->external_routing != OSPF_AREA_DEFAULT) { if (vl_config->area_id_fmt == OSPF_AREA_ID_FMT_DOTTEDQUAD) - vty_out(vty, "Area %s is %s\n", inet_ntoa(area_id), + vty_out(vty, "Area %pI4 is %s\n", &area_id, area->external_routing == OSPF_AREA_NSSA ? "nssa" : "stub"); @@ -1717,8 +1718,8 @@ DEFUN (ospf_area_default_cost, p.prefixlen = 0; if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_stub_defaults(): announcing 0.0.0.0/0 to area %s", - inet_ntoa(area->area_id)); + "ospf_abr_announce_stub_defaults(): announcing 0.0.0.0/0 to area %pI4", + &area->area_id); ospf_abr_announce_network_to_area(&p, area->default_cost, area); return CMD_SUCCESS; @@ -1760,8 +1761,8 @@ DEFUN (no_ospf_area_default_cost, p.prefixlen = 0; if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_stub_defaults(): announcing 0.0.0.0/0 to area %s", - inet_ntoa(area->area_id)); + "ospf_abr_announce_stub_defaults(): announcing 0.0.0.0/0 to area %pI4", + &area->area_id); ospf_abr_announce_network_to_area(&p, area->default_cost, area); @@ -2643,13 +2644,14 @@ static void show_ip_ospf_area(struct vty *vty, struct ospf_area *area, json_object *json_areas, bool use_json) { json_object *json_area = NULL; + char buf[PREFIX_STRLEN]; if (use_json) json_area = json_object_new_object(); /* Show Area ID. */ if (!use_json) - vty_out(vty, " Area ID: %s", inet_ntoa(area->area_id)); + vty_out(vty, " Area ID: %pI4", &area->area_id); /* Show Area type/mode. */ if (OSPF_IS_AREA_BACKBONE(area)) { @@ -2936,7 +2938,9 @@ static void show_ip_ospf_area(struct vty *vty, struct ospf_area *area, } if (use_json) - json_object_object_add(json_areas, inet_ntoa(area->area_id), + json_object_object_add(json_areas, + inet_ntop(AF_INET, &area->area_id, + buf, sizeof(buf)), json_area); else vty_out(vty, "\n"); @@ -2949,6 +2953,7 @@ static int show_ip_ospf_common(struct vty *vty, struct ospf *ospf, struct ospf_area *area; struct timeval result; char timebuf[OSPF_TIME_DUMP_SIZE]; + char buf[PREFIX_STRLEN]; json_object *json_vrf = NULL; json_object *json_areas = NULL; @@ -2974,10 +2979,11 @@ static int show_ip_ospf_common(struct vty *vty, struct ospf *ospf, /* Show Router ID. */ if (json) { json_object_string_add(json_vrf, "routerId", - inet_ntoa(ospf->router_id)); + inet_ntop(AF_INET, &ospf->router_id, + buf, sizeof(buf))); } else { - vty_out(vty, " OSPF Routing Process, Router ID: %s\n", - inet_ntoa(ospf->router_id)); + vty_out(vty, " OSPF Routing Process, Router ID: %pI4\n", + &ospf->router_id); } /* Graceful shutdown */ @@ -3389,6 +3395,7 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf, int is_up; struct ospf_neighbor *nbr; struct route_node *rn; + char buf[PREFIX_STRLEN]; uint32_t bandwidth = ifp->bandwidth ? ifp->bandwidth : ifp->speed; /* Is interface up? */ @@ -3460,7 +3467,9 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf, if (use_json) { json_object_string_add( json_interface_sub, "ipAddress", - inet_ntoa(oi->address->u.prefix4)); + inet_ntop(AF_INET, + &oi->address->u.prefix4, + buf, sizeof(buf))); json_object_int_add(json_interface_sub, "ipAddressPrefixlen", oi->address->prefixlen); @@ -3493,15 +3502,17 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf, json_object_string_add( json_interface_sub, "vlinkPeer", - inet_ntoa(dest)); + inet_ntop(AF_INET, &dest, + buf, sizeof(buf))); else json_object_string_add( json_interface_sub, "localIfUsed", - inet_ntoa(dest)); + inet_ntop(AF_INET, &dest, + buf, sizeof(buf))); } else - vty_out(vty, " %s %s,", dstr, - inet_ntoa(dest)); + vty_out(vty, " %s %pI4,", dstr, + &dest); } if (use_json) { json_object_string_add(json_interface_sub, "area", @@ -3510,8 +3521,10 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf, json_object_boolean_true_add( json_interface_sub, "mtuMismatchDetect"); - json_object_string_add(json_interface_sub, "routerId", - inet_ntoa(ospf->router_id)); + json_object_string_add( + json_interface_sub, "routerId", + inet_ntop(AF_INET, &ospf->router_id, + buf, sizeof(buf))); json_object_string_add(json_interface_sub, "networkType", ospf_network_type_str[oi->type]); @@ -3534,8 +3547,8 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf, : "enabled"); vty_out(vty, - " Router ID %s, Network Type %s, Cost: %d\n", - inet_ntoa(ospf->router_id), + " Router ID %pI4, Network Type %s, Cost: %d\n", + &ospf->router_id, ospf_network_type_str[oi->type], oi->output_cost); @@ -3561,19 +3574,22 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf, if (use_json) { json_object_string_add( json_interface_sub, "bdrId", - inet_ntoa(nbr->router_id)); + inet_ntop(AF_INET, + &nbr->router_id, + buf, sizeof(buf))); json_object_string_add( json_interface_sub, "bdrAddress", - inet_ntoa(nbr->address.u - .prefix4)); + inet_ntop(AF_INET, + &nbr->address.u + .prefix4, + buf, sizeof(buf))); } else { vty_out(vty, - " Backup Designated Router (ID) %s,", - inet_ntoa(nbr->router_id)); - vty_out(vty, " Interface Address %s\n", - inet_ntoa(nbr->address.u - .prefix4)); + " Backup Designated Router (ID) %pI4,", + &nbr->router_id); + vty_out(vty, " Interface Address %pI4\n", + &nbr->address.u.prefix4); } } } @@ -4173,6 +4189,7 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty, struct route_node *rn; struct ospf_neighbor *nbr, *prev_nbr = NULL; char msgbuf[16]; + char buf[PREFIX_STRLEN]; char timebuf[OSPF_TIME_DUMP_SIZE]; json_object *json_neighbor = NULL, *json_neigh_array = NULL; @@ -4199,9 +4216,8 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty, strlcpy(neigh_str, "neighbor", sizeof(neigh_str)); else - strlcpy(neigh_str, - inet_ntoa(nbr->router_id), - sizeof(neigh_str)); + inet_ntop(AF_INET, &nbr->router_id, + neigh_str, sizeof(neigh_str)); json_object_object_get_ex(json, neigh_str, &json_neigh_array); @@ -4233,8 +4249,10 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty, json_object_int_add(json_neighbor, "deadTimeMsecs", time_store); - json_object_string_add(json_neighbor, "address", - inet_ntoa(nbr->src)); + json_object_string_add( + json_neighbor, "address", + inet_ntop(AF_INET, &nbr->src, + buf, sizeof(buf))); json_object_string_add(json_neighbor, "ifaceName", IF_NAME(oi)); @@ -4258,15 +4276,15 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty, vty_out(vty, "%-15s %3d %-15s ", "-", nbr->priority, msgbuf); else - vty_out(vty, "%-15s %3d %-15s ", - inet_ntoa(nbr->router_id), + vty_out(vty, "%-15pI4 %3d %-15s ", + &nbr->router_id, nbr->priority, msgbuf); vty_out(vty, "%9s ", ospf_timer_dump(nbr->t_inactivity, timebuf, sizeof(timebuf))); - vty_out(vty, "%-15s ", inet_ntoa(nbr->src)); + vty_out(vty, "%-15pI4 ", &nbr->src); vty_out(vty, "%-32s %5ld %5ld %5d\n", IF_NAME(oi), ospf_ls_retransmit_count(nbr), @@ -4469,6 +4487,7 @@ static int show_ip_ospf_neighbor_all_common(struct vty *vty, struct ospf *ospf, { struct listnode *node; struct ospf_interface *oi; + char buf[PREFIX_STRLEN]; json_object *json_vrf = NULL; json_object *json_neighbor_sub = NULL; @@ -4524,15 +4543,17 @@ static int show_ip_ospf_neighbor_all_common(struct vty *vty, struct ospf *ospf, "nbrNbmaDbSummaryCounter", 0); json_object_object_add( json_vrf, - inet_ntoa(nbr_nbma->addr), + inet_ntop(AF_INET, + &nbr_nbma->addr, buf, + sizeof(buf)), json_neighbor_sub); } else { vty_out(vty, "%-15s %3d %-15s %9s ", "-", nbr_nbma->priority, "Down", "-"); vty_out(vty, - "%-32s %-20s %5d %5d %5d\n", - inet_ntoa(nbr_nbma->addr), + "%-32pI4 %-20s %5d %5d %5d\n", + &nbr_nbma->addr, IF_NAME(oi), 0, 0, 0); } } @@ -4814,6 +4835,7 @@ static void show_ip_ospf_nbr_nbma_detail_sub(struct vty *vty, bool use_json, json_object *json) { char timebuf[OSPF_TIME_DUMP_SIZE]; + char buf[PREFIX_STRLEN]; json_object *json_sub = NULL; if (use_json) @@ -4824,10 +4846,11 @@ static void show_ip_ospf_nbr_nbma_detail_sub(struct vty *vty, /* Show interface address. */ if (use_json) json_object_string_add(json_sub, "ifaceAddress", - inet_ntoa(nbr_nbma->addr)); + inet_ntop(AF_INET, &nbr_nbma->addr, + buf, sizeof(buf))); else - vty_out(vty, " interface address %s\n", - inet_ntoa(nbr_nbma->addr)); + vty_out(vty, " interface address %pI4\n", + &nbr_nbma->addr); /* Show Area ID. */ if (use_json) { @@ -4897,6 +4920,7 @@ static void show_ip_ospf_neighbor_detail_sub(struct vty *vty, char timebuf[OSPF_TIME_DUMP_SIZE]; json_object *json_neigh = NULL, *json_neigh_array = NULL; char neigh_str[INET_ADDRSTRLEN] = {0}; + char buf[PREFIX_STRLEN]; if (use_json) { if (prev_nbr && @@ -4908,8 +4932,8 @@ static void show_ip_ospf_neighbor_detail_sub(struct vty *vty, && nbr->router_id.s_addr == INADDR_ANY) strlcpy(neigh_str, "noNbrId", sizeof(neigh_str)); else - strlcpy(neigh_str, inet_ntoa(nbr->router_id), - sizeof(neigh_str)); + inet_ntop(AF_INET, &nbr->router_id, + neigh_str, sizeof(neigh_str)); json_object_object_get_ex(json, neigh_str, &json_neigh_array); @@ -4927,17 +4951,19 @@ static void show_ip_ospf_neighbor_detail_sub(struct vty *vty, && nbr->router_id.s_addr == INADDR_ANY) vty_out(vty, " Neighbor %s,", "-"); else - vty_out(vty, " Neighbor %s,", - inet_ntoa(nbr->router_id)); + vty_out(vty, " Neighbor %pI4,", + &nbr->router_id); } /* Show interface address. */ if (use_json) json_object_string_add(json_neigh, "ifaceAddress", - inet_ntoa(nbr->address.u.prefix4)); + inet_ntop(AF_INET, + &nbr->address.u.prefix4, + buf, sizeof(buf))); else - vty_out(vty, " interface address %s\n", - inet_ntoa(nbr->address.u.prefix4)); + vty_out(vty, " interface address %pI4\n", + &nbr->address.u.prefix4); /* Show Area ID. */ if (use_json) { @@ -5012,16 +5038,18 @@ static void show_ip_ospf_neighbor_detail_sub(struct vty *vty, /* Show Designated Rotuer ID. */ if (use_json) json_object_string_add(json_neigh, "routerDesignatedId", - inet_ntoa(nbr->d_router)); + inet_ntop(AF_INET, &nbr->d_router, + buf, sizeof(buf))); else - vty_out(vty, " DR is %s,", inet_ntoa(nbr->d_router)); + vty_out(vty, " DR is %pI4,", &nbr->d_router); /* Show Backup Designated Rotuer ID. */ if (use_json) json_object_string_add(json_neigh, "routerDesignatedBackupId", - inet_ntoa(nbr->bd_router)); + inet_ntop(AF_INET, &nbr->bd_router, + buf, sizeof(buf))); else - vty_out(vty, " BDR is %s\n", inet_ntoa(nbr->bd_router)); + vty_out(vty, " BDR is %pI4\n", &nbr->bd_router); /* Show options. */ if (use_json) { @@ -5788,9 +5816,9 @@ static int show_lsa_summary(struct vty *vty, struct ospf_lsa *lsa, int self) /* If self option is set, check LSA self flag. */ if (self == 0 || IS_LSA_SELF(lsa)) { /* LSA common part show. */ - vty_out(vty, "%-15s ", inet_ntoa(lsa->data->id)); - vty_out(vty, "%-15s %4d 0x%08lx 0x%04x", - inet_ntoa(lsa->data->adv_router), LS_AGE(lsa), + vty_out(vty, "%-15pI4 ", &lsa->data->id); + vty_out(vty, "%-15pI4 %4d 0x%08lx 0x%04x", + &lsa->data->adv_router, LS_AGE(lsa), (unsigned long)ntohl(lsa->data->ls_seqnum), ntohs(lsa->data->checksum)); /* LSA specific part show. */ @@ -5807,8 +5835,7 @@ static int show_lsa_summary(struct vty *vty, struct ospf_lsa *lsa, int self) p.prefixlen = ip_masklen(sl->mask); apply_mask_ipv4(&p); - vty_out(vty, " %s/%d", inet_ntoa(p.prefix), - p.prefixlen); + vty_out(vty, " %pFX", &p); break; case OSPF_AS_EXTERNAL_LSA: case OSPF_AS_NSSA_LSA: @@ -5819,11 +5846,11 @@ static int show_lsa_summary(struct vty *vty, struct ospf_lsa *lsa, int self) p.prefixlen = ip_masklen(asel->mask); apply_mask_ipv4(&p); - vty_out(vty, " %s %s/%d [0x%lx]", + vty_out(vty, " %s %pFX [0x%lx]", IS_EXTERNAL_METRIC(asel->e[0].tos) ? "E2" : "E1", - inet_ntoa(p.prefix), p.prefixlen, + &p, (unsigned long)ntohl( asel->e[0].route_tag)); break; @@ -5898,10 +5925,10 @@ static void show_ip_ospf_database_header(struct vty *vty, struct ospf_lsa *lsa) } vty_out(vty, " LS Type: %s\n", lookup_msg(ospf_lsa_type_msg, lsa->data->type, NULL)); - vty_out(vty, " Link State ID: %s %s\n", inet_ntoa(lsa->data->id), + vty_out(vty, " Link State ID: %pI4 %s\n", &lsa->data->id, lookup_msg(ospf_link_state_id_type_msg, lsa->data->type, NULL)); - vty_out(vty, " Advertising Router: %s\n", - inet_ntoa(lsa->data->adv_router)); + vty_out(vty, " Advertising Router: %pI4\n", + &lsa->data->adv_router); vty_out(vty, " LS Seq Number: %08lx\n", (unsigned long)ntohl(lsa->data->ls_seqnum)); vty_out(vty, " Checksum: 0x%04x\n", ntohs(lsa->data->checksum)); @@ -5939,10 +5966,10 @@ static void show_ip_ospf_database_router_links(struct vty *vty, vty_out(vty, " Link connected to: %s\n", link_type_desc[type]); - vty_out(vty, " (Link ID) %s: %s\n", link_id_desc[type], - inet_ntoa(rl->link[i].link_id)); - vty_out(vty, " (Link Data) %s: %s\n", link_data_desc[type], - inet_ntoa(rl->link[i].link_data)); + vty_out(vty, " (Link ID) %s: %pI4\n", link_id_desc[type], + &rl->link[i].link_id); + vty_out(vty, " (Link Data) %s: %pI4\n", + link_data_desc[type], &rl->link[i].link_data); vty_out(vty, " Number of TOS metrics: 0\n"); vty_out(vty, " TOS 0 Metric: %d\n", ntohs(rl->link[i].metric)); @@ -5982,8 +6009,8 @@ static int show_network_lsa_detail(struct vty *vty, struct ospf_lsa *lsa) length = ntohs(lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4; for (i = 0; length > 0; i++, length -= 4) - vty_out(vty, " Attached Router: %s\n", - inet_ntoa(nl->routers[i])); + vty_out(vty, " Attached Router: %pI4\n", + &nl->routers[i]); vty_out(vty, "\n"); } @@ -6042,8 +6069,8 @@ static int show_as_external_lsa_detail(struct vty *vty, struct ospf_lsa *lsa) vty_out(vty, " TOS: 0\n"); vty_out(vty, " Metric: %d\n", GET_METRIC(al->e[0].metric)); - vty_out(vty, " Forward Address: %s\n", - inet_ntoa(al->e[0].fwd_addr)); + vty_out(vty, " Forward Address: %pI4\n", + &al->e[0].fwd_addr); vty_out(vty, " External Route Tag: %" ROUTE_TAG_PRI "\n\n", @@ -6068,8 +6095,8 @@ show_as_external_lsa_stdvty (struct ospf_lsa *lsa) zlog_debug( " TOS: 0%s", "\n"); zlog_debug( " Metric: %d%s", GET_METRIC (al->e[0].metric), "\n"); - zlog_debug( " Forward Address: %s%s", - inet_ntoa (al->e[0].fwd_addr), "\n"); + zlog_debug( " Forward Address: %pI4%s", + &al->e[0].fwd_addr, "\n"); zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI"%s%s", (route_tag_t)ntohl (al->e[0].route_tag), "\n", "\n"); @@ -6094,8 +6121,8 @@ static int show_as_nssa_lsa_detail(struct vty *vty, struct ospf_lsa *lsa) vty_out(vty, " TOS: 0\n"); vty_out(vty, " Metric: %d\n", GET_METRIC(al->e[0].metric)); - vty_out(vty, " NSSA: Forward Address: %s\n", - inet_ntoa(al->e[0].fwd_addr)); + vty_out(vty, " NSSA: Forward Address: %pI4\n", + &al->e[0].fwd_addr); vty_out(vty, " External Route Tag: %" ROUTE_TAG_PRI "\n\n", @@ -6317,10 +6344,10 @@ static void show_ip_ospf_database_maxage(struct vty *vty, struct ospf *ospf) if ((lsa = rn->info) != NULL) { vty_out(vty, "Link type: %d\n", lsa->data->type); - vty_out(vty, "Link State ID: %s\n", - inet_ntoa(lsa->data->id)); - vty_out(vty, "Advertising Router: %s\n", - inet_ntoa(lsa->data->adv_router)); + vty_out(vty, "Link State ID: %pI4\n", + &lsa->data->id); + vty_out(vty, "Advertising Router: %pI4\n", + &lsa->data->adv_router); vty_out(vty, "LSA lock count: %d\n", lsa->lock); vty_out(vty, "\n"); } @@ -6358,8 +6385,8 @@ static int show_ip_ospf_database_common(struct vty *vty, struct ospf *ospf, ospf_show_vrf_name(ospf, vty, NULL, use_vrf); - vty_out(vty, "\n OSPF Router with ID (%s)\n\n", - inet_ntoa(ospf->router_id)); + vty_out(vty, "\n OSPF Router with ID (%pI4)\n\n", + &ospf->router_id); /* Show all LSA. */ if (argc == arg_base + 4) { @@ -6608,8 +6635,8 @@ static int show_ip_ospf_database_type_adv_router_common(struct vty *vty, ospf_show_vrf_name(ospf, vty, NULL, use_vrf); - vty_out(vty, "\n OSPF Router with ID (%s)\n\n", - inet_ntoa(ospf->router_id)); + vty_out(vty, "\n OSPF Router with ID (%pI4)\n\n", + &ospf->router_id); /* Set database type to show. */ if (strncmp(argv[arg_base + idx_type]->text, "r", 1) == 0) @@ -9214,7 +9241,7 @@ static int ospf_print_vty_helper_dis_rtr_walkcb(struct hash_bucket *backet, struct vty *vty = (struct vty *)arg; static unsigned int count; - vty_out(vty, "%-6s,", inet_ntoa(rtr->advRtrAddr)); + vty_out(vty, "%-6pI4,", &rtr->advRtrAddr); count++; if (count % 5 == 0) @@ -9229,6 +9256,7 @@ static int ospf_show_gr_helper_details(struct vty *vty, struct ospf *ospf, { struct listnode *node; struct ospf_interface *oi; + char buf[PREFIX_STRLEN]; json_object *json_vrf = NULL; if (uj) { @@ -9263,10 +9291,11 @@ static int ospf_show_gr_helper_details(struct vty *vty, struct ospf *ospf, /* Show Router ID. */ if (uj) { json_object_string_add(json_vrf, "routerId", - inet_ntoa(ospf->router_id)); + inet_ntop(AF_INET, &ospf->router_id, + buf, sizeof(buf))); } else { - vty_out(vty, "\n OSPF Router with ID (%s)\n\n", - inet_ntoa(ospf->router_id)); + vty_out(vty, "\n OSPF Router with ID (%pI4)\n\n", + &ospf->router_id); } if (!uj) { @@ -9378,11 +9407,10 @@ static int ospf_show_gr_helper_details(struct vty *vty, struct ospf *ospf, if (!uj) { vty_out(vty, " Neighbour %d :\n", cnt); - vty_out(vty, " Address : %s\n", - inet_ntoa(nbr->address.u - .prefix4)); - vty_out(vty, " Routerid : %s\n", - inet_ntoa(nbr->router_id)); + vty_out(vty, " Address : %pI4\n", + &nbr->address.u.prefix4); + vty_out(vty, " Routerid : %pI4\n", + &nbr->router_id); vty_out(vty, " Received Grace period : %d(in seconds).\n", nbr->gr_helper_info @@ -9406,11 +9434,14 @@ static int ospf_show_gr_helper_details(struct vty *vty, struct ospf *ospf, json_neigh = json_object_new_object(); json_object_string_add( json_neigh, "srcAddr", - inet_ntoa(nbr->src)); + inet_ntop(AF_INET, &nbr->src, + buf, sizeof(buf))); json_object_string_add( json_neigh, "routerid", - inet_ntoa(nbr->router_id)); + inet_ntop(AF_INET, + &nbr->router_id, + buf, sizeof(buf))); json_object_int_add( json_neigh, "recvdGraceInterval", @@ -9433,7 +9464,8 @@ static int ospf_show_gr_helper_details(struct vty *vty, struct ospf *ospf, .gr_restart_reason)); json_object_object_add( json_neighbors, - inet_ntoa(nbr->src), + inet_ntop(AF_INET, &nbr->src, + buf, sizeof(buf)), json_neigh); } } @@ -9575,6 +9607,7 @@ static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf, struct ospf_route * or ; struct listnode *pnode, *pnnode; struct ospf_path *path; + char buf[PREFIX_STRLEN]; json_object *json_route = NULL, *json_nexthop_array = NULL, *json_nexthop = NULL; @@ -9583,11 +9616,11 @@ static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf, "============ OSPF network routing table ============\n"); for (rn = route_top(rt); rn; rn = route_next(rn)) { + char buf1[PREFIX2STR_BUFFER]; + if ((or = rn->info) == NULL) continue; - char buf1[PREFIX2STR_BUFFER]; - memset(buf1, 0, sizeof(buf1)); prefix2str(&rn->p, buf1, sizeof(buf1)); json_route = json_object_new_object(); @@ -9608,12 +9641,14 @@ static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf, or->cost); json_object_string_add( json_route, "area", - inet_ntoa(or->u.std.area_id)); + inet_ntop(AF_INET, + &or->u.std.area_id, + buf1, sizeof(buf1))); } else { vty_out(vty, - "N IA %-18s [%d] area: %s\n", + "N IA %-18s [%d] area: %pI4\n", buf1, or->cost, - inet_ntoa(or->u.std.area_id)); + &or->u.std.area_id); } } else if (or->type == OSPF_DESTINATION_DISCARD) { if (json) { @@ -9635,11 +9670,12 @@ static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf, or->cost); json_object_string_add( json_route, "area", - inet_ntoa(or->u.std.area_id)); + inet_ntop(AF_INET, &or->u.std.area_id, + buf1, sizeof(buf1))); } else { - vty_out(vty, "N %-18s [%d] area: %s\n", + vty_out(vty, "N %-18s [%d] area: %pI4\n", buf1, or->cost, - inet_ntoa(or->u.std.area_id)); + &or->u.std.area_id); } break; default: @@ -9688,8 +9724,11 @@ static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf, json_object_string_add( json_nexthop, "ip", - inet_ntoa( - path->nexthop)); + inet_ntop( + AF_INET, + &path->nexthop, + buf, + sizeof(buf))); json_object_string_add( json_nexthop, "via", @@ -9698,10 +9737,9 @@ static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf, ospf->vrf_id)); } else { vty_out(vty, - "%24s via %s, %s\n", + "%24s via %pI4, %s\n", "", - inet_ntoa( - path->nexthop), + &path->nexthop, ifindex2ifname( path->ifindex, ospf->vrf_id)); @@ -9726,6 +9764,7 @@ static void show_ip_ospf_route_router(struct vty *vty, struct ospf *ospf, struct listnode *pnode; struct listnode *node; struct ospf_path *path; + char buf[PREFIX_STRLEN]; json_object *json_route = NULL, *json_nexthop_array = NULL, *json_nexthop = NULL; @@ -9740,12 +9779,14 @@ static void show_ip_ospf_route_router(struct vty *vty, struct ospf *ospf, json_route = json_object_new_object(); if (json) { - json_object_object_add(json, inet_ntoa(rn->p.u.prefix4), - json_route); + json_object_object_add( + json, inet_ntop(AF_INET, &rn->p.u.prefix4, + buf, sizeof(buf)), + json_route); json_object_string_add(json_route, "routeType", "R "); } else { - vty_out(vty, "R %-15s ", - inet_ntoa(rn->p.u.prefix4)); + vty_out(vty, "R %-15pI4 ", + &rn->p.u.prefix4); } for (ALL_LIST_ELEMENTS_RO((struct list *)rn->info, node, or)) { @@ -9760,7 +9801,8 @@ static void show_ip_ospf_route_router(struct vty *vty, struct ospf *ospf, or->cost); json_object_string_add( json_route, "area", - inet_ntoa(or->u.std.area_id)); + inet_ntop(AF_INET, &or->u.std.area_id, + buf, sizeof(buf))); if (or->path_type == OSPF_PATH_INTER_AREA) json_object_boolean_true_add(json_route, "IA"); @@ -9773,11 +9815,11 @@ static void show_ip_ospf_route_router(struct vty *vty, struct ospf *ospf, "routerType", "asbr"); } else { - vty_out(vty, "%s [%d] area: %s", + vty_out(vty, "%s [%d] area: %pI4", (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "), - or->cost, inet_ntoa(or->u.std.area_id)); + or->cost, &or->u.std.area_id); /* Show flags. */ vty_out(vty, "%s%s\n", (or->u.std.flags & ROUTER_LSA_BORDER @@ -9827,8 +9869,10 @@ static void show_ip_ospf_route_router(struct vty *vty, struct ospf *ospf, json_object_string_add( json_nexthop, "ip", - inet_ntoa( - path->nexthop)); + inet_ntop( + AF_INET, + &path->nexthop, + buf, sizeof(buf))); json_object_string_add( json_nexthop, "via", @@ -9837,10 +9881,9 @@ static void show_ip_ospf_route_router(struct vty *vty, struct ospf *ospf, ospf->vrf_id)); } else { vty_out(vty, - "%24s via %s, %s\n", + "%24s via %pI4, %s\n", "", - inet_ntoa( - path->nexthop), + &path->nexthop, ifindex2ifname( path->ifindex, ospf->vrf_id)); @@ -9864,6 +9907,7 @@ static void show_ip_ospf_route_external(struct vty *vty, struct ospf *ospf, struct ospf_route *er; struct listnode *pnode, *pnnode; struct ospf_path *path; + char buf[PREFIX_STRLEN]; json_object *json_route = NULL, *json_nexthop_array = NULL, *json_nexthop = NULL; @@ -9877,8 +9921,7 @@ static void show_ip_ospf_route_external(struct vty *vty, struct ospf *ospf, char buf1[19]; - snprintf(buf1, sizeof(buf1), "%s/%d", - inet_ntoa(rn->p.u.prefix4), rn->p.prefixlen); + snprintfrr(buf1, sizeof(buf1), "%pFX", &rn->p); json_route = json_object_new_object(); if (json) { json_object_object_add(json, buf1, json_route); @@ -9953,8 +9996,11 @@ static void show_ip_ospf_route_external(struct vty *vty, struct ospf *ospf, if (json) { json_object_string_add( json_nexthop, "ip", - inet_ntoa( - path->nexthop)); + inet_ntop( + AF_INET, + &path->nexthop, + buf, + sizeof(buf))); json_object_string_add( json_nexthop, "via", ifindex2ifname( @@ -9962,10 +10008,9 @@ static void show_ip_ospf_route_external(struct vty *vty, struct ospf *ospf, ospf->vrf_id)); } else { vty_out(vty, - "%24s via %s, %s\n", + "%24s via %pI4, %s\n", "", - inet_ntoa( - path->nexthop), + &path->nexthop, ifindex2ifname( path->ifindex, ospf->vrf_id)); @@ -10275,6 +10320,7 @@ DEFUN (show_ip_ospf_vrfs, struct ospf *ospf = NULL; struct listnode *node = NULL; int count = 0; + char buf[PREFIX_STRLEN]; static const char header[] = "Name Id RouterId "; if (uj) { @@ -10305,14 +10351,16 @@ DEFUN (show_ip_ospf_vrfs, if (uj) { json_object_int_add(json_vrf, "vrfId", vrf_id_ui); - json_object_string_add(json_vrf, "routerId", - inet_ntoa(ospf->router_id)); + json_object_string_add( + json_vrf, "routerId", + inet_ntop(AF_INET, &ospf->router_id, + buf, sizeof(buf))); json_object_object_add(json_vrfs, name, json_vrf); } else { - vty_out(vty, "%-25s %-5d %-16s \n", name, - ospf->vrf_id, inet_ntoa(ospf->router_id)); + vty_out(vty, "%-25s %-5d %-16pI4 \n", name, + ospf->vrf_id, &ospf->router_id); } } @@ -10387,9 +10435,8 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf) ospf_int_type_str [params->type]); if (params != IF_DEF_PARAMS(ifp) && rn) - vty_out(vty, " %s", - inet_ntoa( - rn->p.u.prefix4)); + vty_out(vty, " %pI4", + &rn->p.u.prefix4); vty_out(vty, "\n"); } } @@ -10424,8 +10471,8 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf) vty_out(vty, " ip ospf authentication%s", auth_str); if (params != IF_DEF_PARAMS(ifp) && rn) - vty_out(vty, " %s", - inet_ntoa(rn->p.u.prefix4)); + vty_out(vty, " %pI4", + &rn->p.u.prefix4); vty_out(vty, "\n"); } @@ -10435,8 +10482,8 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf) vty_out(vty, " ip ospf authentication-key %s", params->auth_simple); if (params != IF_DEF_PARAMS(ifp) && rn) - vty_out(vty, " %s", - inet_ntoa(rn->p.u.prefix4)); + vty_out(vty, " %pI4", + &rn->p.u.prefix4); vty_out(vty, "\n"); } @@ -10448,9 +10495,8 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf) " ip ospf message-digest-key %d md5 %s", ck->key_id, ck->auth_key); if (params != IF_DEF_PARAMS(ifp) && rn) - vty_out(vty, " %s", - inet_ntoa( - rn->p.u.prefix4)); + vty_out(vty, " %pI4", + &rn->p.u.prefix4); vty_out(vty, "\n"); } } @@ -10460,8 +10506,8 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf) vty_out(vty, " ip ospf cost %u", params->output_cost_cmd); if (params != IF_DEF_PARAMS(ifp) && rn) - vty_out(vty, " %s", - inet_ntoa(rn->p.u.prefix4)); + vty_out(vty, " %pI4", + &rn->p.u.prefix4); vty_out(vty, "\n"); } @@ -10471,8 +10517,8 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf) vty_out(vty, " ip ospf hello-interval %u", params->v_hello); if (params != IF_DEF_PARAMS(ifp) && rn) - vty_out(vty, " %s", - inet_ntoa(rn->p.u.prefix4)); + vty_out(vty, " %pI4", + &rn->p.u.prefix4); vty_out(vty, "\n"); } @@ -10493,8 +10539,8 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf) vty_out(vty, "%u", params->v_wait); if (params != IF_DEF_PARAMS(ifp) && rn) - vty_out(vty, " %s", - inet_ntoa(rn->p.u.prefix4)); + vty_out(vty, " %pI4", + &rn->p.u.prefix4); vty_out(vty, "\n"); } @@ -10505,8 +10551,8 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf) vty_out(vty, " ip ospf priority %u", params->priority); if (params != IF_DEF_PARAMS(ifp) && rn) - vty_out(vty, " %s", - inet_ntoa(rn->p.u.prefix4)); + vty_out(vty, " %pI4", + &rn->p.u.prefix4); vty_out(vty, "\n"); } @@ -10518,8 +10564,8 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf) vty_out(vty, " ip ospf retransmit-interval %u", params->retransmit_interval); if (params != IF_DEF_PARAMS(ifp) && rn) - vty_out(vty, " %s", - inet_ntoa(rn->p.u.prefix4)); + vty_out(vty, " %pI4", + &rn->p.u.prefix4); vty_out(vty, "\n"); } @@ -10530,8 +10576,8 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf) vty_out(vty, " ip ospf transmit-delay %u", params->transmit_delay); if (params != IF_DEF_PARAMS(ifp) && rn) - vty_out(vty, " %s", - inet_ntoa(rn->p.u.prefix4)); + vty_out(vty, " %pI4", + &rn->p.u.prefix4); vty_out(vty, "\n"); } @@ -10549,8 +10595,8 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf) params->if_area_id_fmt); vty_out(vty, " area %s", buf); if (params != IF_DEF_PARAMS(ifp) && rn) - vty_out(vty, " %s", - inet_ntoa(rn->p.u.prefix4)); + vty_out(vty, " %pI4", + &rn->p.u.prefix4); vty_out(vty, "\n"); } @@ -10566,8 +10612,8 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf) else vty_out(vty, " ip ospf mtu-ignore"); if (params != IF_DEF_PARAMS(ifp) && rn) - vty_out(vty, " %s", - inet_ntoa(rn->p.u.prefix4)); + vty_out(vty, " %pI4", + &rn->p.u.prefix4); vty_out(vty, "\n"); } @@ -10631,9 +10677,7 @@ static int config_write_network_area(struct vty *vty, struct ospf *ospf) n->area_id.s_addr)); /* Network print. */ - vty_out(vty, " network %s/%d area %s\n", - inet_ntoa(rn->p.u.prefix4), rn->p.prefixlen, - buf); + vty_out(vty, " network %pFX area %s\n", &rn->p, buf); } return 0; @@ -10704,9 +10748,8 @@ static int config_write_ospf_area(struct vty *vty, struct ospf *ospf) if (rn1->info) { struct ospf_area_range *range = rn1->info; - vty_out(vty, " area %s range %s/%d", buf, - inet_ntoa(rn1->p.u.prefix4), - rn1->p.prefixlen); + vty_out(vty, " area %s range %pFX", buf, + &rn1->p); if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC) @@ -10719,8 +10762,8 @@ static int config_write_ospf_area(struct vty *vty, struct ospf *ospf) if (CHECK_FLAG(range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) - vty_out(vty, " substitute %s/%d", - inet_ntoa(range->subst_addr), + vty_out(vty, " substitute %pI4/%d", + &range->subst_addr, range->subst_masklen); vty_out(vty, "\n"); @@ -10754,7 +10797,7 @@ static int config_write_ospf_nbr_nbma(struct vty *vty, struct ospf *ospf) /* Static Neighbor configuration print. */ for (rn = route_top(ospf->nbr_nbma); rn; rn = route_next(rn)) if ((nbr_nbma = rn->info)) { - vty_out(vty, " neighbor %s", inet_ntoa(nbr_nbma->addr)); + vty_out(vty, " neighbor %pI4", &nbr_nbma->addr); if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT) @@ -10798,21 +10841,21 @@ static int config_write_virtual_link(struct vty *vty, struct ospf *ospf) || OSPF_IF_PARAM(oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT) vty_out(vty, - " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d\n", - buf, inet_ntoa(vl_data->vl_peer), + " area %s virtual-link %pI4 hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d\n", + buf, &vl_data->vl_peer, OSPF_IF_PARAM(oi, v_hello), OSPF_IF_PARAM(oi, retransmit_interval), OSPF_IF_PARAM(oi, transmit_delay), OSPF_IF_PARAM(oi, v_wait)); else - vty_out(vty, " area %s virtual-link %s\n", buf, - inet_ntoa(vl_data->vl_peer)); + vty_out(vty, " area %s virtual-link %pI4\n", buf, + &vl_data->vl_peer); /* Auth key */ if (IF_DEF_PARAMS(vl_data->vl_oi->ifp)->auth_simple[0] != '\0') vty_out(vty, - " area %s virtual-link %s authentication-key %s\n", - buf, inet_ntoa(vl_data->vl_peer), + " area %s virtual-link %pI4 authentication-key %s\n", + buf, &vl_data->vl_peer, IF_DEF_PARAMS(vl_data->vl_oi->ifp) ->auth_simple); /* md5 keys */ @@ -10821,8 +10864,8 @@ static int config_write_virtual_link(struct vty *vty, struct ospf *ospf) ->auth_crypt, n2, ck)) vty_out(vty, - " area %s virtual-link %s message-digest-key %d md5 %s\n", - buf, inet_ntoa(vl_data->vl_peer), + " area %s virtual-link %pI4 message-digest-key %d md5 %s\n", + buf, &vl_data->vl_peer, ck->key_id, ck->auth_key); } } @@ -10874,8 +10917,8 @@ static int ospf_cfg_write_helper_dis_rtr_walkcb(struct hash_bucket *backet, struct advRtr *rtr = backet->data; struct vty *vty = (struct vty *)arg; - vty_out(vty, " graceful-restart helper-only %s\n", - inet_ntoa(rtr->advRtrAddr)); + vty_out(vty, " graceful-restart helper-only %pI4\n", + &rtr->advRtrAddr); return HASHWALK_CONTINUE; } @@ -10885,7 +10928,8 @@ static int config_write_ospf_gr_helper(struct vty *vty, struct ospf *ospf) vty_out(vty, " graceful-restart helper-only\n"); if (!ospf->strict_lsa_check) - vty_out(vty, " no graceful-restart helper strict-lsa-checking\n"); + vty_out(vty, + " no graceful-restart helper strict-lsa-checking\n"); if (ospf->only_planned_restart) vty_out(vty, " graceful-restart helper planned-only\n"); @@ -10974,9 +11018,8 @@ static int config_write_ospf_distance(struct vty *vty, struct ospf *ospf) for (rn = route_top(ospf->distance_table); rn; rn = route_next(rn)) if ((odistance = rn->info) != NULL) { - vty_out(vty, " distance %d %s/%d %s\n", - odistance->distance, inet_ntoa(rn->p.u.prefix4), - rn->p.prefixlen, + vty_out(vty, " distance %d %pFX %s\n", + odistance->distance, &rn->p, odistance->access_list ? odistance->access_list : ""); } @@ -11009,8 +11052,8 @@ static int ospf_config_write_one(struct vty *vty, struct ospf *ospf) /* Router ID print. */ if (ospf->router_id_static.s_addr != 0) - vty_out(vty, " ospf router-id %s\n", - inet_ntoa(ospf->router_id_static)); + vty_out(vty, " ospf router-id %pI4\n", + &ospf->router_id_static); /* ABR type print. */ if (ospf->abr_type != OSPF_ABR_DEFAULT) @@ -11107,9 +11150,9 @@ static int ospf_config_write_one(struct vty *vty, struct ospf *ospf) == ospf->passive_interface_default) continue; - vty_out(vty, " %spassive-interface %s %s\n", + vty_out(vty, " %spassive-interface %s %pI4\n", oi->params->passive_interface ? "" : "no ", - oi->ifp->name, inet_ntoa(oi->address->u.prefix4)); + oi->ifp->name, &oi->address->u.prefix4); } /* Network area print. */ diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index 5aacbc9061..9fa6a59a72 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -408,8 +408,8 @@ bool ospf_external_default_routemap_apply_walk(struct ospf *ospf, if (ret && ei) { if (IS_DEBUG_OSPF_DEFAULT_INFO) - zlog_debug("Default originate routemap permit ei: %s", - inet_ntoa(ei->p.prefix)); + zlog_debug("Default originate routemap permit ei: %pI4", + &ei->p.prefix); return true; } @@ -850,8 +850,8 @@ static int ospf_external_lsa_originate_check(struct ospf *ospf, /* If prefix is multicast, then do not originate LSA. */ if (IN_MULTICAST(htonl(ei->p.prefix.s_addr))) { zlog_info( - "LSA[Type5:%s]: Not originate AS-external-LSA, Prefix belongs multicast", - inet_ntoa(ei->p.prefix)); + "LSA[Type5:%pI4]: Not originate AS-external-LSA, Prefix belongs multicast", + &ei->p.prefix); return 0; } @@ -943,16 +943,16 @@ static bool ospf_external_lsa_default_routemap_apply(struct ospf *ospf, } if (IS_DEBUG_OSPF_DEFAULT_INFO) - zlog_debug("Apply default originate routemap on ei: %s cmd: %d", - inet_ntoa(ei->p.prefix), cmd); + zlog_debug("Apply default originate routemap on ei: %pI4 cmd: %d", + &ei->p.prefix, cmd); ret = ospf_external_info_apply_default_routemap(ospf, ei, default_ei); /* If deny then nothing to be done both in add and del case. */ if (!ret) { if (IS_DEBUG_OSPF_DEFAULT_INFO) - zlog_debug("Default originte routemap deny for ei: %s", - inet_ntoa(ei->p.prefix)); + zlog_debug("Default originte routemap deny for ei: %pI4", + &ei->p.prefix); return false; } @@ -990,8 +990,8 @@ static bool ospf_external_lsa_default_routemap_apply(struct ospf *ospf, if (IS_DEBUG_OSPF_DEFAULT_INFO) zlog_debug( - "Running default route-map again as ei: %s deleted", - inet_ntoa(ei->p.prefix)); + "Running default route-map again as ei: %pI4 deleted", + &ei->p.prefix); /* * if this route delete was permitted then we need to check * there are any other external info which can still trigger @@ -1192,9 +1192,8 @@ static int ospf_zebra_read_route(ZAPI_CALLBACK_ARGS) zebra, ZEBRA_REDISTRIBUTE)) zlog_debug( - "ospf_zebra_read_route() : %s refreshing LSA", - inet_ntoa( - p.prefix)); + "ospf_zebra_read_route() : %pI4 refreshing LSA", + &p.prefix); ospf_external_lsa_refresh( ospf, current, ei, LSA_REFRESH_FORCE); diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index aa063a0759..ce3bc33c1a 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -103,8 +103,8 @@ void ospf_router_id_update(struct ospf *ospf) } if (IS_DEBUG_OSPF_EVENT) - zlog_debug("Router-ID[OLD:%s]: Update", - inet_ntoa(ospf->router_id)); + zlog_debug("Router-ID[OLD:%pI4]: Update", + &ospf->router_id); router_id_old = ospf->router_id; @@ -123,8 +123,8 @@ void ospf_router_id_update(struct ospf *ospf) router_id = ospf->router_id_zebra; if (IS_DEBUG_OSPF_EVENT) - zlog_debug("Router-ID[OLD:%s]: Update to %s", - inet_ntoa(ospf->router_id), inet_ntoa(router_id)); + zlog_debug("Router-ID[OLD:%pI4]: Update to %pI4", + &ospf->router_id, &router_id); if (!IPV4_ADDR_SAME(&router_id_old, &router_id)) { @@ -162,8 +162,8 @@ void ospf_router_id_update(struct ospf *ospf) ospf->router_id = router_id; if (IS_DEBUG_OSPF_EVENT) - zlog_debug("Router-ID[NEW:%s]: Update", - inet_ntoa(ospf->router_id)); + zlog_debug("Router-ID[NEW:%pI4]: Update", + &ospf->router_id); /* Flush (inline) all external LSAs which now match the new router-id, @@ -1338,10 +1338,10 @@ void ospf_if_update(struct ospf *ospf, struct interface *ifp) if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "%s: interface %s ifp->vrf_id %u ospf vrf %s vrf_id %u router_id %s", + "%s: interface %s ifp->vrf_id %u ospf vrf %s vrf_id %u router_id %pI4", __func__, ifp->name, ifp->vrf_id, ospf_vrf_id_to_name(ospf->vrf_id), ospf->vrf_id, - inet_ntoa(ospf->router_id)); + &ospf->router_id); /* OSPF must be ready. */ if (!ospf_is_ready(ospf)) @@ -1378,16 +1378,16 @@ static void ospf_area_type_set(struct ospf_area *area, int type) if (area->external_routing == type) { if (IS_DEBUG_OSPF_EVENT) - zlog_debug("Area[%s]: Types are the same, ignored.", - inet_ntoa(area->area_id)); + zlog_debug("Area[%pI4]: Types are the same, ignored.", + &area->area_id); return; } area->external_routing = type; if (IS_DEBUG_OSPF_EVENT) - zlog_debug("Area[%s]: Configured as %s", - inet_ntoa(area->area_id), + zlog_debug("Area[%pI4]: Configured as %s", + &area->area_id, lookup_msg(ospf_area_type_msg, type, NULL)); switch (area->external_routing) { -- 2.39.5