summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/ISSUE_TEMPLATE/bug_report.md68
-rw-r--r--babeld/babel_filter.c32
-rw-r--r--babeld/babel_interface.c4
-rw-r--r--bfdd/ptm_adapter.c5
-rw-r--r--bgpd/bgp_attr.c3
-rw-r--r--bgpd/bgp_bfd.c19
-rw-r--r--bgpd/bgp_btoa.c11
-rw-r--r--bgpd/bgp_debug.c106
-rw-r--r--bgpd/bgp_ecommunity.c6
-rw-r--r--bgpd/bgp_evpn.c173
-rw-r--r--bgpd/bgp_evpn_mh.c215
-rw-r--r--bgpd/bgp_evpn_vty.c205
-rw-r--r--bgpd/bgp_evpn_vty.h4
-rw-r--r--bgpd/bgp_flowspec_util.c11
-rw-r--r--bgpd/bgp_fsm.c13
-rw-r--r--bgpd/bgp_label.c15
-rw-r--r--bgpd/bgp_main.c3
-rw-r--r--bgpd/bgp_mplsvpn.c10
-rw-r--r--bgpd/bgp_nht.c19
-rw-r--r--bgpd/bgp_packet.c17
-rw-r--r--bgpd/bgp_pbr.c19
-rw-r--r--bgpd/bgp_rd.c7
-rw-r--r--bgpd/bgp_route.c261
-rw-r--r--bgpd/bgp_route.h2
-rw-r--r--bgpd/bgp_routemap.c60
-rw-r--r--bgpd/bgp_rpki.c19
-rw-r--r--bgpd/bgp_table.h5
-rw-r--r--bgpd/bgp_updgrp_adv.c5
-rw-r--r--bgpd/bgp_updgrp_packet.c28
-rw-r--r--bgpd/bgp_vpn.c24
-rw-r--r--bgpd/bgp_vty.c54
-rw-r--r--bgpd/bgp_zebra.c95
-rw-r--r--bgpd/bgpd.c34
-rw-r--r--bgpd/bgpd.h6
-rw-r--r--bgpd/rfapi/bgp_rfapi_cfg.c32
-rw-r--r--bgpd/rfapi/rfapi.c46
-rw-r--r--bgpd/rfapi/rfapi_import.c46
-rw-r--r--bgpd/rfapi/rfapi_monitor.c28
-rw-r--r--bgpd/rfapi/rfapi_rib.c53
-rw-r--r--bgpd/rfapi/rfapi_vty.c24
-rw-r--r--bgpd/rfapi/vnc_import_bgp.c152
-rw-r--r--bgpd/rfapi/vnc_zebra.c20
-rw-r--r--eigrpd/eigrp_dump.c19
-rw-r--r--eigrpd/eigrp_dump.h15
-rw-r--r--eigrpd/eigrp_fsm.c4
-rw-r--r--eigrpd/eigrp_hello.c36
-rw-r--r--eigrpd/eigrp_neighbor.c14
-rw-r--r--eigrpd/eigrp_network.c23
-rw-r--r--eigrpd/eigrp_northbound.c39
-rw-r--r--eigrpd/eigrp_packet.c44
-rw-r--r--eigrpd/eigrp_reply.c7
-rw-r--r--eigrpd/eigrp_topology.c10
-rw-r--r--eigrpd/eigrp_update.c66
-rw-r--r--eigrpd/eigrp_vty.c21
-rw-r--r--eigrpd/eigrp_zebra.c32
-rw-r--r--eigrpd/eigrpd.c4
-rw-r--r--isisd/isis_adjacency.c6
-rw-r--r--isisd/isis_circuit.c60
-rw-r--r--isisd/isis_lsp.c23
-rw-r--r--isisd/isis_redist.c18
-rw-r--r--isisd/isis_route.c21
-rw-r--r--isisd/isis_te.c23
-rw-r--r--isisd/isis_tlvs.c12
-rw-r--r--isisd/isis_zebra.c22
-rw-r--r--ldpd/address.c6
-rw-r--r--ldpd/adjacency.c6
-rw-r--r--ldpd/hello.c46
-rw-r--r--ldpd/init.c24
-rw-r--r--ldpd/interface.c34
-rw-r--r--ldpd/keepalive.c4
-rw-r--r--ldpd/labelmapping.c4
-rw-r--r--ldpd/ldp_vty_conf.c16
-rw-r--r--ldpd/ldp_vty_exec.c122
-rw-r--r--ldpd/ldp_zebra.c2
-rw-r--r--ldpd/logmsg.c9
-rw-r--r--ldpd/neighbor.c30
-rw-r--r--ldpd/notification.c6
-rw-r--r--ldpd/packet.c10
-rw-r--r--lib/agg_table.h5
-rw-r--r--lib/command.h8
-rw-r--r--lib/filter.c33
-rw-r--r--lib/if.c22
-rw-r--r--lib/nexthop.c8
-rw-r--r--lib/nexthop_group.c20
-rw-r--r--lib/plist.c32
-rw-r--r--lib/routemap.c56
-rw-r--r--lib/sockunion.c12
-rw-r--r--lib/table.c3
-rw-r--r--lib/table.h5
-rw-r--r--lib/zclient.c50
-rw-r--r--nhrpd/nhrp_interface.c14
-rw-r--r--nhrpd/nhrp_route.c27
-rw-r--r--nhrpd/nhrp_shortcut.c28
-rw-r--r--ospf6d/ospf6_abr.c101
-rw-r--r--ospf6d/ospf6_area.c5
-rw-r--r--ospf6d/ospf6_asbr.c100
-rw-r--r--ospf6d/ospf6_bfd.c9
-rw-r--r--ospf6d/ospf6_interface.c13
-rw-r--r--ospf6d/ospf6_intra.c29
-rw-r--r--ospf6d/ospf6_lsa.h20
-rw-r--r--ospf6d/ospf6_lsdb.c6
-rw-r--r--ospf6d/ospf6_route.c10
-rw-r--r--ospf6d/ospf6_spf.c9
-rw-r--r--ospf6d/ospf6_top.c10
-rw-r--r--ospf6d/ospf6_zebra.c59
-rw-r--r--ospfclient/ospfclient.c29
-rw-r--r--ospfd/ospf_abr.c193
-rw-r--r--ospfd/ospf_apiserver.c48
-rw-r--r--ospfd/ospf_asbr.c19
-rw-r--r--ospfd/ospf_ase.c21
-rw-r--r--ospfd/ospf_bfd.c25
-rw-r--r--ospfd/ospf_dump.c36
-rw-r--r--ospfd/ospf_dump_api.c4
-rw-r--r--ospfd/ospf_ext.c18
-rw-r--r--ospfd/ospf_flood.c50
-rw-r--r--ospfd/ospf_gr_helper.c32
-rw-r--r--ospfd/ospf_ia.c20
-rw-r--r--ospfd/ospf_interface.c34
-rw-r--r--ospfd/ospf_ism.c8
-rw-r--r--ospfd/ospf_lsa.c191
-rw-r--r--ospfd/ospf_neighbor.c16
-rw-r--r--ospfd/ospf_network.c36
-rw-r--r--ospfd/ospf_nsm.c36
-rw-r--r--ospfd/ospf_opaque.c20
-rw-r--r--ospfd/ospf_packet.c282
-rw-r--r--ospfd/ospf_ri.c51
-rw-r--r--ospfd/ospf_route.c55
-rw-r--r--ospfd/ospf_snmp.c8
-rw-r--r--ospfd/ospf_spf.c96
-rw-r--r--ospfd/ospf_sr.c58
-rw-r--r--ospfd/ospf_te.c78
-rw-r--r--ospfd/ospf_vty.c414
-rw-r--r--ospfd/ospf_zebra.c122
-rw-r--r--ospfd/ospfd.c24
-rw-r--r--pbrd/pbr_nht.c6
-rw-r--r--pbrd/pbr_vty.c15
-rw-r--r--pbrd/pbr_zebra.c37
-rw-r--r--pimd/mtracebis.c4
-rw-r--r--pimd/pim_bfd.c9
-rw-r--r--pimd/pim_bsm.c49
-rw-r--r--pimd/pim_cmd.c112
-rw-r--r--pimd/pim_iface.c18
-rw-r--r--pimd/pim_igmp.c48
-rw-r--r--pimd/pim_igmp_mtrace.c16
-rw-r--r--pimd/pim_igmpv3.c12
-rw-r--r--pimd/pim_nht.c64
-rw-r--r--pimd/pim_register.c15
-rw-r--r--pimd/pim_rp.c165
-rw-r--r--pimd/pim_upstream.c23
-rw-r--r--pimd/pim_zebra.c33
-rw-r--r--ripd/rip_interface.c18
-rw-r--r--ripd/rip_peer.c4
-rw-r--r--ripd/rip_zebra.c10
-rw-r--r--ripd/ripd.c167
-rw-r--r--ripngd/ripng_interface.c10
-rw-r--r--ripngd/ripngd.c51
-rw-r--r--sharpd/sharp_nht.c11
-rw-r--r--sharpd/sharp_vty.c10
-rw-r--r--staticd/static_vty.c3
-rw-r--r--staticd/static_zebra.c15
-rw-r--r--tests/bgpd/test_bgp_table.c5
-rw-r--r--tests/lib/cli/test_cli.c6
-rw-r--r--tests/lib/test_srcdest_table.c4
-rw-r--r--tests/lib/test_table.c4
-rw-r--r--tests/topotests/bfd-isis-topo1/rt1/isisd.conf1
-rw-r--r--tests/topotests/bfd-isis-topo1/rt2/isisd.conf1
-rw-r--r--tests/topotests/bfd-isis-topo1/rt3/isisd.conf1
-rw-r--r--tests/topotests/bfd-isis-topo1/rt4/isisd.conf1
-rw-r--r--tests/topotests/bfd-isis-topo1/rt5/isisd.conf1
-rw-r--r--tests/topotests/bfd-profiles-topo1/r3/isisd.conf1
-rw-r--r--tests/topotests/bfd-profiles-topo1/r4/isisd.conf1
-rw-r--r--tests/topotests/isis-sr-topo1/rt1/isisd.conf2
-rw-r--r--tests/topotests/isis-sr-topo1/rt2/isisd.conf2
-rw-r--r--tests/topotests/isis-sr-topo1/rt3/isisd.conf2
-rw-r--r--tests/topotests/isis-sr-topo1/rt4/isisd.conf2
-rw-r--r--tests/topotests/isis-sr-topo1/rt5/isisd.conf2
-rw-r--r--tests/topotests/isis-sr-topo1/rt6/isisd.conf2
-rwxr-xr-xtests/topotests/isis-topo1-vrf/r1/isisd.conf1
-rwxr-xr-xtests/topotests/isis-topo1-vrf/r2/isisd.conf1
-rwxr-xr-xtests/topotests/isis-topo1-vrf/r3/isisd.conf1
-rwxr-xr-xtests/topotests/isis-topo1-vrf/r4/isisd.conf1
-rwxr-xr-xtests/topotests/isis-topo1-vrf/r5/isisd.conf1
-rw-r--r--tests/topotests/isis-topo1/r1/isisd.conf2
-rw-r--r--tests/topotests/isis-topo1/r2/isisd.conf2
-rw-r--r--tests/topotests/isis-topo1/r3/isisd.conf2
-rw-r--r--tests/topotests/isis-topo1/r4/isisd.conf2
-rw-r--r--tests/topotests/isis-topo1/r5/isisd.conf2
-rw-r--r--tests/topotests/ldp-sync-isis-topo1/r1/isisd.conf1
-rw-r--r--tests/topotests/ldp-sync-isis-topo1/r2/isisd.conf1
-rw-r--r--tests/topotests/ldp-sync-isis-topo1/r3/isisd.conf1
-rw-r--r--yang/frr-nexthop.yang2
-rw-r--r--zebra/connected.c38
-rw-r--r--zebra/interface.c32
-rw-r--r--zebra/irdp_main.c10
-rw-r--r--zebra/irdp_packet.c32
-rw-r--r--zebra/redistribute.c60
-rw-r--r--zebra/rt_netlink.c29
-rw-r--r--zebra/rt_socket.c22
-rw-r--r--zebra/rtadv.c4
-rw-r--r--zebra/rule_netlink.c29
-rw-r--r--zebra/zapi_msg.c55
-rw-r--r--zebra/zebra_dplane.c48
-rw-r--r--zebra/zebra_evpn.c35
-rw-r--r--zebra/zebra_evpn_mac.c33
-rw-r--r--zebra/zebra_evpn_mh.c49
-rw-r--r--zebra/zebra_evpn_neigh.c34
-rw-r--r--zebra/zebra_fpm.c7
-rw-r--r--zebra/zebra_fpm_dt.c5
-rw-r--r--zebra/zebra_fpm_netlink.c53
-rw-r--r--zebra/zebra_gr.c10
-rw-r--r--zebra/zebra_mpls.c44
-rw-r--r--zebra/zebra_mroute.c4
-rw-r--r--zebra/zebra_nb_config.c12
-rw-r--r--zebra/zebra_nhg.c64
-rw-r--r--zebra/zebra_rib.c49
-rw-r--r--zebra/zebra_rnh.c7
-rw-r--r--zebra/zebra_vrf.c3
-rw-r--r--zebra/zebra_vty.c19
-rw-r--r--zebra/zebra_vxlan.c107
-rw-r--r--zebra/zserv.c8
220 files changed, 3393 insertions, 4007 deletions
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index 98c7c3d54d..8983b39eb3 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -7,37 +7,91 @@ assignees: ''
---
+<!--
+
+*** ATTENTION ***
+
+YOU MUST READ THIS TO HAVE YOUR ISSUE ADDRESSED
+
+PLEASE READ AND FILL OUT THIS TEMPLATE
+
+NEGLECTING TO PROVIDE INFORMATION REQUESTED HERE WILL RESULT IN
+SIGNIFICANT DELAYS ADDRESSING YOUR ISSUE
+
+ALWAYS PROVIDE:
+- FRR VERSION
+- OPERATING SYSTEM VERSION
+- KERNEL VERSION
+
+FAILURE TO PROVIDE THIS MAY RESULT IN YOUR ISSUE BEING IGNORED
+
+FOLLOW THESE GUIDELINES:
+
- When reporting a crash, provide a backtrace
-- When pasting configs, logs, shell output, backtraces, and other large chunks of text use Markdown code blocks
-- Include the FRR version; if you built from Git, please provide the commit hash
+- When pasting configs, logs, shell output, backtraces, and other large chunks
+ of text, surround this text with triple backtics
+
+ ```
+ like this
+ ```
+
+- Include the FRR version; if you built from Git, please provide the commit
+ hash
- Write your issue in English
+-->
+
---------------
**Describe the bug**
+<!--
A clear and concise description of what the bug is.
-(put "x" in "[ ]" if you already tried following)
+Put "x" in "[ ]" if you already tried following:
+-->
+
[ ] Did you check if this is a duplicate issue?
[ ] Did you test it on the latest FRRouting/frr master branch?
**To Reproduce**
-Steps to reproduce the behavior:
+<!--
+Describe the steps to reproduce the behavior.
+Be as descriptive as possible.
+
+For example:
+
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
+-->
**Expected behavior**
-A clear and concise description of what you expected to happen.
+<!--
+Write here a clear and concise description of what you expected to happen when
+using the reproduction steps you provided above
+-->
**Screenshots**
+<!--
If applicable, add screenshots to help explain your problem.
+-->
**Versions**
- - OS Kernel: [e.g. Linux, OpenBSD, etc] [version]
- - FRR Version: [version]
+<!--
+Include your operating system type and version here
+
+FAILURE TO PROVIDE THIS MAY RESULT IN YOUR ISSUE BEING IGNORED
+-->
+<!-- e.g. Fedora 24, Debian 10] -->
+ - OS Version:
+<!-- [e.g. Linux 5.4, OpenBSD 6.6] -->
+ - Kernel:
+<!-- e.g. 6.0, 7.4 -->
+ - FRR Version:
**Additional context**
+<!--
Add any other context about the problem here.
+-->
diff --git a/babeld/babel_filter.c b/babeld/babel_filter.c
index 28ba8e16a2..731ad1ba8b 100644
--- a/babeld/babel_filter.c
+++ b/babeld/babel_filter.c
@@ -59,24 +59,16 @@ babel_filter(int output, const unsigned char *prefix, unsigned short plen,
if (access_list_apply (babel_ifp->list[distribute], &p)
== FILTER_DENY) {
debugf(BABEL_DEBUG_FILTER,
- "%s/%d filtered by distribute %s",
- p.family == AF_INET ?
- inet_ntoa(p.u.prefix4) :
- inet6_ntoa (p.u.prefix6),
- p.prefixlen,
- output ? "out" : "in");
+ "%pFX filtered by distribute %s",
+ &p, output ? "out" : "in");
return INFINITY;
}
}
if (babel_ifp != NULL && babel_ifp->prefix[distribute]) {
if (prefix_list_apply (babel_ifp->prefix[distribute], &p)
== PREFIX_DENY) {
- debugf(BABEL_DEBUG_FILTER, "%s/%d filtered by distribute %s",
- p.family == AF_INET ?
- inet_ntoa(p.u.prefix4) :
- inet6_ntoa (p.u.prefix6),
- p.prefixlen,
- output ? "out" : "in");
+ debugf(BABEL_DEBUG_FILTER, "%pFX filtered by distribute %s",
+ &p, output ? "out" : "in");
return INFINITY;
}
}
@@ -91,12 +83,8 @@ babel_filter(int output, const unsigned char *prefix, unsigned short plen,
if (alist) {
if (access_list_apply (alist, &p) == FILTER_DENY) {
- debugf(BABEL_DEBUG_FILTER,"%s/%d filtered by distribute %s",
- p.family == AF_INET ?
- inet_ntoa(p.u.prefix4) :
- inet6_ntoa (p.u.prefix6),
- p.prefixlen,
- output ? "out" : "in");
+ debugf(BABEL_DEBUG_FILTER,"%pFX filtered by distribute %s",
+ &p, output ? "out" : "in");
return INFINITY;
}
}
@@ -105,12 +93,8 @@ babel_filter(int output, const unsigned char *prefix, unsigned short plen,
plist = prefix_list_lookup (p.family, dist->prefix[distribute]);
if (plist) {
if (prefix_list_apply (plist, &p) == PREFIX_DENY) {
- debugf(BABEL_DEBUG_FILTER,"%s/%d filtered by distribute %s",
- p.family == AF_INET ?
- inet_ntoa(p.u.prefix4) :
- inet6_ntoa (p.u.prefix6),
- p.prefixlen,
- output ? "out" : "in");
+ debugf(BABEL_DEBUG_FILTER,"%pFX filtered by distribute %s",
+ &p, output ? "out" : "in");
return INFINITY;
}
}
diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c
index 1702d9277c..ae8b161b01 100644
--- a/babeld/babel_interface.c
+++ b/babeld/babel_interface.c
@@ -1106,6 +1106,7 @@ DEFUN (show_babel_route_addr,
{
struct in_addr addr;
char buf[INET_ADDRSTRLEN + 8];
+ char buf1[INET_ADDRSTRLEN + 8];
struct route_stream *routes = NULL;
struct xroute_stream *xroutes = NULL;
struct prefix prefix;
@@ -1118,7 +1119,8 @@ DEFUN (show_babel_route_addr,
}
/* Quagga has no convenient prefix constructors. */
- snprintf(buf, sizeof(buf), "%s/%d", inet_ntoa(addr), 32);
+ snprintf(buf, sizeof(buf), "%s/%d",
+ inet_ntop(AF_INET, &addr, buf1, sizeof(buf1)), 32);
ret = str2prefix(buf, &prefix);
if (ret == 0) {
diff --git a/bfdd/ptm_adapter.c b/bfdd/ptm_adapter.c
index 48e55bce37..3a80d9203b 100644
--- a/bfdd/ptm_adapter.c
+++ b/bfdd/ptm_adapter.c
@@ -783,17 +783,16 @@ static void bfdd_sessions_enable_address(struct connected *ifc)
static int bfdd_interface_address_update(ZAPI_CALLBACK_ARGS)
{
struct connected *ifc;
- char buf[64];
ifc = zebra_interface_address_read(cmd, zclient->ibuf, vrf_id);
if (ifc == NULL)
return 0;
if (bglobal.debug_zebra)
- zlog_debug("zclient: %s local address %s",
+ zlog_debug("zclient: %s local address %pFX",
cmd == ZEBRA_INTERFACE_ADDRESS_ADD ? "add"
: "delete",
- prefix2str(ifc->address, buf, sizeof(buf)));
+ ifc->address);
bfdd_sessions_enable_address(ifc);
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index 0821a724a6..429a68d190 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -763,8 +763,7 @@ static void attr_show_all_iterator(struct hash_bucket *bucket, struct vty *vty)
struct attr *attr = bucket->data;
char sid_str[BUFSIZ];
- vty_out(vty, "attr[%ld] nexthop %s\n", attr->refcnt,
- inet_ntoa(attr->nexthop));
+ vty_out(vty, "attr[%ld] nexthop %pI4\n", attr->refcnt, &attr->nexthop);
sid_str[0] = '\0';
if (attr->srv6_l3vpn)
diff --git a/bgpd/bgp_bfd.c b/bgpd/bgp_bfd.c
index 1e1c97c2d9..7e1d64056d 100644
--- a/bgpd/bgp_bfd.c
+++ b/bgpd/bgp_bfd.c
@@ -385,24 +385,21 @@ static int bgp_bfd_dest_update(ZAPI_CALLBACK_ARGS)
if (BGP_DEBUG(zebra, ZEBRA)) {
struct vrf *vrf;
- char buf[2][PREFIX2STR_BUFFER];
vrf = vrf_lookup_by_id(vrf_id);
- prefix2str(&dp, buf[0], sizeof(buf[0]));
- if (ifp) {
+
+ if (ifp)
zlog_debug(
- "Zebra: vrf %s(%u) interface %s bfd destination %s %s %s",
- VRF_LOGNAME(vrf), vrf_id, ifp->name,
- buf[0], bfd_get_status_str(status),
+ "Zebra: vrf %s(%u) interface %s bfd destination %pFX %s %s",
+ VRF_LOGNAME(vrf), vrf_id, ifp->name, &dp,
+ bfd_get_status_str(status),
remote_cbit ? "(cbit on)" : "");
- } else {
- prefix2str(&sp, buf[1], sizeof(buf[1]));
+ else
zlog_debug(
- "Zebra: vrf %s(%u) source %s bfd destination %s %s %s",
- VRF_LOGNAME(vrf), vrf_id, buf[1], buf[0],
+ "Zebra: vrf %s(%u) source %pFX bfd destination %pFX %s %s",
+ VRF_LOGNAME(vrf), vrf_id, &sp, &dp,
bfd_get_status_str(status),
remote_cbit ? "(cbit on)" : "");
- }
}
/* Bring the peer down if BFD is enabled in BGP */
diff --git a/bgpd/bgp_btoa.c b/bgpd/bgp_btoa.c
index cbe18e23cb..13c42d95f4 100644
--- a/bgpd/bgp_btoa.c
+++ b/bgpd/bgp_btoa.c
@@ -108,7 +108,7 @@ static void attr_parse(struct stream *s, uint16_t len)
case BGP_ATTR_NEXT_HOP: {
struct in_addr nexthop;
nexthop.s_addr = stream_get_ipv4(s);
- printf("NEXTHOP: %s\n", inet_ntoa(nexthop));
+ printf("NEXTHOP: %pI4\n", &nexthop);
} break;
default:
stream_getw_from(s, length);
@@ -244,7 +244,7 @@ int main(int argc, char **argv)
while (s->getp < len - 16) {
p.prefix.s_addr = stream_get_ipv4(s);
p.prefixlen = stream_getc(s);
- printf("PREFIX: %s/%d\n", inet_ntoa(p.prefix),
+ printf("PREFIX: %pI4/%d\n", &p.prefix,
p.prefixlen);
status = stream_getc(s);
@@ -252,8 +252,7 @@ int main(int argc, char **argv)
peer.s_addr = stream_get_ipv4(s);
source_as = stream_getw(s);
- printf("FROM: %s AS%d\n", inet_ntoa(peer),
- source_as);
+ printf("FROM: %pI4 AS%d\n", &peer, source_as);
printf("ORIGINATED: %s", ctime(&originated));
attrlen = stream_getw(s);
@@ -278,8 +277,8 @@ int main(int argc, char **argv)
sip.s_addr = stream_get_ipv4(s);
dip.s_addr = stream_get_ipv4(s);
- printf("saddr: %s\n", inet_ntoa(sip));
- printf("daddr: %s\n", inet_ntoa(dip));
+ printf("saddr: %pI4\n", &sip);
+ printf("daddr: %pI4\n", &dip);
printf("\n");
}
diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c
index e9d7c9e8aa..a513bc493d 100644
--- a/bgpd/bgp_debug.c
+++ b/bgpd/bgp_debug.c
@@ -21,6 +21,7 @@
#include <zebra.h>
#include <lib/version.h>
+#include "lib/printfrr.h"
#include "prefix.h"
#include "linklist.h"
#include "stream.h"
@@ -236,7 +237,6 @@ static void bgp_debug_list_print(struct vty *vty, const char *desc,
{
struct bgp_debug_filter *filter;
struct listnode *node, *nnode;
- char buf[PREFIX2STR_BUFFER];
vty_out(vty, "%s", desc);
@@ -248,10 +248,8 @@ static void bgp_debug_list_print(struct vty *vty, const char *desc,
if (filter->p && filter->p->family == AF_EVPN)
bgp_debug_print_evpn_prefix(vty, "", filter->p);
- else if (filter->p) {
- prefix2str(filter->p, buf, sizeof(buf));
- vty_out(vty, " %s", buf);
- }
+ else if (filter->p)
+ vty_out(vty, " %pFX", filter->p);
}
}
@@ -267,7 +265,6 @@ static int bgp_debug_list_conf_print(struct vty *vty, const char *desc,
{
struct bgp_debug_filter *filter;
struct listnode *node, *nnode;
- char buf[PREFIX2STR_BUFFER];
int write = 0;
if (list && !list_isempty(list)) {
@@ -282,8 +279,7 @@ static int bgp_debug_list_conf_print(struct vty *vty, const char *desc,
filter->p);
write++;
} else if (filter->p) {
- prefix2str(filter->p, buf, sizeof(buf));
- vty_out(vty, "%s %s\n", desc, buf);
+ vty_out(vty, "%s %pFX\n", desc, filter->p);
write++;
}
}
@@ -380,7 +376,7 @@ bool bgp_dump_attr(struct attr *attr, char *buf, size_t size)
buf[0] = '\0';
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP)))
- snprintf(buf, size, "nexthop %s", inet_ntoa(attr->nexthop));
+ snprintfrr(buf, size, "nexthop %pI4", &attr->nexthop);
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_ORIGIN)))
snprintf(buf + strlen(buf), size - strlen(buf), ", origin %s",
@@ -400,7 +396,7 @@ bool bgp_dump_attr(struct attr *attr, char *buf, size_t size)
BUFSIZ));
if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV4)
- snprintf(buf, size, "nexthop %s", inet_ntoa(attr->nexthop));
+ snprintfrr(buf, size, "nexthop %pI4", &attr->nexthop);
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)))
snprintf(buf + strlen(buf), size - strlen(buf),
@@ -424,13 +420,13 @@ bool bgp_dump_attr(struct attr *attr, char *buf, size_t size)
", atomic-aggregate");
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR)))
- snprintf(buf + strlen(buf), size - strlen(buf),
- ", aggregated by %u %s", attr->aggregator_as,
- inet_ntoa(attr->aggregator_addr));
+ snprintfrr(buf + strlen(buf), size - strlen(buf),
+ ", aggregated by %u %pI4", attr->aggregator_as,
+ &attr->aggregator_addr);
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))
- snprintf(buf + strlen(buf), size - strlen(buf),
- ", originator %s", inet_ntoa(attr->originator_id));
+ snprintfrr(buf + strlen(buf), size - strlen(buf),
+ ", originator %pI4", &attr->originator_id);
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) {
int i;
@@ -438,8 +434,8 @@ bool bgp_dump_attr(struct attr *attr, char *buf, size_t size)
snprintf(buf + strlen(buf), size - strlen(buf),
", clusterlist");
for (i = 0; i < attr->cluster->length / 4; i++)
- snprintf(buf + strlen(buf), size - strlen(buf), " %s",
- inet_ntoa(attr->cluster->list[i]));
+ snprintfrr(buf + strlen(buf), size - strlen(buf),
+ " %pI4", &attr->cluster->list[i]);
}
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL)))
@@ -592,9 +588,9 @@ static void bgp_debug_print_evpn_prefix(struct vty *vty, const char *desc,
buf, PREFIX2STR_BUFFER));
}
} else if (p->u.prefix_evpn.route_type == BGP_EVPN_IMET_ROUTE) {
- snprintf(evpn_desc, sizeof(evpn_desc),
- "l2vpn evpn type multicast ip %s",
- inet_ntoa(p->u.prefix_evpn.imet_addr.ip.ipaddr_v4));
+ snprintfrr(evpn_desc, sizeof(evpn_desc),
+ "l2vpn evpn type multicast ip %pI4",
+ &p->u.prefix_evpn.imet_addr.ip.ipaddr_v4);
} else if (p->u.prefix_evpn.route_type == BGP_EVPN_IP_PREFIX_ROUTE) {
uint8_t family = is_evpn_prefix_ipaddr_v4(
(struct prefix_evpn *)p) ? AF_INET
@@ -616,21 +612,14 @@ static int bgp_debug_parse_evpn_prefix(struct vty *vty, struct cmd_token **argv,
struct prefix *argv_p;
struct ethaddr mac;
struct ipaddr ip;
- int evpn_type;
- int type_idx = 0;
+ int evpn_type = 0;
int mac_idx = 0;
int ip_idx = 0;
argv_p = *argv_pp;
- if (argv_find(argv, argc, "macip", &type_idx))
- evpn_type = BGP_EVPN_MAC_IP_ROUTE;
- else if (argv_find(argv, argc, "multicast", &type_idx))
- evpn_type = BGP_EVPN_IMET_ROUTE;
- else if (argv_find(argv, argc, "prefix", &type_idx))
- evpn_type = BGP_EVPN_IP_PREFIX_ROUTE;
- else
- evpn_type = 0;
+ if (bgp_evpn_cli_parse_type(&evpn_type, argv, argc) < 0)
+ return CMD_WARNING;
if (evpn_type == BGP_EVPN_MAC_IP_ROUTE) {
memset(&ip, 0, sizeof(struct ipaddr));
@@ -1395,31 +1384,33 @@ DEFUN (no_debug_bgp_update_direct_peer,
DEFPY (debug_bgp_update_prefix_afi_safi,
debug_bgp_update_prefix_afi_safi_cmd,
- "debug bgp updates prefix l2vpn$afi evpn$safi type <macip mac <X:X:X:X:X:X|X:X:X:X:X:X/M> [ip <A.B.C.D|X:X::X:X>]|multicast ip <A.B.C.D|X:X::X:X>|prefix ip <A.B.C.D/M|X:X::X:X/M>>",
+ "debug bgp updates prefix l2vpn$afi evpn$safi type <<macip|2> mac <X:X:X:X:X:X|X:X:X:X:X:X/M> [ip <A.B.C.D|X:X::X:X>]|<multicast|3> ip <A.B.C.D|X:X::X:X>|<prefix|5> ip <A.B.C.D/M|X:X::X:X/M>>",
DEBUG_STR
BGP_STR
"BGP updates\n"
"Specify a prefix to debug\n"
L2VPN_HELP_STR
EVPN_HELP_STR
- "Specify EVPN Route type\n"
- "MAC-IP (Type-2) route\n"
+ EVPN_TYPE_HELP_STR
+ EVPN_TYPE_2_HELP_STR
+ EVPN_TYPE_2_HELP_STR
MAC_STR MAC_STR MAC_STR
IP_STR
"IPv4 address\n"
"IPv6 address\n"
- "Multicast (Type-3) route\n"
+ EVPN_TYPE_3_HELP_STR
+ EVPN_TYPE_3_HELP_STR
IP_STR
"IPv4 address\n"
"IPv6 address\n"
- "Prefix (Type-5) route\n"
+ EVPN_TYPE_5_HELP_STR
+ EVPN_TYPE_5_HELP_STR
IP_STR
"IPv4 prefix\n"
"IPv6 prefix\n")
{
struct prefix *argv_p;
int ret = CMD_SUCCESS;
- char buf[PREFIX2STR_BUFFER];
argv_p = prefix_new();
@@ -1432,12 +1423,10 @@ DEFPY (debug_bgp_update_prefix_afi_safi,
if (!bgp_debug_update_prefixes)
bgp_debug_update_prefixes = list_new();
- prefix2str(argv_p, buf, sizeof(buf));
-
if (bgp_debug_list_has_entry(bgp_debug_update_prefixes, NULL, argv_p)) {
vty_out(vty,
- "BGP updates debugging is already enabled for %s\n",
- buf);
+ "BGP updates debugging is already enabled for %pFX\n",
+ argv_p);
prefix_free(&argv_p);
return CMD_SUCCESS;
}
@@ -1448,7 +1437,7 @@ DEFPY (debug_bgp_update_prefix_afi_safi,
DEBUG_ON(update, UPDATE_PREFIX);
} else {
TERM_DEBUG_ON(update, UPDATE_PREFIX);
- vty_out(vty, "BGP updates debugging is on for %s\n", buf);
+ vty_out(vty, "BGP updates debugging is on for %pFX\n", argv_p);
}
prefix_free(&argv_p);
@@ -1458,7 +1447,7 @@ DEFPY (debug_bgp_update_prefix_afi_safi,
DEFPY (no_debug_bgp_update_prefix_afi_safi,
no_debug_bgp_update_prefix_afi_safi_cmd,
- "no debug bgp updates prefix l2vpn$afi evpn$safi type <macip mac <X:X:X:X:X:X|X:X:X:X:X:X/M> [ip <A.B.C.D|X:X::X:X>]|multicast ip <A.B.C.D|X:X::X:X>|prefix ip <A.B.C.D/M|X:X::X:X/M>>",
+ "no debug bgp updates prefix l2vpn$afi evpn$safi type <<macip|2> mac <X:X:X:X:X:X|X:X:X:X:X:X/M> [ip <A.B.C.D|X:X::X:X>]|<multicast|3> ip <A.B.C.D|X:X::X:X>|<prefix|5> ip <A.B.C.D/M|X:X::X:X/M>>",
NO_STR
DEBUG_STR
BGP_STR
@@ -1466,17 +1455,20 @@ DEFPY (no_debug_bgp_update_prefix_afi_safi,
"Specify a prefix to debug\n"
L2VPN_HELP_STR
EVPN_HELP_STR
- "Specify EVPN Route type\n"
- "MAC-IP (Type-2) route\n"
+ EVPN_TYPE_HELP_STR
+ EVPN_TYPE_2_HELP_STR
+ EVPN_TYPE_2_HELP_STR
MAC_STR MAC_STR MAC_STR
IP_STR
"IPv4 address\n"
"IPv6 address\n"
- "Multicast (Type-3) route\n"
+ EVPN_TYPE_3_HELP_STR
+ EVPN_TYPE_3_HELP_STR
IP_STR
"IPv4 address\n"
"IPv6 address\n"
- "Prefix (Type-5) route\n"
+ EVPN_TYPE_5_HELP_STR
+ EVPN_TYPE_5_HELP_STR
IP_STR
"IPv4 prefix\n"
"IPv6 prefix\n")
@@ -1484,7 +1476,6 @@ DEFPY (no_debug_bgp_update_prefix_afi_safi,
struct prefix *argv_p;
bool found_prefix = false;
int ret = CMD_SUCCESS;
- char buf[PREFIX2STR_BUFFER];
argv_p = prefix_new();
@@ -1510,13 +1501,11 @@ DEFPY (no_debug_bgp_update_prefix_afi_safi,
}
}
- prefix2str(argv_p, buf, sizeof(buf));
-
if (found_prefix)
- vty_out(vty, "BGP updates debugging is off for %s\n", buf);
+ vty_out(vty, "BGP updates debugging is off for %pFX\n", argv_p);
else
- vty_out(vty, "BGP updates debugging was not enabled for %s\n",
- buf);
+ vty_out(vty, "BGP updates debugging was not enabled for %pFX\n",
+ argv_p);
prefix_free(&argv_p);
@@ -2643,7 +2632,6 @@ const char *bgp_debug_rdpfxpath2str(afi_t afi, safi_t safi,
char *str, int size)
{
char rd_buf[RD_ADDRSTRLEN];
- char pfx_buf[PREFIX_STRLEN];
char tag_buf[30];
/* ' with addpath ID ' 17
* max strlen of uint32 + 10
@@ -2681,10 +2669,9 @@ const char *bgp_debug_rdpfxpath2str(afi_t afi, safi_t safi,
}
if (prd)
- snprintf(str, size, "RD %s %s%s%s %s %s",
- prefix_rd2str(prd, rd_buf, sizeof(rd_buf)),
- prefix2str(pu, pfx_buf, sizeof(pfx_buf)), tag_buf,
- pathid_buf, afi2str(afi), safi2str(safi));
+ snprintfrr(str, size, "RD %s %pFX%s%s %s %s",
+ prefix_rd2str(prd, rd_buf, sizeof(rd_buf)), pu.p,
+ tag_buf, pathid_buf, afi2str(afi), safi2str(safi));
else if (safi == SAFI_FLOWSPEC) {
char return_string[BGP_FLOWSPEC_NLRI_STRING_MAX];
const struct prefix_fs *fs = pu.fs;
@@ -2697,9 +2684,8 @@ const char *bgp_debug_rdpfxpath2str(afi_t afi, safi_t safi,
snprintf(str, size, "FS %s Match{%s}", afi2str(afi),
return_string);
} else
- snprintf(str, size, "%s%s%s %s %s",
- prefix2str(pu, pfx_buf, sizeof(pfx_buf)), tag_buf,
- pathid_buf, afi2str(afi), safi2str(safi));
+ snprintfrr(str, size, "%pFX%s%s %s %s", pu.p, tag_buf,
+ pathid_buf, afi2str(afi), safi2str(safi));
return str;
}
diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c
index 3a0400a4b3..353b003c3b 100644
--- a/bgpd/bgp_ecommunity.c
+++ b/bgpd/bgp_ecommunity.c
@@ -29,6 +29,8 @@
#include "jhash.h"
#include "stream.h"
+#include "lib/printfrr.h"
+
#include "bgpd/bgpd.h"
#include "bgpd/bgp_ecommunity.h"
#include "bgpd/bgp_lcommunity.h"
@@ -819,8 +821,8 @@ static int ecommunity_rt_soo_str_internal(char *buf, size_t bufsz,
eip.val = (*pnt++ << 8);
eip.val |= (*pnt++);
- len = snprintf(buf, bufsz, "%s%s:%u", prefix, inet_ntoa(eip.ip),
- eip.val);
+ len = snprintfrr(buf, bufsz, "%s%pI4:%u", prefix, &eip.ip,
+ eip.val);
}
/* consume value */
diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c
index 7f9ef0c9cd..67d0a95cb6 100644
--- a/bgpd/bgp_evpn.c
+++ b/bgpd/bgp_evpn.c
@@ -31,6 +31,8 @@
#include "jhash.h"
#include "zclient.h"
+#include "lib/printfrr.h"
+
#include "bgpd/bgp_attr_evpn.h"
#include "bgpd/bgpd.h"
#include "bgpd/bgp_table.h"
@@ -702,9 +704,9 @@ static int bgp_zebra_send_remote_vtep(struct bgp *bgp, struct bgpevpn *vpn,
stream_putw_at(s, 0, stream_get_endp(s));
if (bgp_debug_zebra(NULL))
- zlog_debug("Tx %s Remote VTEP, VNI %u remote VTEP %s",
+ zlog_debug("Tx %s Remote VTEP, VNI %u remote VTEP %pI4",
add ? "ADD" : "DEL", vpn->vni,
- inet_ntoa(p->prefix.imet_addr.ip.ipaddr_v4));
+ &p->prefix.imet_addr.ip.ipaddr_v4);
return zclient_send_message(zclient);
}
@@ -1032,19 +1034,17 @@ static void evpn_delete_old_local_route(struct bgp *bgp, struct bgpevpn *vpn,
safi_t safi = SAFI_EVPN;
if (BGP_DEBUG(evpn_mh, EVPN_MH_RT)) {
- char prefix_buf[PREFIX_STRLEN];
char esi_buf[ESI_STR_LEN];
char esi_buf2[ESI_STR_LEN];
struct prefix_evpn *evp =
(struct prefix_evpn *)bgp_dest_get_prefix(dest);
- zlog_debug("local path deleted %s es %s; new-path-es %s",
- prefix2str(evp,
- prefix_buf, sizeof(prefix_buf)),
- esi_to_str(&old_local->attr->esi,
- esi_buf, sizeof(esi_buf)),
- new_select ? esi_to_str(&new_select->attr->esi,
- esi_buf2, sizeof(esi_buf2)) : "");
+ zlog_debug("local path deleted %pFX es %s; new-path-es %s", evp,
+ esi_to_str(&old_local->attr->esi, esi_buf,
+ sizeof(esi_buf)),
+ new_select ? esi_to_str(&new_select->attr->esi,
+ esi_buf2, sizeof(esi_buf2))
+ : "");
}
/* Locate route node in the global EVPN routing table. Note that
@@ -1311,23 +1311,18 @@ static int update_evpn_type5_route(struct bgp *bgp_vrf, struct prefix_evpn *evp,
attr.nexthop = bgp_vrf->evpn_info->pip_ip;
attr.mp_nexthop_global_in = bgp_vrf->evpn_info->pip_ip;
} else if (bgp_vrf->evpn_info->pip_ip.s_addr == INADDR_ANY)
- if (bgp_debug_zebra(NULL)) {
- char buf1[PREFIX_STRLEN];
-
- zlog_debug("VRF %s evp %s advertise-pip primary ip is not configured",
- vrf_id_to_name(bgp_vrf->vrf_id),
- prefix2str(evp, buf1, sizeof(buf1)));
- }
+ if (bgp_debug_zebra(NULL))
+ zlog_debug(
+ "VRF %s evp %pFX advertise-pip primary ip is not configured",
+ vrf_id_to_name(bgp_vrf->vrf_id), evp);
}
if (bgp_debug_zebra(NULL)) {
char buf[ETHER_ADDR_STRLEN];
- char buf1[PREFIX_STRLEN];
char buf2[INET6_ADDRSTRLEN];
- zlog_debug("VRF %s type-5 route evp %s RMAC %s nexthop %s",
- vrf_id_to_name(bgp_vrf->vrf_id),
- prefix2str(evp, buf1, sizeof(buf1)),
+ zlog_debug("VRF %s type-5 route evp %pFX RMAC %s nexthop %s",
+ vrf_id_to_name(bgp_vrf->vrf_id), evp,
prefix_mac2str(&attr.rmac, buf, sizeof(buf)),
inet_ntop(AF_INET, &attr.nexthop, buf2,
INET_ADDRSTRLEN));
@@ -1459,21 +1454,23 @@ static void update_evpn_route_entry_sync_info(struct bgp *bgp,
attr->es_flags &= ~ATTR_ES_PEER_ROUTER;
if (BGP_DEBUG(evpn_mh, EVPN_MH_RT)) {
- char prefix_buf[PREFIX_STRLEN];
char esi_buf[ESI_STR_LEN];
- zlog_debug("setup sync info for %s es %s max_seq %d %s%s%s",
- prefix2str(evp, prefix_buf,
- sizeof(prefix_buf)),
+ zlog_debug(
+ "setup sync info for %pFX es %s max_seq %d %s%s%s",
+ evp,
esi_to_str(esi, esi_buf,
- sizeof(esi_buf)),
+ sizeof(esi_buf)),
max_sync_seq,
- (attr->es_flags & ATTR_ES_PEER_ACTIVE) ?
- "peer-active " : "",
- (attr->es_flags & ATTR_ES_PEER_PROXY) ?
- "peer-proxy " : "",
- (attr->es_flags & ATTR_ES_PEER_ROUTER) ?
- "peer-router " : "");
+ (attr->es_flags & ATTR_ES_PEER_ACTIVE)
+ ? "peer-active "
+ : "",
+ (attr->es_flags & ATTR_ES_PEER_PROXY)
+ ? "peer-proxy "
+ : "",
+ (attr->es_flags & ATTR_ES_PEER_ROUTER)
+ ? "peer-router "
+ : "");
}
}
} else {
@@ -1719,18 +1716,16 @@ static int update_evpn_route(struct bgp *bgp, struct bgpevpn *vpn,
if (bgp_debug_zebra(NULL)) {
char buf[ETHER_ADDR_STRLEN];
- char buf1[PREFIX_STRLEN];
char buf3[ESI_STR_LEN];
- zlog_debug("VRF %s vni %u type-2 route evp %s RMAC %s nexthop %s esi %s",
- vpn->bgp_vrf ?
- vrf_id_to_name(vpn->bgp_vrf->vrf_id) : " ",
- vpn->vni,
- prefix2str(p, buf1, sizeof(buf1)),
- prefix_mac2str(&attr.rmac, buf,
- sizeof(buf)),
- inet_ntoa(attr.mp_nexthop_global_in),
- esi_to_str(esi, buf3, sizeof(buf3)));
+ zlog_debug(
+ "VRF %s vni %u type-2 route evp %pFX RMAC %s nexthop %pI4 esi %s",
+ vpn->bgp_vrf ? vrf_id_to_name(vpn->bgp_vrf->vrf_id)
+ : " ",
+ vpn->vni, p,
+ prefix_mac2str(&attr.rmac, buf, sizeof(buf)),
+ &attr.mp_nexthop_global_in,
+ esi_to_str(esi, buf3, sizeof(buf3)));
}
/* router mac is only needed for type-2 routes here. */
if (p->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE) {
@@ -2000,18 +1995,17 @@ static void bgp_evpn_update_type2_route_entry(struct bgp *bgp,
if (bgp_debug_zebra(NULL)) {
char buf[ETHER_ADDR_STRLEN];
- char buf1[PREFIX_STRLEN];
char buf3[ESI_STR_LEN];
- zlog_debug("VRF %s vni %u evp %s RMAC %s nexthop %s esi %s esf 0x%x from %s",
- vpn->bgp_vrf ?
- vrf_id_to_name(vpn->bgp_vrf->vrf_id) : " ",
- vpn->vni,
- prefix2str(evp, buf1, sizeof(buf1)),
- prefix_mac2str(&attr.rmac, buf, sizeof(buf)),
- inet_ntoa(attr.mp_nexthop_global_in),
- esi_to_str(&attr.esi, buf3, sizeof(buf3)),
- attr.es_flags, caller);
+ zlog_debug(
+ "VRF %s vni %u evp %pFX RMAC %s nexthop %pI4 esi %s esf 0x%x from %s",
+ vpn->bgp_vrf ? vrf_id_to_name(vpn->bgp_vrf->vrf_id)
+ : " ",
+ vpn->vni, evp,
+ prefix_mac2str(&attr.rmac, buf, sizeof(buf)),
+ &attr.mp_nexthop_global_in,
+ esi_to_str(&attr.esi, buf3, sizeof(buf3)),
+ attr.es_flags, caller);
}
/* Update the route entry. */
@@ -2390,19 +2384,16 @@ static int install_evpn_route_entry_in_vrf(struct bgp *bgp_vrf,
struct prefix *pp = &p;
afi_t afi = 0;
safi_t safi = 0;
- char buf[PREFIX_STRLEN];
bool new_pi = false;
memset(pp, 0, sizeof(struct prefix));
ip_prefix_from_evpn_prefix(evp, pp);
- if (bgp_debug_zebra(NULL)) {
+ if (bgp_debug_zebra(NULL))
zlog_debug(
- "vrf %s: import evpn prefix %s parent %p flags 0x%x",
- vrf_id_to_name(bgp_vrf->vrf_id),
- prefix2str(evp, buf, sizeof(buf)),
- parent_pi, parent_pi->flags);
- }
+ "vrf %s: import evpn prefix %pFX parent %p flags 0x%x",
+ vrf_id_to_name(bgp_vrf->vrf_id), evp, parent_pi,
+ parent_pi->flags);
/* Create (or fetch) route within the VRF. */
/* NOTE: There is no RD here. */
@@ -2481,11 +2472,10 @@ static int install_evpn_route_entry_in_vrf(struct bgp *bgp_vrf,
bgp_dest_unlock_node(dest);
if (bgp_debug_zebra(NULL))
- zlog_debug(
- "... %s pi dest %p (l %d) pi %p (l %d, f 0x%x)",
- new_pi ? "new" : "update",
- dest, bgp_dest_to_rnode(dest)->lock,
- pi, pi->lock, pi->flags);
+ zlog_debug("... %s pi dest %p (l %d) pi %p (l %d, f 0x%x)",
+ new_pi ? "new" : "update", dest,
+ bgp_dest_get_lock_count(dest), pi, pi->lock,
+ pi->flags);
return ret;
}
@@ -2582,18 +2572,15 @@ static int uninstall_evpn_route_entry_in_vrf(struct bgp *bgp_vrf,
struct prefix *pp = &p;
afi_t afi = 0;
safi_t safi = 0;
- char buf[PREFIX_STRLEN];
memset(pp, 0, sizeof(struct prefix));
ip_prefix_from_evpn_prefix(evp, pp);
- if (bgp_debug_zebra(NULL)) {
+ if (bgp_debug_zebra(NULL))
zlog_debug(
- "vrf %s: unimport evpn prefix %s parent %p flags 0x%x",
- vrf_id_to_name(bgp_vrf->vrf_id),
- prefix2str(evp, buf, sizeof(buf)),
- parent_pi, parent_pi->flags);
- }
+ "vrf %s: unimport evpn prefix %pFX parent %p flags 0x%x",
+ vrf_id_to_name(bgp_vrf->vrf_id), evp, parent_pi,
+ parent_pi->flags);
/* Locate route within the VRF. */
/* NOTE: There is no RD here. */
@@ -2620,10 +2607,9 @@ static int uninstall_evpn_route_entry_in_vrf(struct bgp *bgp_vrf,
return 0;
if (bgp_debug_zebra(NULL))
- zlog_debug(
- "... delete dest %p (l %d) pi %p (l %d, f 0x%x)",
- dest, bgp_dest_to_rnode(dest)->lock,
- pi, pi->lock, pi->flags);
+ zlog_debug("... delete dest %p (l %d) pi %p (l %d, f 0x%x)",
+ dest, bgp_dest_get_lock_count(dest), pi, pi->lock,
+ pi->flags);
/* Process for route leaking. */
vpn_leak_from_vrf_withdraw(bgp_get_default(), bgp_vrf, pi);
@@ -2851,15 +2837,13 @@ static int bgp_evpn_route_rmac_self_check(struct bgp *bgp_vrf,
*/
if (memcmp(&bgp_vrf->rmac, &pi->attr->rmac, ETH_ALEN) == 0) {
if (bgp_debug_update(pi->peer, NULL, NULL, 1)) {
- char buf1[PREFIX_STRLEN];
char attr_str[BUFSIZ] = {0};
bgp_dump_attr(pi->attr, attr_str, sizeof(attr_str));
- zlog_debug("%s: bgp %u prefix %s with attr %s - DENIED due to self mac",
- __func__, bgp_vrf->vrf_id,
- prefix2str(evp, buf1, sizeof(buf1)),
- attr_str);
+ zlog_debug(
+ "%s: bgp %u prefix %pFX with attr %s - DENIED due to self mac",
+ __func__, bgp_vrf->vrf_id, evp, attr_str);
}
return 1;
@@ -2880,7 +2864,6 @@ static int install_uninstall_routes_for_vrf(struct bgp *bgp_vrf, int install)
struct bgp_table *table;
struct bgp_path_info *pi;
int ret;
- char buf[PREFIX_STRLEN];
struct bgp *bgp_evpn = NULL;
afi = AFI_L2VPN;
@@ -2941,11 +2924,10 @@ static int install_uninstall_routes_for_vrf(struct bgp *bgp_vrf, int install)
if (ret) {
flog_err(
EC_BGP_EVPN_FAIL,
- "Failed to %s EVPN %s route in VRF %s",
+ "Failed to %s EVPN %pFX route in VRF %s",
install ? "install"
: "uninstall",
- prefix2str(evp, buf,
- sizeof(buf)),
+ evp,
vrf_id_to_name(
bgp_vrf->vrf_id));
return ret;
@@ -3114,7 +3096,6 @@ static int install_uninstall_route_in_vrfs(struct bgp *bgp_def, afi_t afi,
struct bgp_path_info *pi,
struct list *vrfs, int install)
{
- char buf[PREFIX2STR_BUFFER];
struct bgp *bgp_vrf;
struct listnode *node, *nnode;
@@ -3140,10 +3121,9 @@ static int install_uninstall_route_in_vrfs(struct bgp *bgp_def, afi_t afi,
if (ret) {
flog_err(EC_BGP_EVPN_FAIL,
- "%u: Failed to %s prefix %s in VRF %s",
+ "%u: Failed to %s prefix %pFX in VRF %s",
bgp_def->vrf_id,
- install ? "install" : "uninstall",
- prefix2str(evp, buf, sizeof(buf)),
+ install ? "install" : "uninstall", evp,
vrf_id_to_name(bgp_vrf->vrf_id));
return ret;
}
@@ -4101,17 +4081,14 @@ void bgp_evpn_withdraw_type5_route(struct bgp *bgp_vrf, const struct prefix *p,
{
int ret = 0;
struct prefix_evpn evp;
- char buf[PREFIX_STRLEN];
build_type5_prefix_from_ip_prefix(&evp, p);
ret = delete_evpn_type5_route(bgp_vrf, &evp);
- if (ret) {
+ if (ret)
flog_err(
EC_BGP_EVPN_ROUTE_DELETE,
- "%u failed to delete type-5 route for prefix %s in vrf %s",
- bgp_vrf->vrf_id, prefix2str(p, buf, sizeof(buf)),
- vrf_id_to_name(bgp_vrf->vrf_id));
- }
+ "%u failed to delete type-5 route for prefix %pFX in vrf %s",
+ bgp_vrf->vrf_id, p, vrf_id_to_name(bgp_vrf->vrf_id));
}
/* withdraw all type-5 routes for an address family */
@@ -4173,14 +4150,13 @@ void bgp_evpn_advertise_type5_route(struct bgp *bgp_vrf, const struct prefix *p,
{
int ret = 0;
struct prefix_evpn evp;
- char buf[PREFIX_STRLEN];
build_type5_prefix_from_ip_prefix(&evp, p);
ret = update_evpn_type5_route(bgp_vrf, &evp, src_attr);
if (ret)
flog_err(EC_BGP_EVPN_ROUTE_CREATE,
- "%u: Failed to create type-5 route for prefix %s",
- bgp_vrf->vrf_id, prefix2str(p, buf, sizeof(buf)));
+ "%u: Failed to create type-5 route for prefix %pFX",
+ bgp_vrf->vrf_id, p);
}
/* Inject all prefixes of a particular address-family (currently, IPv4 or
@@ -4967,8 +4943,7 @@ void bgp_evpn_derive_auto_rd(struct bgp *bgp, struct bgpevpn *vpn)
vpn->prd.family = AF_UNSPEC;
vpn->prd.prefixlen = 64;
- snprintf(buf, sizeof(buf), "%s:%hu", inet_ntoa(bgp->router_id),
- vpn->rd_id);
+ snprintfrr(buf, sizeof(buf), "%pI4:%hu", &bgp->router_id, vpn->rd_id);
(void)str2prefix_rd(buf, &vpn->prd);
UNSET_FLAG(vpn->flags, VNI_FLAG_RD_CFGD);
}
diff --git a/bgpd/bgp_evpn_mh.c b/bgpd/bgp_evpn_mh.c
index 6fb5a44208..1a58541a71 100644
--- a/bgpd/bgp_evpn_mh.c
+++ b/bgpd/bgp_evpn_mh.c
@@ -29,6 +29,8 @@
#include "jhash.h"
#include "zclient.h"
+#include "lib/printfrr.h"
+
#include "bgpd/bgp_attr_evpn.h"
#include "bgpd/bgpd.h"
#include "bgpd/bgp_table.h"
@@ -362,10 +364,9 @@ static int bgp_evpn_mh_route_update(struct bgp *bgp, struct bgp_evpn_es *es,
*/
if (remote_pi) {
flog_err(
- EC_BGP_ES_INVALID,
- "%u ERROR: local es route for ESI: %s Vtep %s also learnt from remote",
- bgp->vrf_id, es->esi_str,
- inet_ntoa(es->originator_ip));
+ EC_BGP_ES_INVALID,
+ "%u ERROR: local es route for ESI: %s Vtep %pI4 also learnt from remote",
+ bgp->vrf_id, es->esi_str, &es->originator_ip);
return -1;
}
@@ -420,13 +421,13 @@ static int bgp_evpn_mh_route_update(struct bgp *bgp, struct bgp_evpn_es *es,
if (*route_changed) {
if (BGP_DEBUG(evpn_mh, EVPN_MH_RT))
- zlog_debug("local ES %s vni %u route-type %s nexthop %s updated",
- es->esi_str,
- vpn ? vpn->vni : 0,
- evp->prefix.route_type ==
- BGP_EVPN_ES_ROUTE ? "esr" :
- (vpn ? "ead-evi" : "ead-es"),
- inet_ntoa(attr->mp_nexthop_global_in));
+ zlog_debug(
+ "local ES %s vni %u route-type %s nexthop %pI4 updated",
+ es->esi_str, vpn ? vpn->vni : 0,
+ evp->prefix.route_type == BGP_EVPN_ES_ROUTE
+ ? "esr"
+ : (vpn ? "ead-evi" : "ead-es"),
+ &attr->mp_nexthop_global_in);
}
/* Return back the route entry. */
@@ -467,12 +468,13 @@ static int bgp_evpn_mh_route_delete(struct bgp *bgp, struct bgp_evpn_es *es,
return 0;
if (BGP_DEBUG(evpn_mh, EVPN_MH_RT))
- zlog_debug("local ES %s vni %u route-type %s nexthop %s delete",
- es->esi_str,
- vpn ? vpn->vni : 0,
- p->prefix.route_type == BGP_EVPN_ES_ROUTE ?
- "esr" : (vpn ? "ead-evi" : "ead-es"),
- inet_ntoa(es->originator_ip));
+ zlog_debug(
+ "local ES %s vni %u route-type %s nexthop %pI4 delete",
+ es->esi_str, vpn ? vpn->vni : 0,
+ p->prefix.route_type == BGP_EVPN_ES_ROUTE
+ ? "esr"
+ : (vpn ? "ead-evi" : "ead-es"),
+ &es->originator_ip);
/* Next, locate route node in the global EVPN routing table.
* Note that this table is a 2-level tree (RD-level + Prefix-level)
@@ -575,10 +577,10 @@ static int bgp_evpn_type4_route_update(struct bgp *bgp,
ret = bgp_evpn_mh_route_update(bgp, es, NULL, afi, safi, dest, &attr, 1,
&pi, &route_changed);
if (ret != 0) {
- flog_err(EC_BGP_ES_INVALID,
- "%u ERROR: Failed to updated ES route ESI: %s VTEP %s",
- bgp->vrf_id, es->esi_str,
- inet_ntoa(es->originator_ip));
+ flog_err(
+ EC_BGP_ES_INVALID,
+ "%u ERROR: Failed to updated ES route ESI: %s VTEP %pI4",
+ bgp->vrf_id, es->esi_str, &es->originator_ip);
}
assert(pi);
@@ -697,7 +699,6 @@ static int bgp_evpn_type4_remote_routes_import(struct bgp *bgp,
int ret;
afi_t afi;
safi_t safi;
- char buf[PREFIX_STRLEN];
struct bgp_dest *rd_dest, *dest;
struct bgp_table *table;
struct bgp_path_info *pi;
@@ -742,13 +743,11 @@ static int bgp_evpn_type4_remote_routes_import(struct bgp *bgp,
if (ret) {
flog_err(
- EC_BGP_EVPN_FAIL,
- "Failed to %s EVPN %s route in ESI %s",
- install ? "install"
+ EC_BGP_EVPN_FAIL,
+ "Failed to %s EVPN %pFX route in ESI %s",
+ install ? "install"
: "uninstall",
- prefix2str(evp, buf,
- sizeof(buf)),
- es->esi_str);
+ evp, es->esi_str);
return ret;
}
}
@@ -878,10 +877,11 @@ static int bgp_evpn_type1_route_update(struct bgp *bgp,
ret = bgp_evpn_mh_route_update(bgp, es, vpn, afi, safi, dest,
&attr, 1, &pi, &route_changed);
if (ret != 0) {
- flog_err(EC_BGP_ES_INVALID,
- "%u Failed to update EAD-EVI route ESI: %s VNI %u VTEP %s",
- bgp->vrf_id, es->esi_str, vpn->vni,
- inet_ntoa(es->originator_ip));
+ flog_err(
+ EC_BGP_ES_INVALID,
+ "%u Failed to update EAD-EVI route ESI: %s VNI %u VTEP %pI4",
+ bgp->vrf_id, es->esi_str, vpn->vni,
+ &es->originator_ip);
}
global_rd = &vpn->prd;
} else {
@@ -900,10 +900,10 @@ static int bgp_evpn_type1_route_update(struct bgp *bgp,
ret = bgp_evpn_mh_route_update(bgp, es, vpn, afi, safi, dest,
&attr, 1, &pi, &route_changed);
if (ret != 0) {
- flog_err(EC_BGP_ES_INVALID,
- "%u ERROR: Failed to updated EAD-EVI route ESI: %s VTEP %s",
- bgp->vrf_id, es->esi_str,
- inet_ntoa(es->originator_ip));
+ flog_err(
+ EC_BGP_ES_INVALID,
+ "%u ERROR: Failed to updated EAD-EVI route ESI: %s VTEP %pI4",
+ bgp->vrf_id, es->esi_str, &es->originator_ip);
}
global_rd = &es->prd;
}
@@ -1167,9 +1167,8 @@ static int bgp_zebra_send_remote_es_vtep(struct bgp *bgp,
stream_putw_at(s, 0, stream_get_endp(s));
if (BGP_DEBUG(evpn_mh, EVPN_MH_ES))
- zlog_debug("Tx %s Remote ESI %s VTEP %s",
- add ? "ADD" : "DEL", es->esi_str,
- inet_ntoa(es_vtep->vtep_ip));
+ zlog_debug("Tx %s Remote ESI %s VTEP %pI4", add ? "ADD" : "DEL",
+ es->esi_str, &es_vtep->vtep_ip);
return zclient_send_message(zclient);
}
@@ -1195,10 +1194,9 @@ static void bgp_evpn_es_vtep_re_eval_active(struct bgp *bgp,
return;
if (BGP_DEBUG(evpn_mh, EVPN_MH_ES))
- zlog_debug("es %s vtep %s %s",
- es_vtep->es->esi_str,
- inet_ntoa(es_vtep->vtep_ip),
- new_active ? "active" : "inactive");
+ zlog_debug("es %s vtep %pI4 %s", es_vtep->es->esi_str,
+ &es_vtep->vtep_ip,
+ new_active ? "active" : "inactive");
/* send remote ES to zebra */
bgp_zebra_send_remote_es_vtep(bgp, es_vtep, new_active);
@@ -1218,10 +1216,8 @@ static struct bgp_evpn_es_vtep *bgp_evpn_es_vtep_add(struct bgp *bgp,
es_vtep = bgp_evpn_es_vtep_new(es, vtep_ip);
if (BGP_DEBUG(evpn_mh, EVPN_MH_ES))
- zlog_debug("es %s vtep %s add %s",
- es_vtep->es->esi_str,
- inet_ntoa(es_vtep->vtep_ip),
- esr ? "esr" : "ead");
+ zlog_debug("es %s vtep %pI4 add %s", es_vtep->es->esi_str,
+ &es_vtep->vtep_ip, esr ? "esr" : "ead");
if (esr)
SET_FLAG(es_vtep->flags, BGP_EVPNES_VTEP_ESR);
@@ -1237,10 +1233,8 @@ static void bgp_evpn_es_vtep_do_del(struct bgp *bgp,
struct bgp_evpn_es_vtep *es_vtep, bool esr)
{
if (BGP_DEBUG(evpn_mh, EVPN_MH_ES))
- zlog_debug("es %s vtep %s del %s",
- es_vtep->es->esi_str,
- inet_ntoa(es_vtep->vtep_ip),
- esr ? "esr" : "ead");
+ zlog_debug("es %s vtep %pI4 del %s", es_vtep->es->esi_str,
+ &es_vtep->vtep_ip, esr ? "esr" : "ead");
if (esr) {
UNSET_FLAG(es_vtep->flags, BGP_EVPNES_VTEP_ESR);
} else {
@@ -1319,11 +1313,14 @@ static struct bgp_evpn_es *bgp_evpn_es_new(struct bgp *bgp, const esi_t *esi)
* This just frees appropriate memory, caller should have taken other
* needed actions.
*/
-static void bgp_evpn_es_free(struct bgp_evpn_es *es)
+static void bgp_evpn_es_free(struct bgp_evpn_es *es, const char *caller)
{
if (es->flags & (BGP_EVPNES_LOCAL | BGP_EVPNES_REMOTE))
return;
+ if (BGP_DEBUG(evpn_mh, EVPN_MH_ES))
+ zlog_debug("%s: es %s free", caller, es->esi_str);
+
/* cleanup resources maintained against the ES */
list_delete(&es->es_evi_list);
list_delete(&es->es_vtep_list);
@@ -1353,8 +1350,7 @@ static void bgp_evpn_es_local_info_set(struct bgp *bgp, struct bgp_evpn_es *es)
bf_assign_index(bm->rd_idspace, es->rd_id);
es->prd.family = AF_UNSPEC;
es->prd.prefixlen = 64;
- snprintf(buf, sizeof(buf), "%s:%hu", inet_ntoa(bgp->router_id),
- es->rd_id);
+ snprintfrr(buf, sizeof(buf), "%pI4:%hu", &bgp->router_id, es->rd_id);
(void)str2prefix_rd(buf, &es->prd);
}
@@ -1371,7 +1367,7 @@ static void bgp_evpn_es_local_info_clear(struct bgp_evpn_es *es)
bf_release_index(bm->rd_idspace, es->rd_id);
- bgp_evpn_es_free(es);
+ bgp_evpn_es_free(es, __func__);
}
/* eval remote info associated with the ES */
@@ -1382,7 +1378,7 @@ static void bgp_evpn_es_remote_info_re_eval(struct bgp_evpn_es *es)
} else {
if (CHECK_FLAG(es->flags, BGP_EVPNES_REMOTE)) {
UNSET_FLAG(es->flags, BGP_EVPNES_REMOTE);
- bgp_evpn_es_free(es);
+ bgp_evpn_es_free(es, __func__);
}
}
}
@@ -1533,9 +1529,8 @@ int bgp_evpn_local_es_add(struct bgp *bgp, esi_t *esi,
}
if (BGP_DEBUG(evpn_mh, EVPN_MH_ES))
- zlog_debug("add local es %s orig-ip %s",
- es->esi_str,
- inet_ntoa(originator_ip));
+ zlog_debug("add local es %s orig-ip %pI4", es->esi_str,
+ &originator_ip);
es->originator_ip = originator_ip;
bgp_evpn_es_local_info_set(bgp, es);
@@ -1570,10 +1565,12 @@ static char *bgp_evpn_es_vteps_str(char *vtep_str, struct bgp_evpn_es *es,
struct listnode *node;
struct bgp_evpn_es_vtep *es_vtep;
bool first = true;
+ char vtep_ip[BUFSIZ] = {0};
vtep_str[0] = '\0';
for (ALL_LIST_ELEMENTS_RO(es->es_vtep_list, node, es_vtep)) {
vtep_flag_str[0] = '\0';
+
if (es_vtep->flags & BGP_EVPNES_VTEP_ESR)
strlcat(vtep_flag_str, "E", sizeof(vtep_flag_str));
if (es_vtep->flags & BGP_EVPNES_VTEP_ACTIVE)
@@ -1585,7 +1582,11 @@ static char *bgp_evpn_es_vteps_str(char *vtep_str, struct bgp_evpn_es *es,
first = false;
else
strlcat(vtep_str, ",", vtep_str_size);
- strlcat(vtep_str, inet_ntoa(es_vtep->vtep_ip), vtep_str_size);
+
+ strlcat(vtep_str,
+ inet_ntop(AF_INET, &es_vtep->vtep_ip, vtep_ip,
+ sizeof(vtep_ip)),
+ vtep_str_size);
strlcat(vtep_str, "(", vtep_str_size);
strlcat(vtep_str, vtep_flag_str, vtep_str_size);
strlcat(vtep_str, ")", vtep_str_size);
@@ -1604,11 +1605,14 @@ static void bgp_evpn_es_json_vtep_fill(json_object *json_vteps,
{
json_object *json_vtep_entry;
json_object *json_flags;
+ char vtep_ip[BUFSIZ] = {0};
json_vtep_entry = json_object_new_object();
json_object_string_add(json_vtep_entry, "vtep_ip",
- inet_ntoa(es_vtep->vtep_ip));
+ inet_ntop(AF_INET, &es_vtep->vtep_ip, vtep_ip,
+ sizeof(vtep_ip)));
+
if (es_vtep->flags & (BGP_EVPNES_VTEP_ESR |
BGP_EVPNES_VTEP_ACTIVE)) {
json_flags = json_object_new_array();
@@ -1686,6 +1690,8 @@ static void bgp_evpn_es_show_entry(struct vty *vty,
static void bgp_evpn_es_show_entry_detail(struct vty *vty,
struct bgp_evpn_es *es, json_object *json)
{
+ char originator_ip[BUFSIZ] = {0};
+
if (json) {
json_object *json_flags;
json_object *json_incons;
@@ -1702,7 +1708,9 @@ static void bgp_evpn_es_show_entry_detail(struct vty *vty,
json_object_object_add(json, "flags", json_flags);
}
json_object_string_add(json, "originator_ip",
- inet_ntoa(es->originator_ip));
+ inet_ntop(AF_INET, &es->originator_ip,
+ originator_ip,
+ sizeof(originator_ip)));
json_object_int_add(json, "remoteVniCount",
es->remote_es_evi_cnt);
json_object_int_add(json, "inconsistentVniVtepCount",
@@ -1739,8 +1747,7 @@ static void bgp_evpn_es_show_entry_detail(struct vty *vty,
vty_out(vty, "ESI: %s\n", es->esi_str);
vty_out(vty, " Type: %s\n", type_str);
vty_out(vty, " RD: %s\n", buf1);
- vty_out(vty, " Originator-IP: %s\n",
- inet_ntoa(es->originator_ip));
+ vty_out(vty, " Originator-IP: %pI4\n", &es->originator_ip);
vty_out(vty, " VNI Count: %d\n", listcount(es->es_evi_list));
vty_out(vty, " Remote VNI Count: %d\n",
es->remote_es_evi_cnt);
@@ -1919,11 +1926,10 @@ static void bgp_evpn_es_evi_vtep_re_eval_active(struct bgp *bgp,
return;
if (BGP_DEBUG(evpn_mh, EVPN_MH_ES))
- zlog_debug("es %s evi %u vtep %s %s",
- evi_vtep->es_evi->es->esi_str,
- evi_vtep->es_evi->vpn->vni,
- inet_ntoa(evi_vtep->vtep_ip),
- new_active ? "active" : "inactive");
+ zlog_debug("es %s evi %u vtep %pI4 %s",
+ evi_vtep->es_evi->es->esi_str,
+ evi_vtep->es_evi->vpn->vni, &evi_vtep->vtep_ip,
+ new_active ? "active" : "inactive");
/* add VTEP to parent es */
if (new_active) {
@@ -1955,11 +1961,10 @@ static void bgp_evpn_es_evi_vtep_add(struct bgp *bgp,
evi_vtep = bgp_evpn_es_evi_vtep_new(es_evi, vtep_ip);
if (BGP_DEBUG(evpn_mh, EVPN_MH_ES))
- zlog_debug("add es %s evi %u vtep %s %s",
- evi_vtep->es_evi->es->esi_str,
- evi_vtep->es_evi->vpn->vni,
- inet_ntoa(evi_vtep->vtep_ip),
- ead_es ? "ead_es" : "ead_evi");
+ zlog_debug("add es %s evi %u vtep %pI4 %s",
+ evi_vtep->es_evi->es->esi_str,
+ evi_vtep->es_evi->vpn->vni, &evi_vtep->vtep_ip,
+ ead_es ? "ead_es" : "ead_evi");
if (ead_es)
SET_FLAG(evi_vtep->flags, BGP_EVPN_EVI_VTEP_EAD_PER_ES);
@@ -1980,11 +1985,10 @@ static void bgp_evpn_es_evi_vtep_del(struct bgp *bgp,
return;
if (BGP_DEBUG(evpn_mh, EVPN_MH_ES))
- zlog_debug("del es %s evi %u vtep %s %s",
- evi_vtep->es_evi->es->esi_str,
- evi_vtep->es_evi->vpn->vni,
- inet_ntoa(evi_vtep->vtep_ip),
- ead_es ? "ead_es" : "ead_evi");
+ zlog_debug("del es %s evi %u vtep %pI4 %s",
+ evi_vtep->es_evi->es->esi_str,
+ evi_vtep->es_evi->vpn->vni, &evi_vtep->vtep_ip,
+ ead_es ? "ead_es" : "ead_evi");
if (ead_es)
UNSET_FLAG(evi_vtep->flags, BGP_EVPN_EVI_VTEP_EAD_PER_ES);
@@ -2296,13 +2300,10 @@ int bgp_evpn_remote_es_evi_add(struct bgp *bgp, struct bgpevpn *vpn,
return 0;
if (BGP_DEBUG(evpn_mh, EVPN_MH_ES))
- zlog_debug("add remote %s es %s evi %u vtep %s",
- p->prefix.ead_addr.eth_tag ?
- "ead-es" : "ead-evi",
- esi_to_str(esi, buf,
- sizeof(buf)),
- vpn->vni,
- inet_ntoa(p->prefix.ead_addr.ip.ipaddr_v4));
+ zlog_debug("add remote %s es %s evi %u vtep %pI4",
+ p->prefix.ead_addr.eth_tag ? "ead-es" : "ead-evi",
+ esi_to_str(esi, buf, sizeof(buf)), vpn->vni,
+ &p->prefix.ead_addr.ip.ipaddr_v4);
es = bgp_evpn_es_find(esi);
if (!es) {
@@ -2319,7 +2320,7 @@ int bgp_evpn_remote_es_evi_add(struct bgp *bgp, struct bgpevpn *vpn,
if (!es_evi) {
es_evi = bgp_evpn_es_evi_new(es, vpn);
if (!es_evi) {
- bgp_evpn_es_free(es);
+ bgp_evpn_es_free(es, __func__);
return -1;
}
}
@@ -2348,13 +2349,11 @@ int bgp_evpn_remote_es_evi_del(struct bgp *bgp, struct bgpevpn *vpn,
return 0;
if (BGP_DEBUG(evpn_mh, EVPN_MH_ES))
- zlog_debug("del remote %s es %s evi %u vtep %s",
- p->prefix.ead_addr.eth_tag ?
- "ead-es" : "ead-evi",
- esi_to_str(&p->prefix.ead_addr.esi, buf,
- sizeof(buf)),
- vpn->vni,
- inet_ntoa(p->prefix.ead_addr.ip.ipaddr_v4));
+ zlog_debug(
+ "del remote %s es %s evi %u vtep %pI4",
+ p->prefix.ead_addr.eth_tag ? "ead-es" : "ead-evi",
+ esi_to_str(&p->prefix.ead_addr.esi, buf, sizeof(buf)),
+ vpn->vni, &p->prefix.ead_addr.ip.ipaddr_v4);
es = bgp_evpn_es_find(&p->prefix.ead_addr.esi);
if (!es)
@@ -2405,6 +2404,7 @@ static char *bgp_evpn_es_evi_vteps_str(char *vtep_str,
struct listnode *node;
struct bgp_evpn_es_evi_vtep *evi_vtep;
bool first = true;
+ char vtep_ip[BUFSIZ] = {0};
vtep_str[0] = '\0';
for (ALL_LIST_ELEMENTS_RO(es_evi->es_evi_vtep_list, node, evi_vtep)) {
@@ -2420,7 +2420,10 @@ static char *bgp_evpn_es_evi_vteps_str(char *vtep_str,
first = false;
else
strlcat(vtep_str, ",", vtep_str_size);
- strlcat(vtep_str, inet_ntoa(evi_vtep->vtep_ip), vtep_str_size);
+ strlcat(vtep_str,
+ inet_ntop(AF_INET, &evi_vtep->vtep_ip, vtep_ip,
+ sizeof(vtep_ip)),
+ vtep_str_size);
strlcat(vtep_str, "(", vtep_str_size);
strlcat(vtep_str, vtep_flag_str, vtep_str_size);
strlcat(vtep_str, ")", vtep_str_size);
@@ -2434,12 +2437,14 @@ static void bgp_evpn_es_evi_json_vtep_fill(json_object *json_vteps,
{
json_object *json_vtep_entry;
json_object *json_flags;
+ char vtep_ip[BUFSIZ] = {0};
json_vtep_entry = json_object_new_object();
- json_object_string_add(json_vtep_entry,
- "vtep_ip",
- inet_ntoa(evi_vtep->vtep_ip));
+ json_object_string_add(json_vtep_entry, "vtep_ip",
+ inet_ntop(AF_INET, &evi_vtep->vtep_ip, vtep_ip,
+ sizeof(vtep_ip)));
+
if (evi_vtep->flags & (BGP_EVPN_EVI_VTEP_EAD_PER_ES |
BGP_EVPN_EVI_VTEP_EAD_PER_EVI)) {
json_flags = json_object_new_array();
@@ -2898,15 +2903,13 @@ void bgp_evpn_mh_finish(void)
{
struct bgp_evpn_es *es;
struct bgp_evpn_es *es_next;
- struct bgp *bgp;
- bgp = bgp_get_evpn();
- if (bgp) {
- RB_FOREACH_SAFE(es, bgp_es_rb_head,
- &bgp_mh_info->es_rb_tree, es_next) {
- /* XXX - need to force free remote ESs here */
- bgp_evpn_local_es_do_del(bgp, es);
- }
+ if (BGP_DEBUG(evpn_mh, EVPN_MH_RT))
+ zlog_debug("evpn mh finish");
+
+ RB_FOREACH_SAFE (es, bgp_es_rb_head, &bgp_mh_info->es_rb_tree,
+ es_next) {
+ bgp_evpn_es_local_info_clear(es);
}
thread_cancel(bgp_mh_info->t_cons_check);
list_delete(&bgp_mh_info->local_es_list);
diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c
index 2e1e9d635f..c22bfefb63 100644
--- a/bgpd/bgp_evpn_vty.c
+++ b/bgpd/bgp_evpn_vty.c
@@ -22,6 +22,7 @@
#include "command.h"
#include "prefix.h"
#include "lib/json.h"
+#include "lib/printfrr.h"
#include "stream.h"
#include "bgpd/bgpd.h"
@@ -103,8 +104,7 @@ static void display_vrf_import_rt(struct vty *vty, struct vrf_irt_node *irt,
eip.val = (*pnt++ << 8);
eip.val |= (*pnt++);
- snprintf(rt_buf, sizeof(rt_buf), "%s:%u", inet_ntoa(eip.ip),
- eip.val);
+ snprintfrr(rt_buf, sizeof(rt_buf), "%pI4:%u", &eip.ip, eip.val);
if (json)
json_object_string_add(json_rt, "rt", rt_buf);
@@ -213,8 +213,7 @@ static void display_import_rt(struct vty *vty, struct irt_node *irt,
eip.val = (*pnt++ << 8);
eip.val |= (*pnt++);
- snprintf(rt_buf, sizeof(rt_buf), "%s:%u", inet_ntoa(eip.ip),
- eip.val);
+ snprintfrr(rt_buf, sizeof(rt_buf), "%pI4:%u", &eip.ip, eip.val);
if (json)
json_object_string_add(json_rt, "rt", rt_buf);
@@ -314,8 +313,7 @@ static void bgp_evpn_show_route_rd_header(struct vty *vty,
case RD_TYPE_IP:
decode_rd_ip(pnt + 2, &rd_ip);
- snprintf(rd_str, len, "%s:%d", inet_ntoa(rd_ip.ip),
- rd_ip.val);
+ snprintfrr(rd_str, len, "%pI4:%d", &rd_ip.ip, rd_ip.val);
if (json)
json_object_string_add(json, "rd", rd_str);
else
@@ -343,8 +341,9 @@ static void bgp_evpn_show_route_header(struct vty *vty, struct bgp *bgp,
if (json)
return;
- vty_out(vty, "BGP table version is %" PRIu64 ", local router ID is %s\n",
- tbl_ver, inet_ntoa(bgp->router_id));
+ vty_out(vty,
+ "BGP table version is %" PRIu64 ", local router ID is %pI4\n",
+ tbl_ver, &bgp->router_id);
vty_out(vty,
"Status codes: s suppressed, d damped, h history, * valid, > best, i - internal\n");
vty_out(vty, "Origin codes: i - IGP, e - EGP, ? - incomplete\n");
@@ -368,6 +367,7 @@ static void display_l3vni(struct vty *vty, struct bgp *bgp_vrf,
json_object *json_import_rtl = NULL;
json_object *json_export_rtl = NULL;
char buf2[ETHER_ADDR_STRLEN];
+ char originator_ip[BUFSIZ] = {0};
json_import_rtl = json_export_rtl = 0;
@@ -380,8 +380,10 @@ static void display_l3vni(struct vty *vty, struct bgp *bgp_vrf,
json_object_string_add(
json, "rd",
prefix_rd2str(&bgp_vrf->vrf_prd, buf1, RD_ADDRSTRLEN));
- json_object_string_add(json, "originatorIp",
- inet_ntoa(bgp_vrf->originator_ip));
+ json_object_string_add(
+ json, "originatorIp",
+ inet_ntop(AF_INET, &bgp_vrf->originator_ip,
+ originator_ip, sizeof(originator_ip)));
json_object_string_add(json, "advertiseGatewayMacip", "n/a");
json_object_string_add(json, "advertiseSviMacIp", "n/a");
json_object_to_json_string_ext(json,
@@ -409,8 +411,8 @@ static void display_l3vni(struct vty *vty, struct bgp *bgp_vrf,
vrf_id_to_name(bgp_vrf->vrf_id));
vty_out(vty, " RD: %s\n",
prefix_rd2str(&bgp_vrf->vrf_prd, buf1, RD_ADDRSTRLEN));
- vty_out(vty, " Originator IP: %s\n",
- inet_ntoa(bgp_vrf->originator_ip));
+ vty_out(vty, " Originator IP: %pI4\n",
+ &bgp_vrf->originator_ip);
vty_out(vty, " Advertise-gw-macip : %s\n", "n/a");
vty_out(vty, " Advertise-svi-macip : %s\n", "n/a");
vty_out(vty, " Advertise-pip: %s\n",
@@ -473,6 +475,7 @@ static void display_vni(struct vty *vty, struct bgpevpn *vpn, json_object *json)
json_object *json_import_rtl = NULL;
json_object *json_export_rtl = NULL;
struct bgp *bgp_evpn;
+ char buf[BUFSIZ] = {0};
bgp_evpn = bgp_get_evpn();
@@ -487,9 +490,11 @@ static void display_vni(struct vty *vty, struct bgpevpn *vpn, json_object *json)
json, "rd",
prefix_rd2str(&vpn->prd, buf1, sizeof(buf1)));
json_object_string_add(json, "originatorIp",
- inet_ntoa(vpn->originator_ip));
- json_object_string_add(json, "mcastGroup",
- inet_ntoa(vpn->mcast_grp));
+ inet_ntop(AF_INET, &vpn->originator_ip,
+ buf, sizeof(buf)));
+ json_object_string_add(
+ json, "mcastGroup",
+ inet_ntop(AF_INET, &vpn->mcast_grp, buf, sizeof(buf)));
/* per vni knob is enabled -- Enabled
* Global knob is enabled -- Active
* default -- Disabled
@@ -525,10 +530,8 @@ static void display_vni(struct vty *vty, struct bgpevpn *vpn, json_object *json)
vrf_id_to_name(vpn->tenant_vrf_id));
vty_out(vty, " RD: %s\n",
prefix_rd2str(&vpn->prd, buf1, sizeof(buf1)));
- vty_out(vty, " Originator IP: %s\n",
- inet_ntoa(vpn->originator_ip));
- vty_out(vty, " Mcast group: %s\n",
- inet_ntoa(vpn->mcast_grp));
+ vty_out(vty, " Originator IP: %pI4\n", &vpn->originator_ip);
+ vty_out(vty, " Mcast group: %pI4\n", &vpn->mcast_grp);
if (!vpn->advertise_gw_macip &&
bgp_evpn && bgp_evpn->advertise_gw_macip)
vty_out(vty, " Advertise-gw-macip : %s\n",
@@ -825,6 +828,7 @@ static void show_l3vni_entry(struct vty *vty, struct bgp *bgp,
json_object *json_export_rtl = NULL;
char buf1[10];
char buf2[INET6_ADDRSTRLEN];
+ char buf3[BUFSIZ] = {0};
char rt_buf[25];
char *ecom_str;
struct listnode *node, *nnode;
@@ -848,7 +852,8 @@ static void show_l3vni_entry(struct vty *vty, struct bgp *bgp,
json_object_string_add(json_vni, "type", "L3");
json_object_string_add(json_vni, "inKernel", "True");
json_object_string_add(json_vni, "originatorIp",
- inet_ntoa(bgp->originator_ip));
+ inet_ntop(AF_INET, &bgp->originator_ip,
+ buf3, sizeof(buf3)));
json_object_string_add(
json_vni, "rd",
prefix_rd2str(&bgp->vrf_prd, buf2, RD_ADDRSTRLEN));
@@ -861,7 +866,9 @@ static void show_l3vni_entry(struct vty *vty, struct bgp *bgp,
json_vni, "advertisePip",
bgp->evpn_info->advertise_pip ? "Enabled" : "Disabled");
json_object_string_add(json_vni, "sysIP",
- inet_ntoa(bgp->evpn_info->pip_ip));
+ inet_ntop(AF_INET,
+ &bgp->evpn_info->pip_ip, buf3,
+ sizeof(buf3)));
json_object_string_add(json_vni, "sysMAC",
prefix_mac2str(&bgp->evpn_info->pip_rmac,
buf2, sizeof(buf2)));
@@ -950,6 +957,7 @@ static void show_vni_entry(struct hash_bucket *bucket, void *args[])
struct bgpevpn *vpn = (struct bgpevpn *)bucket->data;
char buf1[10];
char buf2[RD_ADDRSTRLEN];
+ char buf3[BUFSIZ] = {0};
char rt_buf[25];
char *ecom_str;
struct listnode *node, *nnode;
@@ -980,9 +988,11 @@ static void show_vni_entry(struct hash_bucket *bucket, void *args[])
json_vni, "rd",
prefix_rd2str(&vpn->prd, buf2, sizeof(buf2)));
json_object_string_add(json_vni, "originatorIp",
- inet_ntoa(vpn->originator_ip));
+ inet_ntop(AF_INET, &vpn->originator_ip,
+ buf3, sizeof(buf3)));
json_object_string_add(json_vni, "mcastGroup",
- inet_ntoa(vpn->mcast_grp));
+ inet_ntop(AF_INET, &vpn->mcast_grp, buf3,
+ sizeof(buf3)));
/* per vni knob is enabled -- Enabled
* Global knob is enabled -- Active
* default -- Disabled
@@ -1094,6 +1104,7 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
char rd_str[RD_ADDRSTRLEN];
char buf[BUFSIZ];
int no_display;
+ char router_id[BUFSIZ] = {0};
unsigned long output_count = 0;
unsigned long total_count = 0;
@@ -1185,8 +1196,11 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
json_object_string_add(
json,
"bgpLocalRouterId",
- inet_ntoa(
- bgp->router_id));
+ inet_ntop(
+ AF_INET,
+ &bgp->router_id,
+ router_id,
+ sizeof(router_id)));
json_object_int_add(
json,
"defaultLocPrf",
@@ -3986,12 +4000,40 @@ DEFUN(show_bgp_l2vpn_evpn_summary,
show_established, uj);
}
+int bgp_evpn_cli_parse_type(int *type, struct cmd_token **argv, int argc)
+{
+ int type_idx = 0;
+
+ if (argv_find(argv, argc, "type", &type_idx)) {
+ /* Specific type is requested */
+ if ((strncmp(argv[type_idx + 1]->arg, "ma", 2) == 0)
+ || (strmatch(argv[type_idx + 1]->arg, "2")))
+ *type = BGP_EVPN_MAC_IP_ROUTE;
+ else if ((strncmp(argv[type_idx + 1]->arg, "mu", 2) == 0)
+ || (strmatch(argv[type_idx + 1]->arg, "3")))
+ *type = BGP_EVPN_IMET_ROUTE;
+ else if ((strncmp(argv[type_idx + 1]->arg, "es", 2) == 0)
+ || (strmatch(argv[type_idx + 1]->arg, "4")))
+ *type = BGP_EVPN_ES_ROUTE;
+ else if ((strncmp(argv[type_idx + 1]->arg, "ea", 2) == 0)
+ || (strmatch(argv[type_idx + 1]->arg, "1")))
+ *type = BGP_EVPN_AD_ROUTE;
+ else if ((strncmp(argv[type_idx + 1]->arg, "p", 1) == 0)
+ || (strmatch(argv[type_idx + 1]->arg, "5")))
+ *type = BGP_EVPN_IP_PREFIX_ROUTE;
+ else
+ return -1;
+ }
+
+ return 0;
+}
+
/*
* Display global EVPN routing table.
*/
DEFUN(show_bgp_l2vpn_evpn_route,
show_bgp_l2vpn_evpn_route_cmd,
- "show bgp l2vpn evpn route [detail] [type <ead|1|macip|2|multicast|3|es|4|prefix|5>] [json]",
+ "show bgp l2vpn evpn route [detail] [type "EVPN_TYPE_ALL_LIST"] [json]",
SHOW_STR
BGP_STR
L2VPN_HELP_STR
@@ -3999,20 +4041,10 @@ DEFUN(show_bgp_l2vpn_evpn_route,
EVPN_RT_HELP_STR
"Display Detailed Information\n"
EVPN_TYPE_HELP_STR
- EVPN_TYPE_1_HELP_STR
- EVPN_TYPE_1_HELP_STR
- EVPN_TYPE_2_HELP_STR
- EVPN_TYPE_2_HELP_STR
- EVPN_TYPE_3_HELP_STR
- EVPN_TYPE_3_HELP_STR
- EVPN_TYPE_4_HELP_STR
- EVPN_TYPE_4_HELP_STR
- EVPN_TYPE_5_HELP_STR
- EVPN_TYPE_5_HELP_STR
+ EVPN_TYPE_ALL_LIST_HELP_STR
JSON_STR)
{
struct bgp *bgp;
- int type_idx = 0;
int detail = 0;
int type = 0;
bool uj = false;
@@ -4027,27 +4059,8 @@ DEFUN(show_bgp_l2vpn_evpn_route,
if (uj)
json = json_object_new_object();
- /* get the type */
- if (argv_find(argv, argc, "type", &type_idx)) {
- /* Specific type is requested */
- if ((strncmp(argv[type_idx + 1]->arg, "ma", 2) == 0)
- || (strmatch(argv[type_idx + 1]->arg, "2")))
- type = BGP_EVPN_MAC_IP_ROUTE;
- else if ((strncmp(argv[type_idx + 1]->arg, "mu", 2) == 0)
- || (strmatch(argv[type_idx + 1]->arg, "3")))
- type = BGP_EVPN_IMET_ROUTE;
- else if ((strncmp(argv[type_idx + 1]->arg, "es", 2) == 0)
- || (strmatch(argv[type_idx + 1]->arg, "4")))
- type = BGP_EVPN_ES_ROUTE;
- else if ((strncmp(argv[type_idx + 1]->arg, "ea", 2) == 0)
- || (strmatch(argv[type_idx + 1]->arg, "1")))
- type = BGP_EVPN_AD_ROUTE;
- else if ((strncmp(argv[type_idx + 1]->arg, "p", 1) == 0)
- || (strmatch(argv[type_idx + 1]->arg, "5")))
- type = BGP_EVPN_IP_PREFIX_ROUTE;
- else
- return CMD_WARNING;
- }
+ if (bgp_evpn_cli_parse_type(&type, argv, argc) < 0)
+ return CMD_WARNING;
if (argv_find(argv, argc, "detail", &detail))
detail = 1;
@@ -4067,7 +4080,7 @@ DEFUN(show_bgp_l2vpn_evpn_route,
*/
DEFUN(show_bgp_l2vpn_evpn_route_rd,
show_bgp_l2vpn_evpn_route_rd_cmd,
- "show bgp l2vpn evpn route rd ASN:NN_OR_IP-ADDRESS:NN [type <ead|macip|multicast|es|prefix>] [json]",
+ "show bgp l2vpn evpn route rd ASN:NN_OR_IP-ADDRESS:NN [type "EVPN_TYPE_ALL_LIST"] [json]",
SHOW_STR
BGP_STR
L2VPN_HELP_STR
@@ -4076,11 +4089,7 @@ DEFUN(show_bgp_l2vpn_evpn_route_rd,
EVPN_RT_DIST_HELP_STR
EVPN_ASN_IP_HELP_STR
EVPN_TYPE_HELP_STR
- EVPN_TYPE_1_HELP_STR
- EVPN_TYPE_2_HELP_STR
- EVPN_TYPE_3_HELP_STR
- EVPN_TYPE_4_HELP_STR
- EVPN_TYPE_5_HELP_STR
+ EVPN_TYPE_ALL_LIST_HELP_STR
JSON_STR)
{
struct bgp *bgp;
@@ -4088,7 +4097,6 @@ DEFUN(show_bgp_l2vpn_evpn_route_rd,
struct prefix_rd prd;
int type = 0;
int rd_idx = 0;
- int type_idx = 0;
bool uj = false;
json_object *json = NULL;
@@ -4111,22 +4119,8 @@ DEFUN(show_bgp_l2vpn_evpn_route_rd,
}
}
- /* get the type */
- if (argv_find(argv, argc, "type", &type_idx)) {
- /* Specific type is requested */
- if (strncmp(argv[type_idx + 1]->arg, "ma", 2) == 0)
- type = BGP_EVPN_MAC_IP_ROUTE;
- else if (strncmp(argv[type_idx + 1]->arg, "mu", 2) == 0)
- type = BGP_EVPN_IMET_ROUTE;
- else if (strncmp(argv[type_idx + 1]->arg, "es", 2) == 0)
- type = BGP_EVPN_ES_ROUTE;
- else if (strncmp(argv[type_idx + 1]->arg, "ea", 2) == 0)
- type = BGP_EVPN_AD_ROUTE;
- else if (strncmp(argv[type_idx + 1]->arg, "pr", 2) == 0)
- type = BGP_EVPN_IP_PREFIX_ROUTE;
- else
- return CMD_WARNING;
- }
+ if (bgp_evpn_cli_parse_type(&type, argv, argc) < 0)
+ return CMD_WARNING;
evpn_show_route_rd(vty, bgp, &prd, type, json);
@@ -4266,7 +4260,7 @@ DEFUN(show_bgp_l2vpn_evpn_route_esi,
* Display per-VNI EVPN routing table.
*/
DEFUN(show_bgp_l2vpn_evpn_route_vni, show_bgp_l2vpn_evpn_route_vni_cmd,
- "show bgp l2vpn evpn route vni " CMD_VNI_RANGE " [<type <ead|macip|multicast> | vtep A.B.C.D>] [json]",
+ "show bgp l2vpn evpn route vni " CMD_VNI_RANGE " [<type <ead|1|macip|2|multicast|3> | vtep A.B.C.D>] [json]",
SHOW_STR
BGP_STR
L2VPN_HELP_STR
@@ -4276,7 +4270,10 @@ DEFUN(show_bgp_l2vpn_evpn_route_vni, show_bgp_l2vpn_evpn_route_vni_cmd,
"VNI number\n"
EVPN_TYPE_HELP_STR
EVPN_TYPE_1_HELP_STR
+ EVPN_TYPE_1_HELP_STR
EVPN_TYPE_2_HELP_STR
+ EVPN_TYPE_2_HELP_STR
+ EVPN_TYPE_3_HELP_STR
EVPN_TYPE_3_HELP_STR
"Remote VTEP\n"
"Remote VTEP IP address\n"
@@ -4287,6 +4284,7 @@ DEFUN(show_bgp_l2vpn_evpn_route_vni, show_bgp_l2vpn_evpn_route_vni_cmd,
struct in_addr vtep_ip;
int type = 0;
int idx = 0;
+ int vtep_idx = 0;
bool uj = false;
json_object *json = NULL;
@@ -4306,24 +4304,14 @@ DEFUN(show_bgp_l2vpn_evpn_route_vni, show_bgp_l2vpn_evpn_route_vni_cmd,
vni = strtoul(argv[idx + 3]->arg, NULL, 10);
- if ((!uj && ((argc == (idx + 1 + 5)) && argv[idx + 4]->arg))
- || (uj && ((argc == (idx + 1 + 6)) && argv[idx + 4]->arg))) {
- if (strncmp(argv[idx + 4]->arg, "type", 4) == 0) {
- if (strncmp(argv[idx + 5]->arg, "ma", 2) == 0)
- type = BGP_EVPN_MAC_IP_ROUTE;
- else if (strncmp(argv[idx + 5]->arg, "mu", 2) == 0)
- type = BGP_EVPN_IMET_ROUTE;
- else if (strncmp(argv[idx + 5]->arg, "ea", 2) == 0)
- type = BGP_EVPN_AD_ROUTE;
- else
- return CMD_WARNING;
- } else if (strncmp(argv[idx + 4]->arg, "vtep", 4) == 0) {
- if (!inet_aton(argv[idx + 5]->arg, &vtep_ip)) {
- vty_out(vty, "%% Malformed VTEP IP address\n");
- return CMD_WARNING;
- }
- } else
+ if (bgp_evpn_cli_parse_type(&type, argv, argc) < 0)
+ return CMD_WARNING;
+
+ if (argv_find(argv, argc, "vtep", &vtep_idx)) {
+ if (!inet_aton(argv[vtep_idx + 1]->arg, &vtep_ip)) {
+ vty_out(vty, "%% Malformed VTEP IP address\n");
return CMD_WARNING;
+ }
}
evpn_show_routes_vni(vty, bgp, vni, type, vtep_ip, json);
@@ -4702,23 +4690,27 @@ ALIAS_HIDDEN(show_bgp_l2vpn_evpn_summary, show_bgp_evpn_summary_cmd,
"Summary of BGP neighbor status\n" JSON_STR)
ALIAS_HIDDEN(show_bgp_l2vpn_evpn_route, show_bgp_evpn_route_cmd,
- "show bgp evpn route [detail] [type <macip|multicast>]",
+ "show bgp evpn route [detail] [type <macip|2|multicast|3>]",
SHOW_STR BGP_STR EVPN_HELP_STR
EVPN_RT_HELP_STR
"Display Detailed Information\n"
EVPN_TYPE_HELP_STR
EVPN_TYPE_2_HELP_STR
+ EVPN_TYPE_2_HELP_STR
+ EVPN_TYPE_3_HELP_STR
EVPN_TYPE_3_HELP_STR)
ALIAS_HIDDEN(
show_bgp_l2vpn_evpn_route_rd, show_bgp_evpn_route_rd_cmd,
- "show bgp evpn route rd ASN:NN_OR_IP-ADDRESS:NN [type <macip|multicast>]",
+ "show bgp evpn route rd ASN:NN_OR_IP-ADDRESS:NN [type <macip|2|multicast|3>]",
SHOW_STR BGP_STR EVPN_HELP_STR
EVPN_RT_HELP_STR
EVPN_RT_DIST_HELP_STR
EVPN_ASN_IP_HELP_STR
EVPN_TYPE_HELP_STR
EVPN_TYPE_2_HELP_STR
+ EVPN_TYPE_2_HELP_STR
+ EVPN_TYPE_3_HELP_STR
EVPN_TYPE_3_HELP_STR)
ALIAS_HIDDEN(
@@ -4735,13 +4727,15 @@ ALIAS_HIDDEN(
ALIAS_HIDDEN(
show_bgp_l2vpn_evpn_route_vni, show_bgp_evpn_route_vni_cmd,
- "show bgp evpn route vni " CMD_VNI_RANGE " [<type <macip|multicast> | vtep A.B.C.D>]",
+ "show bgp evpn route vni " CMD_VNI_RANGE " [<type <macip|2|multicast|3> | vtep A.B.C.D>]",
SHOW_STR BGP_STR EVPN_HELP_STR
EVPN_RT_HELP_STR
"VXLAN Network Identifier\n"
"VNI number\n"
EVPN_TYPE_HELP_STR
EVPN_TYPE_2_HELP_STR
+ EVPN_TYPE_2_HELP_STR
+ EVPN_TYPE_3_HELP_STR
EVPN_TYPE_3_HELP_STR
"Remote VTEP\n"
"Remote VTEP IP address\n")
@@ -5071,6 +5065,7 @@ DEFUN (show_bgp_vrf_l3vni_info,
{
char buf[ETHER_ADDR_STRLEN];
char buf1[INET6_ADDRSTRLEN];
+ char originator_ip[BUFSIZ] = {0};
int idx_vrf = 3;
const char *name = NULL;
struct bgp *bgp = NULL;
@@ -5106,7 +5101,7 @@ DEFUN (show_bgp_vrf_l3vni_info,
if (!json) {
vty_out(vty, "BGP VRF: %s\n", name);
- vty_out(vty, " Local-Ip: %s\n", inet_ntoa(bgp->originator_ip));
+ vty_out(vty, " Local-Ip: %pI4\n", &bgp->originator_ip);
vty_out(vty, " L3-VNI: %u\n", bgp->l3vni);
vty_out(vty, " Rmac: %s\n",
prefix_mac2str(&bgp->rmac, buf, sizeof(buf)));
@@ -5135,7 +5130,9 @@ DEFUN (show_bgp_vrf_l3vni_info,
} else {
json_object_string_add(json, "vrf", name);
json_object_string_add(json, "local-ip",
- inet_ntoa(bgp->originator_ip));
+ inet_ntop(AF_INET, &bgp->originator_ip,
+ originator_ip,
+ sizeof(originator_ip)));
json_object_int_add(json, "l3vni", bgp->l3vni);
json_object_string_add(
json, "rmac",
diff --git a/bgpd/bgp_evpn_vty.h b/bgpd/bgp_evpn_vty.h
index 4d07f7d038..33f6e4f1b6 100644
--- a/bgpd/bgp_evpn_vty.h
+++ b/bgpd/bgp_evpn_vty.h
@@ -28,4 +28,8 @@ extern void bgp_ethernetvpn_init(void);
#define L2VPN_HELP_STR "Layer 2 Virtual Private Network\n"
#define EVPN_HELP_STR "Ethernet Virtual Private Network\n"
+/* Parse type from "type <ead|1|...>", return -1 on failure */
+extern int bgp_evpn_cli_parse_type(int *type, struct cmd_token **argv,
+ int argc);
+
#endif /* _QUAGGA_BGP_EVPN_VTY_H */
diff --git a/bgpd/bgp_flowspec_util.c b/bgpd/bgp_flowspec_util.c
index 90e9236385..55e7973f81 100644
--- a/bgpd/bgp_flowspec_util.c
+++ b/bgpd/bgp_flowspec_util.c
@@ -20,6 +20,8 @@
#include "zebra.h"
+#include "lib/printfrr.h"
+
#include "prefix.h"
#include "lib_errors.h"
@@ -211,14 +213,11 @@ int bgp_flowspec_ip_address(enum bgp_flowspec_util_nlri_t type,
switch (type) {
case BGP_FLOWSPEC_RETURN_STRING:
if (prefix_local.family == AF_INET6) {
- char str[BGP_FLOWSPEC_STRING_DISPLAY_MAX];
int ret;
- prefix2str(&prefix_local, str,
- BGP_FLOWSPEC_STRING_DISPLAY_MAX);
- ret = snprintf(display, BGP_FLOWSPEC_STRING_DISPLAY_MAX,
- "%s/off %u",
- str, prefix_offset);
+ ret = snprintfrr(
+ display, BGP_FLOWSPEC_STRING_DISPLAY_MAX,
+ "%pFX/off %u", &prefix_local, prefix_offset);
if (ret < 0) {
*error = -1;
break;
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c
index d7df707a36..61119ced80 100644
--- a/bgpd/bgp_fsm.c
+++ b/bgpd/bgp_fsm.c
@@ -740,11 +740,12 @@ void bgp_update_delay_end(struct bgp *bgp)
bgp->main_zebra_update_hold = 1;
bgp->main_peers_update_hold = 1;
- /* Resume the queue processing. This should trigger the event that would
- take
- care of processing any work that was queued during the read-only
- mode. */
- work_queue_unplug(bm->process_main_queue);
+ /*
+ * Resume the queue processing. This should trigger the event that would
+ * take care of processing any work that was queued during the read-only
+ * mode.
+ */
+ work_queue_unplug(bgp->process_queue);
}
/**
@@ -997,7 +998,7 @@ static void bgp_update_delay_begin(struct bgp *bgp)
struct peer *peer;
/* Stop the processing of queued work. Enqueue shall continue */
- work_queue_plug(bm->process_main_queue);
+ work_queue_plug(bgp->process_queue);
for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer))
peer->update_delay_over = 0;
diff --git a/bgpd/bgp_label.c b/bgpd/bgp_label.c
index fba954c432..4f440cd1f8 100644
--- a/bgpd/bgp_label.c
+++ b/bgpd/bgp_label.c
@@ -215,7 +215,6 @@ void bgp_reg_dereg_for_label(struct bgp_dest *dest, struct bgp_path_info *pi,
int command;
uint16_t flags = 0;
size_t flags_pos = 0;
- char addr[PREFIX_STRLEN];
p = bgp_dest_get_prefix(dest);
local_label = &(dest->local_label);
@@ -242,11 +241,11 @@ void bgp_reg_dereg_for_label(struct bgp_dest *dest, struct bgp_path_info *pi,
* always takes precedence over auto-assigned labels.
*/
if (!have_label_to_reg) {
- if (BGP_DEBUG(labelpool, LABELPOOL)) {
- prefix2str(p, addr, PREFIX_STRLEN);
- zlog_debug("%s: Requesting label from LP for %s",
- __func__, addr);
- }
+ if (BGP_DEBUG(labelpool, LABELPOOL))
+ zlog_debug(
+ "%s: Requesting label from LP for %pFX",
+ __func__, p);
+
/* bgp_reg_for_label_callback() will call back
* __func__ when it gets a label from the pool.
* This means we'll never register FECs without
@@ -422,8 +421,8 @@ int bgp_nlri_parse_label(struct peer *peer, struct attr *attr,
*/
flog_err(
EC_BGP_UPDATE_RCV,
- "%s: IPv4 labeled-unicast NLRI is multicast address %s, ignoring",
- peer->host, inet_ntoa(p.u.prefix4));
+ "%s: IPv4 labeled-unicast NLRI is multicast address %pI4, ignoring",
+ peer->host, &p.u.prefix4);
continue;
}
}
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c
index d0a32ee408..21c880e95b 100644
--- a/bgpd/bgp_main.c
+++ b/bgpd/bgp_main.c
@@ -62,6 +62,7 @@
#include "bgpd/bgp_errors.h"
#include "lib/routing_nb.h"
#include "bgpd/bgp_nb.h"
+#include "bgpd/bgp_evpn_mh.h"
#ifdef ENABLE_BGP_VNC
#include "bgpd/rfapi/rfapi_backend.h"
@@ -207,6 +208,8 @@ static __attribute__((__noreturn__)) void bgp_exit(int status)
if (bgp_default)
bgp_delete(bgp_default);
+ bgp_evpn_mh_finish();
+
/* reverse bgp_dump_init */
bgp_dump_finish();
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index 67885cbf7e..f1aeafced7 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -1106,13 +1106,9 @@ vpn_leak_to_vrf_update_onevrf(struct bgp *bgp_vrf, /* to */
return;
}
- if (debug) {
- char buf_prefix[PREFIX_STRLEN];
-
- prefix2str(p, buf_prefix, sizeof(buf_prefix));
- zlog_debug("%s: updating %s to vrf %s", __func__,
- buf_prefix, bgp_vrf->name_pretty);
- }
+ if (debug)
+ zlog_debug("%s: updating %pFX to vrf %s", __func__, p,
+ bgp_vrf->name_pretty);
/* shallow copy */
static_attr = *path_vpn->attr;
diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c
index 6cd38ec78f..64b10c0252 100644
--- a/bgpd/bgp_nht.c
+++ b/bgpd/bgp_nht.c
@@ -315,15 +315,12 @@ static void bgp_process_nexthop_update(struct bgp_nexthop_cache *bnc,
bnc->change_flags = 0;
/* debug print the input */
- if (BGP_DEBUG(nht, NHT)) {
- char buf[PREFIX2STR_BUFFER];
- prefix2str(&nhr->prefix, buf, sizeof(buf));
+ if (BGP_DEBUG(nht, NHT))
zlog_debug(
- "%s(%u): Rcvd NH update %s(%u) - metric %d/%d #nhops %d/%d flags 0x%x",
- bnc->bgp->name_pretty, bnc->bgp->vrf_id, buf,
+ "%s(%u): Rcvd NH update %pFX(%u) - metric %d/%d #nhops %d/%d flags 0x%x",
+ bnc->bgp->name_pretty, bnc->bgp->vrf_id, &nhr->prefix,
bnc->srte_color, nhr->metric, bnc->metric,
nhr->nexthop_num, bnc->nexthop_num, bnc->flags);
- }
if (nhr->metric != bnc->metric)
bnc->change_flags |= BGP_NEXTHOP_METRIC_CHANGED;
@@ -454,14 +451,10 @@ void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id)
bnc = bnc_find(tree, &nhr.prefix, nhr.srte_color);
if (!bnc) {
- if (BGP_DEBUG(nht, NHT)) {
- char buf[PREFIX2STR_BUFFER];
-
- prefix2str(&nhr.prefix, buf, sizeof(buf));
+ if (BGP_DEBUG(nht, NHT))
zlog_debug(
- "parse nexthop update(%s(%u)(%s)): bnc info not found",
- buf, nhr.srte_color, bgp->name_pretty);
- }
+ "parse nexthop update(%pFX(%u)(%s)): bnc info not found",
+ &nhr.prefix, nhr.srte_color, bgp->name_pretty);
return;
}
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index 6c077878b5..ed22f6711c 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -566,9 +566,9 @@ void bgp_open_send(struct peer *peer)
if (bgp_debug_neighbor_events(peer))
zlog_debug(
- "%s sending OPEN, version %d, my as %u, holdtime %d, id %s",
+ "%s sending OPEN, version %d, my as %u, holdtime %d, id %pI4",
peer->host, BGP_VERSION_4, local_as, send_holdtime,
- inet_ntoa(peer->local_id));
+ &peer->local_id);
/* Dump packet if debug option is set. */
/* bgp_packet_dump (s); */
@@ -1022,8 +1022,8 @@ static int bgp_collision_detect(struct peer *new, struct in_addr remote_id)
&& peer->local_as == peer->as)
flog_err(
EC_BGP_ROUTER_ID_SAME,
- "Peer's router-id %s is the same as ours",
- inet_ntoa(remote_id));
+ "Peer's router-id %pI4 is the same as ours",
+ &remote_id);
/* 3. Otherwise, the local system closes newly
created
@@ -1115,9 +1115,8 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size)
/* Receive OPEN message log */
if (bgp_debug_neighbor_events(peer))
zlog_debug(
- "%s rcv OPEN, version %d, remote-as (in open) %u, holdtime %d, id %s",
- peer->host, version, remote_as, holdtime,
- inet_ntoa(remote_id));
+ "%s rcv OPEN, version %d, remote-as (in open) %u, holdtime %d, id %pI4",
+ peer->host, version, remote_as, holdtime, &remote_id);
/* BEGIN to read the capability here, but dont do it yet */
mp_capability = 0;
@@ -1219,8 +1218,8 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size)
|| (peer->sort == BGP_PEER_IBGP
&& ntohl(peer->local_id.s_addr) == ntohl(remote_id.s_addr))) {
if (bgp_debug_neighbor_events(peer))
- zlog_debug("%s bad OPEN, wrong router identifier %s",
- peer->host, inet_ntoa(remote_id));
+ zlog_debug("%s bad OPEN, wrong router identifier %pI4",
+ peer->host, &remote_id);
bgp_notify_send_with_data(peer, BGP_NOTIFY_OPEN_ERR,
BGP_NOTIFY_OPEN_BAD_BGP_IDENT,
notify_data_remote_id, 4);
diff --git a/bgpd/bgp_pbr.c b/bgpd/bgp_pbr.c
index f6e5c196ca..f7dd08443f 100644
--- a/bgpd/bgp_pbr.c
+++ b/bgpd/bgp_pbr.c
@@ -23,6 +23,8 @@
#include "jhash.h"
#include "pbr.h"
+#include "lib/printfrr.h"
+
#include "bgpd/bgpd.h"
#include "bgpd/bgp_pbr.h"
#include "bgpd/bgp_debug.h"
@@ -1438,7 +1440,6 @@ void bgp_pbr_print_policy_route(struct bgp_pbr_entry_main *api)
int i = 0;
char return_string[512];
char *ptr = return_string;
- char buff[64];
int nb_items = 0;
int delta, len = sizeof(return_string);
@@ -1449,12 +1450,10 @@ void bgp_pbr_print_policy_route(struct bgp_pbr_entry_main *api)
struct prefix *p = &(api->src_prefix);
if (api->src_prefix_offset)
- delta = snprintf(ptr, len, "@src %s/off%u",
- prefix2str(p, buff, 64),
- api->src_prefix_offset);
+ delta = snprintfrr(ptr, len, "@src %pFX/off%u", p,
+ api->src_prefix_offset);
else
- delta = snprintf(ptr, len, "@src %s",
- prefix2str(p, buff, 64));
+ delta = snprintfrr(ptr, len, "@src %pFX", p);
len -= delta;
ptr += delta;
INCREMENT_DISPLAY(ptr, nb_items, len);
@@ -1464,12 +1463,10 @@ void bgp_pbr_print_policy_route(struct bgp_pbr_entry_main *api)
INCREMENT_DISPLAY(ptr, nb_items, len);
if (api->dst_prefix_offset)
- delta = snprintf(ptr, len, "@dst %s/off%u",
- prefix2str(p, buff, 64),
- api->dst_prefix_offset);
+ delta = snprintfrr(ptr, len, "@dst %pFX/off%u", p,
+ api->dst_prefix_offset);
else
- delta = snprintf(ptr, len, "@dst %s",
- prefix2str(p, buff, 64));
+ delta = snprintfrr(ptr, len, "@dst %pFX", p);
len -= delta;
ptr += delta;
}
diff --git a/bgpd/bgp_rd.c b/bgpd/bgp_rd.c
index 6ba56c7011..097ab9254e 100644
--- a/bgpd/bgp_rd.c
+++ b/bgpd/bgp_rd.c
@@ -29,6 +29,8 @@
#include "filter.h"
#include "frrstr.h"
+#include "lib/printfrr.h"
+
#include "bgpd/bgpd.h"
#include "bgpd/bgp_rd.h"
#include "bgpd/bgp_attr.h"
@@ -182,8 +184,7 @@ char *prefix_rd2str(const struct prefix_rd *prd, char *buf, size_t size)
return buf;
} else if (type == RD_TYPE_IP) {
decode_rd_ip(pnt + 2, &rd_ip);
- snprintf(buf, size, "%s:%hu", inet_ntoa(rd_ip.ip),
- rd_ip.val);
+ snprintfrr(buf, size, "%pI4:%hu", &rd_ip.ip, rd_ip.val);
return buf;
}
#ifdef ENABLE_BGP_VNC
@@ -210,6 +211,6 @@ void form_auto_rd(struct in_addr router_id,
prd->family = AF_UNSPEC;
prd->prefixlen = 64;
- snprintf(buf, sizeof(buf), "%s:%hu", inet_ntoa(router_id), rd_id);
+ snprintfrr(buf, sizeof(buf), "%pI4:%hu", &router_id, rd_id);
(void)str2prefix_rd(buf, prd);
}
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 1edcbc39b6..eba355fadd 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -224,7 +224,7 @@ void bgp_path_info_extra_free(struct bgp_path_info_extra **extra)
unsigned refcount;
bpi = bgp_path_info_lock(bpi);
- refcount = bpi->net->lock - 1;
+ refcount = bgp_dest_get_lock_count(bpi->net) - 1;
bgp_dest_unlock_node((struct bgp_dest *)bpi->net);
if (!refcount)
bpi->net = NULL;
@@ -731,18 +731,18 @@ static int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
*reason = bgp_path_selection_evpn_lower_ip;
if (debug)
zlog_debug(
- "%s: %s wins over %s due to same MM seq %u and lower IP %s",
+ "%s: %s wins over %s due to same MM seq %u and lower IP %pI4",
pfx_buf, new_buf, exist_buf, new_mm_seq,
- inet_ntoa(new->attr->nexthop));
+ &new->attr->nexthop);
return 1;
}
if (nh_cmp > 0) {
*reason = bgp_path_selection_evpn_lower_ip;
if (debug)
zlog_debug(
- "%s: %s loses to %s due to same MM seq %u and higher IP %s",
+ "%s: %s loses to %s due to same MM seq %u and higher IP %pI4",
pfx_buf, new_buf, exist_buf, new_mm_seq,
- inet_ntoa(new->attr->nexthop));
+ &new->attr->nexthop);
return 0;
}
}
@@ -2434,12 +2434,8 @@ void subgroup_process_announce_selected(struct update_subgroup *subgrp,
onlypeer = ((SUBGRP_PCOUNT(subgrp) == 1) ? (SUBGRP_PFIRST(subgrp))->peer
: NULL);
- if (BGP_DEBUG(update, UPDATE_OUT)) {
- char buf_prefix[PREFIX_STRLEN];
- prefix2str(p, buf_prefix, sizeof(buf_prefix));
- zlog_debug("%s: p=%s, selected=%p", __func__, buf_prefix,
- selected);
- }
+ if (BGP_DEBUG(update, UPDATE_OUT))
+ zlog_debug("%s: p=%pFX, selected=%p", __func__, p, selected);
/* First update is deferred until ORF or ROUTE-REFRESH is received */
if (onlypeer && CHECK_FLAG(onlypeer->af_sflags[afi][safi],
@@ -2943,18 +2939,21 @@ static void bgp_processq_del(struct work_queue *wq, void *data)
XFREE(MTYPE_BGP_PROCESS_QUEUE, pqnode);
}
-void bgp_process_queue_init(void)
+void bgp_process_queue_init(struct bgp *bgp)
{
- if (!bm->process_main_queue)
- bm->process_main_queue =
- work_queue_new(bm->master, "process_main_queue");
+ if (!bgp->process_queue) {
+ char name[BUFSIZ];
- bm->process_main_queue->spec.workfunc = &bgp_process_wq;
- bm->process_main_queue->spec.del_item_data = &bgp_processq_del;
- bm->process_main_queue->spec.max_retries = 0;
- bm->process_main_queue->spec.hold = 50;
+ snprintf(name, BUFSIZ, "process_queue %s", bgp->name_pretty);
+ bgp->process_queue = work_queue_new(bm->master, name);
+ }
+
+ bgp->process_queue->spec.workfunc = &bgp_process_wq;
+ bgp->process_queue->spec.del_item_data = &bgp_processq_del;
+ bgp->process_queue->spec.max_retries = 0;
+ bgp->process_queue->spec.hold = 50;
/* Use a higher yield value of 50ms for main queue processing */
- bm->process_main_queue->spec.yield = 50 * 1000L;
+ bgp->process_queue->spec.yield = 50 * 1000L;
}
static struct bgp_process_queue *bgp_processq_alloc(struct bgp *bgp)
@@ -2974,7 +2973,7 @@ static struct bgp_process_queue *bgp_processq_alloc(struct bgp *bgp)
void bgp_process(struct bgp *bgp, struct bgp_dest *dest, afi_t afi, safi_t safi)
{
#define ARBITRARY_PROCESS_QLEN 10000
- struct work_queue *wq = bm->process_main_queue;
+ struct work_queue *wq = bgp->process_queue;
struct bgp_process_queue *pqnode;
int pqnode_reuse = 0;
@@ -3031,13 +3030,13 @@ void bgp_add_eoiu_mark(struct bgp *bgp)
{
struct bgp_process_queue *pqnode;
- if (bm->process_main_queue == NULL)
+ if (bgp->process_queue == NULL)
return;
pqnode = bgp_processq_alloc(bgp);
SET_FLAG(pqnode->flags, BGP_PROCESS_QUEUE_EOIU_MARKER);
- work_queue_add(bm->process_main_queue, pqnode);
+ work_queue_add(bgp->process_queue, pqnode);
}
static int bgp_maximum_prefix_restart_timer(struct thread *thread)
@@ -4549,7 +4548,7 @@ static void bgp_clear_route_table(struct peer *peer, afi_t afi, safi_t safi,
struct bgp_table *table)
{
struct bgp_dest *dest;
- int force = bm->process_main_queue ? 0 : 1;
+ int force = peer->bgp->process_queue ? 0 : 1;
if (!table)
table = peer->bgp->rib[afi][safi];
@@ -4986,8 +4985,8 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr,
*/
flog_err(
EC_BGP_UPDATE_RCV,
- "%s: IPv4 unicast NLRI is multicast address %s, ignoring",
- peer->host, inet_ntoa(p.u.prefix4));
+ "%s: IPv4 unicast NLRI is multicast address %pI4, ignoring",
+ peer->host, &p.u.prefix4);
continue;
}
}
@@ -7768,13 +7767,10 @@ static void route_vty_out_route(const struct prefix *p, struct vty *vty,
json_object_string_add(json, "network", buf2);
}
} else if (p->family == AF_ETHERNET) {
- prefix2str(p, buf, PREFIX_STRLEN);
len = vty_out(vty, "%pFX", p);
} else if (p->family == AF_EVPN) {
if (!json)
- len = vty_out(vty, "%s",
- prefix2str((struct prefix_evpn *)p, buf,
- BUFSIZ));
+ len = vty_out(vty, "%pFX", (struct prefix_evpn *)p);
else
bgp_evpn_route2json((struct prefix_evpn *)p, json);
} else if (p->family == AF_FLOWSPEC) {
@@ -8030,10 +8026,14 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
}
} else if (safi == SAFI_EVPN) {
if (json_paths) {
+ char buf[BUFSIZ] = {0};
+
json_nexthop_global = json_object_new_object();
json_object_string_add(json_nexthop_global, "ip",
- inet_ntoa(attr->nexthop));
+ inet_ntop(AF_INET,
+ &attr->nexthop, buf,
+ sizeof(buf)));
if (path->peer->hostname)
json_object_string_add(json_nexthop_global,
@@ -8061,13 +8061,16 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
} else if (safi == SAFI_FLOWSPEC) {
if (attr->nexthop.s_addr != INADDR_ANY) {
if (json_paths) {
+ char buf[BUFSIZ] = {0};
+
json_nexthop_global = json_object_new_object();
json_object_string_add(json_nexthop_global,
"afi", "ipv4");
json_object_string_add(
json_nexthop_global, "ip",
- inet_ntoa(attr->nexthop));
+ inet_ntop(AF_INET, &attr->nexthop, buf,
+ sizeof(buf)));
if (path->peer->hostname)
json_object_string_add(
@@ -8097,10 +8100,14 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
}
} else if (p->family == AF_INET && !BGP_ATTR_NEXTHOP_AFI_IP6(attr)) {
if (json_paths) {
+ char buf[BUFSIZ] = {0};
+
json_nexthop_global = json_object_new_object();
json_object_string_add(json_nexthop_global, "ip",
- inet_ntoa(attr->nexthop));
+ inet_ntop(AF_INET,
+ &attr->nexthop, buf,
+ sizeof(buf)));
if (path->peer->hostname)
json_object_string_add(json_nexthop_global,
@@ -8408,18 +8415,24 @@ void route_vty_out_tmp(struct vty *vty, const struct prefix *p,
/* Print attribute */
if (attr) {
if (use_json) {
+ char buf[BUFSIZ] = {0};
+
if (p->family == AF_INET
&& (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) {
if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP)
json_object_string_add(
json_net, "nextHop",
- inet_ntoa(
- attr->mp_nexthop_global_in));
+ inet_ntop(
+ AF_INET,
+ &attr->mp_nexthop_global_in,
+ buf, sizeof(buf)));
else
json_object_string_add(
json_net, "nextHop",
- inet_ntoa(attr->nexthop));
+ inet_ntop(AF_INET,
+ &attr->nexthop, buf,
+ sizeof(buf)));
} else if (p->family == AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr)) {
char buf[BUFSIZ];
@@ -8429,11 +8442,16 @@ void route_vty_out_tmp(struct vty *vty, const struct prefix *p,
inet_ntop(AF_INET6,
&attr->mp_nexthop_global, buf,
BUFSIZ));
- } else if (p->family == AF_EVPN &&
- !BGP_ATTR_NEXTHOP_AFI_IP6(attr))
- json_object_string_add(json_net,
- "nextHop", inet_ntoa(
- attr->mp_nexthop_global_in));
+ } else if (p->family == AF_EVPN
+ && !BGP_ATTR_NEXTHOP_AFI_IP6(attr)) {
+ char buf[BUFSIZ] = {0};
+
+ json_object_string_add(
+ json_net, "nextHop",
+ inet_ntop(AF_INET,
+ &attr->mp_nexthop_global_in,
+ buf, sizeof(buf)));
+ }
if (attr->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
@@ -8461,15 +8479,12 @@ void route_vty_out_tmp(struct vty *vty, const struct prefix *p,
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) {
if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP
|| safi == SAFI_EVPN)
- vty_out(vty, "%-16s",
- inet_ntoa(
- attr->mp_nexthop_global_in));
+ vty_out(vty, "%-16pI4",
+ &attr->mp_nexthop_global_in);
else if (wide)
- vty_out(vty, "%-41s",
- inet_ntoa(attr->nexthop));
+ vty_out(vty, "%-41pI4", &attr->nexthop);
else
- vty_out(vty, "%-16s",
- inet_ntoa(attr->nexthop));
+ vty_out(vty, "%-16pI4", &attr->nexthop);
} else if (p->family == AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr)) {
char buf[BUFSIZ];
@@ -8554,22 +8569,27 @@ void route_vty_out_tag(struct vty *vty, const struct prefix *p,
&& ((safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP)))
|| (safi == SAFI_EVPN && !BGP_ATTR_NEXTHOP_AFI_IP6(attr))
|| (!BGP_ATTR_NEXTHOP_AFI_IP6(attr))) {
+ char buf[BUFSIZ] = {0};
+
if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP
|| safi == SAFI_EVPN) {
if (json)
json_object_string_add(
json_out, "mpNexthopGlobalIn",
- inet_ntoa(attr->mp_nexthop_global_in));
+ inet_ntop(AF_INET,
+ &attr->mp_nexthop_global_in,
+ buf, sizeof(buf)));
else
- vty_out(vty, "%-16s",
- inet_ntoa(attr->mp_nexthop_global_in));
+ vty_out(vty, "%-16pI4",
+ &attr->mp_nexthop_global_in);
} else {
if (json)
json_object_string_add(
json_out, "nexthop",
- inet_ntoa(attr->nexthop));
+ inet_ntop(AF_INET, &attr->nexthop, buf,
+ sizeof(buf)));
else
- vty_out(vty, "%-16s", inet_ntoa(attr->nexthop));
+ vty_out(vty, "%-16pI4", &attr->nexthop);
}
} else if (((p->family == AF_INET6)
&& ((safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP)))
@@ -9078,7 +9098,6 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
{
char buf[INET6_ADDRSTRLEN];
char buf1[BUFSIZ];
- char buf2[EVPN_ROUTE_STRLEN];
struct attr *attr = path->attr;
int sockunion_vty_out(struct vty *, union sockunion *);
time_t tbuf;
@@ -9116,7 +9135,6 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
if (path->extra) {
char tag_buf[30];
- buf2[0] = '\0';
tag_buf[0] = '\0';
if (path->extra && path->extra->num_labels) {
bgp_evpn_label2str(path->extra->label,
@@ -9125,10 +9143,9 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
}
if (safi == SAFI_EVPN) {
if (!json_paths) {
- prefix2str((struct prefix_evpn *)
- bgp_dest_get_prefix(bn),
- buf2, sizeof(buf2));
- vty_out(vty, " Route %s", buf2);
+ vty_out(vty, " Route %pFX",
+ (struct prefix_evpn *)
+ bgp_dest_get_prefix(bn));
if (tag_buf[0] != '\0')
vty_out(vty, " VNI %s", tag_buf);
vty_out(vty, "\n");
@@ -9152,13 +9169,20 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
pdest),
buf1, sizeof(buf1));
if (is_pi_family_evpn(parent_ri)) {
- prefix2str((struct prefix_evpn *)
- bgp_dest_get_prefix(
- dest),
- buf2, sizeof(buf2));
- vty_out(vty, " Imported from %s:%s, VNI %s\n", buf1, buf2, tag_buf);
+ vty_out(vty,
+ " Imported from %s:%pFX, VNI %s\n",
+ buf1,
+ (struct prefix_evpn *)
+ bgp_dest_get_prefix(
+ dest),
+ tag_buf);
} else
- vty_out(vty, " Imported from %s:%s\n", buf1, buf2);
+ vty_out(vty,
+ " Imported from %s:%pFX\n",
+ buf1,
+ (struct prefix_evpn *)
+ bgp_dest_get_prefix(
+ dest));
}
}
}
@@ -9195,11 +9219,14 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR))) {
if (json_paths) {
+ char buf[BUFSIZ] = {0};
+
json_object_int_add(json_path, "aggregatorAs",
attr->aggregator_as);
- json_object_string_add(
- json_path, "aggregatorId",
- inet_ntoa(attr->aggregator_addr));
+ json_object_string_add(json_path, "aggregatorId",
+ inet_ntop(AF_INET,
+ &attr->aggregator_addr,
+ buf, sizeof(buf)));
if (attr->aggregator_as == BGP_AS_ZERO)
json_object_boolean_true_add(
json_path, "aggregatorAsMalformed");
@@ -9209,13 +9236,13 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
} else {
if (attr->aggregator_as == BGP_AS_ZERO)
vty_out(vty,
- ", (aggregated by %u(malformed) %s)",
+ ", (aggregated by %u(malformed) %pI4)",
attr->aggregator_as,
- inet_ntoa(attr->aggregator_addr));
+ &attr->aggregator_addr);
else
- vty_out(vty, ", (aggregated by %u %s)",
+ vty_out(vty, ", (aggregated by %u %pI4)",
attr->aggregator_as,
- inet_ntoa(attr->aggregator_addr));
+ &attr->aggregator_addr);
}
}
@@ -9262,12 +9289,16 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
|| bn_p->family == AF_EVPN)
&& (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP || safi == SAFI_EVPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) {
+ char buf[BUFSIZ] = {0};
+
if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP
|| safi == SAFI_EVPN) {
if (json_paths) {
json_object_string_add(
json_nexthop_global, "ip",
- inet_ntoa(attr->mp_nexthop_global_in));
+ inet_ntop(AF_INET,
+ &attr->mp_nexthop_global_in,
+ buf, sizeof(buf)));
if (path->peer->hostname)
json_object_string_add(
@@ -9286,7 +9317,8 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
if (json_paths) {
json_object_string_add(
json_nexthop_global, "ip",
- inet_ntoa(attr->nexthop));
+ inet_ntop(AF_INET, &attr->nexthop, buf,
+ sizeof(buf)));
if (path->peer->hostname)
json_object_string_add(
@@ -9383,11 +9415,16 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
vty_out(vty, " from :: ");
}
- if (json_paths)
+ if (json_paths) {
+ char buf[BUFSIZ] = {0};
+
json_object_string_add(json_peer, "routerId",
- inet_ntoa(bgp->router_id));
- else
- vty_out(vty, "(%s)", inet_ntoa(bgp->router_id));
+ inet_ntop(AF_INET,
+ &bgp->router_id, buf,
+ sizeof(buf)));
+ } else {
+ vty_out(vty, "(%pI4)", &bgp->router_id);
+ }
}
/* We RXed this path from one of our peers */
@@ -9440,8 +9477,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
}
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
- vty_out(vty, " (%s)",
- inet_ntoa(attr->originator_id));
+ vty_out(vty, " (%pI4)", &attr->originator_id);
else
vty_out(vty, " (%s)",
inet_ntop(AF_INET,
@@ -9751,14 +9787,17 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
/* Line 7 display Originator, Cluster-id */
if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
|| (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) {
+ char buf[BUFSIZ] = {0};
+
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) {
if (json_paths)
json_object_string_add(
json_path, "originatorId",
- inet_ntoa(attr->originator_id));
+ inet_ntop(AF_INET, &attr->originator_id,
+ buf, sizeof(buf)));
else
- vty_out(vty, " Originator: %s",
- inet_ntoa(attr->originator_id));
+ vty_out(vty, " Originator: %pI4",
+ &attr->originator_id);
}
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) {
@@ -9772,8 +9811,10 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
for (i = 0; i < attr->cluster->length / 4;
i++) {
json_string = json_object_new_string(
- inet_ntoa(attr->cluster
- ->list[i]));
+ inet_ntop(
+ AF_INET,
+ &attr->cluster->list[i],
+ buf, sizeof(buf)));
json_object_array_add(
json_cluster_list_list,
json_string);
@@ -9797,9 +9838,8 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
for (i = 0; i < attr->cluster->length / 4;
i++) {
- vty_out(vty, "%s ",
- inet_ntoa(attr->cluster
- ->list[i]));
+ vty_out(vty, "%pI4 ",
+ &attr->cluster->list[i]);
}
}
}
@@ -10023,13 +10063,14 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
}
vty_out(vty,
- " \"vrfId\": %d,\n \"vrfName\": \"%s\",\n \"tableVersion\": %" PRId64",\n \"routerId\": \"%s\",\n \"defaultLocPrf\": %u,\n"
+ " \"vrfId\": %d,\n \"vrfName\": \"%s\",\n \"tableVersion\": %" PRId64
+ ",\n \"routerId\": \"%pI4\",\n \"defaultLocPrf\": %u,\n"
" \"localAS\": %u,\n \"routes\": { ",
bgp->vrf_id == VRF_UNKNOWN ? -1 : (int)bgp->vrf_id,
bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT
- ? VRF_DEFAULT_NAME
- : bgp->name,
- table->version, inet_ntoa(bgp->router_id),
+ ? VRF_DEFAULT_NAME
+ : bgp->name,
+ table->version, &bgp->router_id,
bgp->default_local_pref, bgp->as);
if (rd) {
vty_out(vty, " \"routeDistinguishers\" : {");
@@ -10207,9 +10248,10 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
}
if (!use_json && header) {
- vty_out(vty, "BGP table version is %" PRIu64", local router ID is %s, vrf id ",
- table->version,
- inet_ntoa(bgp->router_id));
+ vty_out(vty,
+ "BGP table version is %" PRIu64
+ ", local router ID is %pI4, vrf id ",
+ table->version, &bgp->router_id);
if (bgp->vrf_id == VRF_UNKNOWN)
vty_out(vty, "%s", VRFID_NONE_STR);
else
@@ -10472,7 +10514,6 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
struct peer *peer;
struct listnode *node, *nnode;
char buf1[RD_ADDRSTRLEN];
- char buf3[EVPN_ROUTE_STRLEN];
char prefix_str[BUFSIZ];
int count = 0;
int best = 0;
@@ -10504,12 +10545,10 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
if (safi == SAFI_EVPN) {
if (!json) {
- vty_out(vty, "BGP routing table entry for %s%s%s\n",
+ vty_out(vty, "BGP routing table entry for %s%s%pFX\n",
prd ? prefix_rd2str(prd, buf1, sizeof(buf1))
: "",
- prd ? ":" : "",
- prefix2str((struct prefix_evpn *)p, buf3,
- sizeof(buf3)));
+ prd ? ":" : "", (struct prefix_evpn *)p);
} else {
json_object_string_add(json, "rd",
prd ? prefix_rd2str(prd, buf1, sizeof(buf1)) :
@@ -12541,12 +12580,15 @@ static void show_adj_route_header(struct vty *vty, struct bgp *bgp,
json_object *json_ocode, bool wide)
{
uint64_t version = table ? table->version : 0;
+ char buf[BUFSIZ] = {0};
if (*header1) {
if (json) {
json_object_int_add(json, "bgpTableVersion", version);
json_object_string_add(json, "bgpLocalRouterId",
- inet_ntoa(bgp->router_id));
+ inet_ntop(AF_INET,
+ &bgp->router_id, buf,
+ sizeof(buf)));
json_object_int_add(json, "defaultLocPrf",
bgp->default_local_pref);
json_object_int_add(json, "localAS", bgp->as);
@@ -12556,8 +12598,9 @@ static void show_adj_route_header(struct vty *vty, struct bgp *bgp,
json_ocode);
} else {
vty_out(vty,
- "BGP table version is %" PRIu64 ", local router ID is %s, vrf id ",
- version, inet_ntoa(bgp->router_id));
+ "BGP table version is %" PRIu64
+ ", local router ID is %pI4, vrf id ",
+ version, &bgp->router_id);
if (bgp->vrf_id == VRF_UNKNOWN)
vty_out(vty, "%s", VRFID_NONE_STR);
else
@@ -12649,11 +12692,15 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
if (type == bgp_show_adj_route_advertised && subgrp
&& CHECK_FLAG(subgrp->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) {
+ char buf[BUFSIZ] = {0};
+
if (use_json) {
json_object_int_add(json, "bgpTableVersion",
table->version);
json_object_string_add(json, "bgpLocalRouterId",
- inet_ntoa(bgp->router_id));
+ inet_ntop(AF_INET,
+ &bgp->router_id, buf,
+ sizeof(buf)));
json_object_int_add(json, "defaultLocPrf",
bgp->default_local_pref);
json_object_int_add(json, "localAS", bgp->as);
@@ -12665,8 +12712,10 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
json, "bgpOriginatingDefaultNetwork",
(afi == AFI_IP) ? "0.0.0.0/0" : "::/0");
} else {
- vty_out(vty, "BGP table version is %" PRIu64", local router ID is %s, vrf id ",
- table->version, inet_ntoa(bgp->router_id));
+ vty_out(vty,
+ "BGP table version is %" PRIu64
+ ", local router ID is %pI4, vrf id ",
+ table->version, &bgp->router_id);
if (bgp->vrf_id == VRF_UNKNOWN)
vty_out(vty, "%s", VRFID_NONE_STR);
else
diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h
index b3efbbafd8..4a4959298a 100644
--- a/bgpd/bgp_route.h
+++ b/bgpd/bgp_route.h
@@ -532,7 +532,7 @@ DECLARE_HOOK(bgp_process,
/* Prototypes. */
extern void bgp_rib_remove(struct bgp_dest *dest, struct bgp_path_info *pi,
struct peer *peer, afi_t afi, safi_t safi);
-extern void bgp_process_queue_init(void);
+extern void bgp_process_queue_init(struct bgp *bgp);
extern void bgp_route_init(void);
extern void bgp_route_finish(void);
extern void bgp_cleanup_routes(struct bgp *);
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index 5065940967..c655743936 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -4053,32 +4053,64 @@ DEFUN (no_match_mac_address,
RMAP_EVENT_FILTER_DELETED);
}
+/*
+ * Helper to handle the case of the user passing in a number or type string
+ */
+static const char *parse_evpn_rt_type(const char *num_rt_type)
+{
+ switch (num_rt_type[0]) {
+ case '1':
+ return "ead";
+ case '2':
+ return "macip";
+ case '3':
+ return "multicast";
+ case '4':
+ return "es";
+ case '5':
+ return "prefix";
+ default:
+ break;
+ }
+
+ /* Was already full type string */
+ return num_rt_type;
+}
+
DEFUN (match_evpn_route_type,
match_evpn_route_type_cmd,
- "match evpn route-type <macip | multicast | prefix>",
+ "match evpn route-type <macip|2|multicast|3|prefix|5>",
MATCH_STR
EVPN_HELP_STR
- "Match route-type\n"
- "mac-ip route\n"
- "IMET route\n"
- "prefix route\n")
-{
- return bgp_route_match_add(vty, "evpn route-type", argv[3]->arg,
+ EVPN_TYPE_HELP_STR
+ EVPN_TYPE_2_HELP_STR
+ EVPN_TYPE_2_HELP_STR
+ EVPN_TYPE_3_HELP_STR
+ EVPN_TYPE_3_HELP_STR
+ EVPN_TYPE_5_HELP_STR
+ EVPN_TYPE_5_HELP_STR)
+{
+ return bgp_route_match_add(vty, "evpn route-type",
+ parse_evpn_rt_type(argv[3]->arg),
RMAP_EVENT_MATCH_ADDED);
}
DEFUN (no_match_evpn_route_type,
no_match_evpn_route_type_cmd,
- "no match evpn route-type <macip | multicast | prefix>",
+ "no match evpn route-type <macip|2|multicast|3|prefix|5>",
NO_STR
MATCH_STR
EVPN_HELP_STR
- "Match route-type\n"
- "mac-ip route\n"
- "IMET route\n"
- "prefix route\n")
-{
- return bgp_route_match_delete(vty, "evpn route-type", argv[4]->arg,
+ EVPN_TYPE_HELP_STR
+ EVPN_TYPE_2_HELP_STR
+ EVPN_TYPE_2_HELP_STR
+ EVPN_TYPE_3_HELP_STR
+ EVPN_TYPE_3_HELP_STR
+ EVPN_TYPE_5_HELP_STR
+ EVPN_TYPE_5_HELP_STR)
+{
+ return bgp_route_match_delete(vty, "evpn route-type",
+ parse_evpn_rt_type(argv[4]->arg),
RMAP_EVENT_MATCH_DELETED);
}
diff --git a/bgpd/bgp_rpki.c b/bgpd/bgp_rpki.c
index ca47fb316a..0f0aff7eaa 100644
--- a/bgpd/bgp_rpki.c
+++ b/bgpd/bgp_rpki.c
@@ -702,8 +702,6 @@ static int rpki_validate_prefix(struct peer *peer, struct attr *attr,
as_t as_number = 0;
struct lrtr_ip_addr ip_addr_prefix;
enum pfxv_state result;
- char buf[BUFSIZ];
- const char *prefix_string;
if (!is_synchronized())
return 0;
@@ -754,27 +752,26 @@ static int rpki_validate_prefix(struct peer *peer, struct attr *attr,
prefix->prefixlen, &result);
// Print Debug output
- prefix_string = prefix2str(prefix, buf, sizeof(buf));
switch (result) {
case BGP_PFXV_STATE_VALID:
RPKI_DEBUG(
- "Validating Prefix %s from asn %u Result: VALID",
- prefix_string, as_number);
+ "Validating Prefix %pFX from asn %u Result: VALID",
+ prefix, as_number);
return RPKI_VALID;
case BGP_PFXV_STATE_NOT_FOUND:
RPKI_DEBUG(
- "Validating Prefix %s from asn %u Result: NOT FOUND",
- prefix_string, as_number);
+ "Validating Prefix %pFX from asn %u Result: NOT FOUND",
+ prefix, as_number);
return RPKI_NOTFOUND;
case BGP_PFXV_STATE_INVALID:
RPKI_DEBUG(
- "Validating Prefix %s from asn %u Result: INVALID",
- prefix_string, as_number);
+ "Validating Prefix %pFX from asn %u Result: INVALID",
+ prefix, as_number);
return RPKI_INVALID;
default:
RPKI_DEBUG(
- "Validating Prefix %s from asn %u Result: CANNOT VALIDATE",
- prefix_string, as_number);
+ "Validating Prefix %pFX from asn %u Result: CANNOT VALIDATE",
+ prefix, as_number);
break;
}
return 0;
diff --git a/bgpd/bgp_table.h b/bgpd/bgp_table.h
index 31ea5554d5..9dd27628ce 100644
--- a/bgpd/bgp_table.h
+++ b/bgpd/bgp_table.h
@@ -469,6 +469,11 @@ static inline const struct prefix *bgp_dest_get_prefix(const struct bgp_dest *de
return &dest->p;
}
+static inline unsigned int bgp_dest_get_lock_count(const struct bgp_dest *dest)
+{
+ return dest->lock;
+}
+
#ifdef _FRR_ATTRIBUTE_PRINTFRR
#pragma FRR printfrr_ext "%pRN" (struct bgp_node *)
#pragma FRR printfrr_ext "%pBD" (struct bgp_dest *)
diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c
index 67fa9a3ea3..2e59bb3a5f 100644
--- a/bgpd/bgp_updgrp_adv.c
+++ b/bgpd/bgp_updgrp_adv.c
@@ -246,9 +246,10 @@ static void subgrp_show_adjq_vty(struct update_subgroup *subgrp,
if (adj->subgroup == subgrp) {
if (header1) {
vty_out(vty,
- "BGP table version is %" PRIu64", local router ID is %s\n",
+ "BGP table version is %" PRIu64
+ ", local router ID is %pI4\n",
table->version,
- inet_ntoa(bgp->router_id));
+ &bgp->router_id);
vty_out(vty, BGP_SHOW_SCODE_HEADER);
vty_out(vty, BGP_SHOW_OCODE_HEADER);
header1 = 0;
diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c
index f706b834fe..c3edb9e9a4 100644
--- a/bgpd/bgp_updgrp_packet.c
+++ b/bgpd/bgp_updgrp_packet.c
@@ -488,10 +488,10 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
stream_put_in_addr_at(s, offset_nh, mod_v4nh);
if (bgp_debug_update(peer, NULL, NULL, 0))
- zlog_debug("u%" PRIu64 ":s%" PRIu64" %s send UPDATE w/ nexthop %s%s",
+ zlog_debug("u%" PRIu64 ":s%" PRIu64
+ " %s send UPDATE w/ nexthop %pI4%s",
PAF_SUBGRP(paf)->update_group->id,
- PAF_SUBGRP(paf)->id, peer->host,
- inet_ntoa(*mod_v4nh),
+ PAF_SUBGRP(paf)->id, peer->host, mod_v4nh,
(nhlen == BGP_ATTR_NHLEN_VPNV4 ? " and RD"
: ""));
} else if (nhafi == AFI_IP6) {
@@ -642,10 +642,10 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
stream_put_in_addr_at(s, vec->offset + 1, mod_v4nh);
if (bgp_debug_update(peer, NULL, NULL, 0))
- zlog_debug("u%" PRIu64 ":s%" PRIu64" %s send UPDATE w/ nexthop %s",
+ zlog_debug("u%" PRIu64 ":s%" PRIu64
+ " %s send UPDATE w/ nexthop %pI4",
PAF_SUBGRP(paf)->update_group->id,
- PAF_SUBGRP(paf)->id, peer->host,
- inet_ntoa(*mod_v4nh));
+ PAF_SUBGRP(paf)->id, peer->host, mod_v4nh);
}
return s;
@@ -1137,7 +1137,6 @@ void subgroup_default_update_packet(struct update_subgroup *subgrp,
/* Logging the attribute. */
if (bgp_debug_update(NULL, &p, subgrp->update_group, 0)) {
char attrstr[BUFSIZ];
- char buf[PREFIX_STRLEN];
/* ' with addpath ID ' 17
* max strlen of uint32 + 10
* +/- (just in case) + 1
@@ -1156,10 +1155,9 @@ void subgroup_default_update_packet(struct update_subgroup *subgrp,
else
tx_id_buf[0] = '\0';
- zlog_debug("u%" PRIu64 ":s%" PRIu64 " send UPDATE %s%s %s",
- (SUBGRP_UPDGRP(subgrp))->id, subgrp->id,
- prefix2str(&p, buf, sizeof(buf)), tx_id_buf,
- attrstr);
+ zlog_debug("u%" PRIu64 ":s%" PRIu64 " send UPDATE %pFX%s %s",
+ (SUBGRP_UPDGRP(subgrp))->id, subgrp->id, &p,
+ tx_id_buf, attrstr);
}
s = stream_new(BGP_MAX_PACKET_SIZE);
@@ -1222,7 +1220,6 @@ void subgroup_default_withdraw_packet(struct update_subgroup *subgrp)
p.prefixlen = 0;
if (bgp_debug_update(NULL, &p, subgrp->update_group, 0)) {
- char buf[PREFIX_STRLEN];
/* ' with addpath ID ' 17
* max strlen of uint32 + 10
* +/- (just in case) + 1
@@ -1235,9 +1232,10 @@ void subgroup_default_withdraw_packet(struct update_subgroup *subgrp)
" with addpath ID %u",
BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE);
- zlog_debug("u%" PRIu64 ":s%" PRIu64" send UPDATE %s%s -- unreachable",
- (SUBGRP_UPDGRP(subgrp))->id, subgrp->id,
- prefix2str(&p, buf, sizeof(buf)), tx_id_buf);
+ zlog_debug("u%" PRIu64 ":s%" PRIu64
+ " send UPDATE %pFX%s -- unreachable",
+ (SUBGRP_UPDGRP(subgrp))->id, subgrp->id, &p,
+ tx_id_buf);
}
s = stream_new(BGP_MAX_PACKET_SIZE);
diff --git a/bgpd/bgp_vpn.c b/bgpd/bgp_vpn.c
index 0b5d156e6d..cb459ae13c 100644
--- a/bgpd/bgp_vpn.c
+++ b/bgpd/bgp_vpn.c
@@ -22,6 +22,7 @@
#include "command.h"
#include "prefix.h"
#include "lib/json.h"
+#include "lib/printfrr.h"
#include "bgpd/bgpd.h"
#include "bgpd/bgp_route.h"
@@ -117,11 +118,15 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer,
if (header) {
if (use_json) {
+ char buf[BUFSIZ] = {0};
+
json_object_int_add(
json, "bgpTableVersion", 0);
json_object_string_add(
json, "bgpLocalRouterId",
- inet_ntoa(bgp->router_id));
+ inet_ntop(AF_INET,
+ &bgp->router_id, buf,
+ sizeof(buf)));
json_object_int_add(
json,
"defaultLocPrf",
@@ -137,8 +142,8 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer,
json_ocode);
} else {
vty_out(vty,
- "BGP table version is 0, local router ID is %s\n",
- inet_ntoa(bgp->router_id));
+ "BGP table version is 0, local router ID is %pI4\n",
+ &bgp->router_id);
vty_out(vty, "Default local pref %u, ",
bgp->default_local_pref);
vty_out(vty, "local AS %u\n", bgp->as);
@@ -184,10 +189,10 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer,
"%u:%d", rd_as.as,
rd_as.val);
else if (type == RD_TYPE_IP)
- snprintf(rd_str, sizeof(rd_str),
- "%s:%d",
- inet_ntoa(rd_ip.ip),
- rd_ip.val);
+ snprintfrr(rd_str,
+ sizeof(rd_str),
+ "%pI4:%d", &rd_ip.ip,
+ rd_ip.val);
json_object_string_add(
json_routes,
"rd", rd_str);
@@ -199,9 +204,8 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer,
vty_out(vty, "%u:%d", rd_as.as,
rd_as.val);
else if (type == RD_TYPE_IP)
- vty_out(vty, "%s:%d",
- inet_ntoa(rd_ip.ip),
- rd_ip.val);
+ vty_out(vty, "%pI4:%d",
+ &rd_ip.ip, rd_ip.val);
#ifdef ENABLE_BGP_VNC
else if (type == RD_TYPE_VNC_ETH)
vty_out(vty,
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index c8a3c28523..087836425b 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -3883,7 +3883,6 @@ void bgp_config_write_listen(struct vty *vty, struct bgp *bgp)
struct listnode *node, *nnode, *rnode, *nrnode;
struct prefix *range;
afi_t afi;
- char buf[PREFIX2STR_BUFFER];
if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT)
vty_out(vty, " bgp listen limit %d\n",
@@ -3893,10 +3892,9 @@ void bgp_config_write_listen(struct vty *vty, struct bgp *bgp)
for (afi = AFI_IP; afi < AFI_MAX; afi++) {
for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode,
nrnode, range)) {
- prefix2str(range, buf, sizeof(buf));
vty_out(vty,
- " bgp listen range %s peer-group %s\n",
- buf, group->name);
+ " bgp listen range %pFX peer-group %s\n",
+ range, group->name);
}
}
}
@@ -9079,10 +9077,14 @@ DEFUN (show_bgp_vrfs,
int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN)
? -1
: (int64_t)bgp->vrf_id;
+ char buf[BUFSIZ] = {0};
+
json_object_string_add(json_vrf, "type", type);
json_object_int_add(json_vrf, "vrfId", vrf_id_ui);
json_object_string_add(json_vrf, "routerId",
- inet_ntoa(bgp->router_id));
+ inet_ntop(AF_INET,
+ &bgp->router_id, buf,
+ sizeof(buf)));
json_object_int_add(json_vrf, "numConfiguredPeers",
peers_cfg);
json_object_int_add(json_vrf, "numEstablishedPeers",
@@ -9097,13 +9099,11 @@ DEFUN (show_bgp_vrfs,
bgp->vrf_id));
json_object_object_add(json_vrfs, name, json_vrf);
} else {
- vty_out(vty,
- "%4s %-5d %-16s %-9u %-10u %-37s\n",
+ vty_out(vty, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
type,
bgp->vrf_id == VRF_UNKNOWN ? -1
: (int)bgp->vrf_id,
- inet_ntoa(bgp->router_id), peers_cfg,
- peers_estb, name);
+ &bgp->router_id, peers_cfg, peers_estb, name);
vty_out(vty,"%11s %-16u %-21s %-20s\n", " ",
bgp->l3vni,
prefix_mac2str(&bgp->rmac, buf, sizeof(buf)),
@@ -9148,8 +9148,7 @@ static void show_tip_entry(struct hash_bucket *bucket, void *args)
struct vty *vty = (struct vty *)args;
struct tip_addr *tip = (struct tip_addr *)bucket->data;
- vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(tip->addr),
- tip->refcnt);
+ vty_out(vty, "addr: %pI4, count: %d\n", &tip->addr, tip->refcnt);
}
static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp)
@@ -9614,9 +9613,12 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
/* Usage summary and header */
if (use_json) {
+ char buf[BUFSIZ] = {0};
+
json_object_string_add(
json, "routerId",
- inet_ntoa(bgp->router_id));
+ inet_ntop(AF_INET, &bgp->router_id, buf,
+ sizeof(buf)));
json_object_int_add(json, "as", bgp->as);
json_object_int_add(json, "vrfId", vrf_id_ui);
json_object_string_add(
@@ -9627,8 +9629,8 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
: bgp->name);
} else {
vty_out(vty,
- "BGP router identifier %s, local AS number %u vrf-id %d",
- inet_ntoa(bgp->router_id), bgp->as,
+ "BGP router identifier %pI4, local AS number %u vrf-id %d",
+ &bgp->router_id, bgp->as,
bgp->vrf_id == VRF_UNKNOWN
? -1
: (int)bgp->vrf_id);
@@ -14108,7 +14110,6 @@ static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group)
struct prefix *range;
struct peer *conf;
struct peer *peer;
- char buf[PREFIX2STR_BUFFER];
afi_t afi;
safi_t safi;
const char *peer_status;
@@ -14162,10 +14163,8 @@ static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group)
for (ALL_LIST_ELEMENTS(group->listen_range[afi], node,
- nnode, range)) {
- prefix2str(range, buf, sizeof(buf));
- vty_out(vty, " %s\n", buf);
- }
+ nnode, range))
+ vty_out(vty, " %pFX\n", range);
}
}
@@ -15892,8 +15891,8 @@ int bgp_config_write(struct vty *vty)
/* BGP router ID. */
if (bgp->router_id_static.s_addr != 0)
- vty_out(vty, " bgp router-id %s\n",
- inet_ntoa(bgp->router_id_static));
+ vty_out(vty, " bgp router-id %pI4\n",
+ &bgp->router_id_static);
/* BGP log-neighbor-changes. */
if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES)
@@ -15959,8 +15958,8 @@ int bgp_config_write(struct vty *vty)
/* BGP cluster ID. */
if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID))
- vty_out(vty, " bgp cluster-id %s\n",
- inet_ntoa(bgp->cluster_id));
+ vty_out(vty, " bgp cluster-id %pI4\n",
+ &bgp->cluster_id);
/* Disable ebgp connected nexthop check */
if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK))
@@ -17933,9 +17932,10 @@ DEFUN (no_community_list_expanded_all,
return CMD_SUCCESS;
}
-ALIAS(no_community_list_expanded_all, no_bgp_community_list_expanded_all_list_cmd,
+ALIAS(no_community_list_expanded_all,
+ no_bgp_community_list_expanded_all_list_cmd,
"no bgp community-list <(100-500)|expanded WORD>",
- NO_STR IP_STR COMMUNITY_LIST_STR
+ NO_STR BGP_STR COMMUNITY_LIST_STR
"Community list number (expanded)\n"
"Add an expanded community-list entry\n"
"Community list name\n")
@@ -18554,7 +18554,7 @@ DEFUN (no_extcommunity_list_standard_all,
ALIAS(no_extcommunity_list_standard_all,
no_bgp_extcommunity_list_standard_all_list_cmd,
"no bgp extcommunity-list <(1-99)|standard WORD>",
- NO_STR IP_STR EXTCOMMUNITY_LIST_STR
+ NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
"Extended Community list number (standard)\n"
"Specify standard extcommunity-list\n"
"Community list name\n")
@@ -18619,7 +18619,7 @@ DEFUN (no_extcommunity_list_expanded_all,
ALIAS(no_extcommunity_list_expanded_all,
no_bgp_extcommunity_list_expanded_all_list_cmd,
"no bgp extcommunity-list <(100-500)|expanded WORD>",
- NO_STR IP_STR EXTCOMMUNITY_LIST_STR
+ NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
"Extended Community list number (expanded)\n"
"Specify expanded extcommunity-list\n"
"Extended Community list name\n")
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index 1ee8a1a50b..d4a69af4f7 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -91,11 +91,9 @@ static int bgp_router_id_update(ZAPI_CALLBACK_ARGS)
zebra_router_id_update_read(zclient->ibuf, &router_id);
- if (BGP_DEBUG(zebra, ZEBRA)) {
- char buf[PREFIX2STR_BUFFER];
- prefix2str(&router_id, buf, sizeof(buf));
- zlog_debug("Rx Router Id update VRF %u Id %s", vrf_id, buf);
- }
+ if (BGP_DEBUG(zebra, ZEBRA))
+ zlog_debug("Rx Router Id update VRF %u Id %pFX", vrf_id,
+ &router_id);
bgp_router_id_zebra_bump(vrf_id, &router_id);
return 0;
@@ -313,12 +311,9 @@ static int bgp_interface_address_add(ZAPI_CALLBACK_ARGS)
if (ifc == NULL)
return 0;
- if (bgp_debug_zebra(ifc->address)) {
- char buf[PREFIX2STR_BUFFER];
- prefix2str(ifc->address, buf, sizeof(buf));
- zlog_debug("Rx Intf address add VRF %u IF %s addr %s", vrf_id,
- ifc->ifp->name, buf);
- }
+ if (bgp_debug_zebra(ifc->address))
+ zlog_debug("Rx Intf address add VRF %u IF %s addr %pFX", vrf_id,
+ ifc->ifp->name, ifc->address);
if (!bgp)
return 0;
@@ -350,12 +345,9 @@ static int bgp_interface_address_delete(ZAPI_CALLBACK_ARGS)
if (ifc == NULL)
return 0;
- if (bgp_debug_zebra(ifc->address)) {
- char buf[PREFIX2STR_BUFFER];
- prefix2str(ifc->address, buf, sizeof(buf));
- zlog_debug("Rx Intf address del VRF %u IF %s addr %s", vrf_id,
- ifc->ifp->name, buf);
- }
+ if (bgp_debug_zebra(ifc->address))
+ zlog_debug("Rx Intf address del VRF %u IF %s addr %pFX", vrf_id,
+ ifc->ifp->name, ifc->address);
if (bgp && if_is_operative(ifc->ifp)) {
bgp_connected_delete(bgp, ifc);
@@ -376,12 +368,9 @@ static int bgp_interface_nbr_address_add(ZAPI_CALLBACK_ARGS)
if (ifc == NULL)
return 0;
- if (bgp_debug_zebra(ifc->address)) {
- char buf[PREFIX2STR_BUFFER];
- prefix2str(ifc->address, buf, sizeof(buf));
- zlog_debug("Rx Intf neighbor add VRF %u IF %s addr %s", vrf_id,
- ifc->ifp->name, buf);
- }
+ if (bgp_debug_zebra(ifc->address))
+ zlog_debug("Rx Intf neighbor add VRF %u IF %s addr %pFX",
+ vrf_id, ifc->ifp->name, ifc->address);
if (if_is_operative(ifc->ifp)) {
bgp = bgp_lookup_by_vrf_id(vrf_id);
@@ -402,12 +391,9 @@ static int bgp_interface_nbr_address_delete(ZAPI_CALLBACK_ARGS)
if (ifc == NULL)
return 0;
- if (bgp_debug_zebra(ifc->address)) {
- char buf[PREFIX2STR_BUFFER];
- prefix2str(ifc->address, buf, sizeof(buf));
- zlog_debug("Rx Intf neighbor del VRF %u IF %s addr %s", vrf_id,
- ifc->ifp->name, buf);
- }
+ if (bgp_debug_zebra(ifc->address))
+ zlog_debug("Rx Intf neighbor del VRF %u IF %s addr %pFX",
+ vrf_id, ifc->ifp->name, ifc->address);
if (if_is_operative(ifc->ifp)) {
bgp = bgp_lookup_by_vrf_id(vrf_id);
@@ -534,22 +520,20 @@ static int zebra_read_route(ZAPI_CALLBACK_ARGS)
}
if (bgp_debug_zebra(&api.prefix)) {
- char buf[2][PREFIX_STRLEN];
+ char buf[PREFIX_STRLEN];
- prefix2str(&api.prefix, buf[0], sizeof(buf[0]));
if (add) {
- inet_ntop(api.prefix.family, &nexthop, buf[1],
- sizeof(buf[1]));
+ inet_ntop(api.prefix.family, &nexthop, buf,
+ sizeof(buf));
zlog_debug(
- "Rx route ADD VRF %u %s[%d] %s nexthop %s (type %d if %u) metric %u tag %" ROUTE_TAG_PRI,
+ "Rx route ADD VRF %u %s[%d] %pFX nexthop %s (type %d if %u) metric %u tag %" ROUTE_TAG_PRI,
vrf_id, zebra_route_string(api.type),
- api.instance, buf[0], buf[1], nhtype,
- ifindex, api.metric, api.tag);
+ api.instance, &api.prefix, buf, nhtype, ifindex,
+ api.metric, api.tag);
} else {
- zlog_debug(
- "Rx route DEL VRF %u %s[%d] %s",
- vrf_id, zebra_route_string(api.type),
- api.instance, buf[0]);
+ zlog_debug("Rx route DEL VRF %u %s[%d] %s", vrf_id,
+ zebra_route_string(api.type), api.instance,
+ buf);
}
}
@@ -1436,18 +1420,17 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
}
if (bgp_debug_zebra(p)) {
- char prefix_buf[PREFIX_STRLEN];
char nh_buf[INET6_ADDRSTRLEN];
char eth_buf[ETHER_ADDR_STRLEN + 7] = {'\0'};
char buf1[ETHER_ADDR_STRLEN];
char label_buf[20];
int i;
- prefix2str(&api.prefix, prefix_buf, sizeof(prefix_buf));
- zlog_debug("Tx route %s VRF %u %s metric %u tag %" ROUTE_TAG_PRI
- " count %d",
- valid_nh_count ? "add" : "delete", bgp->vrf_id,
- prefix_buf, api.metric, api.tag, api.nexthop_num);
+ zlog_debug(
+ "Tx route %s VRF %u %pFX metric %u tag %" ROUTE_TAG_PRI
+ " count %d",
+ valid_nh_count ? "add" : "delete", bgp->vrf_id,
+ &api.prefix, api.metric, api.tag, api.nexthop_num);
for (i = 0; i < api.nexthop_num; i++) {
api_nh = &api.nexthops[i];
@@ -1596,12 +1579,9 @@ void bgp_zebra_withdraw(const struct prefix *p, struct bgp_path_info *info,
if (is_route_parent_evpn(info))
SET_FLAG(api.flags, ZEBRA_FLAG_EVPN_ROUTE);
- if (bgp_debug_zebra(p)) {
- char buf[PREFIX_STRLEN];
-
- prefix2str(&api.prefix, buf, sizeof(buf));
- zlog_debug("Tx route delete VRF %u %s", bgp->vrf_id, buf);
- }
+ if (bgp_debug_zebra(p))
+ zlog_debug("Tx route delete VRF %u %pFX", bgp->vrf_id,
+ &api.prefix);
zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api);
}
@@ -2576,10 +2556,9 @@ static int bgp_zebra_process_local_es_add(ZAPI_CALLBACK_ARGS)
active = stream_getc(s);
if (BGP_DEBUG(zebra, ZEBRA))
- zlog_debug("Rx add ESI %s originator-ip %s active %u",
- esi_to_str(&esi, buf, sizeof(buf)),
- inet_ntoa(originator_ip),
- active);
+ zlog_debug("Rx add ESI %s originator-ip %pI4 active %u",
+ esi_to_str(&esi, buf, sizeof(buf)), &originator_ip,
+ active);
bgp_evpn_local_es_add(bgp, &esi, originator_ip, active);
@@ -2788,7 +2767,6 @@ static void bgp_zebra_process_local_ip_prefix(ZAPI_CALLBACK_ARGS)
struct stream *s = NULL;
struct bgp *bgp_vrf = NULL;
struct prefix p;
- char buf[PREFIX_STRLEN];
memset(&p, 0, sizeof(struct prefix));
s = zclient->ibuf;
@@ -2799,8 +2777,7 @@ static void bgp_zebra_process_local_ip_prefix(ZAPI_CALLBACK_ARGS)
return;
if (BGP_DEBUG(zebra, ZEBRA))
- zlog_debug("Recv prefix %s %s on vrf %s",
- prefix2str(&p, buf, sizeof(buf)),
+ zlog_debug("Recv prefix %pFX %s on vrf %s", &p,
(cmd == ZEBRA_IP_PREFIX_ROUTE_ADD) ? "ADD" : "DEL",
vrf_id_to_name(vrf_id));
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 3e2ca70a02..be3322e468 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -332,10 +332,9 @@ void bgp_router_id_zebra_bump(vrf_id_t vrf_id, const struct prefix *router_id)
if (bgp->established_peers == 0) {
if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug(
- "RID change : vrf %s(%u), RTR ID %s",
+ "RID change : vrf %s(%u), RTR ID %pI4",
bgp->name_pretty,
- bgp->vrf_id,
- inet_ntoa(*addr));
+ bgp->vrf_id, addr);
/*
* if old router-id was 0x0, set flag
* to use this new value
@@ -363,10 +362,9 @@ void bgp_router_id_zebra_bump(vrf_id_t vrf_id, const struct prefix *router_id)
if (bgp->established_peers == 0) {
if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug(
- "RID change : vrf %s(%u), RTR ID %s",
+ "RID change : vrf %s(%u), RTR ID %pI4",
bgp->name_pretty,
- bgp->vrf_id,
- inet_ntoa(*addr));
+ bgp->vrf_id, addr);
/*
* if old router-id was 0x0, set flag
* to use this new value
@@ -2740,7 +2738,6 @@ int peer_group_listen_range_del(struct peer_group *group, struct prefix *range)
struct listnode *node, *nnode;
struct peer *peer;
afi_t afi;
- char buf[PREFIX2STR_BUFFER];
afi = family2afi(range->family);
@@ -2753,8 +2750,6 @@ int peer_group_listen_range_del(struct peer_group *group, struct prefix *range)
if (!prefix)
return BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_NOT_FOUND;
- prefix2str(prefix, buf, sizeof(buf));
-
/* Dispose off any dynamic neighbors that exist due to this listen range
*/
for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) {
@@ -2765,8 +2760,8 @@ int peer_group_listen_range_del(struct peer_group *group, struct prefix *range)
if (prefix_match(prefix, &prefix2)) {
if (bgp_debug_neighbor_events(peer))
zlog_debug(
- "Deleting dynamic neighbor %s group %s upon delete of listen range %s",
- peer->host, group->name, buf);
+ "Deleting dynamic neighbor %s group %s upon delete of listen range %pFX",
+ peer->host, group->name, prefix);
peer_delete(peer);
}
}
@@ -2983,6 +2978,8 @@ static struct bgp *bgp_create(as_t *as, const char *name,
}
bgp_lock(bgp);
+
+ bgp_process_queue_init(bgp);
bgp->heuristic_coalesce = true;
bgp->inst_type = inst_type;
bgp->vrf_id = (inst_type == BGP_INSTANCE_TYPE_DEFAULT) ? VRF_DEFAULT
@@ -3507,6 +3504,9 @@ int bgp_delete(struct bgp *bgp)
bgp_set_evpn(bgp_get_default());
}
+ if (bgp->process_queue)
+ work_queue_free_and_null(&bgp->process_queue);
+
thread_master_free_unused(bm->master);
bgp_unlock(bgp); /* initial reference */
@@ -3772,7 +3772,6 @@ struct peer *peer_lookup_dynamic_neighbor(struct bgp *bgp, union sockunion *su)
struct prefix *listen_range;
int dncount;
char buf[PREFIX2STR_BUFFER];
- char buf1[PREFIX2STR_BUFFER];
sockunion2hostprefix(su, &prefix);
@@ -3789,12 +3788,11 @@ struct peer *peer_lookup_dynamic_neighbor(struct bgp *bgp, union sockunion *su)
return NULL;
prefix2str(&prefix, buf, sizeof(buf));
- prefix2str(listen_range, buf1, sizeof(buf1));
if (bgp_debug_neighbor_events(NULL))
zlog_debug(
- "Dynamic Neighbor %s matches group %s listen range %s",
- buf, group->name, buf1);
+ "Dynamic Neighbor %s matches group %s listen range %pFX",
+ buf, group->name, listen_range);
/* Are we within the listen limit? */
dncount = gbgp->dynamic_neighbors_count;
@@ -7087,8 +7085,6 @@ void bgp_master_init(struct thread_master *master, const int buffer_size)
bm->terminating = false;
bm->socket_buffer = buffer_size;
- bgp_process_queue_init();
-
bgp_mac_init();
/* init the rd id space.
assign 0th index in the bitfield,
@@ -7293,14 +7289,10 @@ void bgp_terminate(void)
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_PEER_UNCONFIG);
- if (bm->process_main_queue)
- work_queue_free_and_null(&bm->process_main_queue);
-
if (bm->t_rmap_update)
BGP_TIMER_OFF(bm->t_rmap_update);
bgp_mac_finish();
- bgp_evpn_mh_finish();
}
struct peer *peer_lookup_in_view(struct vty *vty, struct bgp *bgp,
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index 00f1d5acc9..eae3d97730 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -122,9 +122,6 @@ struct bgp_master {
/* BGP thread master. */
struct thread_master *master;
- /* work queues */
- struct work_queue *process_main_queue;
-
/* Listening sockets */
struct list *listen_sockets;
@@ -682,6 +679,9 @@ struct bgp {
/* Weighted ECMP related config. */
enum bgp_link_bw_handling lb_handling;
+ /* Process Queue for handling routes */
+ struct work_queue *process_queue;
+
QOBJ_FIELDS
};
DECLARE_QOBJ_TYPE(bgp)
diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c
index 2bcef97fc3..88c92f7954 100644
--- a/bgpd/rfapi/bgp_rfapi_cfg.c
+++ b/bgpd/rfapi/bgp_rfapi_cfg.c
@@ -170,14 +170,8 @@ struct rfapi_nve_group_cfg *bgp_rfapi_cfg_match_group(struct rfapi_cfg *hc,
#ifdef BGP_VNC_DEBUG_MATCH_GROUP
{
- char buf[PREFIX_STRLEN];
-
- prefix2str(vn, buf, sizeof(buf));
- vnc_zlog_debug_verbose("%s: vn prefix: %s", __func__, buf);
-
- prefix2str(un, buf, sizeof(buf));
- vnc_zlog_debug_verbose("%s: un prefix: %s", __func__, buf);
-
+ vnc_zlog_debug_verbose("%s: vn prefix: %pFX", __func__, vn);
+ vnc_zlog_debug_verbose("%s: un prefix: %pFX", __func__, un);
vnc_zlog_debug_verbose(
"%s: rn_vn=%p, rn_un=%p, rfg_vn=%p, rfg_un=%p",
__func__, rn_vn, rn_un, rfg_vn, rfg_un);
@@ -4215,23 +4209,13 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp)
++write;
vty_out(vty, " vnc nve-group %s\n", rfg->name);
- if (rfg->vn_prefix.family && rfg->vn_node) {
- char buf[PREFIX_STRLEN];
+ if (rfg->vn_prefix.family && rfg->vn_node)
+ vty_out(vty, " prefix %s %pFX\n", "vn",
+ &rfg->vn_prefix);
- prefix2str(&rfg->vn_prefix, buf,
- sizeof(buf));
- vty_out(vty, " prefix %s %s\n", "vn",
- buf);
- }
-
- if (rfg->un_prefix.family && rfg->un_node) {
- char buf[PREFIX_STRLEN];
-
- prefix2str(&rfg->un_prefix, buf,
- sizeof(buf));
- vty_out(vty, " prefix %s %s\n", "un",
- buf);
- }
+ if (rfg->un_prefix.family && rfg->un_node)
+ vty_out(vty, " prefix %s %pFX\n", "un",
+ &rfg->un_prefix);
if (rfg->rd.prefixlen) {
diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c
index 0ff4b2c825..2d81a6ce65 100644
--- a/bgpd/rfapi/rfapi.c
+++ b/bgpd/rfapi/rfapi.c
@@ -362,12 +362,9 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
afi_t afi; /* of the VN address */
struct bgp_dest *bn;
struct bgp_path_info *bpi;
- char buf[PREFIX_STRLEN];
char buf2[RD_ADDRSTRLEN];
struct prefix_rd prd0;
- prefix2str(p, buf, sizeof(buf));
-
afi = family2afi(p->family);
assert(afi == AFI_IP || afi == AFI_IP6);
@@ -380,9 +377,9 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
bn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p, prd);
vnc_zlog_debug_verbose(
- "%s: peer=%p, prefix=%s, prd=%s afi=%d, safi=%d bn=%p, bn->info=%p",
- __func__, peer, buf, prefix_rd2str(prd, buf2, sizeof(buf2)),
- afi, safi, bn, (bn ? bgp_dest_get_bgp_path_info(bn) : NULL));
+ "%s: peer=%p, prefix=%pFX, prd=%s afi=%d, safi=%d bn=%p, bn->info=%p",
+ __func__, peer, p, prefix_rd2str(prd, buf2, sizeof(buf2)), afi,
+ safi, bn, (bn ? bgp_dest_get_bgp_path_info(bn) : NULL));
for (bpi = (bn ? bgp_dest_get_bgp_path_info(bn) : NULL); bpi;
bpi = bpi->next) {
@@ -418,8 +415,8 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
* no local nexthops
*/
vnc_zlog_debug_verbose(
- "%s: lnh list already empty at prefix %s",
- __func__, buf);
+ "%s: lnh list already empty at prefix %pFX",
+ __func__, p);
goto done;
}
@@ -445,8 +442,8 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
* list->del on data */
rfapi_nexthop_free(pLnh);
} else {
- vnc_zlog_debug_verbose("%s: desired lnh not found %s",
- __func__, buf);
+ vnc_zlog_debug_verbose("%s: desired lnh not found %pFX",
+ __func__, p);
}
goto done;
}
@@ -459,10 +456,9 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
rfapiProcessWithdraw(peer, rfd, p, prd, NULL, afi, safi, type, kill);
if (bpi) {
- prefix2str(p, buf, sizeof(buf));
vnc_zlog_debug_verbose(
- "%s: Found route (safi=%d) to delete at prefix %s",
- __func__, safi, buf);
+ "%s: Found route (safi=%d) to delete at prefix %pFX",
+ __func__, safi, p);
if (safi == SAFI_MPLS_VPN) {
struct bgp_dest *pdest = NULL;
@@ -488,8 +484,8 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
bgp_process(bgp, bn, afi, safi);
} else {
vnc_zlog_debug_verbose(
- "%s: Couldn't find route (safi=%d) at prefix %s",
- __func__, safi, buf);
+ "%s: Couldn't find route (safi=%d) at prefix %pFX",
+ __func__, safi, p);
}
done:
bgp_dest_unlock_node(bn);
@@ -1577,12 +1573,10 @@ rfapi_query_inner(void *handle, struct rfapi_ip_addr *target,
}
{
- char buf[PREFIX_STRLEN];
char *s;
- prefix2str(&p, buf, sizeof(buf));
- vnc_zlog_debug_verbose("%s(rfd=%p, target=%s, ppNextHop=%p)",
- __func__, rfd, buf, ppNextHopEntry);
+ vnc_zlog_debug_verbose("%s(rfd=%p, target=%pFX, ppNextHop=%p)",
+ __func__, rfd, &p, ppNextHopEntry);
s = ecommunity_ecom2str(rfd->import_table->rt_import_list,
ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
@@ -2397,16 +2391,10 @@ int rfapi_register(void *handle, struct rfapi_ip_prefix *prefix,
afi = family2afi(prefix->prefix.addr_family);
assert(afi);
-
- {
- char buf[PREFIX_STRLEN];
-
- prefix2str(&p, buf, sizeof(buf));
- vnc_zlog_debug_verbose(
- "%s(rfd=%p, pfx=%s, lifetime=%d, opts_un=%p, opts_vn=%p, action=%s)",
- __func__, rfd, buf, lifetime, options_un, options_vn,
- action_str);
- }
+ vnc_zlog_debug_verbose(
+ "%s(rfd=%p, pfx=%pFX, lifetime=%d, opts_un=%p, opts_vn=%p, action=%s)",
+ __func__, rfd, &p, lifetime, options_un, options_vn,
+ action_str);
/*
* These tests come after the prefix conversion so that we can
diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c
index c3ad95ff28..68d4f622ed 100644
--- a/bgpd/rfapi/rfapi_import.c
+++ b/bgpd/rfapi/rfapi_import.c
@@ -265,11 +265,12 @@ void rfapiCheckRefcount(struct agg_node *rn, safi_t safi, int lockoffset)
}
}
- if (count_bpi + count_monitor + lockoffset != rn->lock) {
+ if (count_bpi + count_monitor + lockoffset
+ != agg_node_get_lock_count(rn)) {
vnc_zlog_debug_verbose(
"%s: count_bpi=%d, count_monitor=%d, lockoffset=%d, rn->lock=%d",
__func__, count_bpi, count_monitor, lockoffset,
- rn->lock);
+ agg_node_get_lock_count(rn));
assert(0);
}
}
@@ -611,11 +612,8 @@ rfapiMonitorMoveShorter(struct agg_node *original_vpn_node, int lockoffset)
#ifdef DEBUG_MONITOR_MOVE_SHORTER
{
- char buf[PREFIX_STRLEN];
-
- prefix2str(&original_vpn_node->p, buf, sizeof(buf));
- vnc_zlog_debug_verbose("%s: called with node pfx=%s", __func__,
- buf);
+ vnc_zlog_debug_verbose("%s: called with node pfx=%pFX",
+ __func__, &original_vpn_node->p);
}
#endif
@@ -750,11 +748,8 @@ rfapiMonitorMoveShorter(struct agg_node *original_vpn_node, int lockoffset)
#ifdef DEBUG_MONITOR_MOVE_SHORTER
{
- char buf[PREFIX_STRLEN];
-
- prefix2str(&par->p, buf, sizeof(buf));
- vnc_zlog_debug_verbose("%s: moved to node pfx=%s", __func__,
- buf);
+ vnc_zlog_debug_verbose("%s: moved to node pfx=%pFX", __func__,
+ &par->p);
}
#endif
@@ -1555,12 +1550,9 @@ static int rfapiNhlAddNodeRoutes(
}
if (!skiplist_search(seen_nexthops, &pfx_vn, NULL)) {
#ifdef DEBUG_RETURNED_NHL
- char buf[PREFIX_STRLEN];
-
- prefix2str(&pfx_vn, buf, sizeof(buf));
vnc_zlog_debug_verbose(
- "%s: already put VN/nexthop %s, skip", __func__,
- buf);
+ "%s: already put VN/nexthop %pFX, skip",
+ __func__, &pfx_vn);
#endif
continue;
}
@@ -3633,12 +3625,9 @@ void rfapiBgpInfoFilteredImportVPN(
rfapiCopyUnEncap2VPN(ern->info, info_new);
agg_unlock_node(ern); /* undo lock in route_note_match */
} else {
- char bpf[PREFIX_STRLEN];
-
- prefix2str(&vn_prefix, bpf, sizeof(bpf));
/* Not a big deal, just means VPN route got here first */
- vnc_zlog_debug_verbose("%s: no encap route for vn addr %s",
- __func__, bpf);
+ vnc_zlog_debug_verbose("%s: no encap route for vn addr %pFX",
+ __func__, &vn_prefix);
info_new->extra->vnc.import.un_family = 0;
}
@@ -3665,7 +3654,8 @@ void rfapiBgpInfoFilteredImportVPN(
}
vnc_zlog_debug_verbose("%s: inserting bpi %p at prefix %pRN #%d",
- __func__, info_new, rn, rn->lock);
+ __func__, info_new, rn,
+ agg_node_get_lock_count(rn));
rfapiBgpInfoAttachSorted(rn, info_new, afi, SAFI_MPLS_VPN);
rfapiItBiIndexAdd(rn, info_new);
@@ -4439,13 +4429,9 @@ static void rfapiDeleteRemotePrefixesIt(
struct bgp_path_info *next;
const struct prefix *rn_p = agg_node_get_prefix(rn);
- if (p && VNC_DEBUG(IMPORT_DEL_REMOTE)) {
- char p1line[PREFIX_STRLEN];
-
- prefix2str(p, p1line, sizeof(p1line));
- vnc_zlog_debug_any("%s: want %s, have %pRN",
- __func__, p1line, rn);
- }
+ if (p && VNC_DEBUG(IMPORT_DEL_REMOTE))
+ vnc_zlog_debug_any("%s: want %pFX, have %pRN",
+ __func__, p, rn);
if (p && prefix_cmp(p, rn_p))
continue;
diff --git a/bgpd/rfapi/rfapi_monitor.c b/bgpd/rfapi/rfapi_monitor.c
index cd26892b84..a4b0eff03e 100644
--- a/bgpd/rfapi/rfapi_monitor.c
+++ b/bgpd/rfapi/rfapi_monitor.c
@@ -846,9 +846,6 @@ void rfapiMonitorItNodeChanged(
struct bgp *bgp = bgp_get_default();
const struct prefix *p = agg_node_get_prefix(rn);
afi_t afi = family2afi(p->family);
-#if DEBUG_L2_EXTRA
- char buf_prefix[PREFIX_STRLEN];
-#endif
assert(bgp);
assert(import_table);
@@ -856,9 +853,8 @@ void rfapiMonitorItNodeChanged(
nves_seen = skiplist_new(0, NULL, NULL);
#if DEBUG_L2_EXTRA
- prefix2str(&it_node->p, buf_prefix, sizeof(buf_prefix));
- vnc_zlog_debug_verbose("%s: it=%p, it_node=%p, it_node->prefix=%s",
- __func__, import_table, it_node, buf_prefix);
+ vnc_zlog_debug_verbose("%s: it=%p, it_node=%p, it_node->prefix=%pFX",
+ __func__, import_table, it_node, &it_node->p);
#endif
if (AFI_L2VPN == afi) {
@@ -934,14 +930,10 @@ void rfapiMonitorItNodeChanged(
assert(!skiplist_insert(nves_seen,
m->rfd, NULL));
- char buf_target_pfx[PREFIX_STRLEN];
-
- prefix2str(&m->p, buf_target_pfx,
- sizeof(buf_target_pfx));
vnc_zlog_debug_verbose(
- "%s: update rfd %p attached to pfx %pRN (targ=%s)",
+ "%s: update rfd %p attached to pfx %pRN (targ=%pFX)",
__func__, m->rfd, m->node,
- buf_target_pfx);
+ &m->p);
/*
* update its RIB
@@ -1269,21 +1261,15 @@ static void rfapiMonitorEthDetachImport(
rn = agg_node_get(it->imported_vpn[AFI_L2VPN], &pfx_mac_buf);
assert(rn);
-#if DEBUG_L2_EXTRA
- char buf_prefix[PREFIX_STRLEN];
-
- prefix2str(agg_node_get_prefix(rn), buf_prefix, sizeof(buf_prefix));
-#endif
-
/*
* Get sl to detach from
*/
sl = RFAPI_MONITOR_ETH(rn);
#if DEBUG_L2_EXTRA
vnc_zlog_debug_verbose(
- "%s: it=%p, rn=%p, rn->lock=%d, sl=%p, pfx=%s, LNI=%d, detaching eth mon %p",
- __func__, it, rn, rn->lock, sl, buf_prefix, mon->logical_net_id,
- mon);
+ "%s: it=%p, rn=%p, rn->lock=%d, sl=%p, pfx=%pFX, LNI=%d, detaching eth mon %p",
+ __func__, it, rn, rn->lock, sl, agg_node_get_prefix(rn),
+ mon->logical_net_id, mon);
#endif
assert(sl);
diff --git a/bgpd/rfapi/rfapi_rib.c b/bgpd/rfapi/rfapi_rib.c
index e068eb7af6..09832b32ac 100644
--- a/bgpd/rfapi/rfapi_rib.c
+++ b/bgpd/rfapi/rfapi_rib.c
@@ -802,7 +802,7 @@ int rfapiRibPreloadBi(
*/
trn = agg_node_get(rfd->rsp_times[afi], p); /* locks trn */
trn->info = (void *)(uintptr_t)bgp_clock();
- if (trn->lock > 1)
+ if (agg_node_get_lock_count(trn) > 1)
agg_unlock_node(trn);
return 0;
@@ -907,10 +907,6 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd,
delete_list = list_new();
while (0
== skiplist_first(slRibPt, NULL, (void **)&ri)) {
-
- char buf[PREFIX_STRLEN];
- char buf2[PREFIX_STRLEN];
-
listnode_add(delete_list, ri);
vnc_zlog_debug_verbose(
"%s: after listnode_add, delete_list->count=%d",
@@ -927,12 +923,10 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd,
ri->timer = NULL;
}
- prefix2str(&ri->rk.vn, buf, sizeof(buf));
- prefix2str(&ri->un, buf2, sizeof(buf2));
vnc_zlog_debug_verbose(
- "%s: put dl pfx=%pRN vn=%s un=%s cost=%d life=%d vn_options=%p",
- __func__, pn, buf, buf2, ri->cost,
- ri->lifetime, ri->vn_options);
+ "%s: put dl pfx=%pRN vn=%pFX un=%pFX cost=%d life=%d vn_options=%p",
+ __func__, pn, &ri->rk.vn, &ri->un,
+ ri->cost, ri->lifetime, ri->vn_options);
skiplist_delete_first(slRibPt);
}
@@ -1242,7 +1236,7 @@ callback:
trn = agg_node_get(rfd->rsp_times[afi],
p); /* locks trn */
trn->info = (void *)(uintptr_t)bgp_clock();
- if (trn->lock > 1)
+ if (agg_node_get_lock_count(trn) > 1)
agg_unlock_node(trn);
rfapiRfapiIpAddr2Str(&new->vn_address, buf, BUFSIZ);
@@ -1589,7 +1583,6 @@ void rfapiRibUpdatePendingNode(
afi_t afi;
uint32_t queued_flag;
int count = 0;
- char buf[PREFIX_STRLEN];
vnc_zlog_debug_verbose("%s: entry", __func__);
@@ -1602,8 +1595,7 @@ void rfapiRibUpdatePendingNode(
prefix = agg_node_get_prefix(it_node);
afi = family2afi(prefix->family);
- prefix2str(prefix, buf, sizeof(buf));
- vnc_zlog_debug_verbose("%s: prefix=%s", __func__, buf);
+ vnc_zlog_debug_verbose("%s: prefix=%pFX", __func__, prefix);
pn = agg_node_get(rfd->rib_pending[afi], prefix);
assert(pn);
@@ -1809,11 +1801,8 @@ int rfapiRibFTDFilterRecentPrefix(
#ifdef DEBUG_FTD_FILTER_RECENT
{
- char buf_pfx[PREFIX_STRLEN];
-
- prefix2str(agg_node_get_prefix(it_rn), buf_pfx,
- sizeof(buf_pfx));
- vnc_zlog_debug_verbose("%s: prefix %s", __func__, buf_pfx);
+ vnc_zlog_debug_verbose("%s: prefix %pFX", __func__,
+ agg_node_get_prefix(it_rn));
}
#endif
@@ -1833,7 +1822,7 @@ int rfapiRibFTDFilterRecentPrefix(
*/
trn = agg_node_get(rfd->rsp_times[afi], p); /* locks trn */
prefix_time = (time_t)trn->info;
- if (trn->lock > 1)
+ if (agg_node_get_lock_count(trn) > 1)
agg_unlock_node(trn);
#ifdef DEBUG_FTD_FILTER_RECENT
@@ -1974,21 +1963,18 @@ rfapiRibPreload(struct bgp *bgp, struct rfapi_descriptor *rfd,
#if DEBUG_NHL
{
- char str_vn[PREFIX_STRLEN];
char str_aux_prefix[PREFIX_STRLEN];
- str_vn[0] = 0;
str_aux_prefix[0] = 0;
- prefix2str(&rk.vn, str_vn, sizeof(str_vn));
prefix2str(&rk.aux_prefix, str_aux_prefix,
sizeof(str_aux_prefix));
if (!rk.aux_prefix.family) {
}
vnc_zlog_debug_verbose(
- "%s: rk.vn=%s rk.aux_prefix=%s", __func__,
- str_vn,
+ "%s: rk.vn=%pFX rk.aux_prefix=%s", __func__,
+ &rk.vn,
(rk.aux_prefix.family ? str_aux_prefix : "-"));
}
vnc_zlog_debug_verbose(
@@ -2069,20 +2055,13 @@ rfapiRibPreload(struct bgp *bgp, struct rfapi_descriptor *rfd,
*/
trn = agg_node_get(rfd->rsp_times[afi], &pfx); /* locks trn */
trn->info = (void *)(uintptr_t)bgp_clock();
- if (trn->lock > 1)
+ if (agg_node_get_lock_count(trn) > 1)
agg_unlock_node(trn);
- {
- char str_pfx[PREFIX_STRLEN];
- char str_pfx_vn[PREFIX_STRLEN];
-
- prefix2str(&pfx, str_pfx, sizeof(str_pfx));
- prefix2str(&rk.vn, str_pfx_vn, sizeof(str_pfx_vn));
- vnc_zlog_debug_verbose(
- "%s: added pfx=%s nh[vn]=%s, cost=%u, lifetime=%u, allowed=%d",
- __func__, str_pfx, str_pfx_vn, nhp->prefix.cost,
- nhp->lifetime, allowed);
- }
+ vnc_zlog_debug_verbose(
+ "%s: added pfx=%pFX nh[vn]=%pFX, cost=%u, lifetime=%u, allowed=%d",
+ __func__, &pfx, &rk.vn, nhp->prefix.cost, nhp->lifetime,
+ allowed);
if (allowed) {
if (tail)
diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c
index d74404ea56..b9a6c4ddc4 100644
--- a/bgpd/rfapi/rfapi_vty.c
+++ b/bgpd/rfapi/rfapi_vty.c
@@ -751,7 +751,7 @@ void rfapiShowItNode(void *stream, struct agg_node *rn)
if (rfapiStream2Vty(stream, &fp, &vty, &out, &vty_newline) == 0)
return;
- fp(out, "%pRN @%p #%d%s", rn, rn, rn->lock, HVTYNL);
+ fp(out, "%pRN @%p #%d%s", rn, rn, agg_node_get_lock_count(rn), HVTYNL);
for (bpi = rn->info; bpi; bpi = bpi->next) {
rfapiPrintBi(stream, bpi);
@@ -787,7 +787,8 @@ void rfapiShowImportTable(void *stream, const char *label, struct agg_table *rt,
}
fp(out, "%s/%d @%p #%d%s", buf, p->prefixlen, rn,
- rn->lock - 1, /* account for loop iterator locking */
+ agg_node_get_lock_count(rn)
+ - 1, /* account for loop iterator locking */
HVTYNL);
for (bpi = rn->info; bpi; bpi = bpi->next) {
@@ -1595,7 +1596,6 @@ void rfapiPrintDescriptor(struct vty *vty, struct rfapi_descriptor *rfd)
int rc;
afi_t afi;
struct rfapi_adb *adb;
- char buf[PREFIX_STRLEN];
vty_out(vty, "%-10p ", rfd);
rfapiPrintRfapiIpAddr(vty, &rfd->un_addr);
@@ -1647,9 +1647,8 @@ void rfapiPrintDescriptor(struct vty *vty, struct rfapi_descriptor *rfd)
if (family != adb->u.s.prefix_ip.family)
continue;
- prefix2str(&adb->u.s.prefix_ip, buf, sizeof(buf));
-
- vty_out(vty, " Adv Pfx: %s%s", buf, HVTYNL);
+ vty_out(vty, " Adv Pfx: %pFX%s", &adb->u.s.prefix_ip,
+ HVTYNL);
rfapiPrintAdvertisedInfo(vty, rfd, SAFI_MPLS_VPN,
&adb->u.s.prefix_ip);
}
@@ -1658,10 +1657,7 @@ void rfapiPrintDescriptor(struct vty *vty, struct rfapi_descriptor *rfd)
(void **)&adb, &cursor);
rc == 0; rc = skiplist_next(rfd->advertised.ip0_by_ether, NULL,
(void **)&adb, &cursor)) {
-
- prefix2str(&adb->u.s.prefix_eth, buf, sizeof(buf));
-
- vty_out(vty, " Adv Pfx: %s%s", buf, HVTYNL);
+ vty_out(vty, " Adv Pfx: %pFX%s", &adb->u.s.prefix_eth, HVTYNL);
/* TBD update the following function to print ethernet info */
/* Also need to pass/use rd */
@@ -1862,11 +1858,9 @@ void rfapiPrintNhl(void *stream, struct rfapi_next_hop_entry *next_hops)
break;
case RFAPI_VN_OPTION_TYPE_LOCAL_NEXTHOP:
- prefix2str(&vo->v.local_nexthop.addr,
- pbuf, sizeof(pbuf));
- fp(out, "%sLNH %s cost=%d%s", offset,
- pbuf, vo->v.local_nexthop.cost,
- HVTYNL);
+ fp(out, "%sLNH %pFX cost=%d%s", offset,
+ &vo->v.local_nexthop.addr,
+ vo->v.local_nexthop.cost, HVTYNL);
break;
default:
diff --git a/bgpd/rfapi/vnc_import_bgp.c b/bgpd/rfapi/vnc_import_bgp.c
index 85d64b5a72..0b6b39b966 100644
--- a/bgpd/rfapi/vnc_import_bgp.c
+++ b/bgpd/rfapi/vnc_import_bgp.c
@@ -206,19 +206,11 @@ static void print_rhn_list(const char *tag1, const char *tag2)
/* XXX uses secret knowledge of skiplist structure */
for (p = sl->header->forward[0]; p; p = p->forward[0]) {
- char kbuf[PREFIX_STRLEN];
- char hbuf[PREFIX_STRLEN];
- char ubuf[PREFIX_STRLEN];
-
pb = p->value;
- prefix2str(p->key, kbuf, sizeof(kbuf));
- prefix2str(&pb->hpfx, hbuf, sizeof(hbuf));
- prefix2str(&pb->upfx, ubuf, sizeof(ubuf));
-
vnc_zlog_debug_verbose(
- "RHN Entry %d (q=%p): kpfx=%s, upfx=%s, hpfx=%s, ubpi=%p",
- ++count, p, kbuf, ubuf, hbuf, pb->ubpi);
+ "RHN Entry %d (q=%p): kpfx=%pFX, upfx=%pFX, hpfx=%pFX, ubpi=%p",
+ ++count, p, p->key, &pb->upfx, &pb->hpfx, pb->ubpi);
}
}
#endif
@@ -260,15 +252,9 @@ static void vnc_rhnck(char *tag)
* pfx */
assert(!vnc_prefix_cmp(&pb->hpfx, pkey));
if (vnc_prefix_cmp(&pb->hpfx, &pfx_orig_nexthop)) {
- char str_onh[PREFIX_STRLEN];
- char str_nve_pfx[PREFIX_STRLEN];
-
- prefix2str(&pfx_orig_nexthop, str_onh, sizeof(str_onh));
- prefix2str(&pb->hpfx, str_nve_pfx, sizeof(str_nve_pfx));
-
vnc_zlog_debug_verbose(
- "%s: %s: FATAL: resolve_nve_nexthop list item bpi nexthop %s != nve pfx %s",
- __func__, tag, str_onh, str_nve_pfx);
+ "%s: %s: FATAL: resolve_nve_nexthop list item bpi nexthop %pFX != nve pfx %pFX",
+ __func__, tag, &pfx_orig_nexthop, &pb->hpfx);
assert(0);
}
}
@@ -529,13 +515,7 @@ static void vnc_import_bgp_add_route_mode_resolve_nve_one_rd(
if (!table_rd)
return;
- {
- char str_nh[PREFIX_STRLEN];
-
- prefix2str(ubpi_nexthop, str_nh, sizeof(str_nh));
-
- vnc_zlog_debug_verbose("%s: ubpi_nexthop=%s", __func__, str_nh);
- }
+ vnc_zlog_debug_verbose("%s: ubpi_nexthop=%pFX", __func__, ubpi_nexthop);
/* exact match */
bd = bgp_node_lookup(table_rd, ubpi_nexthop);
@@ -574,12 +554,9 @@ static void vnc_import_bgp_add_route_mode_resolve_nve(
/*debugging */
if (VNC_DEBUG(VERBOSE)) {
- char str_pfx[PREFIX_STRLEN];
char str_nh[PREFIX_STRLEN];
struct prefix nh;
- prefix2str(prefix, str_pfx, sizeof(str_pfx));
-
nh.prefixlen = 0;
rfapiUnicastNexthop2Prefix(afi, info->attr, &nh);
if (nh.prefixlen) {
@@ -590,8 +567,8 @@ static void vnc_import_bgp_add_route_mode_resolve_nve(
}
vnc_zlog_debug_verbose(
- "%s(bgp=%p, unicast prefix=%s, unicast nh=%s)",
- __func__, bgp, str_pfx, str_nh);
+ "%s(bgp=%p, unicast prefix=%pFX, unicast nh=%s)",
+ __func__, bgp, prefix, str_nh);
}
if (info->type != ZEBRA_ROUTE_BGP) {
@@ -713,12 +690,7 @@ static void vnc_import_bgp_add_route_mode_plain(struct bgp *bgp,
uint32_t local_pref;
uint32_t *med = NULL;
- {
- char buf[PREFIX_STRLEN];
-
- prefix2str(prefix, buf, sizeof(buf));
- vnc_zlog_debug_verbose("%s(prefix=%s) entry", __func__, buf);
- }
+ vnc_zlog_debug_verbose("%s(prefix=%pFX) entry", __func__, prefix);
if (!afi) {
flog_err(EC_LIB_DEVELOPMENT, "%s: can't get afi of prefix",
@@ -783,12 +755,8 @@ static void vnc_import_bgp_add_route_mode_plain(struct bgp *bgp,
ahr_flags |= RFAPI_AHR_NO_TUNNEL_SUBTLV;
}
- if (VNC_DEBUG(IMPORT_BGP_ADD_ROUTE)) {
- char buf[PREFIX_STRLEN];
-
- prefix2str(vn_pfx, buf, sizeof(buf));
- vnc_zlog_debug_any("%s vn_pfx=%s", __func__, buf);
- }
+ if (VNC_DEBUG(IMPORT_BGP_ADD_ROUTE))
+ vnc_zlog_debug_any("%s vn_pfx=%pFX", __func__, vn_pfx);
/*
* Compute VN address
@@ -899,12 +867,7 @@ static void vnc_import_bgp_add_route_mode_nvegroup(
struct route_map *rmap = NULL;
uint32_t local_pref;
- {
- char buf[PREFIX_STRLEN];
-
- prefix2str(prefix, buf, sizeof(buf));
- vnc_zlog_debug_verbose("%s(prefix=%s) entry", __func__, buf);
- }
+ vnc_zlog_debug_verbose("%s(prefix=%pFX) entry", __func__, prefix);
assert(rfg);
@@ -985,12 +948,8 @@ static void vnc_import_bgp_add_route_mode_nvegroup(
vncHDBgpDirect.un_addr = pfx_un.prefix;
}
- if (VNC_DEBUG(IMPORT_BGP_ADD_ROUTE)) {
- char buf[PREFIX_STRLEN];
-
- prefix2str(vn_pfx, buf, sizeof(buf));
- vnc_zlog_debug_any("%s vn_pfx=%s", __func__, buf);
- }
+ if (VNC_DEBUG(IMPORT_BGP_ADD_ROUTE))
+ vnc_zlog_debug_any("%s vn_pfx=%pFX", __func__, vn_pfx);
/*
* Compute VN address
@@ -1288,12 +1247,7 @@ static void vnc_import_bgp_del_route_mode_resolve_nve_one_rd(
if (!table_rd)
return;
- {
- char str_nh[PREFIX_STRLEN];
-
- prefix2str(ubpi_nexthop, str_nh, sizeof(str_nh));
- vnc_zlog_debug_verbose("%s: ubpi_nexthop=%s", __func__, str_nh);
- }
+ vnc_zlog_debug_verbose("%s: ubpi_nexthop=%pFX", __func__, ubpi_nexthop);
/* exact match */
@@ -1467,17 +1421,11 @@ void vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
memset(&pfx_unicast_nexthop, 0,
sizeof(struct prefix)); /* keep valgrind happy */
- if (VNC_DEBUG(IMPORT_BGP_ADD_ROUTE)) {
- char hbuf[PREFIX_STRLEN];
- char ubuf[PREFIX_STRLEN];
-
- prefix2str(&pb->hpfx, hbuf, sizeof(hbuf));
- prefix2str(&pb->upfx, ubuf, sizeof(ubuf));
-
+ if (VNC_DEBUG(IMPORT_BGP_ADD_ROUTE))
vnc_zlog_debug_any(
- "%s: examining RHN Entry (q=%p): upfx=%s, hpfx=%s, ubpi=%p",
- __func__, cursor, ubuf, hbuf, pb->ubpi);
- }
+ "%s: examining RHN Entry (q=%p): upfx=%pFX, hpfx=%pFX, ubpi=%p",
+ __func__, cursor, &pb->upfx, &pb->hpfx,
+ pb->ubpi);
if (process_unicast_route(bgp, afi, &pb->upfx, pb->ubpi, &ecom,
&pfx_unicast_nexthop)) {
@@ -1497,16 +1445,9 @@ void vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
* Sanity check
*/
if (vnc_prefix_cmp(&pfx_unicast_nexthop, prefix)) {
- char str_unh[PREFIX_STRLEN];
- char str_nve_pfx[PREFIX_STRLEN];
-
- prefix2str(&pfx_unicast_nexthop, str_unh,
- sizeof(str_unh));
- prefix2str(prefix, str_nve_pfx, sizeof(str_nve_pfx));
-
vnc_zlog_debug_verbose(
- "%s: FATAL: resolve_nve_nexthop list item bpi nexthop %s != nve pfx %s",
- __func__, str_unh, str_nve_pfx);
+ "%s: FATAL: resolve_nve_nexthop list item bpi nexthop %pFX != nve pfx %pFX",
+ __func__, &pfx_unicast_nexthop, prefix);
assert(0);
}
@@ -1521,13 +1462,9 @@ void vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
#if DEBUG_RHN_LIST
/* debug */
{
- char pbuf[PREFIX_STRLEN];
-
- prefix2str(prefix, pbuf, sizeof(pbuf));
-
vnc_zlog_debug_verbose(
- "%s: advancing past RHN Entry (q=%p): with prefix %s",
- __func__, cursor, pbuf);
+ "%s: advancing past RHN Entry (q=%p): with prefix %pFX",
+ __func__, cursor, prefix);
print_rhn_list(__func__, NULL); /* debug */
}
#endif
@@ -1550,14 +1487,8 @@ void vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
struct rfapi_cfg *hc = NULL;
int rc;
- {
- char str_pfx[PREFIX_STRLEN];
-
- prefix2str(prefix, str_pfx, sizeof(str_pfx));
-
- vnc_zlog_debug_verbose("%s(bgp=%p, nve prefix=%s)", __func__,
- bgp, str_pfx);
- }
+ vnc_zlog_debug_verbose("%s(bgp=%p, nve prefix=%pFX)", __func__, bgp,
+ prefix);
if (afi != AFI_IP && afi != AFI_IP6)
return;
@@ -1621,16 +1552,9 @@ void vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
* Sanity check
*/
if (vnc_prefix_cmp(&pfx_unicast_nexthop, prefix)) {
- char str_unh[PREFIX_STRLEN];
- char str_nve_pfx[PREFIX_STRLEN];
-
- prefix2str(&pfx_unicast_nexthop, str_unh,
- sizeof(str_unh));
- prefix2str(prefix, str_nve_pfx, sizeof(str_nve_pfx));
-
vnc_zlog_debug_verbose(
- "%s: FATAL: resolve_nve_nexthop list item bpi nexthop %s != nve pfx %s",
- __func__, str_unh, str_nve_pfx);
+ "%s: FATAL: resolve_nve_nexthop list item bpi nexthop %pFX != nve pfx %pFX",
+ __func__, &pfx_unicast_nexthop, prefix);
assert(0);
}
@@ -2305,13 +2229,11 @@ void vnc_import_bgp_exterior_add_route_interior(
(void **)&pfx_exterior, &cursor)) {
struct prefix pfx_nexthop;
- char buf[PREFIX_STRLEN];
afi_t afi_exterior = family2afi(pfx_exterior->family);
- prefix2str(pfx_exterior, buf, sizeof(buf));
vnc_zlog_debug_verbose(
- "%s: checking exterior orphan at prefix %s", __func__,
- buf);
+ "%s: checking exterior orphan at prefix %pFX", __func__,
+ pfx_exterior);
if (afi_exterior != afi) {
vnc_zlog_debug_verbose(
@@ -2602,15 +2524,10 @@ void vnc_import_bgp_add_route(struct bgp *bgp, const struct prefix *prefix,
if (VNC_DEBUG(VERBOSE)) {
struct prefix pfx_nexthop;
- char buf[PREFIX_STRLEN];
- char buf_nh[PREFIX_STRLEN];
- prefix2str(prefix, buf, sizeof(buf));
rfapiUnicastNexthop2Prefix(afi, info->attr, &pfx_nexthop);
- prefix2str(&pfx_nexthop, buf_nh, sizeof(buf_nh));
-
- vnc_zlog_debug_verbose("%s: pfx %s, nh %s", __func__, buf,
- buf_nh);
+ vnc_zlog_debug_verbose("%s: pfx %pFX, nh %pFX", __func__,
+ prefix, &pfx_nexthop);
}
#if DEBUG_RHN_LIST
print_rhn_list(__func__, "ENTER ");
@@ -2673,15 +2590,10 @@ void vnc_import_bgp_del_route(struct bgp *bgp, const struct prefix *prefix,
{
struct prefix pfx_nexthop;
- char buf[PREFIX_STRLEN];
- char buf_nh[PREFIX_STRLEN];
- prefix2str(prefix, buf, sizeof(buf));
rfapiUnicastNexthop2Prefix(afi, info->attr, &pfx_nexthop);
- prefix2str(&pfx_nexthop, buf_nh, sizeof(buf_nh));
-
- vnc_zlog_debug_verbose("%s: pfx %s, nh %s", __func__, buf,
- buf_nh);
+ vnc_zlog_debug_verbose("%s: pfx %pFX, nh %pFX", __func__,
+ prefix, &pfx_nexthop);
}
#if DEBUG_RHN_LIST
print_rhn_list(__func__, "ENTER ");
diff --git a/bgpd/rfapi/vnc_zebra.c b/bgpd/rfapi/vnc_zebra.c
index 008c7b28b7..b254f11ce7 100644
--- a/bgpd/rfapi/vnc_zebra.c
+++ b/bgpd/rfapi/vnc_zebra.c
@@ -363,15 +363,11 @@ static int vnc_zebra_read_route(ZAPI_CALLBACK_ARGS)
else
vnc_redistribute_delete(&api.prefix, api.type);
- if (BGP_DEBUG(zebra, ZEBRA)) {
- char buf[PREFIX_STRLEN];
-
- prefix2str(&api.prefix, buf, sizeof(buf));
+ if (BGP_DEBUG(zebra, ZEBRA))
vnc_zlog_debug_verbose(
- "%s: Zebra rcvd: route delete %s %s metric %u",
- __func__, zebra_route_string(api.type), buf,
+ "%s: Zebra rcvd: route delete %s %pFX metric %u",
+ __func__, zebra_route_string(api.type), &api.prefix,
api.metric);
- }
return 0;
}
@@ -425,14 +421,10 @@ static void vnc_zebra_route_msg(const struct prefix *p, unsigned int nhp_count,
}
}
- if (BGP_DEBUG(zebra, ZEBRA)) {
- char buf[PREFIX_STRLEN];
-
- prefix2str(&api.prefix, buf, sizeof(buf));
+ if (BGP_DEBUG(zebra, ZEBRA))
vnc_zlog_debug_verbose(
- "%s: Zebra send: route %s %s, nhp_count=%d", __func__,
- (add ? "add" : "del"), buf, nhp_count);
- }
+ "%s: Zebra send: route %s %pFX, nhp_count=%d", __func__,
+ (add ? "add" : "del"), &api.prefix, nhp_count);
zclient_route_send((add ? ZEBRA_ROUTE_ADD : ZEBRA_ROUTE_DELETE),
zclient_vnc, &api);
diff --git a/eigrpd/eigrp_dump.c b/eigrpd/eigrp_dump.c
index 97de73116b..dfce2acad4 100644
--- a/eigrpd/eigrp_dump.c
+++ b/eigrpd/eigrp_dump.c
@@ -122,8 +122,8 @@ void eigrp_ip_header_dump(struct ip *iph)
zlog_debug("ip_ttl %u", iph->ip_ttl);
zlog_debug("ip_p %u", iph->ip_p);
zlog_debug("ip_sum 0x%x", (uint32_t)iph->ip_sum);
- zlog_debug("ip_src %s", inet_ntoa(iph->ip_src));
- zlog_debug("ip_dst %s", inet_ntoa(iph->ip_dst));
+ zlog_debug("ip_src %pI4", &iph->ip_src);
+ zlog_debug("ip_dst %pI4", &iph->ip_dst);
}
/*
@@ -204,8 +204,7 @@ void show_ip_eigrp_neighbor_sub(struct vty *vty, struct eigrp_neighbor *nbr,
int detail)
{
- vty_out(vty, "%-3u %-17s %-21s", 0, eigrp_neigh_ip_string(nbr),
- IF_NAME(nbr->ei));
+ vty_out(vty, "%-3u %-17pI4 %-21s", 0, &nbr->src, IF_NAME(nbr->ei));
if (nbr->t_holddown)
vty_out(vty, "%-7lu",
thread_timer_remain_second(nbr->t_holddown));
@@ -231,8 +230,8 @@ void show_ip_eigrp_neighbor_sub(struct vty *vty, struct eigrp_neighbor *nbr,
*/
void show_ip_eigrp_topology_header(struct vty *vty, struct eigrp *eigrp)
{
- vty_out(vty, "\nEIGRP Topology Table for AS(%d)/ID(%s)\n\n", eigrp->AS,
- inet_ntoa(eigrp->router_id));
+ vty_out(vty, "\nEIGRP Topology Table for AS(%d)/ID(%pI4)\n\n",
+ eigrp->AS, &eigrp->router_id);
vty_out(vty,
"Codes: P - Passive, A - Active, U - Update, Q - Query, R - Reply\n r - reply Status, s - sia Status\n\n");
}
@@ -240,12 +239,10 @@ void show_ip_eigrp_topology_header(struct vty *vty, struct eigrp *eigrp)
void show_ip_eigrp_prefix_entry(struct vty *vty, struct eigrp_prefix_entry *tn)
{
struct list *successors = eigrp_topology_get_successor(tn);
- char buffer[PREFIX_STRLEN];
vty_out(vty, "%-3c", (tn->state > 0) ? 'A' : 'P');
- vty_out(vty, "%s, ",
- prefix2str(tn->destination, buffer, PREFIX_STRLEN));
+ vty_out(vty, "%pFX, ", tn->destination);
vty_out(vty, "%u successors, ", (successors) ? successors->count : 0);
vty_out(vty, "FD is %u, serno: %" PRIu64 " \n", tn->fdistance,
tn->serno);
@@ -269,8 +266,8 @@ void show_ip_eigrp_nexthop_entry(struct vty *vty, struct eigrp *eigrp,
vty_out(vty, "%-7s%s, %s\n", " ", "via Connected",
IF_NAME(te->ei));
else {
- vty_out(vty, "%-7s%s%s (%u/%u), %s\n", " ", "via ",
- inet_ntoa(te->adv_router->src), te->distance,
+ vty_out(vty, "%-7s%s%pI4 (%u/%u), %s\n", " ", "via ",
+ &te->adv_router->src, te->distance,
te->reported_distance, IF_NAME(te->ei));
}
}
diff --git a/eigrpd/eigrp_dump.h b/eigrpd/eigrp_dump.h
index f141f3cbc6..348356bb3c 100644
--- a/eigrpd/eigrp_dump.h
+++ b/eigrpd/eigrp_dump.h
@@ -138,21 +138,6 @@ extern unsigned long term_debug_eigrp_zebra;
/* Prototypes. */
extern const char *eigrp_if_name_string(struct eigrp_interface *);
-static inline const char
-*eigrp_topology_ip_string(struct eigrp_prefix_entry *tn)
-{
- return inet_ntoa(tn->destination->u.prefix4);
-}
-
-static inline const char *eigrp_if_ip_string(struct eigrp_interface *ei)
-{
- return ei ? inet_ntoa(ei->address.u.prefix4) : "inactive";
-}
-
-static inline const char *eigrp_neigh_ip_string(struct eigrp_neighbor *nbr)
-{
- return inet_ntoa(nbr->src);
-}
extern void eigrp_ip_header_dump(struct ip *);
extern void eigrp_header_dump(struct eigrp_header *);
diff --git a/eigrpd/eigrp_fsm.c b/eigrpd/eigrp_fsm.c
index e43eca0e0d..a69a3eec0a 100644
--- a/eigrpd/eigrp_fsm.c
+++ b/eigrpd/eigrp_fsm.c
@@ -417,9 +417,9 @@ int eigrp_fsm_event(struct eigrp_fsm_action_message *msg)
enum eigrp_fsm_events event = eigrp_get_fsm_event(msg);
zlog_info(
- "EIGRP AS: %d State: %s Event: %s Network: %s Packet Type: %s Reply RIJ Count: %d change: %s",
+ "EIGRP AS: %d State: %s Event: %s Network: %pI4 Packet Type: %s Reply RIJ Count: %d change: %s",
msg->eigrp->AS, prefix_state2str(msg->prefix->state),
- fsm_state2str(event), eigrp_topology_ip_string(msg->prefix),
+ fsm_state2str(event), &msg->prefix->destination->u.prefix4,
packet_type2str(msg->packet_type), msg->prefix->rij->count,
change2str(msg->change));
(*(NSM[msg->prefix->state][event].func))(msg);
diff --git a/eigrpd/eigrp_hello.c b/eigrpd/eigrp_hello.c
index 6f93cd7b3e..f512833e0a 100644
--- a/eigrpd/eigrp_hello.c
+++ b/eigrpd/eigrp_hello.c
@@ -144,10 +144,11 @@ eigrp_hello_parameter_decode(struct eigrp_neighbor *nbr,
&& (eigrp->k_values[4] == nbr->K5)) {
if (eigrp_nbr_state_get(nbr) == EIGRP_NEIGHBOR_DOWN) {
- zlog_info("Neighbor %s (%s) is pending: new adjacency",
- inet_ntoa(nbr->src),
- ifindex2ifname(nbr->ei->ifp->ifindex,
- eigrp->vrf_id));
+ zlog_info(
+ "Neighbor %pI4 (%s) is pending: new adjacency",
+ &nbr->src,
+ ifindex2ifname(nbr->ei->ifp->ifindex,
+ eigrp->vrf_id));
/* Expedited hello sent */
eigrp_hello_send(nbr->ei, EIGRP_HELLO_NORMAL, NULL);
@@ -164,16 +165,16 @@ eigrp_hello_parameter_decode(struct eigrp_neighbor *nbr,
& param->K5)
== 255) {
zlog_info(
- "Neighbor %s (%s) is down: Interface PEER-TERMINATION received",
- inet_ntoa(nbr->src),
+ "Neighbor %pI4 (%s) is down: Interface PEER-TERMINATION received",
+ &nbr->src,
ifindex2ifname(nbr->ei->ifp->ifindex,
eigrp->vrf_id));
eigrp_nbr_delete(nbr);
return NULL;
} else {
zlog_info(
- "Neighbor %s (%s) going down: Kvalue mismatch",
- inet_ntoa(nbr->src),
+ "Neighbor %pI4 (%s) going down: Kvalue mismatch",
+ &nbr->src,
ifindex2ifname(nbr->ei->ifp->ifindex,
eigrp->vrf_id));
eigrp_nbr_state_set(nbr, EIGRP_NEIGHBOR_DOWN);
@@ -253,9 +254,10 @@ static void eigrp_peer_termination_decode(struct eigrp_neighbor *nbr,
uint32_t received_ip = param->neighbor_ip;
if (my_ip == received_ip) {
- zlog_info("Neighbor %s (%s) is down: Peer Termination received",
- inet_ntoa(nbr->src),
- ifindex2ifname(nbr->ei->ifp->ifindex, eigrp->vrf_id));
+ zlog_info(
+ "Neighbor %pI4 (%s) is down: Peer Termination received",
+ &nbr->src,
+ ifindex2ifname(nbr->ei->ifp->ifindex, eigrp->vrf_id));
/* set neighbor to DOWN */
nbr->state = EIGRP_NEIGHBOR_DOWN;
/* delete neighbor */
@@ -330,9 +332,9 @@ void eigrp_hello_receive(struct eigrp *eigrp, struct ip *iph,
assert(nbr);
if (IS_DEBUG_EIGRP_PACKET(eigrph->opcode - 1, RECV))
- zlog_debug("Processing Hello size[%u] int(%s) nbr(%s)", size,
+ zlog_debug("Processing Hello size[%u] int(%s) nbr(%pI4)", size,
ifindex2ifname(nbr->ei->ifp->ifindex, eigrp->vrf_id),
- inet_ntoa(nbr->src));
+ &nbr->src);
size -= EIGRP_HEADER_LEN;
if (size < 0)
@@ -403,8 +405,7 @@ void eigrp_hello_receive(struct eigrp *eigrp, struct ip *iph,
}
if (IS_DEBUG_EIGRP_PACKET(0, RECV))
- zlog_debug("Hello Packet received from %s",
- inet_ntoa(nbr->src));
+ zlog_debug("Hello Packet received from %pI4", &nbr->src);
}
uint32_t FRR_MAJOR;
@@ -708,9 +709,8 @@ void eigrp_hello_send_ack(struct eigrp_neighbor *nbr)
if (ep) {
if (IS_DEBUG_EIGRP_PACKET(0, SEND))
- zlog_debug("Queueing [Hello] Ack Seq [%u] nbr [%s]",
- nbr->recv_sequence_number,
- inet_ntoa(nbr->src));
+ zlog_debug("Queueing [Hello] Ack Seq [%u] nbr [%pI4]",
+ nbr->recv_sequence_number, &nbr->src);
/* Add packet to the top of the interface output queue*/
eigrp_fifo_push(nbr->ei->obuf, ep);
diff --git a/eigrpd/eigrp_neighbor.c b/eigrpd/eigrp_neighbor.c
index 2ae3997fae..2d5bb0a7d1 100644
--- a/eigrpd/eigrp_neighbor.c
+++ b/eigrpd/eigrp_neighbor.c
@@ -87,10 +87,6 @@ static struct eigrp_neighbor *eigrp_nbr_add(struct eigrp_interface *ei,
nbr = eigrp_nbr_new(ei);
nbr->src = iph->ip_src;
- // if (IS_DEBUG_EIGRP_EVENT)
- // zlog_debug("NSM[%s:%s]: start", IF_NAME (nbr->oi),
- // inet_ntoa (nbr->router_id));
-
return nbr;
}
@@ -197,8 +193,7 @@ int holddown_timer_expired(struct thread *thread)
struct eigrp_neighbor *nbr = THREAD_ARG(thread);
struct eigrp *eigrp = nbr->ei->eigrp;
- zlog_info("Neighbor %s (%s) is down: holding time expired",
- inet_ntoa(nbr->src),
+ zlog_info("Neighbor %pI4 (%s) is down: holding time expired", &nbr->src,
ifindex2ifname(nbr->ei->ifp->ifindex, eigrp->vrf_id));
nbr->state = EIGRP_NEIGHBOR_DOWN;
eigrp_nbr_delete(nbr);
@@ -330,13 +325,12 @@ void eigrp_nbr_hard_restart(struct eigrp_neighbor *nbr, struct vty *vty)
{
struct eigrp *eigrp = nbr->ei->eigrp;
- zlog_debug("Neighbor %s (%s) is down: manually cleared",
- inet_ntoa(nbr->src),
+ zlog_debug("Neighbor %pI4 (%s) is down: manually cleared", &nbr->src,
ifindex2ifname(nbr->ei->ifp->ifindex, eigrp->vrf_id));
if (vty != NULL) {
vty_time_print(vty, 0);
- vty_out(vty, "Neighbor %s (%s) is down: manually cleared\n",
- inet_ntoa(nbr->src),
+ vty_out(vty, "Neighbor %pI4 (%s) is down: manually cleared\n",
+ &nbr->src,
ifindex2ifname(nbr->ei->ifp->ifindex, eigrp->vrf_id));
}
diff --git a/eigrpd/eigrp_network.c b/eigrpd/eigrp_network.c
index 92b5ce3482..bd8ec2f879 100644
--- a/eigrpd/eigrp_network.c
+++ b/eigrpd/eigrp_network.c
@@ -160,9 +160,8 @@ int eigrp_if_ipmulticast(struct eigrp *top, struct prefix *p,
ret = setsockopt_ipv4_multicast_if(top->fd, p->u.prefix4, ifindex);
if (ret < 0)
zlog_warn(
- "can't setsockopt IP_MULTICAST_IF (fd %d, addr %s, ifindex %u): %s",
- top->fd, inet_ntoa(p->u.prefix4), ifindex,
- safe_strerror(errno));
+ "can't setsockopt IP_MULTICAST_IF (fd %d, addr %pI4, ifindex %u): %s",
+ top->fd, &p->u.prefix4, ifindex, safe_strerror(errno));
return ret;
}
@@ -178,12 +177,11 @@ int eigrp_if_add_allspfrouters(struct eigrp *top, struct prefix *p,
htonl(EIGRP_MULTICAST_ADDRESS), ifindex);
if (ret < 0)
zlog_warn(
- "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,
- safe_strerror(errno));
+ "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
- zlog_debug("interface %s [%u] join EIGRP Multicast group.",
- inet_ntoa(p->u.prefix4), ifindex);
+ zlog_debug("interface %pI4 [%u] join EIGRP Multicast group.",
+ &p->u.prefix4, ifindex);
return ret;
}
@@ -198,12 +196,11 @@ int eigrp_if_drop_allspfrouters(struct eigrp *top, struct prefix *p,
htonl(EIGRP_MULTICAST_ADDRESS), ifindex);
if (ret < 0)
zlog_warn(
- "can't setsockopt IP_DROP_MEMBERSHIP (fd %d, addr %s, ifindex %u, AllSPFRouters): %s",
- top->fd, inet_ntoa(p->u.prefix4), ifindex,
- safe_strerror(errno));
+ "can't setsockopt IP_DROP_MEMBERSHIP (fd %d, addr %pI4, ifindex %u, AllSPFRouters): %s",
+ top->fd, &p->u.prefix4, ifindex, safe_strerror(errno));
else
- zlog_debug("interface %s [%u] leave EIGRP Multicast group.",
- inet_ntoa(p->u.prefix4), ifindex);
+ zlog_debug("interface %pI4 [%u] leave EIGRP Multicast group.",
+ &p->u.prefix4, ifindex);
return ret;
}
diff --git a/eigrpd/eigrp_northbound.c b/eigrpd/eigrp_northbound.c
index 13887368f7..5b87f72640 100644
--- a/eigrpd/eigrp_northbound.c
+++ b/eigrpd/eigrp_northbound.c
@@ -243,10 +243,12 @@ static int eigrpd_instance_active_time_modify(struct nb_cb_modify_args *args)
switch (args->event) {
case NB_EV_VALIDATE:
/* TODO: Not implemented. */
- return NB_ERR_INCONSISTENCY;
case NB_EV_PREPARE:
case NB_EV_ABORT:
+ return NB_OK;
case NB_EV_APPLY:
+ snprintf(args->errmsg, args->errmsg_len,
+ "active time not implemented yet");
/* NOTHING */
break;
}
@@ -677,11 +679,12 @@ static int eigrpd_instance_neighbor_create(struct nb_cb_create_args *args)
switch (args->event) {
case NB_EV_VALIDATE:
/* TODO: Not implemented. */
- return NB_ERR_INCONSISTENCY;
case NB_EV_PREPARE:
case NB_EV_ABORT:
+ return NB_OK;
case NB_EV_APPLY:
- /* NOTHING */
+ snprintf(args->errmsg, args->errmsg_len,
+ "neighbor Command is not implemented yet");
break;
}
@@ -693,11 +696,12 @@ static int eigrpd_instance_neighbor_destroy(struct nb_cb_destroy_args *args)
switch (args->event) {
case NB_EV_VALIDATE:
/* TODO: Not implemented. */
- return NB_ERR_INCONSISTENCY;
case NB_EV_PREPARE:
case NB_EV_ABORT:
+ return NB_OK;
case NB_EV_APPLY:
- /* NOTHING */
+ snprintf(args->errmsg, args->errmsg_len,
+ "no neighbor Command is not implemented yet");
break;
}
@@ -768,11 +772,13 @@ eigrpd_instance_redistribute_route_map_modify(struct nb_cb_modify_args *args)
switch (args->event) {
case NB_EV_VALIDATE:
/* TODO: Not implemented. */
- return NB_ERR_INCONSISTENCY;
case NB_EV_PREPARE:
case NB_EV_ABORT:
+ return NB_OK;
case NB_EV_APPLY:
- /* NOTHING */
+ snprintf(
+ args->errmsg, args->errmsg_len,
+ "'redistribute X route-map FOO' command not implemented yet");
break;
}
@@ -785,11 +791,13 @@ eigrpd_instance_redistribute_route_map_destroy(struct nb_cb_destroy_args *args)
switch (args->event) {
case NB_EV_VALIDATE:
/* TODO: Not implemented. */
- return NB_ERR_INCONSISTENCY;
case NB_EV_PREPARE:
case NB_EV_ABORT:
+ return NB_OK;
case NB_EV_APPLY:
- /* NOTHING */
+ snprintf(
+ args->errmsg, args->errmsg_len,
+ "'no redistribute X route-map FOO' command not implemented yet");
break;
}
@@ -1079,10 +1087,12 @@ lib_interface_eigrp_split_horizon_modify(struct nb_cb_modify_args *args)
switch (args->event) {
case NB_EV_VALIDATE:
/* TODO: Not implemented. */
- return NB_ERR_INCONSISTENCY;
case NB_EV_PREPARE:
case NB_EV_ABORT:
+ return NB_OK;
case NB_EV_APPLY:
+ snprintf(args->errmsg, args->errmsg_len,
+ "split-horizon command not implemented yet");
/* NOTHING */
break;
}
@@ -1161,11 +1171,12 @@ static int lib_interface_eigrp_instance_summarize_addresses_create(
switch (args->event) {
case NB_EV_VALIDATE:
/* TODO: Not implemented. */
- return NB_ERR_INCONSISTENCY;
case NB_EV_PREPARE:
case NB_EV_ABORT:
+ return NB_OK;
case NB_EV_APPLY:
- /* NOTHING */
+ snprintf(args->errmsg, args->errmsg_len,
+ "summary command not implemented yet");
break;
}
@@ -1178,10 +1189,12 @@ static int lib_interface_eigrp_instance_summarize_addresses_destroy(
switch (args->event) {
case NB_EV_VALIDATE:
/* TODO: Not implemented. */
- return NB_ERR_INCONSISTENCY;
case NB_EV_PREPARE:
case NB_EV_ABORT:
+ return NB_OK;
case NB_EV_APPLY:
+ snprintf(args->errmsg, args->errmsg_len,
+ "no summary command not implemented yet");
/* NOTHING */
break;
}
diff --git a/eigrpd/eigrp_packet.c b/eigrpd/eigrp_packet.c
index cfff63f839..f5f6ab5dff 100644
--- a/eigrpd/eigrp_packet.c
+++ b/eigrpd/eigrp_packet.c
@@ -442,17 +442,16 @@ int eigrp_write(struct thread *thread)
if (IS_DEBUG_EIGRP_TRANSMIT(0, SEND)) {
eigrph = (struct eigrp_header *)STREAM_DATA(ep->s);
zlog_debug(
- "Sending [%s][%d/%d] to [%s] via [%s] ret [%d].",
+ "Sending [%s][%d/%d] to [%pI4] via [%s] ret [%d].",
lookup_msg(eigrp_packet_type_str, eigrph->opcode, NULL),
- seqno, ack, inet_ntoa(ep->dst), IF_NAME(ei), ret);
+ seqno, ack, &ep->dst, IF_NAME(ei), ret);
}
if (ret < 0)
zlog_warn(
- "*** sendmsg in eigrp_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,
- iph.ip_len, ei->ifp->name, ei->ifp->mtu,
- safe_strerror(errno));
+ "*** sendmsg in eigrp_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,
+ ei->ifp->name, ei->ifp->mtu, safe_strerror(errno));
/* Now delete packet from queue. */
eigrp_packet_delete(ei);
@@ -552,8 +551,8 @@ int eigrp_read(struct thread *thread)
|| (IPV4_ADDR_SAME(&srcaddr, &ei->address.u.prefix4))) {
if (IS_DEBUG_EIGRP_TRANSMIT(0, RECV))
zlog_debug(
- "eigrp_read[%s]: Dropping self-originated packet",
- inet_ntoa(srcaddr));
+ "eigrp_read[%pI4]: Dropping self-originated packet",
+ &srcaddr);
return 0;
}
@@ -596,8 +595,9 @@ int eigrp_read(struct thread *thread)
*/
else if (ei->ifp != ifp) {
if (IS_DEBUG_EIGRP_TRANSMIT(0, RECV))
- zlog_warn("Packet from [%s] received on wrong link %s",
- inet_ntoa(iph->ip_src), ifp->name);
+ zlog_warn(
+ "Packet from [%pI4] received on wrong link %s",
+ &iph->ip_src, ifp->name);
return 0;
}
@@ -606,8 +606,8 @@ int eigrp_read(struct thread *thread)
if (ret < 0) {
if (IS_DEBUG_EIGRP_TRANSMIT(0, RECV))
zlog_debug(
- "eigrp_read[%s]: Header check failed, dropping.",
- inet_ntoa(iph->ip_src));
+ "eigrp_read[%pI4]: Header check failed, dropping.",
+ &iph->ip_src);
return ret;
}
@@ -615,17 +615,12 @@ int eigrp_read(struct thread *thread)
start of the eigrp TLVs */
opcode = eigrph->opcode;
- if (IS_DEBUG_EIGRP_TRANSMIT(0, RECV)) {
- char src[PREFIX_STRLEN], dst[PREFIX_STRLEN];
-
- strlcpy(src, inet_ntoa(iph->ip_src), sizeof(src));
- strlcpy(dst, inet_ntoa(iph->ip_dst), sizeof(dst));
+ if (IS_DEBUG_EIGRP_TRANSMIT(0, RECV))
zlog_debug(
- "Received [%s][%d/%d] length [%u] via [%s] src [%s] dst [%s]",
+ "Received [%s][%d/%d] length [%u] via [%s] src [%pI4] dst [%pI4]",
lookup_msg(eigrp_packet_type_str, opcode, NULL),
ntohl(eigrph->sequence), ntohl(eigrph->ack), length,
- IF_NAME(ei), src, dst);
- }
+ IF_NAME(ei), &iph->ip_src, &iph->ip_dst);
/* Read rest of the packet and call each sort of packet routine. */
stream_forward_getp(ibuf, EIGRP_HEADER_LEN);
@@ -648,8 +643,9 @@ int eigrp_read(struct thread *thread)
&& (ntohl(eigrph->ack)
== nbr->init_sequence_number)) {
eigrp_nbr_state_set(nbr, EIGRP_NEIGHBOR_UP);
- zlog_info("Neighbor(%s) adjacency became full",
- inet_ntoa(nbr->src));
+ zlog_info(
+ "Neighbor(%pI4) adjacency became full",
+ &nbr->src);
nbr->init_sequence_number = 0;
nbr->recv_sequence_number =
ntohl(eigrph->sequence);
@@ -957,8 +953,8 @@ static int eigrp_verify_header(struct stream *ibuf, struct eigrp_interface *ei,
/* Check network mask, Silently discarded. */
if (!eigrp_check_network_mask(ei, iph->ip_src)) {
zlog_warn(
- "interface %s: eigrp_read network address is not same [%s]",
- IF_NAME(ei), inet_ntoa(iph->ip_src));
+ "interface %s: eigrp_read network address is not same [%pI4]",
+ IF_NAME(ei), &iph->ip_src);
return -1;
}
//
diff --git a/eigrpd/eigrp_reply.c b/eigrpd/eigrp_reply.c
index 79405efbbf..26bb27d7ac 100644
--- a/eigrpd/eigrp_reply.c
+++ b/eigrpd/eigrp_reply.c
@@ -168,13 +168,10 @@ void eigrp_reply_receive(struct eigrp *eigrp, struct ip *iph,
* Destination must exists
*/
if (!dest) {
- char buf[PREFIX_STRLEN];
-
flog_err(
EC_EIGRP_PACKET,
- "%s: Received prefix %s which we do not know about",
- __func__,
- prefix2str(&dest_addr, buf, sizeof(buf)));
+ "%s: Received prefix %pFX which we do not know about",
+ __func__, &dest_addr);
eigrp_IPv4_InternalTLV_free(tlv);
continue;
}
diff --git a/eigrpd/eigrp_topology.c b/eigrpd/eigrp_topology.c
index 7676af15f2..2dbee16694 100644
--- a/eigrpd/eigrp_topology.c
+++ b/eigrpd/eigrp_topology.c
@@ -133,14 +133,10 @@ void eigrp_prefix_entry_add(struct route_table *topology,
rn = route_node_get(topology, pe->destination);
if (rn->info) {
- if (IS_DEBUG_EIGRP_EVENT) {
- char buf[PREFIX_STRLEN];
-
+ if (IS_DEBUG_EIGRP_EVENT)
zlog_debug(
- "%s: %s Should we have found this entry in the topo table?",
- __func__,
- prefix2str(pe->destination, buf, sizeof(buf)));
- }
+ "%s: %pFX Should we have found this entry in the topo table?",
+ __func__, pe->destination);
route_unlock_node(rn);
}
diff --git a/eigrpd/eigrp_update.c b/eigrpd/eigrp_update.c
index 6e2a81e32a..cd30eb5ab5 100644
--- a/eigrpd/eigrp_update.c
+++ b/eigrpd/eigrp_update.c
@@ -141,10 +141,8 @@ static void eigrp_update_receive_GR_ask(struct eigrp *eigrp,
/* iterate over all prefixes which weren't advertised by neighbor */
for (ALL_LIST_ELEMENTS_RO(nbr_prefixes, node1, prefix)) {
- char buffer[PREFIX_STRLEN];
- zlog_debug(
- "GR receive: Neighbor not advertised %s",
- prefix2str(prefix->destination, buffer, PREFIX_STRLEN));
+ zlog_debug("GR receive: Neighbor not advertised %pFX",
+ prefix->destination);
fsm_msg.metrics = prefix->reported_metric;
/* set delay to MAX */
@@ -209,18 +207,18 @@ void eigrp_update_receive(struct eigrp *eigrp, struct ip *iph,
nbr->recv_sequence_number = ntohl(eigrph->sequence);
if (IS_DEBUG_EIGRP_PACKET(0, RECV))
zlog_debug(
- "Processing Update size[%u] int(%s) nbr(%s) seq [%u] flags [%0x]",
+ "Processing Update size[%u] int(%s) nbr(%pI4) seq [%u] flags [%0x]",
size,
ifindex2ifname(nbr->ei->ifp->ifindex, eigrp->vrf_id),
- inet_ntoa(nbr->src), nbr->recv_sequence_number, flags);
+ &nbr->src, nbr->recv_sequence_number, flags);
if ((flags == (EIGRP_INIT_FLAG + EIGRP_RS_FLAG + EIGRP_EOT_FLAG))
&& (!same)) {
/* Graceful restart Update received with all routes */
- zlog_info("Neighbor %s (%s) is resync: peer graceful-restart",
- inet_ntoa(nbr->src),
+ zlog_info("Neighbor %pI4 (%s) is resync: peer graceful-restart",
+ &nbr->src,
ifindex2ifname(nbr->ei->ifp->ifindex, eigrp->vrf_id));
/* get all prefixes from neighbor from topology table */
@@ -231,8 +229,8 @@ void eigrp_update_receive(struct eigrp *eigrp, struct ip *iph,
/* Graceful restart Update received, routes also in next packet
*/
- zlog_info("Neighbor %s (%s) is resync: peer graceful-restart",
- inet_ntoa(nbr->src),
+ zlog_info("Neighbor %pI4 (%s) is resync: peer graceful-restart",
+ &nbr->src,
ifindex2ifname(nbr->ei->ifp->ifindex, eigrp->vrf_id));
/* get all prefixes from neighbor from topology table */
@@ -279,15 +277,16 @@ void eigrp_update_receive(struct eigrp *eigrp, struct ip *iph,
eigrp_nbr_state_set(nbr, EIGRP_NEIGHBOR_DOWN);
eigrp_topology_neighbor_down(nbr->ei->eigrp, nbr);
nbr->recv_sequence_number = ntohl(eigrph->sequence);
- zlog_info("Neighbor %s (%s) is down: peer restarted",
- inet_ntoa(nbr->src),
+ zlog_info("Neighbor %pI4 (%s) is down: peer restarted",
+ &nbr->src,
ifindex2ifname(nbr->ei->ifp->ifindex,
eigrp->vrf_id));
eigrp_nbr_state_set(nbr, EIGRP_NEIGHBOR_PENDING);
- zlog_info("Neighbor %s (%s) is pending: new adjacency",
- inet_ntoa(nbr->src),
- ifindex2ifname(nbr->ei->ifp->ifindex,
- eigrp->vrf_id));
+ zlog_info(
+ "Neighbor %pI4 (%s) is pending: new adjacency",
+ &nbr->src,
+ ifindex2ifname(nbr->ei->ifp->ifindex,
+ eigrp->vrf_id));
eigrp_update_send_init(nbr);
}
}
@@ -450,8 +449,9 @@ void eigrp_update_send_init(struct eigrp_neighbor *nbr)
nbr->init_sequence_number = nbr->ei->eigrp->sequence_number;
ep->sequence_number = nbr->ei->eigrp->sequence_number;
if (IS_DEBUG_EIGRP_PACKET(0, RECV))
- zlog_debug("Enqueuing Update Init Len [%u] Seq [%u] Dest [%s]",
- ep->length, ep->sequence_number, inet_ntoa(ep->dst));
+ zlog_debug(
+ "Enqueuing Update Init Len [%u] Seq [%u] Dest [%pI4]",
+ ep->length, ep->sequence_number, &ep->dst);
/*Put packet to retransmission queue*/
eigrp_fifo_push(nbr->retrans_queue, ep);
@@ -480,8 +480,9 @@ static void eigrp_update_place_on_nbr_queue(struct eigrp_neighbor *nbr,
ep->sequence_number = seq_no;
if (IS_DEBUG_EIGRP_PACKET(0, RECV))
- zlog_debug("Enqueuing Update Init Len [%u] Seq [%u] Dest [%s]",
- ep->length, ep->sequence_number, inet_ntoa(ep->dst));
+ zlog_debug(
+ "Enqueuing Update Init Len [%u] Seq [%u] Dest [%pI4]",
+ ep->length, ep->sequence_number, &ep->dst);
/*Put packet to retransmission queue*/
eigrp_fifo_push(nbr->retrans_queue, ep);
@@ -815,8 +816,8 @@ static void eigrp_update_send_GR_part(struct eigrp_neighbor *nbr)
if (eigrp_update_prefix_apply(eigrp, ei, EIGRP_FILTER_OUT,
dest_addr)) {
/* do not send filtered route */
- zlog_info("Filtered prefix %s won't be sent out.",
- inet_ntoa(dest_addr->u.prefix4));
+ zlog_info("Filtered prefix %pI4 won't be sent out.",
+ &dest_addr->u.prefix4);
} else {
/* sending route which wasn't filtered */
length += eigrp_add_internalTLV_to_stream(ep->s, pe);
@@ -830,8 +831,8 @@ static void eigrp_update_send_GR_part(struct eigrp_neighbor *nbr)
if (eigrp_update_prefix_apply(eigrp, ei, EIGRP_FILTER_IN,
dest_addr)) {
/* do not send filtered route */
- zlog_info("Filtered prefix %s will be removed.",
- inet_ntoa(dest_addr->u.prefix4));
+ zlog_info("Filtered prefix %pI4 will be removed.",
+ &dest_addr->u.prefix4);
/* prepare message for FSM */
struct eigrp_fsm_action_message fsm_msg;
@@ -880,8 +881,9 @@ static void eigrp_update_send_GR_part(struct eigrp_neighbor *nbr)
ep->sequence_number = eigrp->sequence_number;
if (IS_DEBUG_EIGRP_PACKET(0, RECV))
- zlog_debug("Enqueuing Update Init Len [%u] Seq [%u] Dest [%s]",
- ep->length, ep->sequence_number, inet_ntoa(ep->dst));
+ zlog_debug(
+ "Enqueuing Update Init Len [%u] Seq [%u] Dest [%pI4]",
+ ep->length, ep->sequence_number, &ep->dst);
/*Put packet to retransmission queue*/
eigrp_fifo_push(nbr->retrans_queue, ep);
@@ -963,20 +965,20 @@ void eigrp_update_send_GR(struct eigrp_neighbor *nbr, enum GR_type gr_type,
if (gr_type == EIGRP_GR_FILTER) {
/* function was called after applying filtration */
zlog_info(
- "Neighbor %s (%s) is resync: route configuration changed",
- inet_ntoa(nbr->src),
+ "Neighbor %pI4 (%s) is resync: route configuration changed",
+ &nbr->src,
ifindex2ifname(ei->ifp->ifindex, eigrp->vrf_id));
} else if (gr_type == EIGRP_GR_MANUAL) {
/* Graceful restart was called manually */
- zlog_info("Neighbor %s (%s) is resync: manually cleared",
- inet_ntoa(nbr->src),
+ zlog_info("Neighbor %pI4 (%s) is resync: manually cleared",
+ &nbr->src,
ifindex2ifname(ei->ifp->ifindex, eigrp->vrf_id));
if (vty != NULL) {
vty_time_print(vty, 0);
vty_out(vty,
- "Neighbor %s (%s) is resync: manually cleared\n",
- inet_ntoa(nbr->src),
+ "Neighbor %pI4 (%s) is resync: manually cleared\n",
+ &nbr->src,
ifindex2ifname(ei->ifp->ifindex,
eigrp->vrf_id));
}
diff --git a/eigrpd/eigrp_vty.c b/eigrpd/eigrp_vty.c
index 4426cf67e9..66dfbaa538 100644
--- a/eigrpd/eigrp_vty.c
+++ b/eigrpd/eigrp_vty.c
@@ -360,14 +360,14 @@ DEFPY (clear_ip_eigrp_neighbors,
for (ALL_LIST_ELEMENTS(ei->nbrs, node2, nnode2, nbr)) {
if (nbr->state != EIGRP_NEIGHBOR_DOWN) {
zlog_debug(
- "Neighbor %s (%s) is down: manually cleared",
- inet_ntoa(nbr->src),
+ "Neighbor %pI4 (%s) is down: manually cleared",
+ &nbr->src,
ifindex2ifname(nbr->ei->ifp->ifindex,
eigrp->vrf_id));
vty_time_print(vty, 0);
vty_out(vty,
- "Neighbor %s (%s) is down: manually cleared\n",
- inet_ntoa(nbr->src),
+ "Neighbor %pI4 (%s) is down: manually cleared\n",
+ &nbr->src,
ifindex2ifname(nbr->ei->ifp->ifindex,
eigrp->vrf_id));
@@ -420,14 +420,15 @@ DEFPY (clear_ip_eigrp_neighbors_int,
/* iterate over all neighbors on eigrp interface */
for (ALL_LIST_ELEMENTS(ei->nbrs, node2, nnode2, nbr)) {
if (nbr->state != EIGRP_NEIGHBOR_DOWN) {
- zlog_debug("Neighbor %s (%s) is down: manually cleared",
- inet_ntoa(nbr->src),
- ifindex2ifname(nbr->ei->ifp->ifindex,
- eigrp->vrf_id));
+ zlog_debug(
+ "Neighbor %pI4 (%s) is down: manually cleared",
+ &nbr->src,
+ ifindex2ifname(nbr->ei->ifp->ifindex,
+ eigrp->vrf_id));
vty_time_print(vty, 0);
vty_out(vty,
- "Neighbor %s (%s) is down: manually cleared\n",
- inet_ntoa(nbr->src),
+ "Neighbor %pI4 (%s) is down: manually cleared\n",
+ &nbr->src,
ifindex2ifname(nbr->ei->ifp->ifindex,
eigrp->vrf_id));
diff --git a/eigrpd/eigrp_zebra.c b/eigrpd/eigrp_zebra.c
index 3205f13922..473cc75a2a 100644
--- a/eigrpd/eigrp_zebra.c
+++ b/eigrpd/eigrp_zebra.c
@@ -150,12 +150,9 @@ static int eigrp_interface_address_add(ZAPI_CALLBACK_ARGS)
if (c == NULL)
return 0;
- if (IS_DEBUG_EIGRP(zebra, ZEBRA_INTERFACE)) {
- char buf[128];
- prefix2str(c->address, buf, sizeof(buf));
- zlog_debug("Zebra: interface %s address add %s", c->ifp->name,
- buf);
- }
+ if (IS_DEBUG_EIGRP(zebra, ZEBRA_INTERFACE))
+ zlog_debug("Zebra: interface %s address add %pFX", c->ifp->name,
+ c->address);
eigrp_if_update(c->ifp);
@@ -173,12 +170,9 @@ static int eigrp_interface_address_delete(ZAPI_CALLBACK_ARGS)
if (c == NULL)
return 0;
- if (IS_DEBUG_EIGRP(zebra, ZEBRA_INTERFACE)) {
- char buf[128];
- prefix2str(c->address, buf, sizeof(buf));
- zlog_debug("Zebra: interface %s address delete %s",
- c->ifp->name, buf);
- }
+ if (IS_DEBUG_EIGRP(zebra, ZEBRA_INTERFACE))
+ zlog_debug("Zebra: interface %s address delete %pFX",
+ c->ifp->name, c->address);
ifp = c->ifp;
ei = ifp->info;
@@ -234,10 +228,9 @@ void eigrp_zebra_route_add(struct eigrp *eigrp, struct prefix *p,
api.nexthop_num = count;
if (IS_DEBUG_EIGRP(zebra, ZEBRA_REDISTRIBUTE)) {
- char buf[2][PREFIX_STRLEN];
- zlog_debug("Zebra: Route add %s nexthop %s",
- prefix2str(p, buf[0], PREFIX_STRLEN),
- inet_ntop(AF_INET, 0, buf[1], PREFIX_STRLEN));
+ char buf[PREFIX_STRLEN];
+ zlog_debug("Zebra: Route add %pFX nexthop %s", p,
+ inet_ntop(AF_INET, 0, buf, PREFIX_STRLEN));
}
zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api);
@@ -257,11 +250,8 @@ void eigrp_zebra_route_delete(struct eigrp *eigrp, struct prefix *p)
memcpy(&api.prefix, p, sizeof(*p));
zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api);
- if (IS_DEBUG_EIGRP(zebra, ZEBRA_REDISTRIBUTE)) {
- char buf[PREFIX_STRLEN];
- zlog_debug("Zebra: Route del %s",
- prefix2str(p, buf, PREFIX_STRLEN));
- }
+ if (IS_DEBUG_EIGRP(zebra, ZEBRA_REDISTRIBUTE))
+ zlog_debug("Zebra: Route del %pFX", p);
return;
}
diff --git a/eigrpd/eigrpd.c b/eigrpd/eigrpd.c
index 820f015b57..5002630796 100644
--- a/eigrpd/eigrpd.c
+++ b/eigrpd/eigrpd.c
@@ -110,10 +110,6 @@ void eigrp_router_id_update(struct eigrp *eigrp)
eigrp->router_id = router_id;
if (router_id_old.s_addr != router_id.s_addr) {
- // if (IS_DEBUG_EIGRP_EVENT)
- // zlog_debug("Router-ID[NEW:%s]: Update",
- // inet_ntoa(eigrp->router_id));
-
/* update eigrp_interface's */
FOR_ALL_INTERFACES (vrf, ifp)
eigrp_if_update(ifp);
diff --git a/isisd/isis_adjacency.c b/isisd/isis_adjacency.c
index 5bfbb2cf7e..59403b6c23 100644
--- a/isisd/isis_adjacency.c
+++ b/isisd/isis_adjacency.c
@@ -393,7 +393,7 @@ void isis_adj_print(struct isis_adjacency *adj)
if (adj->ipv4_address_count) {
zlog_debug("IPv4 Address(es):");
for (unsigned int i = 0; i < adj->ipv4_address_count; i++)
- zlog_debug("%s", inet_ntoa(adj->ipv4_addresses[i]));
+ zlog_debug("%pI4", &adj->ipv4_addresses[i]);
}
if (adj->ipv6_address_count) {
@@ -562,8 +562,8 @@ void isis_adj_print_vty(struct isis_adjacency *adj, struct vty *vty,
vty_out(vty, " IPv4 Address(es):\n");
for (unsigned int i = 0; i < adj->ipv4_address_count;
i++)
- vty_out(vty, " %s\n",
- inet_ntoa(adj->ipv4_addresses[i]));
+ vty_out(vty, " %pI4\n",
+ &adj->ipv4_addresses[i]);
}
if (adj->ipv6_address_count) {
vty_out(vty, " IPv6 Address(es):\n");
diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c
index 695e1318ae..3eb3b900a5 100644
--- a/isisd/isis_circuit.c
+++ b/isisd/isis_circuit.c
@@ -253,9 +253,6 @@ void isis_circuit_add_addr(struct isis_circuit *circuit,
{
struct listnode *node;
struct prefix_ipv4 *ipv4;
-#if defined(EXTREME_DEBUG)
- char buf[PREFIX2STR_BUFFER];
-#endif
struct prefix_ipv6 *ipv6;
if (connected->address->family == AF_INET) {
@@ -287,9 +284,8 @@ void isis_circuit_add_addr(struct isis_circuit *circuit,
0);
#ifdef EXTREME_DEBUG
- prefix2str(connected->address, buf, sizeof(buf));
- zlog_debug("Added IP address %s to circuit %s", buf,
- circuit->interface->name);
+ zlog_debug("Added IP address %pFX to circuit %s",
+ connected->address, circuit->interface->name);
#endif /* EXTREME_DEBUG */
}
if (connected->address->family == AF_INET6) {
@@ -318,9 +314,8 @@ void isis_circuit_add_addr(struct isis_circuit *circuit,
0);
#ifdef EXTREME_DEBUG
- prefix2str(connected->address, buf, sizeof(buf));
- zlog_debug("Added IPv6 address %s to circuit %s", buf,
- circuit->interface->name);
+ zlog_debug("Added IPv6 address %pFX to circuit %s",
+ connected->address, circuit->interface->name);
#endif /* EXTREME_DEBUG */
}
return;
@@ -331,7 +326,6 @@ void isis_circuit_del_addr(struct isis_circuit *circuit,
{
struct prefix_ipv4 *ipv4, *ip = NULL;
struct listnode *node;
- char buf[PREFIX2STR_BUFFER];
struct prefix_ipv6 *ipv6, *ip6 = NULL;
int found = 0;
@@ -352,16 +346,14 @@ void isis_circuit_del_addr(struct isis_circuit *circuit,
lsp_regenerate_schedule(circuit->area,
circuit->is_type, 0);
} else {
- prefix2str(connected->address, buf, sizeof(buf));
zlog_warn(
- "Nonexistent ip address %s removal attempt from circuit %s",
- buf, circuit->interface->name);
+ "Nonexistent ip address %pFX removal attempt from circuit %s",
+ connected->address, circuit->interface->name);
zlog_warn("Current ip addresses on %s:",
circuit->interface->name);
for (ALL_LIST_ELEMENTS_RO(circuit->ip_addrs, node,
ip)) {
- prefix2str(ip, buf, sizeof(buf));
- zlog_warn(" %s", buf);
+ zlog_warn(" %pFX", ip);
}
zlog_warn("End of addresses");
}
@@ -400,25 +392,18 @@ void isis_circuit_del_addr(struct isis_circuit *circuit,
}
if (!found) {
- prefix2str(connected->address, buf, sizeof(buf));
zlog_warn(
- "Nonexistent ip address %s removal attempt from circuit %s",
- buf, circuit->interface->name);
+ "Nonexistent ip address %pFX removal attempt from circuit %s",
+ connected->address, circuit->interface->name);
zlog_warn("Current ip addresses on %s:",
circuit->interface->name);
for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_link, node,
- ip6)) {
- prefix2str((struct prefix *)ip6, (char *)buf,
- sizeof(buf));
- zlog_warn(" %s", buf);
- }
+ ip6))
+ zlog_warn(" %pFX", (struct prefix *)ip6);
zlog_warn(" -----");
for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_non_link, node,
- ip6)) {
- prefix2str((struct prefix *)ip6, (char *)buf,
- sizeof(buf));
- zlog_warn(" %s", buf);
- }
+ ip6))
+ zlog_warn(" %pFX", (struct prefix *)ip6);
zlog_warn("End of addresses");
} else if (circuit->area)
lsp_regenerate_schedule(circuit->area, circuit->is_type,
@@ -895,7 +880,6 @@ void isis_circuit_print_vty(struct isis_circuit *circuit, struct vty *vty,
if (detail == ISIS_UI_LEVEL_DETAIL) {
struct listnode *node;
struct prefix *ip_addr;
- char buf[BUFSIZ];
vty_out(vty, " Interface: %s", circuit->interface->name);
vty_out(vty, ", State: %s",
@@ -980,27 +964,21 @@ void isis_circuit_print_vty(struct isis_circuit *circuit, struct vty *vty,
if (circuit->ip_addrs && listcount(circuit->ip_addrs) > 0) {
vty_out(vty, " IP Prefix(es):\n");
for (ALL_LIST_ELEMENTS_RO(circuit->ip_addrs, node,
- ip_addr)) {
- prefix2str(ip_addr, buf, sizeof(buf));
- vty_out(vty, " %s\n", buf);
- }
+ ip_addr))
+ vty_out(vty, " %pFX\n", ip_addr);
}
if (circuit->ipv6_link && listcount(circuit->ipv6_link) > 0) {
vty_out(vty, " IPv6 Link-Locals:\n");
for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_link, node,
- ip_addr)) {
- prefix2str(ip_addr, (char *)buf, BUFSIZ);
- vty_out(vty, " %s\n", buf);
- }
+ ip_addr))
+ vty_out(vty, " %pFX\n", ip_addr);
}
if (circuit->ipv6_non_link
&& listcount(circuit->ipv6_non_link) > 0) {
vty_out(vty, " IPv6 Prefixes:\n");
for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_non_link, node,
- ip_addr)) {
- prefix2str(ip_addr, (char *)buf, BUFSIZ);
- vty_out(vty, " %s\n", buf);
- }
+ ip_addr))
+ vty_out(vty, " %pFX\n", ip_addr);
}
vty_out(vty, "\n");
diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c
index 7abfbe63cc..2e38663d3f 100644
--- a/isisd/isis_lsp.c
+++ b/isisd/isis_lsp.c
@@ -852,7 +852,6 @@ static struct isis_lsp *lsp_next_frag(uint8_t frag_num, struct isis_lsp *lsp0,
static void lsp_build(struct isis_lsp *lsp, struct isis_area *area)
{
int level = lsp->level;
- char buf[PREFIX2STR_BUFFER];
struct listnode *node;
struct isis_lsp *frag;
@@ -964,9 +963,8 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area)
*/
if (area->isis->router_id != 0) {
struct in_addr id = {.s_addr = area->isis->router_id};
- inet_ntop(AF_INET, &id, buf, sizeof(buf));
- lsp_debug("ISIS (%s): Adding router ID %s as IPv4 tlv.",
- area->area_tag, buf);
+ lsp_debug("ISIS (%s): Adding router ID %pI4 as IPv4 tlv.",
+ area->area_tag, &id);
isis_tlvs_add_ipv4_address(lsp->tlvs, &id);
/* If new style TLV's are in use, add TE router ID TLV
@@ -1033,10 +1031,8 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area)
ipv4)) {
if (area->oldmetric) {
lsp_debug(
- "ISIS (%s): Adding old-style IP reachability for %s",
- area->area_tag,
- prefix2str(ipv4, buf,
- sizeof(buf)));
+ "ISIS (%s): Adding old-style IP reachability for %pFX",
+ area->area_tag, ipv4);
isis_tlvs_add_oldstyle_ip_reach(
lsp->tlvs, ipv4, metric);
}
@@ -1045,10 +1041,8 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area)
struct sr_prefix_cfg *pcfg = NULL;
lsp_debug(
- "ISIS (%s): Adding te-style IP reachability for %s",
- area->area_tag,
- prefix2str(ipv4, buf,
- sizeof(buf)));
+ "ISIS (%s): Adding te-style IP reachability for %pFX",
+ area->area_tag, ipv4);
if (area->srdb.enabled)
pcfg = isis_sr_cfg_prefix_find(
@@ -1071,9 +1065,8 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area)
struct sr_prefix_cfg *pcfg = NULL;
lsp_debug(
- "ISIS (%s): Adding IPv6 reachability for %s",
- area->area_tag,
- prefix2str(ipv6, buf, sizeof(buf)));
+ "ISIS (%s): Adding IPv6 reachability for %pFX",
+ area->area_tag, ipv6);
if (area->srdb.enabled)
pcfg = isis_sr_cfg_prefix_find(area,
diff --git a/isisd/isis_redist.c b/isisd/isis_redist.c
index 44422ff664..e6c7a734bd 100644
--- a/isisd/isis_redist.c
+++ b/isisd/isis_redist.c
@@ -231,11 +231,8 @@ void isis_redist_add(struct isis *isis, int type, struct prefix *p,
int level;
struct isis_redist *redist;
- char debug_buf[BUFSIZ];
- prefix2str(p, debug_buf, sizeof(debug_buf));
-
- zlog_debug("%s: New route %s from %s: distance %d.", __func__,
- debug_buf, zebra_route_string(type), distance);
+ zlog_debug("%s: New route %pFX from %s: distance %d.", __func__, p,
+ zebra_route_string(type), distance);
if (!ei_table) {
zlog_warn("%s: External information table not initialized.",
@@ -282,10 +279,7 @@ void isis_redist_delete(struct isis *isis, int type, struct prefix *p,
int level;
struct isis_redist *redist;
- char debug_buf[BUFSIZ];
- prefix2str(p, debug_buf, sizeof(debug_buf));
-
- zlog_debug("%s: Removing route %s from %s.", __func__, debug_buf,
+ zlog_debug("%s: Removing route %pFX from %s.", __func__, p,
zebra_route_string(type));
if (is_default_prefix(p)
@@ -307,11 +301,9 @@ void isis_redist_delete(struct isis *isis, int type, struct prefix *p,
ei_node = srcdest_rnode_lookup(ei_table, p, src_p);
if (!ei_node || !ei_node->info) {
- char buf[BUFSIZ];
- prefix2str(p, buf, sizeof(buf));
zlog_warn(
- "%s: Got a delete for %s route %s, but that route was never added.",
- __func__, zebra_route_string(type), buf);
+ "%s: Got a delete for %s route %pFX, but that route was never added.",
+ __func__, zebra_route_string(type), p);
if (ei_node)
route_unlock_node(ei_node);
return;
diff --git a/isisd/isis_route.c b/isisd/isis_route.c
index 0868ab487c..7e8c877bd0 100644
--- a/isisd/isis_route.c
+++ b/isisd/isis_route.c
@@ -313,12 +313,8 @@ struct isis_route_info *isis_route_create(struct prefix *prefix,
{
struct route_node *route_node;
struct isis_route_info *rinfo_new, *rinfo_old, *route_info = NULL;
- char buff[PREFIX2STR_BUFFER];
char change_buf[64];
- /* for debugs */
- prefix2str(prefix, buff, sizeof(buff));
-
if (!table)
return NULL;
@@ -329,31 +325,32 @@ struct isis_route_info *isis_route_create(struct prefix *prefix,
rinfo_old = route_node->info;
if (!rinfo_old) {
if (IS_DEBUG_RTE_EVENTS)
- zlog_debug("ISIS-Rte (%s) route created: %s",
- area->area_tag, buff);
+ zlog_debug("ISIS-Rte (%s) route created: %pFX",
+ area->area_tag, prefix);
route_info = rinfo_new;
UNSET_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED);
} else {
route_unlock_node(route_node);
#ifdef EXTREME_DEBUG
if (IS_DEBUG_RTE_EVENTS)
- zlog_debug("ISIS-Rte (%s) route already exists: %s",
- area->area_tag, buff);
+ zlog_debug("ISIS-Rte (%s) route already exists: %pFX",
+ area->area_tag, prefix);
#endif /* EXTREME_DEBUG */
if (isis_route_info_same(rinfo_new, rinfo_old, change_buf,
sizeof(change_buf))) {
#ifdef EXTREME_DEBUG
if (IS_DEBUG_RTE_EVENTS)
- zlog_debug("ISIS-Rte (%s) route unchanged: %s",
- area->area_tag, buff);
+ zlog_debug(
+ "ISIS-Rte (%s) route unchanged: %pFX",
+ area->area_tag, prefix);
#endif /* EXTREME_DEBUG */
isis_route_info_delete(rinfo_new);
route_info = rinfo_old;
} else {
if (IS_DEBUG_RTE_EVENTS)
zlog_debug(
- "ISIS-Rte (%s): route changed: %s, change: %s",
- area->area_tag, buff, change_buf);
+ "ISIS-Rte (%s): route changed: %pFX, change: %s",
+ area->area_tag, prefix, change_buf);
isis_route_info_delete(rinfo_old);
route_info = rinfo_new;
UNSET_FLAG(route_info->flag,
diff --git a/isisd/isis_te.c b/isisd/isis_te.c
index 87c4428155..8daa2b36bf 100644
--- a/isisd/isis_te.c
+++ b/isisd/isis_te.c
@@ -336,10 +336,8 @@ DEFUN(show_isis_mpls_te_router,
if (ntohs(area->mta->router_id.s_addr)
!= 0)
vty_out(vty,
- " MPLS-TE Router-Address: %s\n",
- inet_ntoa(
- area->mta
- ->router_id));
+ " MPLS-TE Router-Address: %pI4\n",
+ &area->mta->router_id);
else
vty_out(vty, " N/A\n");
}
@@ -357,9 +355,8 @@ DEFUN(show_isis_mpls_te_router,
vty_out(vty, "Area %s:\n", area->area_tag);
if (ntohs(area->mta->router_id.s_addr) != 0)
vty_out(vty,
- " MPLS-TE Router-Address: %s\n",
- inet_ntoa(
- area->mta->router_id));
+ " MPLS-TE Router-Address: %pI4\n",
+ &area->mta->router_id);
else
vty_out(vty, " N/A\n");
}
@@ -394,11 +391,11 @@ static void show_ext_sub(struct vty *vty, char *name,
ext->remote_llri);
}
if (IS_SUBTLV(ext, EXT_LOCAL_ADDR))
- sbuf_push(&buf, 4, "Local Interface IP Address(es): %s\n",
- inet_ntoa(ext->local_addr));
+ sbuf_push(&buf, 4, "Local Interface IP Address(es): %pI4\n",
+ &ext->local_addr);
if (IS_SUBTLV(ext, EXT_NEIGH_ADDR))
- sbuf_push(&buf, 4, "Remote Interface IP Address(es): %s\n",
- inet_ntoa(ext->neigh_addr));
+ sbuf_push(&buf, 4, "Remote Interface IP Address(es): %pI4\n",
+ &ext->neigh_addr);
if (IS_SUBTLV(ext, EXT_LOCAL_ADDR6))
sbuf_push(&buf, 4, "Local Interface IPv6 Address(es): %s\n",
inet_ntop(AF_INET6, &ext->local_addr6, ibuf,
@@ -432,8 +429,8 @@ static void show_ext_sub(struct vty *vty, char *name,
ext->remote_as);
if (IS_SUBTLV(ext, EXT_RMT_IP))
sbuf_push(&buf, 4,
- "Inter-AS TE Remote ASBR IP address: %s\n",
- inet_ntoa(ext->remote_ip));
+ "Inter-AS TE Remote ASBR IP address: %pI4\n",
+ &ext->remote_ip);
if (IS_SUBTLV(ext, EXT_DELAY))
sbuf_push(&buf, 4,
"%s Average Link Delay: %u (micro-sec)\n",
diff --git a/isisd/isis_tlvs.c b/isisd/isis_tlvs.c
index a1f9cc236f..c1603d2ef0 100644
--- a/isisd/isis_tlvs.c
+++ b/isisd/isis_tlvs.c
@@ -209,11 +209,11 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts,
exts->remote_llri);
}
if (IS_SUBTLV(exts, EXT_LOCAL_ADDR))
- sbuf_push(buf, indent, "Local Interface IP Address(es): %s\n",
- inet_ntoa(exts->local_addr));
+ sbuf_push(buf, indent, "Local Interface IP Address(es): %pI4\n",
+ &exts->local_addr);
if (IS_SUBTLV(exts, EXT_NEIGH_ADDR))
- sbuf_push(buf, indent, "Remote Interface IP Address(es): %s\n",
- inet_ntoa(exts->neigh_addr));
+ sbuf_push(buf, indent, "Remote Interface IP Address(es): %pI4\n",
+ &exts->neigh_addr);
if (IS_SUBTLV(exts, EXT_LOCAL_ADDR6))
sbuf_push(buf, indent, "Local Interface IPv6 Address(es): %s\n",
inet_ntop(AF_INET6, &exts->local_addr6, ibuf,
@@ -247,8 +247,8 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts,
exts->remote_as);
if (IS_SUBTLV(exts, EXT_RMT_IP))
sbuf_push(buf, indent,
- "Inter-AS TE Remote ASBR IP address: %s\n",
- inet_ntoa(exts->remote_ip));
+ "Inter-AS TE Remote ASBR IP address: %pI4\n",
+ &exts->remote_ip);
/* Extended metrics */
if (IS_SUBTLV(exts, EXT_DELAY))
sbuf_push(buf, indent,
diff --git a/isisd/isis_zebra.c b/isisd/isis_zebra.c
index 0e92dc2a89..aeb54fce28 100644
--- a/isisd/isis_zebra.c
+++ b/isisd/isis_zebra.c
@@ -87,10 +87,6 @@ static int isis_zebra_if_address_add(ZAPI_CALLBACK_ARGS)
{
struct isis_circuit *circuit;
struct connected *c;
-#ifdef EXTREME_DEBUG
- struct prefix *p;
- char buf[PREFIX2STR_BUFFER];
-#endif /* EXTREME_DEBUG */
c = zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_ADD,
zclient->ibuf, vrf_id);
@@ -99,13 +95,10 @@ static int isis_zebra_if_address_add(ZAPI_CALLBACK_ARGS)
return 0;
#ifdef EXTREME_DEBUG
- p = c->address;
- prefix2str(p, buf, sizeof(buf));
-
if (p->family == AF_INET)
- zlog_debug("connected IP address %s", buf);
+ zlog_debug("connected IP address %pFX", c->address);
if (p->family == AF_INET6)
- zlog_debug("connected IPv6 address %s", buf);
+ zlog_debug("connected IPv6 address %pFX", c->address);
#endif /* EXTREME_DEBUG */
if (if_is_operative(c->ifp)) {
@@ -121,10 +114,6 @@ static int isis_zebra_if_address_del(ZAPI_CALLBACK_ARGS)
{
struct isis_circuit *circuit;
struct connected *c;
-#ifdef EXTREME_DEBUG
- struct prefix *p;
- char buf[PREFIX2STR_BUFFER];
-#endif /* EXTREME_DEBUG */
c = zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_DELETE,
zclient->ibuf, vrf_id);
@@ -133,13 +122,10 @@ static int isis_zebra_if_address_del(ZAPI_CALLBACK_ARGS)
return 0;
#ifdef EXTREME_DEBUG
- p = c->address;
- prefix2str(p, buf, sizeof(buf));
-
if (p->family == AF_INET)
- zlog_debug("disconnected IP address %s", buf);
+ zlog_debug("disconnected IP address %pFX", c->address);
if (p->family == AF_INET6)
- zlog_debug("disconnected IPv6 address %s", buf);
+ zlog_debug("disconnected IPv6 address %pFX", c->address);
#endif /* EXTREME_DEBUG */
if (if_is_operative(c->ifp)) {
diff --git a/ldpd/address.c b/ldpd/address.c
index 74a3f5a309..c3e27357b5 100644
--- a/ldpd/address.c
+++ b/ldpd/address.c
@@ -410,8 +410,8 @@ static void
log_msg_address(int out, uint16_t msg_type, struct nbr *nbr, int af,
union ldpd_addr *addr)
{
- debug_msg(out, "%s: lsr-id %s, address %s", msg_name(msg_type),
- inet_ntoa(nbr->id), log_addr(af, addr));
+ debug_msg(out, "%s: lsr-id %pI4, address %s", msg_name(msg_type),
+ &nbr->id, log_addr(af, addr));
}
static void
@@ -419,7 +419,7 @@ log_msg_mac_withdrawal(int out, struct nbr *nbr, uint8_t *mac)
{
char buf[ETHER_ADDR_STRLEN];
- debug_msg(out, "mac withdrawal: lsr-id %s, mac %s", inet_ntoa(nbr->id),
+ debug_msg(out, "mac withdrawal: lsr-id %pI4, mac %s", &nbr->id,
(mac) ? prefix_mac2str((struct ethaddr *)mac, buf, sizeof(buf)) :
"wildcard");
}
diff --git a/ldpd/adjacency.c b/ldpd/adjacency.c
index 4e09a6c4c9..3923c169d6 100644
--- a/ldpd/adjacency.c
+++ b/ldpd/adjacency.c
@@ -84,7 +84,7 @@ adj_new(struct in_addr lsr_id, struct hello_source *source,
{
struct adj *adj;
- log_debug("%s: lsr-id %s, %s", __func__, inet_ntoa(lsr_id),
+ log_debug("%s: lsr-id %pI4, %s", __func__, &lsr_id,
log_hello_src(source));
if ((adj = calloc(1, sizeof(*adj))) == NULL)
@@ -114,7 +114,7 @@ adj_del(struct adj *adj, uint32_t notif_status)
{
struct nbr *nbr = adj->nbr;
- log_debug("%s: lsr-id %s, %s (%s)", __func__, inet_ntoa(adj->lsr_id),
+ log_debug("%s: lsr-id %pI4, %s (%s)", __func__, &adj->lsr_id,
log_hello_src(&adj->source), af_name(adj_get_af(adj)));
adj_stop_itimer(adj);
@@ -179,7 +179,7 @@ adj_itimer(struct thread *thread)
adj->inactivity_timer = NULL;
- log_debug("%s: lsr-id %s", __func__, inet_ntoa(adj->lsr_id));
+ log_debug("%s: lsr-id %pI4", __func__, &adj->lsr_id);
if (adj->source.type == HELLO_TARGETED) {
if (!(adj->source.target->flags & F_TNBR_CONFIGURED) &&
diff --git a/ldpd/hello.c b/ldpd/hello.c
index caf63c13d7..327cb32434 100644
--- a/ldpd/hello.c
+++ b/ldpd/hello.c
@@ -179,24 +179,24 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af,
r = tlv_decode_hello_prms(buf, len, &holdtime, &flags);
if (r == -1) {
- log_debug("%s: lsr-id %s: failed to decode params", __func__,
- inet_ntoa(lsr_id));
+ log_debug("%s: lsr-id %pI4: failed to decode params", __func__,
+ &lsr_id);
return;
}
/* safety checks */
if (holdtime != 0 && holdtime < MIN_HOLDTIME) {
- log_debug("%s: lsr-id %s: invalid hello holdtime (%u)",
- __func__, inet_ntoa(lsr_id), holdtime);
+ log_debug("%s: lsr-id %pI4: invalid hello holdtime (%u)",
+ __func__, &lsr_id, holdtime);
return;
}
if (multicast && (flags & F_HELLO_TARGETED)) {
- log_debug("%s: lsr-id %s: multicast targeted hello", __func__,
- inet_ntoa(lsr_id));
+ log_debug("%s: lsr-id %pI4: multicast targeted hello", __func__,
+ &lsr_id);
return;
}
if (!multicast && !((flags & F_HELLO_TARGETED))) {
- log_debug("%s: lsr-id %s: unicast link hello", __func__,
- inet_ntoa(lsr_id));
+ log_debug("%s: lsr-id %pI4: unicast link hello", __func__,
+ &lsr_id);
return;
}
buf += r;
@@ -205,13 +205,13 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af,
r = tlv_decode_opt_hello_prms(buf, len, &tlvs_rcvd, af, &trans_addr,
&conf_seqnum, &trans_pref);
if (r == -1) {
- log_debug("%s: lsr-id %s: failed to decode optional params",
- __func__, inet_ntoa(lsr_id));
+ log_debug("%s: lsr-id %pI4: failed to decode optional params",
+ __func__, &lsr_id);
return;
}
if (r != len) {
- log_debug("%s: lsr-id %s: unexpected data in message",
- __func__, inet_ntoa(lsr_id));
+ log_debug("%s: lsr-id %pI4: unexpected data in message",
+ __func__, &lsr_id);
return;
}
ds_tlv = (tlvs_rcvd & F_HELLO_TLV_RCVD_DS) ? 1 : 0;
@@ -220,8 +220,8 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af,
if (!(tlvs_rcvd & F_HELLO_TLV_RCVD_ADDR))
trans_addr = *src;
if (bad_addr(af, &trans_addr)) {
- log_debug("%s: lsr-id %s: invalid transport address %s",
- __func__, inet_ntoa(lsr_id), log_addr(af, &trans_addr));
+ log_debug("%s: lsr-id %pI4: invalid transport address %s",
+ __func__, &lsr_id, log_addr(af, &trans_addr));
return;
}
if (af == AF_INET6 && IN6_IS_SCOPE_EMBED(&trans_addr.v6)) {
@@ -234,7 +234,7 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af,
* check)".
*/
if (flags & F_HELLO_TARGETED) {
- log_debug("%s: lsr-id %s: invalid targeted hello transport address %s", __func__, inet_ntoa(lsr_id),
+ log_debug("%s: lsr-id %pI4: invalid targeted hello transport address %s", __func__, &lsr_id,
log_addr(af, &trans_addr));
return;
}
@@ -249,8 +249,8 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af,
* targeted LDP Hello packet's source or destination addresses".
*/
if (af == AF_INET6 && IN6_IS_SCOPE_EMBED(&src->v6)) {
- log_debug("%s: lsr-id %s: targeted hello with link-local source address", __func__,
- inet_ntoa(lsr_id));
+ log_debug("%s: lsr-id %pI4: targeted hello with link-local source address", __func__,
+ &lsr_id);
return;
}
@@ -290,8 +290,8 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af,
source.link.src_addr = *src;
}
- debug_hello_recv("%s lsr-id %s transport-address %s holdtime %u%s",
- log_hello_src(&source), inet_ntoa(lsr_id), log_addr(af, &trans_addr),
+ debug_hello_recv("%s lsr-id %pI4 transport-address %s holdtime %u%s",
+ log_hello_src(&source), &lsr_id, log_addr(af, &trans_addr),
holdtime, (ds_tlv) ? " (dual stack TLV present)" : "");
adj = adj_find(lsr_id, &source);
@@ -316,7 +316,7 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af,
* send a fatal Notification message with status code of
* 'Transport Connection Mismatch' and reset the session".
*/
- log_debug("%s: lsr-id %s: remote transport preference does not match the local preference", __func__, inet_ntoa(lsr_id));
+ log_debug("%s: lsr-id %pI4: remote transport preference does not match the local preference", __func__, &lsr_id);
if (nbr)
session_shutdown(nbr, S_TRANS_MISMTCH, msg->id,
msg->type);
@@ -356,7 +356,7 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af,
if (nbr && nbr->af == af &&
(ldp_addrcmp(af, &nbr->raddr, &trans_addr) ||
nbr->raddr_scope != scope_id)) {
- log_warnx("%s: lsr-id %s: hello packet advertising a different transport address", __func__, inet_ntoa(lsr_id));
+ log_warnx("%s: lsr-id %pI4: hello packet advertising a different transport address", __func__, &lsr_id);
if (adj)
adj_del(adj, S_SHUTDOWN);
return;
@@ -364,8 +364,8 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af,
if (nbr == NULL) {
nbrt = nbr_find_addr(af, &trans_addr);
if (nbrt) {
- log_debug("%s: transport address %s is already being used by lsr-id %s", __func__, log_addr(af,
- &trans_addr), inet_ntoa(nbrt->id));
+ log_debug("%s: transport address %s is already being used by lsr-id %pI4", __func__, log_addr(af,
+ &trans_addr), &nbrt->id);
if (adj)
adj_del(adj, S_SHUTDOWN);
return;
diff --git a/ldpd/init.c b/ldpd/init.c
index 30b78315f9..d394fb08ea 100644
--- a/ldpd/init.c
+++ b/ldpd/init.c
@@ -35,7 +35,7 @@ send_init(struct nbr *nbr)
uint16_t size;
int err = 0;
- debug_msg_send("initialization: lsr-id %s", inet_ntoa(nbr->id));
+ debug_msg_send("initialization: lsr-id %pI4", &nbr->id);
size = LDP_HDR_SIZE + LDP_MSG_SIZE + SESS_PRMS_SIZE +
CAP_TLV_DYNAMIC_SIZE + CAP_TLV_TWCARD_SIZE + CAP_TLV_UNOTIF_SIZE;
@@ -65,7 +65,7 @@ recv_init(struct nbr *nbr, char *buf, uint16_t len)
uint16_t max_pdu_len;
int caps_rcvd = 0;
- debug_msg_recv("initialization: lsr-id %s", inet_ntoa(nbr->id));
+ debug_msg_recv("initialization: lsr-id %pI4", &nbr->id);
memcpy(&msg, buf, sizeof(msg));
buf += LDP_MSG_SIZE;
@@ -146,8 +146,8 @@ recv_init(struct nbr *nbr, char *buf, uint16_t len)
nbr->flags |= F_NBR_CAP_DYNAMIC;
- log_debug("%s: lsr-id %s announced the Dynamic Capability Announcement capability", __func__,
- inet_ntoa(nbr->id));
+ log_debug("%s: lsr-id %pI4 announced the Dynamic Capability Announcement capability", __func__,
+ &nbr->id);
break;
case TLV_TYPE_TWCARD_CAP:
if (tlv_len != CAP_TLV_TWCARD_LEN) {
@@ -165,7 +165,7 @@ recv_init(struct nbr *nbr, char *buf, uint16_t len)
nbr->flags |= F_NBR_CAP_TWCARD;
- log_debug("%s: lsr-id %s announced the Typed Wildcard FEC capability", __func__, inet_ntoa(nbr->id));
+ log_debug("%s: lsr-id %pI4 announced the Typed Wildcard FEC capability", __func__, &nbr->id);
break;
case TLV_TYPE_UNOTIF_CAP:
if (tlv_len != CAP_TLV_UNOTIF_LEN) {
@@ -183,8 +183,8 @@ recv_init(struct nbr *nbr, char *buf, uint16_t len)
nbr->flags |= F_NBR_CAP_UNOTIF;
- log_debug("%s: lsr-id %s announced the Unrecognized Notification capability", __func__,
- inet_ntoa(nbr->id));
+ log_debug("%s: lsr-id %pI4 announced the Unrecognized Notification capability", __func__,
+ &nbr->id);
break;
default:
if (!(ntohs(tlv.type) & UNKNOWN_FLAG))
@@ -222,7 +222,7 @@ send_capability(struct nbr *nbr, uint16_t capability, int enable)
uint16_t size;
int err = 0;
- log_debug("%s: lsr-id %s", __func__, inet_ntoa(nbr->id));
+ log_debug("%s: lsr-id %pI4", __func__, &nbr->id);
size = LDP_HDR_SIZE + LDP_MSG_SIZE + CAP_TLV_DYNAMIC_SIZE;
if ((buf = ibuf_open(size)) == NULL)
@@ -268,7 +268,7 @@ recv_capability(struct nbr *nbr, char *buf, uint16_t len)
int enable = 0;
int caps_rcvd = 0;
- log_debug("%s: lsr-id %s", __func__, inet_ntoa(nbr->id));
+ log_debug("%s: lsr-id %pI4", __func__, &nbr->id);
memcpy(&msg, buf, sizeof(msg));
buf += LDP_MSG_SIZE;
@@ -318,7 +318,7 @@ recv_capability(struct nbr *nbr, char *buf, uint16_t len)
else
nbr->flags &= ~F_NBR_CAP_TWCARD;
- log_debug("%s: lsr-id %s %s the Typed Wildcard FEC capability", __func__, inet_ntoa(nbr->id),
+ log_debug("%s: lsr-id %pI4 %s the Typed Wildcard FEC capability", __func__, &nbr->id,
(enable) ? "announced" : "withdrew");
break;
case TLV_TYPE_UNOTIF_CAP:
@@ -342,8 +342,8 @@ recv_capability(struct nbr *nbr, char *buf, uint16_t len)
else
nbr->flags &= ~F_NBR_CAP_UNOTIF;
- log_debug("%s: lsr-id %s %s the Unrecognized Notification capability", __func__,
- inet_ntoa(nbr->id), (enable) ? "announced" :
+ log_debug("%s: lsr-id %pI4 %s the Unrecognized Notification capability", __func__,
+ &nbr->id, (enable) ? "announced" :
"withdrew");
break;
case TLV_TYPE_DYNAMIC_CAP:
diff --git a/ldpd/interface.c b/ldpd/interface.c
index bc8f26bc58..8b3dd71fd7 100644
--- a/ldpd/interface.c
+++ b/ldpd/interface.c
@@ -578,15 +578,15 @@ if_join_ipv4_group(struct iface *iface, struct in_addr *addr)
{
struct in_addr if_addr;
- log_debug("%s: interface %s addr %s", __func__, iface->name,
- inet_ntoa(*addr));
+ log_debug("%s: interface %s addr %pI4", __func__, iface->name,
+ addr);
if_addr.s_addr = if_get_ipv4_addr(iface);
if (setsockopt_ipv4_multicast(global.ipv4.ldp_disc_socket,
IP_ADD_MEMBERSHIP, if_addr, addr->s_addr, iface->ifindex) < 0) {
- log_warn("%s: error IP_ADD_MEMBERSHIP, interface %s address %s",
- __func__, iface->name, inet_ntoa(*addr));
+ log_warn("%s: error IP_ADD_MEMBERSHIP, interface %s address %pI4",
+ __func__, iface->name, addr);
return (-1);
}
return (0);
@@ -597,14 +597,14 @@ if_leave_ipv4_group(struct iface *iface, struct in_addr *addr)
{
struct in_addr if_addr;
- log_debug("%s: interface %s addr %s", __func__, iface->name,
- inet_ntoa(*addr));
+ log_debug("%s: interface %s addr %pI4", __func__, iface->name,
+ addr);
if_addr.s_addr = if_get_ipv4_addr(iface);
if (setsockopt_ipv4_multicast(global.ipv4.ldp_disc_socket,
IP_DROP_MEMBERSHIP, if_addr, addr->s_addr, iface->ifindex) < 0) {
- log_warn("%s: error IP_DROP_MEMBERSHIP, interface %s address %s", __func__, iface->name, inet_ntoa(*addr));
+ log_warn("%s: error IP_DROP_MEMBERSHIP, interface %s address %pI4", __func__, iface->name, addr);
return (-1);
}
@@ -828,14 +828,14 @@ ldp_sync_fsm_adj_event(struct adj *adj, enum ldp_sync_event event)
}
debug_evt_ldp_sync("%s: event %s, "
- "adj iface %s (%d) lsr-id %s "
- "source address %s transport address %s",
- __func__, ldp_sync_event_names[event],
- adj->source.link.ia->iface->name,
- adj->source.link.ia->iface->ifindex,
- inet_ntoa(adj->lsr_id),
- log_addr(adj_get_af(adj), &adj->source.link.src_addr),
- log_addr(adj_get_af(adj), &adj->trans_addr));
+ "adj iface %s (%d) lsr-id %pI4 "
+ "source address %s transport address %s",
+ __func__, ldp_sync_event_names[event],
+ adj->source.link.ia->iface->name,
+ adj->source.link.ia->iface->ifindex,
+ &adj->lsr_id,
+ log_addr(adj_get_af(adj), &adj->source.link.src_addr),
+ log_addr(adj_get_af(adj), &adj->trans_addr));
return ldp_sync_fsm(iface, event);
}
@@ -861,9 +861,9 @@ ldp_sync_fsm_nbr_event(struct nbr *nbr, enum ldp_sync_event event)
*/
continue;
- debug_evt_ldp_sync("%s: event %s, iface %s, lsr-id %s",
+ debug_evt_ldp_sync("%s: event %s, iface %s, lsr-id %pI4",
__func__, ldp_sync_event_names[event],
- iface->name, inet_ntoa(nbr->id));
+ iface->name, &nbr->id);
ldp_sync_fsm(iface, event);
}
diff --git a/ldpd/keepalive.c b/ldpd/keepalive.c
index ba5f223316..b03127109f 100644
--- a/ldpd/keepalive.c
+++ b/ldpd/keepalive.c
@@ -37,7 +37,7 @@ send_keepalive(struct nbr *nbr)
size -= LDP_HDR_SIZE;
gen_msg_hdr(buf, MSG_TYPE_KEEPALIVE, size);
- debug_kalive_send("keepalive: lsr-id %s", inet_ntoa(nbr->id));
+ debug_kalive_send("keepalive: lsr-id %pI4", &nbr->id);
evbuf_enqueue(&nbr->tcp->wbuf, buf);
nbr->stats.kalive_sent++;
@@ -54,7 +54,7 @@ recv_keepalive(struct nbr *nbr, char *buf, uint16_t len)
return (-1);
}
- debug_kalive_recv("keepalive: lsr-id %s", inet_ntoa(nbr->id));
+ debug_kalive_recv("keepalive: lsr-id %pI4", &nbr->id);
if (nbr->state != NBR_STA_OPER)
nbr_fsm(nbr, NBR_EVT_KEEPALIVE_RCVD);
diff --git a/ldpd/labelmapping.c b/ldpd/labelmapping.c
index a656626356..cee9d527e8 100644
--- a/ldpd/labelmapping.c
+++ b/ldpd/labelmapping.c
@@ -910,6 +910,6 @@ tlv_decode_fec_elm(struct nbr *nbr, struct ldp_msg *msg, char *buf,
static void
log_msg_mapping(int out, uint16_t msg_type, struct nbr *nbr, struct map *map)
{
- debug_msg(out, "%s: lsr-id %s, fec %s, label %s", msg_name(msg_type),
- inet_ntoa(nbr->id), log_map(map), log_label(map->label));
+ debug_msg(out, "%s: lsr-id %pI4, fec %s, label %s", msg_name(msg_type),
+ &nbr->id, log_map(map), log_label(map->label));
}
diff --git a/ldpd/ldp_vty_conf.c b/ldpd/ldp_vty_conf.c
index c217cfc78a..d21e3c0409 100644
--- a/ldpd/ldp_vty_conf.c
+++ b/ldpd/ldp_vty_conf.c
@@ -255,7 +255,7 @@ ldp_config_write(struct vty *vty)
vty_out (vty, "mpls ldp\n");
if (ldpd_conf->rtr_id.s_addr != INADDR_ANY)
- vty_out(vty, " router-id %s\n", inet_ntoa(ldpd_conf->rtr_id));
+ vty_out(vty, " router-id %pI4\n", &ldpd_conf->rtr_id);
if (ldpd_conf->lhello_holdtime != LINK_DFLT_HOLDTIME &&
ldpd_conf->lhello_holdtime != 0)
@@ -292,20 +292,20 @@ ldp_config_write(struct vty *vty)
RB_FOREACH(nbrp, nbrp_head, &ldpd_conf->nbrp_tree) {
if (nbrp->flags & F_NBRP_KEEPALIVE)
- vty_out (vty, " neighbor %s session holdtime %u\n",
- inet_ntoa(nbrp->lsr_id),nbrp->keepalive);
+ vty_out (vty, " neighbor %pI4 session holdtime %u\n",
+ &nbrp->lsr_id,nbrp->keepalive);
if (nbrp->flags & F_NBRP_GTSM) {
if (nbrp->gtsm_enabled)
- vty_out (vty, " neighbor %s ttl-security hops %u\n", inet_ntoa(nbrp->lsr_id),
+ vty_out (vty, " neighbor %pI4 ttl-security hops %u\n", &nbrp->lsr_id,
nbrp->gtsm_hops);
else
- vty_out (vty, " neighbor %s ttl-security disable\n",inet_ntoa(nbrp->lsr_id));
+ vty_out (vty, " neighbor %pI4 ttl-security disable\n",&nbrp->lsr_id);
}
if (nbrp->auth.method == AUTH_MD5SIG)
- vty_out (vty, " neighbor %s password %s\n",
- inet_ntoa(nbrp->lsr_id),nbrp->auth.md5key);
+ vty_out (vty, " neighbor %pI4 password %s\n",
+ &nbrp->lsr_id,nbrp->auth.md5key);
}
ldp_af_config_write(vty, AF_INET, ldpd_conf, &ldpd_conf->ipv4);
@@ -326,7 +326,7 @@ ldp_l2vpn_pw_config_write(struct vty *vty, struct l2vpn_pw *pw)
vty_out (vty, " member pseudowire %s\n", pw->ifname);
if (pw->lsr_id.s_addr != INADDR_ANY)
- vty_out (vty, " neighbor lsr-id %s\n",inet_ntoa(pw->lsr_id));
+ vty_out (vty, " neighbor lsr-id %pI4\n",&pw->lsr_id);
else
missing_lsrid = 1;
diff --git a/ldpd/ldp_vty_exec.c b/ldpd/ldp_vty_exec.c
index 609598a768..09b820e3f6 100644
--- a/ldpd/ldp_vty_exec.c
+++ b/ldpd/ldp_vty_exec.c
@@ -19,6 +19,7 @@
#include <zebra.h>
#include <sys/un.h>
+#include "lib/printfrr.h"
#include "ldpd.h"
#include "ldpe.h"
@@ -237,8 +238,8 @@ show_ldp_sync_msg(struct vty *vty, struct imsg *imsg,
}
if (iface->peer_ldp_id.s_addr)
- vty_out (vty, " Peer LDP Identifier: %s:0\n",
- inet_ntoa(iface->peer_ldp_id));
+ vty_out (vty, " Peer LDP Identifier: %pI4:0\n",
+ &iface->peer_ldp_id);
break;
case IMSG_CTL_END:
@@ -256,6 +257,7 @@ show_ldp_sync_msg_json(struct imsg *imsg, struct show_params *params,
{
struct ctl_ldp_sync *iface;
json_object *json_iface;
+ char buf[PREFIX_STRLEN];
switch (imsg->hdr.type) {
case IMSG_CTL_SHOW_LDP_SYNC:
@@ -278,7 +280,8 @@ show_ldp_sync_msg_json(struct imsg *imsg, struct show_params *params,
json_object_string_add(json_iface, "peerLdpId",
iface->peer_ldp_id.s_addr ?
- inet_ntoa(iface->peer_ldp_id) : "");
+ inet_ntop(AF_INET, &iface->peer_ldp_id, buf, sizeof(buf)) :
+ "");
json_object_object_add(json, iface->name, json_iface);
break;
@@ -305,8 +308,7 @@ show_discovery_msg(struct vty *vty, struct imsg *imsg,
if (params->family != AF_UNSPEC && params->family != adj->af)
break;
- vty_out(vty, "%-4s %-15s ", af_name(adj->af),
- inet_ntoa(adj->id));
+ vty_out(vty, "%-4s %-15pI4 ", af_name(adj->af), &adj->id);
switch(adj->type) {
case HELLO_LINK:
vty_out(vty, "%-8s %-15s ", "Link", adj->ifname);
@@ -336,8 +338,8 @@ show_discovery_detail_adj(struct vty *vty, char *buffer, struct ctl_adj *adj)
{
size_t buflen = strlen(buffer);
- snprintf(buffer + buflen, LDPBUFSIZ - buflen,
- " LSR Id: %s:0\n", inet_ntoa(adj->id));
+ snprintfrr(buffer + buflen, LDPBUFSIZ - buflen,
+ " LSR Id: %pI4:0\n", &adj->id);
buflen = strlen(buffer);
snprintf(buffer + buflen, LDPBUFSIZ - buflen,
" Source address: %s\n",
@@ -419,7 +421,7 @@ show_discovery_detail_msg(struct vty *vty, struct imsg *imsg,
case IMSG_CTL_END:
rtr_id.s_addr = ldp_rtr_id_get(ldpd_conf);
vty_out (vty, "Local:\n");
- vty_out (vty, " LSR Id: %s:0\n",inet_ntoa(rtr_id));
+ vty_out (vty, " LSR Id: %pI4:0\n",&rtr_id);
if (ldpd_conf->ipv4.flags & F_LDPD_AF_ENABLED)
vty_out (vty, " Transport Address (IPv4): %s\n",
log_addr(AF_INET, &ldpd_conf->ipv4.trans_addr));
@@ -445,6 +447,7 @@ show_discovery_msg_json(struct imsg *imsg, struct show_params *params,
json_object *json)
{
struct ctl_adj *adj;
+ char buf[PREFIX_STRLEN];
json_object *json_array;
json_object *json_adj;
@@ -465,7 +468,8 @@ show_discovery_msg_json(struct imsg *imsg, struct show_params *params,
json_object_string_add(json_adj, "addressFamily",
af_name(adj->af));
json_object_string_add(json_adj, "neighborId",
- inet_ntoa(adj->id));
+ inet_ntop(AF_INET, &adj->id, buf,
+ sizeof(buf)));
switch(adj->type) {
case HELLO_LINK:
json_object_string_add(json_adj, "type", "link");
@@ -494,6 +498,7 @@ show_discovery_msg_json(struct imsg *imsg, struct show_params *params,
static void
show_discovery_detail_adj_json(json_object *json, struct ctl_adj *adj)
{
+ char buf[PREFIX_STRLEN];
json_object *json_adj;
json_object *json_array;
@@ -504,7 +509,8 @@ show_discovery_detail_adj_json(json_object *json, struct ctl_adj *adj)
}
json_adj = json_object_new_object();
- json_object_string_add(json_adj, "lsrId", inet_ntoa(adj->id));
+ json_object_string_add(json_adj, "lsrId", inet_ntop(AF_INET, &adj->id,
+ buf, sizeof(buf)));
json_object_string_add(json_adj, "sourceAddress", log_addr(adj->af,
&adj->src_addr));
json_object_string_add(json_adj, "transportAddress", log_addr(adj->af,
@@ -526,6 +532,7 @@ show_discovery_detail_msg_json(struct imsg *imsg, struct show_params *params,
struct ctl_disc_tnbr *tnbr;
struct in_addr rtr_id;
union ldpd_addr *trans_addr;
+ char buf[PREFIX_STRLEN];
json_object *json_interface;
json_object *json_target;
static json_object *json_interfaces;
@@ -535,7 +542,9 @@ show_discovery_detail_msg_json(struct imsg *imsg, struct show_params *params,
switch (imsg->hdr.type) {
case IMSG_CTL_SHOW_DISCOVERY:
rtr_id.s_addr = ldp_rtr_id_get(ldpd_conf);
- json_object_string_add(json, "lsrId", inet_ntoa(rtr_id));
+ json_object_string_add(json, "lsrId",
+ inet_ntop(AF_INET, &rtr_id, buf,
+ sizeof(buf)));
if (ldpd_conf->ipv4.flags & F_LDPD_AF_ENABLED)
json_object_string_add(json, "transportAddressIPv4",
log_addr(AF_INET, &ldpd_conf->ipv4.trans_addr));
@@ -612,9 +621,9 @@ show_nbr_msg(struct vty *vty, struct imsg *imsg, struct show_params *params)
addr = log_addr(nbr->af, &nbr->raddr);
- vty_out(vty, "%-4s %-15s %-11s %-15s",
- af_name(nbr->af), inet_ntoa(nbr->id),
- nbr_state_name(nbr->nbr_state), addr);
+ vty_out(vty, "%-4s %-15pI4 %-11s %-15s",
+ af_name(nbr->af), &nbr->id,
+ nbr_state_name(nbr->nbr_state), addr);
if (strlen(addr) > 15)
vty_out(vty, "\n%48s", " ");
vty_out (vty, " %8s\n", log_time(nbr->uptime));
@@ -662,8 +671,8 @@ show_nbr_detail_msg(struct vty *vty, struct imsg *imsg,
v4adjs_buffer[0] = '\0';
v6adjs_buffer[0] = '\0';
- vty_out (vty, "Peer LDP Identifier: %s:0\n",
- inet_ntoa(nbr->id));
+ vty_out (vty, "Peer LDP Identifier: %pI4:0\n",
+ &nbr->id);
vty_out (vty, " TCP connection: %s:%u - %s:%u\n",
log_addr(nbr->af, &nbr->laddr), ntohs(nbr->lport),
log_addr(nbr->af, &nbr->raddr),ntohs(nbr->rport));
@@ -740,6 +749,7 @@ show_nbr_msg_json(struct imsg *imsg, struct show_params *params,
json_object *json)
{
struct ctl_nbr *nbr;
+ char buf[PREFIX_STRLEN];
json_object *json_array;
json_object *json_nbr;
@@ -757,7 +767,8 @@ show_nbr_msg_json(struct imsg *imsg, struct show_params *params,
json_object_string_add(json_nbr, "addressFamily",
af_name(nbr->af));
json_object_string_add(json_nbr, "neighborId",
- inet_ntoa(nbr->id));
+ inet_ntop(AF_INET, &nbr->id, buf,
+ sizeof(buf)));
json_object_string_add(json_nbr, "state",
nbr_state_name(nbr->nbr_state));
json_object_string_add(json_nbr, "transportAddress",
@@ -803,6 +814,7 @@ show_nbr_detail_msg_json(struct imsg *imsg, struct show_params *params,
struct ctl_nbr *nbr;
struct ldp_stats *stats;
struct ctl_adj *adj;
+ char buf[PREFIX_STRLEN];
json_object *json_nbr;
json_object *json_array;
json_object *json_counter;
@@ -815,9 +827,12 @@ show_nbr_detail_msg_json(struct imsg *imsg, struct show_params *params,
nbr = imsg->data;
json_nbr = json_object_new_object();
- json_object_object_add(json, inet_ntoa(nbr->id), json_nbr);
-
- json_object_string_add(json_nbr, "peerId", inet_ntoa(nbr->id));
+ json_object_object_add(json,
+ inet_ntop(AF_INET, &nbr->id, buf,
+ sizeof(buf)), json_nbr);
+ json_object_string_add(json_nbr, "peerId",
+ inet_ntop(AF_INET, &nbr->id, buf,
+ sizeof(buf)));
json_object_string_add(json_nbr, "tcpLocalAddress",
log_addr(nbr->af, &nbr->laddr));
json_object_int_add(json_nbr, "tcpLocalPort",
@@ -998,8 +1013,8 @@ show_nbr_capabilities_msg(struct vty *vty, struct imsg *imsg, struct show_params
if (nbr->nbr_state != NBR_STA_OPER)
break;
- vty_out (vty, "Peer LDP Identifier: %s:0\n",
- inet_ntoa(nbr->id));
+ vty_out (vty, "Peer LDP Identifier: %pI4:0\n",
+ &nbr->id);
show_nbr_capabilities(vty, nbr);
vty_out (vty, "\n");
break;
@@ -1079,6 +1094,7 @@ show_nbr_capabilities_msg_json(struct imsg *imsg, struct show_params *params,
json_object *json)
{
struct ctl_nbr *nbr;
+ char buf[PREFIX_STRLEN];
json_object *json_nbr;
switch (imsg->hdr.type) {
@@ -1089,7 +1105,8 @@ show_nbr_capabilities_msg_json(struct imsg *imsg, struct show_params *params,
break;
json_nbr = json_object_new_object();
- json_object_object_add(json, inet_ntoa(nbr->id), json_nbr);
+ json_object_object_add(json, inet_ntop(AF_INET, &nbr->id, buf,
+ sizeof(buf)), json_nbr);
show_nbr_capabilities_json(nbr, json_nbr);
break;
case IMSG_CTL_END:
@@ -1128,9 +1145,10 @@ show_lib_msg(struct vty *vty, struct imsg *imsg, struct show_params *params)
vty_out(vty, "%-4s %-20s", af_name(rt->af), dstnet);
if (strlen(dstnet) > 20)
vty_out(vty, "\n%25s", " ");
- vty_out (vty, " %-15s %-11s %-13s %6s\n", inet_ntoa(rt->nexthop),
- log_label(rt->local_label), log_label(rt->remote_label),
- rt->in_use ? "yes" : "no");
+ vty_out (vty, " %-15pI4 %-11s %-13s %6s\n",
+ &rt->nexthop, log_label(rt->local_label),
+ log_label(rt->remote_label),
+ rt->in_use ? "yes" : "no");
break;
case IMSG_CTL_END:
vty_out (vty, "\n");
@@ -1168,17 +1186,17 @@ show_lib_detail_msg(struct vty *vty, struct imsg *imsg, struct show_params *para
upstream = 1;
buflen = strlen(sent_buffer);
- snprintf(sent_buffer + buflen, LDPBUFSIZ - buflen,
- "%12s%s:0\n", "", inet_ntoa(rt->nexthop));
+ snprintfrr(sent_buffer + buflen, LDPBUFSIZ - buflen,
+ "%12s%pI4:0\n", "", &rt->nexthop);
break;
case IMSG_CTL_SHOW_LIB_RCVD:
rt = imsg->data;
downstream = 1;
buflen = strlen(rcvd_buffer);
- snprintf(rcvd_buffer + buflen, LDPBUFSIZ - buflen,
- "%12s%s:0, label %s%s\n", "", inet_ntoa(rt->nexthop),
- log_label(rt->remote_label),
- rt->in_use ? " (in use)" : "");
+ snprintfrr(rcvd_buffer + buflen, LDPBUFSIZ - buflen,
+ "%12s%pI4:0, label %s%s\n", "", &rt->nexthop,
+ log_label(rt->remote_label),
+ rt->in_use ? " (in use)" : "");
break;
case IMSG_CTL_SHOW_LIB_END:
rt = imsg->data;
@@ -1217,6 +1235,7 @@ show_lib_msg_json(struct imsg *imsg, struct show_params *params,
json_object *json_array;
json_object *json_lib_entry;
char dstnet[BUFSIZ];
+ char buf[PREFIX_STRLEN];
switch (imsg->hdr.type) {
case IMSG_CTL_SHOW_LIB_BEGIN:
@@ -1240,11 +1259,12 @@ show_lib_msg_json(struct imsg *imsg, struct show_params *params,
log_addr(rt->af, &rt->prefix), rt->prefixlen);
json_object_string_add(json_lib_entry, "prefix", dstnet);
json_object_string_add(json_lib_entry, "neighborId",
- inet_ntoa(rt->nexthop));
+ inet_ntop(AF_INET, &rt->nexthop, buf,
+ sizeof(buf)));
json_object_string_add(json_lib_entry, "localLabel",
- log_label(rt->local_label));
+ log_label(rt->local_label));
json_object_string_add(json_lib_entry, "remoteLabel",
- log_label(rt->remote_label));
+ log_label(rt->remote_label));
json_object_int_add(json_lib_entry, "inUse", rt->in_use);
json_object_array_add(json_array, json_lib_entry);
@@ -1264,6 +1284,7 @@ show_lib_detail_msg_json(struct imsg *imsg, struct show_params *params,
{
struct ctl_rt *rt = NULL;
char dstnet[BUFSIZ];
+ char buf[PREFIX_STRLEN];
static json_object *json_lib_entry;
static json_object *json_adv_labels;
json_object *json_adv_label;
@@ -1296,7 +1317,8 @@ show_lib_detail_msg_json(struct imsg *imsg, struct show_params *params,
json_adv_label = json_object_new_object();
json_object_string_add(json_adv_label, "neighborId",
- inet_ntoa(rt->nexthop));
+ inet_ntop(AF_INET, &rt->nexthop, buf,
+ sizeof(buf)));
json_object_array_add(json_adv_labels, json_adv_label);
break;
case IMSG_CTL_SHOW_LIB_RCVD:
@@ -1304,9 +1326,10 @@ show_lib_detail_msg_json(struct imsg *imsg, struct show_params *params,
json_remote_label = json_object_new_object();
json_object_string_add(json_remote_label, "neighborId",
- inet_ntoa(rt->nexthop));
+ inet_ntop(AF_INET, &rt->nexthop,
+ buf, sizeof(buf)));
json_object_string_add(json_remote_label, "label",
- log_label(rt->remote_label));
+ log_label(rt->remote_label));
json_object_int_add(json_remote_label, "inUse", rt->in_use);
json_object_array_add(json_remote_labels, json_remote_label);
break;
@@ -1329,8 +1352,8 @@ show_l2vpn_binding_msg(struct vty *vty, struct imsg *imsg,
case IMSG_CTL_SHOW_L2VPN_BINDING:
pw = imsg->data;
- vty_out (vty, " Destination Address: %s, VC ID: %u\n",
- inet_ntoa(pw->lsr_id), pw->pwid);
+ vty_out (vty, " Destination Address: %pI4, VC ID: %u\n",
+ &pw->lsr_id, pw->pwid);
/* local binding */
if (pw->local_label != NO_LABEL) {
@@ -1371,6 +1394,7 @@ show_l2vpn_binding_msg_json(struct imsg *imsg, struct show_params *params,
struct ctl_pw *pw;
json_object *json_pw;
char key_name[64];
+ char buf[PREFIX_STRLEN];
switch (imsg->hdr.type) {
case IMSG_CTL_SHOW_L2VPN_BINDING:
@@ -1378,7 +1402,8 @@ show_l2vpn_binding_msg_json(struct imsg *imsg, struct show_params *params,
json_pw = json_object_new_object();
json_object_string_add(json_pw, "destination",
- inet_ntoa(pw->lsr_id));
+ inet_ntop(AF_INET, &pw->lsr_id, buf,
+ sizeof(buf)));
json_object_int_add(json_pw, "vcId", pw->pwid);
/* local binding */
@@ -1415,8 +1440,8 @@ show_l2vpn_binding_msg_json(struct imsg *imsg, struct show_params *params,
json_object_string_add(json_pw, "remoteLabel",
"unassigned");
- snprintf(key_name, sizeof(key_name), "%s: %u",
- inet_ntoa(pw->lsr_id), pw->pwid);
+ snprintfrr(key_name, sizeof(key_name), "%pI4: %u",
+ &pw->lsr_id, pw->pwid);
json_object_object_add(json, key_name, json_pw);
break;
case IMSG_CTL_END:
@@ -1437,9 +1462,9 @@ show_l2vpn_pw_msg(struct vty *vty, struct imsg *imsg, struct show_params *params
case IMSG_CTL_SHOW_L2VPN_PW:
pw = imsg->data;
- vty_out (vty, "%-9s %-15s %-10u %-16s %-10s\n", pw->ifname,
- inet_ntoa(pw->lsr_id), pw->pwid, pw->l2vpn_name,
- (pw->status == PW_FORWARDING ? "UP" : "DOWN"));
+ vty_out (vty, "%-9s %-15pI4 %-10u %-16s %-10s\n", pw->ifname,
+ &pw->lsr_id, pw->pwid, pw->l2vpn_name,
+ (pw->status == PW_FORWARDING ? "UP" : "DOWN"));
break;
case IMSG_CTL_END:
vty_out (vty, "\n");
@@ -1456,6 +1481,7 @@ show_l2vpn_pw_msg_json(struct imsg *imsg, struct show_params *params,
json_object *json)
{
struct ctl_pw *pw;
+ char buf[PREFIX_STRLEN];
json_object *json_pw;
switch (imsg->hdr.type) {
@@ -1463,7 +1489,9 @@ show_l2vpn_pw_msg_json(struct imsg *imsg, struct show_params *params,
pw = imsg->data;
json_pw = json_object_new_object();
- json_object_string_add(json_pw, "peerId", inet_ntoa(pw->lsr_id));
+ json_object_string_add(json_pw, "peerId",
+ inet_ntop(AF_INET, &pw->lsr_id,
+ buf, sizeof(buf)));
json_object_int_add(json_pw, "vcId", pw->pwid);
json_object_string_add(json_pw, "VpnName", pw->l2vpn_name);
if (pw->status == PW_FORWARDING)
diff --git a/ldpd/ldp_zebra.c b/ldpd/ldp_zebra.c
index 16e9adc9d9..3852d8d23b 100644
--- a/ldpd/ldp_zebra.c
+++ b/ldpd/ldp_zebra.c
@@ -359,7 +359,7 @@ ldp_router_id_update(ZAPI_CALLBACK_ARGS)
if (bad_addr_v4(router_id.u.prefix4))
return (0);
- debug_zebra_in("router-id update %s", inet_ntoa(router_id.u.prefix4));
+ debug_zebra_in("router-id update %pI4", &router_id.u.prefix4);
global.rtr_id.s_addr = router_id.u.prefix4.s_addr;
main_imsg_compose_ldpe(IMSG_RTRID_UPDATE, 0, &global.rtr_id,
diff --git a/ldpd/logmsg.c b/ldpd/logmsg.c
index 6427d0e13b..ff9294f9d2 100644
--- a/ldpd/logmsg.c
+++ b/ldpd/logmsg.c
@@ -17,6 +17,7 @@
*/
#include <zebra.h>
+#include "lib/printfrr.h"
#include "mpls.h"
@@ -254,10 +255,10 @@ log_fec(const struct fec *fec)
return ("???");
break;
case FEC_TYPE_PWID:
- if (snprintf(buf, sizeof(buf),
- "pwid %u (%s) - %s",
- fec->u.pwid.pwid, pw_type_name(fec->u.pwid.type),
- inet_ntoa(fec->u.pwid.lsr_id)) == -1)
+ if (snprintfrr(buf, sizeof(buf),
+ "pwid %u (%s) - %pI4",
+ fec->u.pwid.pwid, pw_type_name(fec->u.pwid.type),
+ &fec->u.pwid.lsr_id) == -1)
return ("???");
break;
default:
diff --git a/ldpd/neighbor.c b/ldpd/neighbor.c
index 236d3eaa58..423410f290 100644
--- a/ldpd/neighbor.c
+++ b/ldpd/neighbor.c
@@ -143,7 +143,7 @@ nbr_fsm(struct nbr *nbr, enum nbr_event event)
if (nbr_fsm_tbl[i].state == -1) {
/* event outside of the defined fsm, ignore it. */
- log_warnx("%s: lsr-id %s, event %s not expected in state %s", __func__, inet_ntoa(nbr->id),
+ log_warnx("%s: lsr-id %pI4, event %s not expected in state %s", __func__, &nbr->id,
nbr_event_names[event], nbr_state_name(old_state));
return (0);
}
@@ -152,10 +152,10 @@ nbr_fsm(struct nbr *nbr, enum nbr_event event)
nbr->state = new_state;
if (old_state != nbr->state) {
- log_debug("%s: event %s resulted in action %s and changing state for lsr-id %s from %s to %s",
+ log_debug("%s: event %s resulted in action %s and changing state for lsr-id %pI4 from %s to %s",
__func__, nbr_event_names[event],
nbr_action_names[nbr_fsm_tbl[i].action],
- inet_ntoa(nbr->id), nbr_state_name(old_state),
+ &nbr->id, nbr_state_name(old_state),
nbr_state_name(nbr->state));
if (nbr->state == NBR_STA_OPER) {
@@ -223,8 +223,8 @@ nbr_new(struct in_addr id, int af, int ds_tlv, union ldpd_addr *addr,
struct adj *adj;
struct pending_conn *pconn;
- log_debug("%s: lsr-id %s transport-address %s", __func__,
- inet_ntoa(id), log_addr(af, addr));
+ log_debug("%s: lsr-id %pI4 transport-address %s", __func__,
+ &id, log_addr(af, addr));
if ((nbr = calloc(1, sizeof(*nbr))) == NULL)
fatal(__func__);
@@ -289,7 +289,7 @@ nbr_del(struct nbr *nbr)
{
struct adj *adj;
- log_debug("%s: lsr-id %s", __func__, inet_ntoa(nbr->id));
+ log_debug("%s: lsr-id %pI4", __func__, &nbr->id);
nbr_fsm(nbr, NBR_EVT_CLOSE_SESSION);
#ifdef __OpenBSD__
@@ -436,7 +436,7 @@ nbr_ktimeout(struct thread *thread)
nbr->keepalive_timeout = NULL;
- log_debug("%s: lsr-id %s", __func__, inet_ntoa(nbr->id));
+ log_debug("%s: lsr-id %pI4", __func__, &nbr->id);
session_shutdown(nbr, S_KEEPALIVE_TMR, 0, 0);
@@ -465,7 +465,7 @@ nbr_itimeout(struct thread *thread)
{
struct nbr *nbr = THREAD_ARG(thread);
- log_debug("%s: lsr-id %s", __func__, inet_ntoa(nbr->id));
+ log_debug("%s: lsr-id %pI4", __func__, &nbr->id);
nbr_fsm(nbr, NBR_EVT_CLOSE_SESSION);
@@ -498,7 +498,7 @@ nbr_idtimer(struct thread *thread)
nbr->initdelay_timer = NULL;
- log_debug("%s: lsr-id %s", __func__, inet_ntoa(nbr->id));
+ log_debug("%s: lsr-id %pI4", __func__, &nbr->id);
nbr_establish_connection(nbr);
@@ -619,12 +619,12 @@ nbr_establish_connection(struct nbr *nbr)
if (nbr->af == AF_INET) {
if (sock_set_ipv4_tos(nbr->fd, IPTOS_PREC_INTERNETCONTROL) == -1)
- log_warn("%s: lsr-id %s, sock_set_ipv4_tos error",
- __func__, inet_ntoa(nbr->id));
+ log_warn("%s: lsr-id %pI4, sock_set_ipv4_tos error",
+ __func__, &nbr->id);
} else if (nbr->af == AF_INET6) {
if (sock_set_ipv6_dscp(nbr->fd, IPTOS_PREC_INTERNETCONTROL) == -1)
- log_warn("%s: lsr-id %s, sock_set_ipv6_dscp error",
- __func__, inet_ntoa(nbr->id));
+ log_warn("%s: lsr-id %pI4, sock_set_ipv6_dscp error",
+ __func__, &nbr->id);
}
addr2sa(nbr->af, &nbr->laddr, 0, &local_su);
@@ -746,8 +746,8 @@ nbr_gtsm_check(int fd, struct nbr *nbr, struct nbr_params *nbrp)
}
if (nbr_gtsm_setup(fd, nbr->af, nbrp) == -1) {
- log_warnx("%s: error enabling GTSM for lsr-id %s", __func__,
- inet_ntoa(nbr->id));
+ log_warnx("%s: error enabling GTSM for lsr-id %pI4", __func__,
+ &nbr->id);
return (-1);
}
diff --git a/ldpd/notification.c b/ldpd/notification.c
index 93be9d3cb0..f84e0f893b 100644
--- a/ldpd/notification.c
+++ b/ldpd/notification.c
@@ -309,13 +309,13 @@ void
log_msg_notification(int out, struct nbr *nbr, struct notify_msg *nm)
{
if (nm->status_code & STATUS_FATAL) {
- debug_msg(out, "notification: lsr-id %s, status %s (fatal error)", inet_ntoa(nbr->id),
+ debug_msg(out, "notification: lsr-id %pI4, status %s (fatal error)", &nbr->id,
status_code_name(nm->status_code));
return;
}
- debug_msg(out, "notification: lsr-id %s, status %s",
- inet_ntoa(nbr->id), status_code_name(nm->status_code));
+ debug_msg(out, "notification: lsr-id %pI4, status %s",
+ &nbr->id, status_code_name(nm->status_code));
if (nm->flags & F_NOTIF_FEC)
debug_msg(out, "notification: fec %s", log_map(&nm->fec));
if (nm->flags & F_NOTIF_PW_STATUS)
diff --git a/ldpd/packet.c b/ldpd/packet.c
index 3f73f8cd88..06ada5957e 100644
--- a/ldpd/packet.c
+++ b/ldpd/packet.c
@@ -366,7 +366,7 @@ session_accept(struct thread *thread)
return (0);
}
if (nbr->state != NBR_STA_PRESENT) {
- log_debug("%s: lsr-id %s: rejecting additional transport connection", __func__, inet_ntoa(nbr->id));
+ log_debug("%s: lsr-id %pI4: rejecting additional transport connection", __func__, &nbr->id);
close(newfd);
return (0);
}
@@ -558,8 +558,8 @@ session_read(struct thread *thread)
type);
break;
default:
- log_debug("%s: unknown LDP message from nbr %s",
- __func__, inet_ntoa(nbr->id));
+ log_debug("%s: unknown LDP message from nbr %pI4",
+ __func__, &nbr->id);
if (!(ntohs(msg->type) & UNKNOWN_FLAG))
send_notification(nbr->tcp,
S_UNKNOWN_MSG, msg->id, msg->type);
@@ -680,8 +680,8 @@ session_shutdown(struct nbr *nbr, uint32_t status, uint32_t msg_id,
void
session_close(struct nbr *nbr)
{
- log_debug("%s: closing session with lsr-id %s", __func__,
- inet_ntoa(nbr->id));
+ log_debug("%s: closing session with lsr-id %pI4", __func__,
+ &nbr->id);
ldp_sync_fsm_nbr_event(nbr, LDP_SYNC_EVT_SESSION_CLOSE);
diff --git a/lib/agg_table.h b/lib/agg_table.h
index e98476f1b7..e0c06449ee 100644
--- a/lib/agg_table.h
+++ b/lib/agg_table.h
@@ -161,6 +161,11 @@ agg_node_get_prefix(const struct agg_node *node)
return &node->p;
}
+static inline unsigned int agg_node_get_lock_count(const struct agg_node *node)
+{
+ return node->lock;
+}
+
#ifdef _FRR_ATTRIBUTE_PRINTFRR
#pragma FRR printfrr_ext "%pRN" (struct agg_node *)
#endif
diff --git a/lib/command.h b/lib/command.h
index 677d4b2dad..bb007b0868 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -462,6 +462,14 @@ struct cmd_node {
#define EVPN_TYPE_3_HELP_STR "Multicast (Type-3) route\n"
#define EVPN_TYPE_4_HELP_STR "Ethernet Segment (Type-4) route\n"
#define EVPN_TYPE_5_HELP_STR "Prefix (Type-5) route\n"
+#define EVPN_TYPE_ALL_LIST "<ead|1|macip|2|multicast|3|es|4|prefix|5>"
+#define EVPN_TYPE_ALL_LIST_HELP_STR \
+ EVPN_TYPE_1_HELP_STR EVPN_TYPE_1_HELP_STR \
+ EVPN_TYPE_2_HELP_STR EVPN_TYPE_2_HELP_STR \
+ EVPN_TYPE_3_HELP_STR EVPN_TYPE_3_HELP_STR \
+ EVPN_TYPE_4_HELP_STR EVPN_TYPE_4_HELP_STR \
+ EVPN_TYPE_5_HELP_STR EVPN_TYPE_5_HELP_STR
+
/* Prototypes. */
extern void install_node(struct cmd_node *node);
diff --git a/lib/filter.c b/lib/filter.c
index e6add0462b..f5ae9ee2b7 100644
--- a/lib/filter.c
+++ b/lib/filter.c
@@ -576,14 +576,12 @@ static int filter_show(struct vty *vty, const char *name, afi_t afi)
if (filter->addr_mask.s_addr == 0xffffffff)
vty_out(vty, " any\n");
else {
- vty_out(vty, " %s",
- inet_ntoa(filter->addr));
+ vty_out(vty, " %pI4", &filter->addr);
if (filter->addr_mask.s_addr
!= INADDR_ANY)
vty_out(vty,
- ", wildcard bits %s",
- inet_ntoa(
- filter->addr_mask));
+ ", wildcard bits %pI4",
+ &filter->addr_mask);
vty_out(vty, "\n");
}
}
@@ -625,14 +623,12 @@ static int filter_show(struct vty *vty, const char *name, afi_t afi)
if (filter->addr_mask.s_addr == 0xffffffff)
vty_out(vty, " any\n");
else {
- vty_out(vty, " %s",
- inet_ntoa(filter->addr));
+ vty_out(vty, " %pI4", &filter->addr);
if (filter->addr_mask.s_addr
!= INADDR_ANY)
vty_out(vty,
- ", wildcard bits %s",
- inet_ntoa(
- filter->addr_mask));
+ ", wildcard bits %pI4",
+ &filter->addr_mask);
vty_out(vty, "\n");
}
}
@@ -722,29 +718,28 @@ static void config_write_access_cisco(struct vty *vty, struct filter *mfilter)
if (filter->addr_mask.s_addr == 0xffffffff)
vty_out(vty, " any");
else if (filter->addr_mask.s_addr == INADDR_ANY)
- vty_out(vty, " host %s", inet_ntoa(filter->addr));
+ vty_out(vty, " host %pI4", &filter->addr);
else {
- vty_out(vty, " %s", inet_ntoa(filter->addr));
- vty_out(vty, " %s", inet_ntoa(filter->addr_mask));
+ vty_out(vty, " %pI4", &filter->addr);
+ vty_out(vty, " %pI4", &filter->addr_mask);
}
if (filter->mask_mask.s_addr == 0xffffffff)
vty_out(vty, " any");
else if (filter->mask_mask.s_addr == INADDR_ANY)
- vty_out(vty, " host %s", inet_ntoa(filter->mask));
+ vty_out(vty, " host %pI4", &filter->mask);
else {
- vty_out(vty, " %s", inet_ntoa(filter->mask));
- vty_out(vty, " %s", inet_ntoa(filter->mask_mask));
+ vty_out(vty, " %pI4", &filter->mask);
+ vty_out(vty, " %pI4", &filter->mask_mask);
}
vty_out(vty, "\n");
} else {
if (filter->addr_mask.s_addr == 0xffffffff)
vty_out(vty, " any\n");
else {
- vty_out(vty, " %s", inet_ntoa(filter->addr));
+ vty_out(vty, " %pI4", &filter->addr);
if (filter->addr_mask.s_addr != INADDR_ANY)
- vty_out(vty, " %s",
- inet_ntoa(filter->addr_mask));
+ vty_out(vty, " %pI4", &filter->addr_mask);
vty_out(vty, "\n");
}
}
diff --git a/lib/if.c b/lib/if.c
index 304840e5b9..c707c4c6d9 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -826,7 +826,7 @@ DEFUN (show_address,
p = ifc->address;
if (p->family == AF_INET)
- vty_out (vty, "%s/%d\n", inet_ntoa (p->u.prefix4), p->prefixlen);
+ vty_out (vty, "%pFX\n", p);
}
}
return CMD_SUCCESS;
@@ -858,7 +858,7 @@ DEFUN (show_address_vrf_all,
p = ifc->address;
if (p->family == AF_INET)
- vty_out (vty, "%s/%d\n", inet_ntoa (p->u.prefix4), p->prefixlen);
+ vty_out (vty, "%pFX\n", p);
}
}
}
@@ -929,10 +929,9 @@ connected_log(struct connected *connected, char *str)
p = connected->address;
vrf = vrf_lookup_by_id(ifp->vrf_id);
- snprintf(logbuf, sizeof(logbuf), "%s interface %s vrf %s(%u) %s %s/%d ",
+ snprintf(logbuf, sizeof(logbuf), "%s interface %s vrf %s(%u) %s %pFX ",
str, ifp->name, VRF_LOGNAME(vrf), ifp->vrf_id,
- prefix_family_str(p),
- inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ), p->prefixlen);
+ prefix_family_str(p), p);
p = connected->destination;
if (p) {
@@ -949,14 +948,12 @@ nbr_connected_log(struct nbr_connected *connected, char *str)
struct prefix *p;
struct interface *ifp;
char logbuf[BUFSIZ];
- char buf[BUFSIZ];
ifp = connected->ifp;
p = connected->address;
- snprintf(logbuf, sizeof(logbuf), "%s interface %s %s %s/%d ", str,
- ifp->name, prefix_family_str(p),
- inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ), p->prefixlen);
+ snprintf(logbuf, sizeof(logbuf), "%s interface %s %s %pFX ", str,
+ ifp->name, prefix_family_str(p), p);
zlog_info("%s", logbuf);
}
@@ -1109,8 +1106,8 @@ ifaddr_ipv4_add (struct in_addr *ifaddr, struct interface *ifp)
if (rn)
{
route_unlock_node (rn);
- zlog_info ("ifaddr_ipv4_add(): address %s is already added",
- inet_ntoa (*ifaddr));
+ zlog_info("ifaddr_ipv4_add(): address %pI4 is already added",
+ ifaddr);
return;
}
rn->info = ifp;
@@ -1129,8 +1126,7 @@ ifaddr_ipv4_delete (struct in_addr *ifaddr, struct interface *ifp)
rn = route_node_lookup (ifaddr_ipv4_table, (struct prefix *) &p);
if (! rn)
{
- zlog_info ("ifaddr_ipv4_delete(): can't find address %s",
- inet_ntoa (*ifaddr));
+ zlog_info("%s: can't find address %pI4", __func__, ifaddr);
return;
}
rn->info = NULL;
diff --git a/lib/nexthop.c b/lib/nexthop.c
index f1575649b1..b2fa945690 100644
--- a/lib/nexthop.c
+++ b/lib/nexthop.c
@@ -431,13 +431,13 @@ const char *nexthop2str(const struct nexthop *nexthop, char *str, int size)
break;
case NEXTHOP_TYPE_IPV4:
case NEXTHOP_TYPE_IPV4_IFINDEX:
- snprintf(str, size, "%s if %u", inet_ntoa(nexthop->gate.ipv4),
- nexthop->ifindex);
+ snprintfrr(str, size, "%pI4 if %u", &nexthop->gate.ipv4,
+ nexthop->ifindex);
break;
case NEXTHOP_TYPE_IPV6:
case NEXTHOP_TYPE_IPV6_IFINDEX:
- snprintf(str, size, "%s if %u", inet6_ntoa(nexthop->gate.ipv6),
- nexthop->ifindex);
+ snprintfrr(str, size, "%pI6 if %u", &nexthop->gate.ipv6,
+ nexthop->ifindex);
break;
case NEXTHOP_TYPE_BLACKHOLE:
snprintf(str, size, "blackhole");
diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c
index 4afb1d642a..dee98ad8d7 100644
--- a/lib/nexthop_group.c
+++ b/lib/nexthop_group.c
@@ -975,7 +975,6 @@ void nexthop_group_write_nexthop_simple(struct vty *vty,
const struct nexthop *nh,
char *altifname)
{
- char buf[100];
char *ifname;
vty_out(vty, "nexthop ");
@@ -990,19 +989,16 @@ void nexthop_group_write_nexthop_simple(struct vty *vty,
vty_out(vty, "%s", ifname);
break;
case NEXTHOP_TYPE_IPV4:
- vty_out(vty, "%s", inet_ntoa(nh->gate.ipv4));
+ vty_out(vty, "%pI4", &nh->gate.ipv4);
break;
case NEXTHOP_TYPE_IPV4_IFINDEX:
- vty_out(vty, "%s %s", inet_ntoa(nh->gate.ipv4), ifname);
+ vty_out(vty, "%pI4 %s", &nh->gate.ipv4, ifname);
break;
case NEXTHOP_TYPE_IPV6:
- vty_out(vty, "%s",
- inet_ntop(AF_INET6, &nh->gate.ipv6, buf, sizeof(buf)));
+ vty_out(vty, "%pI6", &nh->gate.ipv6);
break;
case NEXTHOP_TYPE_IPV6_IFINDEX:
- vty_out(vty, "%s %s",
- inet_ntop(AF_INET6, &nh->gate.ipv6, buf, sizeof(buf)),
- ifname);
+ vty_out(vty, "%pI6 %s", &nh->gate.ipv6, ifname);
break;
case NEXTHOP_TYPE_BLACKHOLE:
break;
@@ -1056,10 +1052,14 @@ void nexthop_group_json_nexthop(json_object *j, const struct nexthop *nh)
ifindex2ifname(nh->ifindex, nh->vrf_id));
break;
case NEXTHOP_TYPE_IPV4:
- json_object_string_add(j, "nexthop", inet_ntoa(nh->gate.ipv4));
+ json_object_string_add(
+ j, "nexthop",
+ inet_ntop(AF_INET, &nh->gate.ipv4, buf, sizeof(buf)));
break;
case NEXTHOP_TYPE_IPV4_IFINDEX:
- json_object_string_add(j, "nexthop", inet_ntoa(nh->gate.ipv4));
+ json_object_string_add(
+ j, "nexthop",
+ inet_ntop(AF_INET, &nh->gate.ipv4, buf, sizeof(buf)));
json_object_string_add(j, "vrfId",
ifindex2ifname(nh->ifindex, nh->vrf_id));
break;
diff --git a/lib/plist.c b/lib/plist.c
index 981e86e2ac..4588dfe1d3 100644
--- a/lib/plist.c
+++ b/lib/plist.c
@@ -901,14 +901,11 @@ static void __attribute__((unused)) prefix_list_print(struct prefix_list *plist)
printf("any %s\n", prefix_list_type_str(pentry));
else {
struct prefix *p;
- char buf[BUFSIZ];
p = &pentry->prefix;
- printf(" seq %lld %s %s/%d", (long long)pentry->seq,
- prefix_list_type_str(pentry),
- inet_ntop(p->family, p->u.val, buf, BUFSIZ),
- p->prefixlen);
+ printf(" seq %lld %s %pFX", (long long)pentry->seq,
+ prefix_list_type_str(pentry), p);
if (pentry->ge)
printf(" ge %d", pentry->ge);
if (pentry->le)
@@ -1014,12 +1011,8 @@ static void vty_show_prefix_entry(struct vty *vty, afi_t afi,
vty_out(vty, "any");
else {
struct prefix *p = &pentry->prefix;
- char buf[BUFSIZ];
- vty_out(vty, "%s/%d",
- inet_ntop(p->family, p->u.val, buf,
- BUFSIZ),
- p->prefixlen);
+ vty_out(vty, "%pFX", p);
if (pentry->ge)
vty_out(vty, " ge %d", pentry->ge);
@@ -1121,12 +1114,8 @@ static int vty_show_prefix_list_prefix(struct vty *vty, afi_t afi,
vty_out(vty, "any");
else {
struct prefix *pf = &pentry->prefix;
- char buf[BUFSIZ];
- vty_out(vty, "%s/%d",
- inet_ntop(pf->family, pf->u.val, buf,
- BUFSIZ),
- pf->prefixlen);
+ vty_out(vty, "%pFX", pf);
if (pentry->ge)
vty_out(vty, " ge %d", pentry->ge);
@@ -1491,11 +1480,8 @@ int prefix_bgp_show_prefix_list(struct vty *vty, afi_t afi, char *name,
for (pentry = plist->head; pentry; pentry = pentry->next) {
struct prefix *p = &pentry->prefix;
char buf_a[BUFSIZ];
- char buf_b[BUFSIZ];
- snprintf(buf_a, sizeof(buf_a), "%s/%d",
- inet_ntop(p->family, p->u.val, buf_b, BUFSIZ),
- p->prefixlen);
+ snprintf(buf_a, sizeof(buf_a), "%pFX", p);
json_object_int_add(json_list, "seq", pentry->seq);
json_object_string_add(json_list, "seqPrefixListType",
@@ -1526,13 +1512,9 @@ int prefix_bgp_show_prefix_list(struct vty *vty, afi_t afi, char *name,
for (pentry = plist->head; pentry; pentry = pentry->next) {
struct prefix *p = &pentry->prefix;
- char buf[BUFSIZ];
- vty_out(vty, " seq %" PRId64 " %s %s/%d",
- pentry->seq,
- prefix_list_type_str(pentry),
- inet_ntop(p->family, p->u.val, buf, BUFSIZ),
- p->prefixlen);
+ vty_out(vty, " seq %" PRId64 " %s %pFX", pentry->seq,
+ prefix_list_type_str(pentry), p);
if (pentry->ge)
vty_out(vty, " ge %d", pentry->ge);
diff --git a/lib/routemap.c b/lib/routemap.c
index fb70860024..0eb54a4794 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -2377,7 +2377,6 @@ route_map_result_t route_map_apply(struct route_map *map,
route_map_result_t ret = RMAP_PERMITMATCH;
struct route_map_index *index = NULL;
struct route_map_rule *set = NULL;
- char buf[PREFIX_STRLEN];
bool skip_match_clause = false;
if (recursion > RMAP_RECURSION_LIMIT) {
@@ -2403,16 +2402,14 @@ route_map_result_t route_map_apply(struct route_map *map,
if (index) {
if (rmap_debug)
zlog_debug(
- "Best match route-map: %s, sequence: %d for pfx: %s, result: %s",
- map->name, index->pref,
- prefix2str(prefix, buf, sizeof(buf)),
+ "Best match route-map: %s, sequence: %d for pfx: %pFX, result: %s",
+ map->name, index->pref, prefix,
route_map_cmd_result_str(match_ret));
} else {
if (rmap_debug)
zlog_debug(
- "No best match sequence for pfx: %s in route-map: %s, result: %s",
- prefix2str(prefix, buf, sizeof(buf)),
- map->name,
+ "No best match sequence for pfx: %pFX in route-map: %s, result: %s",
+ prefix, map->name,
route_map_cmd_result_str(match_ret));
/*
* No index matches this prefix. Return deny unless,
@@ -2437,9 +2434,8 @@ route_map_result_t route_map_apply(struct route_map *map,
prefix, type, object);
if (rmap_debug) {
zlog_debug(
- "Route-map: %s, sequence: %d, prefix: %s, result: %s",
- map->name, index->pref,
- prefix2str(prefix, buf, sizeof(buf)),
+ "Route-map: %s, sequence: %d, prefix: %pFX, result: %s",
+ map->name, index->pref, prefix,
route_map_cmd_result_str(match_ret));
}
} else
@@ -2549,12 +2545,10 @@ route_map_result_t route_map_apply(struct route_map *map,
}
route_map_apply_end:
- if (rmap_debug) {
- zlog_debug("Route-map: %s, prefix: %s, result: %s",
- (map ? map->name : "null"),
- prefix2str(prefix, buf, sizeof(buf)),
+ if (rmap_debug)
+ zlog_debug("Route-map: %s, prefix: %pFX, result: %s",
+ (map ? map->name : "null"), prefix,
route_map_result_str(ret));
- }
return (ret);
}
@@ -3156,8 +3150,6 @@ DEFUN_HIDDEN(show_route_map_pfx_tbl, show_route_map_pfx_tbl_cmd,
struct list *rmap_index_list = NULL;
struct listnode *ln = NULL, *nln = NULL;
struct route_map_index *index = NULL;
- struct prefix *p = NULL, *pp = NULL;
- char buf[SU_ADDRSTRLEN], pbuf[SU_ADDRSTRLEN];
uint8_t len = 54;
vty_out(vty, "%s:\n", frr_protonameinst);
@@ -3171,22 +3163,13 @@ DEFUN_HIDDEN(show_route_map_pfx_tbl, show_route_map_pfx_tbl_cmd,
"____________________");
for (rn = route_top(rm_pfx_tbl4); rn;
rn = route_next(rn)) {
- p = &rn->p;
-
- vty_out(vty, " %s/%d (%d)\n",
- inet_ntop(p->family, &p->u.prefix, buf,
- SU_ADDRSTRLEN),
- p->prefixlen, rn->lock);
+ vty_out(vty, " %pRN (%d)\n", rn,
+ route_node_get_lock_count(rn));
vty_out(vty, "(P) ");
prn = rn->parent;
if (prn) {
- pp = &prn->p;
- vty_out(vty, "%s/%d\n",
- inet_ntop(pp->family,
- &pp->u.prefix, pbuf,
- SU_ADDRSTRLEN),
- pp->prefixlen);
+ vty_out(vty, "%pRN\n", prn);
}
vty_out(vty, "\n");
@@ -3215,22 +3198,13 @@ DEFUN_HIDDEN(show_route_map_pfx_tbl, show_route_map_pfx_tbl_cmd,
"____________________");
for (rn = route_top(rm_pfx_tbl6); rn;
rn = route_next(rn)) {
- p = &rn->p;
-
- vty_out(vty, " %s/%d (%d)\n",
- inet_ntop(p->family, &p->u.prefix, buf,
- SU_ADDRSTRLEN),
- p->prefixlen, rn->lock);
+ vty_out(vty, " %pRN (%d)\n", rn,
+ route_node_get_lock_count(rn));
vty_out(vty, "(P) ");
prn = rn->parent;
if (prn) {
- pp = &prn->p;
- vty_out(vty, "%s/%d\n",
- inet_ntop(pp->family,
- &pp->u.prefix, pbuf,
- SU_ADDRSTRLEN),
- pp->prefixlen);
+ vty_out(vty, "%pRN\n", prn);
}
vty_out(vty, "\n");
diff --git a/lib/sockunion.c b/lib/sockunion.c
index d77229797c..c999845659 100644
--- a/lib/sockunion.c
+++ b/lib/sockunion.c
@@ -587,15 +587,11 @@ static void __attribute__((unused)) sockunion_print(const union sockunion *su)
switch (su->sa.sa_family) {
case AF_INET:
- printf("%s\n", inet_ntoa(su->sin.sin_addr));
+ printf("%pI4\n", &su->sin.sin_addr);
+ break;
+ case AF_INET6:
+ printf("%pI6\n", &su->sin6.sin6_addr);
break;
- case AF_INET6: {
- char buf[SU_ADDRSTRLEN];
-
- printf("%s\n", inet_ntop(AF_INET6, &(su->sin6.sin6_addr), buf,
- sizeof(buf)));
- } break;
-
#ifdef AF_LINK
case AF_LINK: {
struct sockaddr_dl *sdl;
diff --git a/lib/table.c b/lib/table.c
index 86347cbacd..b315637f19 100644
--- a/lib/table.c
+++ b/lib/table.c
@@ -119,7 +119,8 @@ static void route_table_free(struct route_table *rt)
node = node->parent;
tmp_node->table->count--;
- tmp_node->lock = 0; /* to cause assert if unlocked after this */
+ tmp_node->lock =
+ 0; /* to cause assert if unlocked after this */
rn_hash_node_del(&rt->hash, tmp_node);
route_node_free(rt, tmp_node);
diff --git a/lib/table.h b/lib/table.h
index 9cd9503376..5d620d332b 100644
--- a/lib/table.h
+++ b/lib/table.h
@@ -262,6 +262,11 @@ static inline void route_unlock_node(struct route_node *node)
route_node_delete(node);
}
+static inline unsigned int route_node_get_lock_count(struct route_node *node)
+{
+ return node->lock;
+}
+
/*
* route_table_iter_next
*
diff --git a/lib/zclient.c b/lib/zclient.c
index 914b02749e..d0144279e5 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -1116,13 +1116,11 @@ int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api)
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP)) {
/* limit the number of nexthops if necessary */
if (api->nexthop_num > MULTIPATH_NUM) {
- char buf[PREFIX2STR_BUFFER];
-
- prefix2str(&api->prefix, buf, sizeof(buf));
flog_err(
EC_LIB_ZAPI_ENCODE,
- "%s: prefix %s: can't encode %u nexthops (maximum is %u)",
- __func__, buf, api->nexthop_num, MULTIPATH_NUM);
+ "%s: prefix %pFX: can't encode %u nexthops (maximum is %u)",
+ __func__, &api->prefix, api->nexthop_num,
+ MULTIPATH_NUM);
return -1;
}
@@ -1139,15 +1137,11 @@ int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api)
/* MPLS labels for BGP-LU or Segment Routing */
if (api_nh->label_num > MPLS_MAX_LABELS) {
- char buf[PREFIX2STR_BUFFER];
-
- prefix2str(&api->prefix, buf, sizeof(buf));
-
- flog_err(EC_LIB_ZAPI_ENCODE,
- "%s: prefix %s: can't encode %u labels (maximum is %u)",
- __func__, buf,
- api_nh->label_num,
- MPLS_MAX_LABELS);
+ flog_err(
+ EC_LIB_ZAPI_ENCODE,
+ "%s: prefix %pFX: can't encode %u labels (maximum is %u)",
+ __func__, &api->prefix,
+ api_nh->label_num, MPLS_MAX_LABELS);
return -1;
}
@@ -1162,13 +1156,10 @@ int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api)
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_BACKUP_NEXTHOPS)) {
/* limit the number of nexthops if necessary */
if (api->backup_nexthop_num > MULTIPATH_NUM) {
- char buf[PREFIX2STR_BUFFER];
-
- prefix2str(&api->prefix, buf, sizeof(buf));
flog_err(
EC_LIB_ZAPI_ENCODE,
- "%s: prefix %s: can't encode %u backup nexthops (maximum is %u)",
- __func__, buf, api->backup_nexthop_num,
+ "%s: prefix %pFX: can't encode %u backup nexthops (maximum is %u)",
+ __func__, &api->prefix, api->backup_nexthop_num,
MULTIPATH_NUM);
return -1;
}
@@ -1185,15 +1176,11 @@ int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api)
/* MPLS labels for BGP-LU or Segment Routing */
if (api_nh->label_num > MPLS_MAX_LABELS) {
- char buf[PREFIX2STR_BUFFER];
-
- prefix2str(&api->prefix, buf, sizeof(buf));
-
- flog_err(EC_LIB_ZAPI_ENCODE,
- "%s: prefix %s: backup: can't encode %u labels (maximum is %u)",
- __func__, buf,
- api_nh->label_num,
- MPLS_MAX_LABELS);
+ flog_err(
+ EC_LIB_ZAPI_ENCODE,
+ "%s: prefix %pFX: backup: can't encode %u labels (maximum is %u)",
+ __func__, &api->prefix,
+ api_nh->label_num, MPLS_MAX_LABELS);
return -1;
}
@@ -2319,13 +2306,10 @@ struct connected *zebra_interface_address_read(int type, struct stream *s,
else if (CHECK_FLAG(ifc->flags, ZEBRA_IFA_PEER)) {
/* carp interfaces on OpenBSD with 0.0.0.0/0 as
* "peer" */
- char buf[PREFIX_STRLEN];
flog_err(
EC_LIB_ZAPI_ENCODE,
- "warning: interface %s address %s with peer flag set, but no peer address!",
- ifp->name,
- prefix2str(ifc->address, buf,
- sizeof(buf)));
+ "warning: interface %s address %pFX with peer flag set, but no peer address!",
+ ifp->name, ifc->address);
UNSET_FLAG(ifc->flags, ZEBRA_IFA_PEER);
}
}
diff --git a/nhrpd/nhrp_interface.c b/nhrpd/nhrp_interface.c
index 1e576fc5ac..0ed2371eb0 100644
--- a/nhrpd/nhrp_interface.c
+++ b/nhrpd/nhrp_interface.c
@@ -220,8 +220,8 @@ static void nhrp_interface_update_address(struct interface *ifp, afi_t afi,
/* On NHRP interfaces a host prefix is required */
if (best && if_ad->configured
&& best->address->prefixlen != 8 * prefix_blen(best->address)) {
- zlog_notice("%s: %s is not a host prefix", ifp->name,
- prefix2str(best->address, buf, sizeof(buf)));
+ zlog_notice("%s: %pFX is not a host prefix", ifp->name,
+ best->address);
best = NULL;
}
@@ -335,14 +335,13 @@ int nhrp_ifp_down(struct interface *ifp)
int nhrp_interface_address_add(ZAPI_CALLBACK_ARGS)
{
struct connected *ifc;
- char buf[PREFIX_STRLEN];
ifc = zebra_interface_address_read(cmd, zclient->ibuf, vrf_id);
if (ifc == NULL)
return 0;
- debugf(NHRP_DEBUG_IF, "if-addr-add: %s: %s", ifc->ifp->name,
- prefix2str(ifc->address, buf, sizeof(buf)));
+ debugf(NHRP_DEBUG_IF, "if-addr-add: %s: %pFX", ifc->ifp->name,
+ ifc->address);
nhrp_interface_update_address(
ifc->ifp, family2afi(PREFIX_FAMILY(ifc->address)), 0);
@@ -353,14 +352,13 @@ int nhrp_interface_address_add(ZAPI_CALLBACK_ARGS)
int nhrp_interface_address_delete(ZAPI_CALLBACK_ARGS)
{
struct connected *ifc;
- char buf[PREFIX_STRLEN];
ifc = zebra_interface_address_read(cmd, zclient->ibuf, vrf_id);
if (ifc == NULL)
return 0;
- debugf(NHRP_DEBUG_IF, "if-addr-del: %s: %s", ifc->ifp->name,
- prefix2str(ifc->address, buf, sizeof(buf)));
+ debugf(NHRP_DEBUG_IF, "if-addr-del: %s: %pFX", ifc->ifp->name,
+ ifc->address);
nhrp_interface_update_address(
ifc->ifp, family2afi(PREFIX_FAMILY(ifc->address)), 0);
diff --git a/nhrpd/nhrp_route.c b/nhrpd/nhrp_route.c
index 0c5513b892..2bc2d91597 100644
--- a/nhrpd/nhrp_route.c
+++ b/nhrpd/nhrp_route.c
@@ -166,14 +166,13 @@ void nhrp_route_announce(int add, enum nhrp_cache_type type,
}
if (unlikely(debug_flags & NHRP_DEBUG_ROUTE)) {
- char buf[2][PREFIX_STRLEN];
+ char buf[PREFIX_STRLEN];
- prefix2str(&api.prefix, buf[0], sizeof(buf[0]));
zlog_debug(
- "Zebra send: route %s %s nexthop %s metric %u count %d dev %s",
- add ? "add" : "del", buf[0],
+ "Zebra send: route %s %pFX nexthop %s metric %u count %d dev %s",
+ add ? "add" : "del", &api.prefix,
nexthop ? inet_ntop(api.prefix.family, &api_nh->gate,
- buf[1], sizeof(buf[1]))
+ buf, sizeof(buf))
: "<onlink>",
api.metric, api.nexthop_num, ifp ? ifp->name : "none");
}
@@ -188,7 +187,7 @@ int nhrp_route_read(ZAPI_CALLBACK_ARGS)
struct zapi_nexthop *api_nh;
struct interface *ifp = NULL;
union sockunion nexthop_addr;
- char buf[2][PREFIX_STRLEN];
+ char buf[PREFIX_STRLEN];
int added;
if (zapi_route_decode(zclient->ibuf, &api) < 0)
@@ -221,10 +220,9 @@ int nhrp_route_read(ZAPI_CALLBACK_ARGS)
}
added = (cmd == ZEBRA_REDISTRIBUTE_ROUTE_ADD);
- debugf(NHRP_DEBUG_ROUTE, "if-route-%s: %s via %s dev %s",
- added ? "add" : "del",
- prefix2str(&api.prefix, buf[0], sizeof(buf[0])),
- sockunion2str(&nexthop_addr, buf[1], sizeof(buf[1])),
+ debugf(NHRP_DEBUG_ROUTE, "if-route-%s: %pFX via %s dev %s",
+ added ? "add" : "del", &api.prefix,
+ sockunion2str(&nexthop_addr, buf, sizeof(buf)),
ifp ? ifp->name : "(none)");
nhrp_route_update_zebra(&api.prefix, &nexthop_addr, ifp);
@@ -240,7 +238,6 @@ int nhrp_route_get_nexthop(const union sockunion *addr, struct prefix *p,
struct route_info *ri;
struct prefix lookup;
afi_t afi = family2afi(sockunion_family(addr));
- char buf[PREFIX_STRLEN];
sockunion2hostprefix(addr, &lookup);
@@ -250,8 +247,7 @@ int nhrp_route_get_nexthop(const union sockunion *addr, struct prefix *p,
ri = rn->info;
if (ri->nhrp_ifp) {
- debugf(NHRP_DEBUG_ROUTE, "lookup %s: nhrp_if=%s",
- prefix2str(&lookup, buf, sizeof(buf)),
+ debugf(NHRP_DEBUG_ROUTE, "lookup %pFX: nhrp_if=%s", &lookup,
ri->nhrp_ifp->name);
if (via)
@@ -259,9 +255,8 @@ int nhrp_route_get_nexthop(const union sockunion *addr, struct prefix *p,
if (ifp)
*ifp = ri->nhrp_ifp;
} else {
- debugf(NHRP_DEBUG_ROUTE, "lookup %s: zebra route dev %s",
- prefix2str(&lookup, buf, sizeof(buf)),
- ri->ifp ? ri->ifp->name : "(none)");
+ debugf(NHRP_DEBUG_ROUTE, "lookup %pFX: zebra route dev %s",
+ &lookup, ri->ifp ? ri->ifp->name : "(none)");
if (via)
*via = ri->via;
diff --git a/nhrpd/nhrp_shortcut.c b/nhrpd/nhrp_shortcut.c
index 1c2b2b28f2..9a6f77334f 100644
--- a/nhrpd/nhrp_shortcut.c
+++ b/nhrpd/nhrp_shortcut.c
@@ -28,11 +28,9 @@ static void nhrp_shortcut_send_resolution_req(struct nhrp_shortcut *s);
static void nhrp_shortcut_check_use(struct nhrp_shortcut *s)
{
- char buf[PREFIX_STRLEN];
-
if (s->expiring && s->cache && s->cache->used) {
- debugf(NHRP_DEBUG_ROUTE, "Shortcut %s used and expiring",
- prefix2str(s->p, buf, sizeof(buf)));
+ debugf(NHRP_DEBUG_ROUTE, "Shortcut %pFX used and expiring",
+ s->p);
nhrp_shortcut_send_resolution_req(s);
}
}
@@ -53,8 +51,6 @@ static int nhrp_shortcut_do_expire(struct thread *t)
static void nhrp_shortcut_cache_notify(struct notifier_block *n,
unsigned long cmd)
{
- char buf[PREFIX_STRLEN];
-
struct nhrp_shortcut *s =
container_of(n, struct nhrp_shortcut, cache_notifier);
@@ -62,9 +58,8 @@ static void nhrp_shortcut_cache_notify(struct notifier_block *n,
case NOTIFY_CACHE_UP:
if (!s->route_installed) {
debugf(NHRP_DEBUG_ROUTE,
- "Shortcut: route install %s nh (unspec) dev %s",
- prefix2str(s->p, buf, sizeof(buf)),
- s->cache->ifp->name);
+ "Shortcut: route install %pFX nh (unspec) dev %s",
+ s->p, s->cache->ifp->name);
nhrp_route_announce(1, s->type, s->p, s->cache->ifp,
NULL, 0);
@@ -152,13 +147,11 @@ static void nhrp_shortcut_delete(struct nhrp_shortcut *s)
{
struct route_node *rn;
afi_t afi = family2afi(PREFIX_FAMILY(s->p));
- char buf[PREFIX_STRLEN];
THREAD_OFF(s->t_timer);
nhrp_reqid_free(&nhrp_packet_reqid, &s->reqid);
- debugf(NHRP_DEBUG_ROUTE, "Shortcut %s purged",
- prefix2str(s->p, buf, sizeof(buf)));
+ debugf(NHRP_DEBUG_ROUTE, "Shortcut %pFX purged", s->p);
nhrp_shortcut_update_binding(s, NHRP_CACHE_INVALID, NULL, 0);
@@ -184,7 +177,6 @@ static struct nhrp_shortcut *nhrp_shortcut_get(struct prefix *p)
{
struct nhrp_shortcut *s;
struct route_node *rn;
- char buf[PREFIX_STRLEN];
afi_t afi = family2afi(PREFIX_FAMILY(p));
if (!shortcut_rib[afi])
@@ -197,8 +189,7 @@ static struct nhrp_shortcut *nhrp_shortcut_get(struct prefix *p)
s->type = NHRP_CACHE_INVALID;
s->p = &rn->p;
- debugf(NHRP_DEBUG_ROUTE, "Shortcut %s created",
- prefix2str(s->p, buf, sizeof(buf)));
+ debugf(NHRP_DEBUG_ROUTE, "Shortcut %pFX created", s->p);
} else {
s = rn->info;
route_unlock_node(rn);
@@ -219,7 +210,7 @@ static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid,
union sockunion *proto, cie_proto, *nbma, cie_nbma, nat_nbma;
struct prefix prefix, route_prefix;
struct zbuf extpl;
- char bufp[PREFIX_STRLEN], buf[4][SU_ADDRSTRLEN];
+ char buf[4][SU_ADDRSTRLEN];
int holding_time = pp->if_ad->holdtime;
nhrp_reqid_free(&nhrp_packet_reqid, &s->reqid);
@@ -287,9 +278,8 @@ static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid,
}
debugf(NHRP_DEBUG_COMMON,
- "Shortcut: %s is at proto %s dst_proto %s cie-nbma %s nat-nbma %s cie-holdtime %d",
- prefix2str(&prefix, bufp, sizeof(bufp)),
- sockunion2str(proto, buf[0], sizeof(buf[0])),
+ "Shortcut: %pFX is at proto %s dst_proto %s cie-nbma %s nat-nbma %s cie-holdtime %d",
+ &prefix, sockunion2str(proto, buf[0], sizeof(buf[0])),
sockunion2str(&pp->dst_proto, buf[1], sizeof(buf[1])),
sockunion2str(&cie_nbma, buf[2], sizeof(buf[2])),
sockunion2str(&nat_nbma, buf[3], sizeof(buf[3])),
diff --git a/ospf6d/ospf6_abr.c b/ospf6d/ospf6_abr.c
index 6fe3a289ce..cbb80b668d 100644
--- a/ospf6d/ospf6_abr.c
+++ b/ospf6d/ospf6_abr.c
@@ -153,7 +153,6 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
struct ospf6_inter_router_lsa *router_lsa;
struct ospf6_route_table *summary_table = NULL;
uint16_t type;
- char buf[PREFIX2STR_BUFFER];
int is_debug = 0;
/* Only destination type network, range or ASBR are considered */
@@ -196,12 +195,10 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
if (route->type == OSPF6_DEST_TYPE_ROUTER) {
if (ADV_ROUTER_IN_PREFIX(&route->prefix)
== area->ospf6->router_id) {
- inet_ntop(AF_INET,
- &(ADV_ROUTER_IN_PREFIX(&route->prefix)), buf,
- sizeof(buf));
zlog_debug(
- "%s: Skipping ASBR announcement for ABR (%s)",
- __func__, buf);
+ "%s: Skipping ASBR announcement for ABR (%pFX)",
+ __func__,
+ &ADV_ROUTER_IN_PREFIX(&route->prefix));
return 0;
}
}
@@ -210,11 +207,10 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
if (IS_OSPF6_DEBUG_ABR
|| IS_OSPF6_DEBUG_ORIGINATE(INTER_ROUTER)) {
is_debug++;
- inet_ntop(AF_INET,
- &(ADV_ROUTER_IN_PREFIX(&route->prefix)), buf,
- sizeof(buf));
- zlog_debug("Originating summary in area %s for ASBR %s",
- area->name, buf);
+ zlog_debug(
+ "Originating summary in area %s for ASBR %pFX",
+ area->name,
+ &ADV_ROUTER_IN_PREFIX(&route->prefix));
}
summary_table = area->summary_router;
} else {
@@ -226,16 +222,13 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
route->path.origin.type ==
htons(OSPF6_LSTYPE_INTER_PREFIX)) {
if (!CHECK_FLAG(route->flag, OSPF6_ROUTE_BEST)) {
- if (is_debug) {
- inet_ntop(AF_INET,
- &(ADV_ROUTER_IN_PREFIX(
- &route->prefix)), buf,
- sizeof(buf));
+ if (is_debug)
zlog_debug(
- "%s: route %s with cost %u is not best, ignore.",
- __func__, buf,
+ "%s: route %pFX with cost %u is not best, ignore.",
+ __func__,
+ &ADV_ROUTER_IN_PREFIX(
+ &route->prefix),
route->path.cost);
- }
return 0;
}
}
@@ -243,23 +236,19 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
if (route->path.origin.type ==
htons(OSPF6_LSTYPE_INTRA_PREFIX)) {
if (!CHECK_FLAG(route->flag, OSPF6_ROUTE_BEST)) {
- if (is_debug) {
- prefix2str(&route->prefix, buf,
- sizeof(buf));
+ if (is_debug)
zlog_debug(
- "%s: intra-prefix route %s with cost %u is not best, ignore.",
- __func__, buf,
+ "%s: intra-prefix route %pFX with cost %u is not best, ignore.",
+ __func__, &route->prefix,
route->path.cost);
- }
return 0;
}
}
- if (is_debug) {
- prefix2str(&route->prefix, buf, sizeof(buf));
- zlog_debug("Originating summary in area %s for %s cost %u",
- area->name, buf, route->path.cost);
- }
+ if (is_debug)
+ zlog_debug(
+ "Originating summary in area %s for %pFX cost %u",
+ area->name, &route->prefix, route->path.cost);
summary_table = area->summary_prefix;
}
@@ -369,11 +358,10 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
if (range && !CHECK_FLAG(range->flag, OSPF6_ROUTE_REMOVE)
&& (route->path.area_id != OSPF_AREA_BACKBONE
|| !IS_AREA_TRANSIT(area))) {
- if (is_debug) {
- prefix2str(&range->prefix, buf, sizeof(buf));
- zlog_debug("Suppressed by range %s of area %s",
- buf, route_area->name);
- }
+ if (is_debug)
+ zlog_debug(
+ "Suppressed by range %pFX of area %s",
+ &range->prefix, route_area->name);
ospf6_abr_delete_route(route, summary, summary_table,
old);
return 0;
@@ -411,15 +399,11 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
if (EXPORT_LIST(area))
if (access_list_apply(EXPORT_LIST(area), &route->prefix)
== FILTER_DENY) {
- if (is_debug) {
- inet_ntop(AF_INET,
- &(ADV_ROUTER_IN_PREFIX(
- &route->prefix)),
- buf, sizeof(buf));
+ if (is_debug)
zlog_debug(
- "prefix %s was denied by export list",
- buf);
- }
+ "prefix %pFX was denied by export list",
+ &ADV_ROUTER_IN_PREFIX(
+ &route->prefix));
return 0;
}
}
@@ -428,15 +412,10 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
if (PREFIX_LIST_OUT(area))
if (prefix_list_apply(PREFIX_LIST_OUT(area), &route->prefix)
!= PREFIX_PERMIT) {
- if (is_debug) {
- inet_ntop(
- AF_INET,
- &(ADV_ROUTER_IN_PREFIX(&route->prefix)),
- buf, sizeof(buf));
+ if (is_debug)
zlog_debug(
- "prefix %s was denied by filter-list out",
- buf);
- }
+ "prefix %pFX was denied by filter-list out",
+ &ADV_ROUTER_IN_PREFIX(&route->prefix));
return 0;
}
@@ -798,7 +777,6 @@ void ospf6_abr_old_route_remove(struct ospf6_lsa *lsa,
struct ospf6_path *o_path;
struct ospf6_nexthop *nh, *rnh;
bool nh_updated = false;
- char buf[PREFIX2STR_BUFFER];
for (ALL_LIST_ELEMENTS(old->paths, anode, anext, o_path)) {
if (o_path->origin.adv_router != lsa->header->adv_router
@@ -820,16 +798,13 @@ void ospf6_abr_old_route_remove(struct ospf6_lsa *lsa,
if (nh_updated) {
if (listcount(old->paths)) {
- if (IS_OSPF6_DEBUG_ABR ||
- IS_OSPF6_DEBUG_EXAMIN(INTER_PREFIX)) {
- prefix2str(&old->prefix, buf,
- sizeof(buf));
- zlog_debug("%s: old %s updated nh %u",
- __func__, buf,
+ if (IS_OSPF6_DEBUG_ABR
+ || IS_OSPF6_DEBUG_EXAMIN(INTER_PREFIX))
+ zlog_debug("%s: old %pFX updated nh %u",
+ __func__, &old->prefix,
old->nh_list ? listcount(
old->nh_list)
: 0);
- }
if (table->hook_add)
(*table->hook_add)(old);
@@ -1140,13 +1115,11 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
continue;
if ((ospf6_route_cmp(route, old_route) != 0)) {
- if (is_debug) {
- prefix2str(&prefix, buf, sizeof(buf));
+ if (is_debug)
zlog_debug(
- "%s: old %p %s cost %u new route cost %u are not same",
- __func__, (void *)old_route, buf,
+ "%s: old %p %pFX cost %u new route cost %u are not same",
+ __func__, (void *)old_route, &prefix,
old_route->path.cost, route->path.cost);
- }
/* Check new route's adv. router is same in one of
* the paths with differed cost, if so remove the
diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c
index 713ce26ecb..866bc7e189 100644
--- a/ospf6d/ospf6_area.c
+++ b/ospf6d/ospf6_area.c
@@ -505,13 +505,12 @@ void ospf6_area_config_write(struct vty *vty)
struct listnode *node;
struct ospf6_area *oa;
struct ospf6_route *range;
- char buf[PREFIX2STR_BUFFER];
for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, node, oa)) {
for (range = ospf6_route_head(oa->range_table); range;
range = ospf6_route_next(range)) {
- prefix2str(&range->prefix, buf, sizeof(buf));
- vty_out(vty, " area %s range %s", oa->name, buf);
+ vty_out(vty, " area %s range %pFX", oa->name,
+ &range->prefix);
if (CHECK_FLAG(range->flag,
OSPF6_ROUTE_DO_NOT_ADVERTISE)) {
diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c
index 10a92414b9..80a3c1005d 100644
--- a/ospf6d/ospf6_asbr.c
+++ b/ospf6d/ospf6_asbr.c
@@ -63,13 +63,11 @@ static void ospf6_as_external_lsa_originate(struct ospf6_route *route)
struct ospf6_external_info *info = route->route_option;
struct ospf6_as_external_lsa *as_external_lsa;
- char buf[PREFIX2STR_BUFFER];
caddr_t p;
- if (IS_OSPF6_DEBUG_ASBR || IS_OSPF6_DEBUG_ORIGINATE(AS_EXTERNAL)) {
- prefix2str(&route->prefix, buf, sizeof(buf));
- zlog_debug("Originate AS-External-LSA for %s", buf);
- }
+ if (IS_OSPF6_DEBUG_ASBR || IS_OSPF6_DEBUG_ORIGINATE(AS_EXTERNAL))
+ zlog_debug("Originate AS-External-LSA for %pFX",
+ &route->prefix);
/* prepare buffer */
memset(buffer, 0, sizeof(buffer));
@@ -211,7 +209,6 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,
struct listnode *anode, *anext;
struct listnode *nnode, *rnode, *rnext;
struct ospf6_nexthop *nh, *rnh;
- char buf[PREFIX2STR_BUFFER];
bool route_found = false;
/* check for old entry match with new route origin,
@@ -371,11 +368,9 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,
listnode_add_sort(old_route->paths, ecmp_path);
if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) {
- prefix2str(&route->prefix, buf,
- sizeof(buf));
zlog_debug(
- "%s: route %s another path added with nh %u, effective paths %u nh %u",
- __func__, buf,
+ "%s: route %pFX another path added with nh %u, effective paths %u nh %u",
+ __func__, &route->prefix,
listcount(ecmp_path->nh_list),
old_route->paths ? listcount(
old_route->paths)
@@ -401,32 +396,27 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,
&o_path->ls_prefix,
ospf6->brouter_table);
if (asbr_entry == NULL) {
- if (IS_OSPF6_DEBUG_EXAMIN(
- AS_EXTERNAL)) {
- prefix2str(&old_route->prefix,
- buf, sizeof(buf));
+ if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL))
zlog_debug(
- "%s: ls_prfix %s asbr_entry not found.",
- __func__, buf);
- }
+ "%s: ls_prfix %pFX asbr_entry not found.",
+ __func__,
+ &old_route->prefix);
continue;
}
ospf6_route_merge_nexthops(old_route,
asbr_entry);
}
- if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) {
- prefix2str(&route->prefix, buf, sizeof(buf));
+ if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL))
zlog_debug(
- "%s: route %s with effective paths %u nh %u",
- __func__, buf,
+ "%s: route %pFX with effective paths %u nh %u",
+ __func__, &route->prefix,
old_route->paths
? listcount(old_route->paths)
: 0,
old_route->nh_list
? listcount(old_route->nh_list)
: 0);
- }
/* Update RIB/FIB */
if (ospf6->route_table->hook_add)
@@ -453,7 +443,6 @@ void ospf6_asbr_lsa_add(struct ospf6_lsa *lsa)
struct prefix asbr_id;
struct ospf6_route *asbr_entry, *route, *old;
struct ospf6_path *path;
- char buf[PREFIX2STR_BUFFER];
external = (struct ospf6_as_external_lsa *)OSPF6_LSA_HEADER_END(
lsa->header);
@@ -484,10 +473,8 @@ void ospf6_asbr_lsa_add(struct ospf6_lsa *lsa)
asbr_entry = ospf6_route_lookup(&asbr_id, ospf6->brouter_table);
if (asbr_entry == NULL
|| !CHECK_FLAG(asbr_entry->path.router_bits, OSPF6_ROUTER_BIT_E)) {
- if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) {
- prefix2str(&asbr_id, buf, sizeof(buf));
- zlog_debug("ASBR entry not found: %s", buf);
- }
+ if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL))
+ zlog_debug("ASBR entry not found: %pFX", &asbr_id);
return;
}
@@ -527,15 +514,13 @@ void ospf6_asbr_lsa_add(struct ospf6_lsa *lsa)
listnode_add_sort(route->paths, path);
- if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) {
- prefix2str(&route->prefix, buf, sizeof(buf));
- zlog_debug("%s: AS-External %u route add %s cost %u(%u) nh %u",
- __func__,
- (route->path.type == OSPF6_PATH_TYPE_EXTERNAL1) ? 1
- : 2,
- buf, route->path.cost, route->path.u.cost_e2,
- listcount(route->nh_list));
- }
+ if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL))
+ zlog_debug(
+ "%s: AS-External %u route add %pFX cost %u(%u) nh %u",
+ __func__,
+ (route->path.type == OSPF6_PATH_TYPE_EXTERNAL1) ? 1 : 2,
+ &route->prefix, route->path.cost, route->path.u.cost_e2,
+ listcount(route->nh_list));
old = ospf6_route_lookup(&route->prefix, ospf6->route_table);
if (!old) {
@@ -1029,7 +1014,7 @@ void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex,
struct ospf6_external_info *info;
struct prefix prefix_id;
struct route_node *node;
- char pbuf[PREFIX2STR_BUFFER], ibuf[16];
+ char ibuf[16];
struct listnode *lnode, *lnnode;
struct ospf6_area *oa;
@@ -1039,10 +1024,8 @@ void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex,
memset(&troute, 0, sizeof(troute));
memset(&tinfo, 0, sizeof(tinfo));
- if (IS_OSPF6_DEBUG_ASBR) {
- prefix2str(prefix, pbuf, sizeof(pbuf));
- zlog_debug("Redistribute %s (%s)", pbuf, ZROUTE_NAME(type));
- }
+ if (IS_OSPF6_DEBUG_ASBR)
+ zlog_debug("Redistribute %pFX (%s)", prefix, ZROUTE_NAME(type));
/* if route-map was specified but not found, do not advertise */
if (ospf6->rmap[type].name) {
@@ -1109,10 +1092,9 @@ void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex,
if (IS_OSPF6_DEBUG_ASBR) {
inet_ntop(AF_INET, &prefix_id.u.prefix4, ibuf,
sizeof(ibuf));
- prefix2str(prefix, pbuf, sizeof(pbuf));
zlog_debug(
- "Advertise as AS-External Id:%s prefix %s metric %u",
- ibuf, pbuf, match->path.metric_type);
+ "Advertise as AS-External Id:%s prefix %pFX metric %u",
+ ibuf, prefix, match->path.metric_type);
}
match->path.origin.id = htonl(info->id);
@@ -1163,9 +1145,9 @@ void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex,
if (IS_OSPF6_DEBUG_ASBR) {
inet_ntop(AF_INET, &prefix_id.u.prefix4, ibuf, sizeof(ibuf));
- prefix2str(prefix, pbuf, sizeof(pbuf));
- zlog_debug("Advertise as AS-External Id:%s prefix %s metric %u",
- ibuf, pbuf, route->path.metric_type);
+ zlog_debug(
+ "Advertise as AS-External Id:%s prefix %pFX metric %u",
+ ibuf, prefix, route->path.metric_type);
}
route->path.origin.id = htonl(info->id);
@@ -1184,16 +1166,14 @@ void ospf6_asbr_redistribute_remove(int type, ifindex_t ifindex,
struct route_node *node;
struct ospf6_lsa *lsa;
struct prefix prefix_id;
- char pbuf[PREFIX2STR_BUFFER], ibuf[16];
+ char ibuf[16];
struct listnode *lnode, *lnnode;
struct ospf6_area *oa;
match = ospf6_route_lookup(prefix, ospf6->external_table);
if (match == NULL) {
- if (IS_OSPF6_DEBUG_ASBR) {
- prefix2str(prefix, pbuf, sizeof(pbuf));
- zlog_debug("No such route %s to withdraw", pbuf);
- }
+ if (IS_OSPF6_DEBUG_ASBR)
+ zlog_debug("No such route %pFX to withdraw", prefix);
return;
}
@@ -1201,17 +1181,14 @@ void ospf6_asbr_redistribute_remove(int type, ifindex_t ifindex,
assert(info);
if (info->type != type) {
- if (IS_OSPF6_DEBUG_ASBR) {
- prefix2str(prefix, pbuf, sizeof(pbuf));
- zlog_debug("Original protocol mismatch: %s", pbuf);
- }
+ if (IS_OSPF6_DEBUG_ASBR)
+ zlog_debug("Original protocol mismatch: %pFX", prefix);
return;
}
if (IS_OSPF6_DEBUG_ASBR) {
- prefix2str(prefix, pbuf, sizeof(pbuf));
inet_ntop(AF_INET, &prefix_id.u.prefix4, ibuf, sizeof(ibuf));
- zlog_debug("Withdraw %s (AS-External Id:%s)", pbuf, ibuf);
+ zlog_debug("Withdraw %pFX (AS-External Id:%s)", prefix, ibuf);
}
lsa = ospf6_lsdb_lookup(htons(OSPF6_LSTYPE_AS_EXTERNAL),
@@ -1823,10 +1800,9 @@ static void ospf6_asbr_external_route_show(struct vty *vty,
struct ospf6_route *route)
{
struct ospf6_external_info *info = route->route_option;
- char prefix[PREFIX2STR_BUFFER], id[16], forwarding[64];
+ char id[16], forwarding[64];
uint32_t tmp_id;
- prefix2str(&route->prefix, prefix, sizeof(prefix));
tmp_id = ntohl(info->id);
inet_ntop(AF_INET, &tmp_id, id, sizeof(id));
if (!IN6_IS_ADDR_UNSPECIFIED(&info->forwarding))
@@ -1836,8 +1812,8 @@ static void ospf6_asbr_external_route_show(struct vty *vty,
snprintf(forwarding, sizeof(forwarding), ":: (ifindex %d)",
ospf6_route_get_first_nh_index(route));
- vty_out(vty, "%c %-32s %-15s type-%d %5lu %s\n",
- zebra_route_char(info->type), prefix, id,
+ vty_out(vty, "%c %-32pFX %-15s type-%d %5lu %s\n",
+ zebra_route_char(info->type), &route->prefix, id,
route->path.metric_type,
(unsigned long)(route->path.metric_type == 2
? route->path.u.cost_e2
diff --git a/ospf6d/ospf6_bfd.c b/ospf6d/ospf6_bfd.c
index 1b58cd14f6..4e50ab5244 100644
--- a/ospf6d/ospf6_bfd.c
+++ b/ospf6d/ospf6_bfd.c
@@ -204,12 +204,9 @@ static int ospf6_bfd_interface_dest_update(ZAPI_CALLBACK_ARGS)
if ((ifp == NULL) || (dp.family != AF_INET6))
return 0;
- if (IS_OSPF6_DEBUG_ZEBRA(RECV)) {
- char buf[PREFIX2STR_BUFFER];
- prefix2str(&dp, buf, sizeof(buf));
- zlog_debug("Zebra: interface %s bfd destination %s %s",
- ifp->name, buf, bfd_get_status_str(status));
- }
+ if (IS_OSPF6_DEBUG_ZEBRA(RECV))
+ zlog_debug("Zebra: interface %s bfd destination %pFX %s",
+ ifp->name, &dp, bfd_get_status_str(status));
oi = (struct ospf6_interface *)ifp->info;
diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c
index 72e40676a0..a724157737 100644
--- a/ospf6d/ospf6_interface.c
+++ b/ospf6d/ospf6_interface.c
@@ -436,16 +436,14 @@ void ospf6_interface_connected_route_update(struct interface *ifp)
if (oi->plist_name) {
struct prefix_list *plist;
enum prefix_list_type ret;
- char buf[PREFIX2STR_BUFFER];
- prefix2str(c->address, buf, sizeof(buf));
plist = prefix_list_lookup(AFI_IP6, oi->plist_name);
ret = prefix_list_apply(plist, (void *)c->address);
if (ret == PREFIX_DENY) {
if (IS_OSPF6_DEBUG_INTERFACE)
zlog_debug(
- "%s on %s filtered by prefix-list %s ",
- buf, oi->interface->name,
+ "%pFX on %s filtered by prefix-list %s ",
+ c->address, oi->interface->name,
oi->plist_name);
continue;
}
@@ -929,16 +927,15 @@ static int ospf6_interface_show(struct vty *vty, struct interface *ifp)
for (ALL_LIST_ELEMENTS_RO(ifp->connected, i, c)) {
p = c->address;
- prefix2str(p, strbuf, sizeof(strbuf));
switch (p->family) {
case AF_INET:
- vty_out(vty, " inet : %s\n", strbuf);
+ vty_out(vty, " inet : %pFX\n", p);
break;
case AF_INET6:
- vty_out(vty, " inet6: %s\n", strbuf);
+ vty_out(vty, " inet6: %pFX\n", p);
break;
default:
- vty_out(vty, " ??? : %s\n", strbuf);
+ vty_out(vty, " ??? : %pFX\n", p);
break;
}
}
diff --git a/ospf6d/ospf6_intra.c b/ospf6d/ospf6_intra.c
index 6eda9f750c..733b9cffb1 100644
--- a/ospf6d/ospf6_intra.c
+++ b/ospf6d/ospf6_intra.c
@@ -907,7 +907,6 @@ int ospf6_intra_prefix_lsa_originate_stub(struct thread *thread)
struct listnode *i, *j;
int full_count = 0;
unsigned short prefix_num = 0;
- char buf[PREFIX2STR_BUFFER];
struct ospf6_route_table *route_advertise;
int ls_id = 0;
@@ -985,10 +984,8 @@ int ospf6_intra_prefix_lsa_originate_stub(struct thread *thread)
/* connected prefix to advertise */
for (route = ospf6_route_head(oi->route_connected); route;
route = ospf6_route_best_next(route)) {
- if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX)) {
- prefix2str(&route->prefix, buf, sizeof(buf));
- zlog_debug(" include %s", buf);
- }
+ if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX))
+ zlog_debug(" include %pFX", &route->prefix);
ospf6_route_add(ospf6_route_copy(route),
route_advertise);
}
@@ -1144,7 +1141,6 @@ int ospf6_intra_prefix_lsa_originate_transit(struct thread *thread)
struct ospf6_link_lsa *link_lsa;
char *start, *end, *current;
uint16_t type;
- char buf[PREFIX2STR_BUFFER];
oi = (struct ospf6_interface *)THREAD_ARG(thread);
oi->thread_intra_prefix_lsa = NULL;
@@ -1255,10 +1251,8 @@ int ospf6_intra_prefix_lsa_originate_transit(struct thread *thread)
route->path.area_id = oi->area->area_id;
route->path.type = OSPF6_PATH_TYPE_INTRA;
- if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX)) {
- prefix2str(&route->prefix, buf, sizeof(buf));
- zlog_debug(" include %s", buf);
- }
+ if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX))
+ zlog_debug(" include %pFX", &route->prefix);
ospf6_route_add(route, route_advertise);
prefix_num--;
@@ -1554,11 +1548,9 @@ void ospf6_intra_prefix_route_ecmp_path(struct ospf6_area *oa,
ospf6_linkstate_prefix(
o_path->origin.adv_router,
o_path->origin.id, &adv_prefix);
- prefix2str(&adv_prefix, buf,
- sizeof(buf));
zlog_debug(
- "%s: adv_router %s lsa not found",
- __func__, buf);
+ "%s: adv_router %pFX lsa not found",
+ __func__, &adv_prefix);
}
continue;
}
@@ -1582,16 +1574,15 @@ void ospf6_intra_prefix_route_ecmp_path(struct ospf6_area *oa,
}
}
- if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) {
- prefix2str(&route->prefix, buf, sizeof(buf));
+ if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX))
zlog_debug(
- "%s: route %s %p with final effective paths %u nh%u",
- __func__, buf, (void *)old_route,
+ "%s: route %pFX %p with final effective paths %u nh%u",
+ __func__, &route->prefix,
+ (void *)old_route,
old_route->paths
? listcount(old_route->paths)
: 0,
listcount(old_route->nh_list));
- }
/* used in intra_route_calculation() to add to
* global ospf6 route table.
diff --git a/ospf6d/ospf6_lsa.h b/ospf6d/ospf6_lsa.h
index cd873e2f00..f8f0780baa 100644
--- a/ospf6d/ospf6_lsa.h
+++ b/ospf6d/ospf6_lsa.h
@@ -156,46 +156,36 @@ extern vector ospf6_lsa_handler_vector;
/* addr is (struct prefix *) */
#define CONTINUE_IF_ADDRESS_LINKLOCAL(debug, addr) \
if (IN6_IS_ADDR_LINKLOCAL(&(addr)->u.prefix6)) { \
- char buf[PREFIX2STR_BUFFER]; \
- prefix2str(addr, buf, sizeof(buf)); \
if (debug) \
- zlog_debug("Filter out Linklocal: %s", buf); \
+ zlog_debug("Filter out Linklocal: %pFX", addr); \
continue; \
}
#define CONTINUE_IF_ADDRESS_UNSPECIFIED(debug, addr) \
if (IN6_IS_ADDR_UNSPECIFIED(&(addr)->u.prefix6)) { \
- char buf[PREFIX2STR_BUFFER]; \
- prefix2str(addr, buf, sizeof(buf)); \
if (debug) \
- zlog_debug("Filter out Unspecified: %s", buf); \
+ zlog_debug("Filter out Unspecified: %pFX", addr); \
continue; \
}
#define CONTINUE_IF_ADDRESS_LOOPBACK(debug, addr) \
if (IN6_IS_ADDR_LOOPBACK(&(addr)->u.prefix6)) { \
- char buf[PREFIX2STR_BUFFER]; \
- prefix2str(addr, buf, sizeof(buf)); \
if (debug) \
- zlog_debug("Filter out Loopback: %s", buf); \
+ zlog_debug("Filter out Loopback: %pFX", addr); \
continue; \
}
#define CONTINUE_IF_ADDRESS_V4COMPAT(debug, addr) \
if (IN6_IS_ADDR_V4COMPAT(&(addr)->u.prefix6)) { \
- char buf[PREFIX2STR_BUFFER]; \
- prefix2str(addr, buf, sizeof(buf)); \
if (debug) \
- zlog_debug("Filter out V4Compat: %s", buf); \
+ zlog_debug("Filter out V4Compat: %pFX", addr); \
continue; \
}
#define CONTINUE_IF_ADDRESS_V4MAPPED(debug, addr) \
if (IN6_IS_ADDR_V4MAPPED(&(addr)->u.prefix6)) { \
- char buf[PREFIX2STR_BUFFER]; \
- prefix2str(addr, buf, sizeof(buf)); \
if (debug) \
- zlog_debug("Filter out V4Mapped: %s", buf); \
+ zlog_debug("Filter out V4Mapped: %pFX", addr); \
continue; \
}
diff --git a/ospf6d/ospf6_lsdb.c b/ospf6d/ospf6_lsdb.c
index db6f9a7801..0892863cf1 100644
--- a/ospf6d/ospf6_lsdb.c
+++ b/ospf6d/ospf6_lsdb.c
@@ -207,11 +207,7 @@ struct ospf6_lsa *ospf6_lsdb_lookup_next(uint16_t type, uint32_t id,
ospf6_lsdb_set_key(&key, &adv_router, sizeof(adv_router));
ospf6_lsdb_set_key(&key, &id, sizeof(id));
- {
- char buf[PREFIX2STR_BUFFER];
- prefix2str(&key, buf, sizeof(buf));
- zlog_debug("lsdb_lookup_next: key: %s", buf);
- }
+ zlog_debug("lsdb_lookup_next: key: %pFX", &key);
node = route_table_get_next(lsdb->table, &key);
diff --git a/ospf6d/ospf6_route.c b/ospf6d/ospf6_route.c
index a443e4c3ba..1cd6b8cff4 100644
--- a/ospf6d/ospf6_route.c
+++ b/ospf6d/ospf6_route.c
@@ -550,7 +550,6 @@ ospf6_route_lookup_bestmatch(struct prefix *prefix,
static void route_table_assert(struct ospf6_route_table *table)
{
struct ospf6_route *prev, *r, *next;
- char buf[PREFIX2STR_BUFFER];
unsigned int link_error = 0, num = 0;
r = ospf6_route_head(table);
@@ -579,10 +578,9 @@ static void route_table_assert(struct ospf6_route_table *table)
"Something has gone wrong with ospf6_route_table[%p]", table);
zlog_debug("table count = %d, real number = %d", table->count, num);
zlog_debug("DUMP START");
- for (r = ospf6_route_head(table); r; r = ospf6_route_next(r)) {
- prefix2str(&r->prefix, buf, sizeof(buf));
- zlog_info("%p<-[%p]->%p : %s", r->prev, r, r->next, buf);
- }
+ for (r = ospf6_route_head(table); r; r = ospf6_route_next(r))
+ zlog_info("%p<-[%p]->%p : %pFX", r->prev, r, r->next,
+ &r->prefix);
zlog_debug("DUMP END");
assert(link_error == 0 && num == table->count);
@@ -714,7 +712,7 @@ struct ospf6_route *ospf6_route_add(struct ospf6_route *route,
"%s %p: route add %p cost %u: another path: prev %p, next %p node ref %u",
ospf6_route_table_name(table), (void *)table,
(void *)route, route->path.cost, (void *)prev,
- (void *)next, node->lock);
+ (void *)next, route_node_get_lock_count(node));
else if (IS_OSPF6_DEBUG_ROUTE(TABLE))
zlog_debug("%s: route add cost %u: another path found",
ospf6_route_table_name(table),
diff --git a/ospf6d/ospf6_spf.c b/ospf6d/ospf6_spf.c
index bb6a050976..d3a330c3c7 100644
--- a/ospf6d/ospf6_spf.c
+++ b/ospf6d/ospf6_spf.c
@@ -320,7 +320,6 @@ static int ospf6_spf_install(struct ospf6_vertex *v,
{
struct ospf6_route *route, *parent_route;
struct ospf6_vertex *prev;
- char pbuf[PREFIX2STR_BUFFER];
if (IS_OSPF6_DEBUG_SPF(PROCESS))
zlog_debug("SPF install %s (lsa %s) hops %d cost %d", v->name,
@@ -335,12 +334,10 @@ static int ospf6_spf_install(struct ospf6_vertex *v,
ospf6_vertex_delete(v);
return -1;
} else if (route && route->path.cost == v->cost) {
- if (IS_OSPF6_DEBUG_SPF(PROCESS)) {
- prefix2str(&route->prefix, pbuf, sizeof(pbuf));
+ if (IS_OSPF6_DEBUG_SPF(PROCESS))
zlog_debug(
- " another path found to route %s lsa %s, merge",
- pbuf, v->lsa->name);
- }
+ " another path found to route %pFX lsa %s, merge",
+ &route->prefix, v->lsa->name);
ospf6_spf_merge_nexthops_to_route(route, v);
prev = (struct ospf6_vertex *)route->route_option;
diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c
index 49b7e4f142..1f906cadd1 100644
--- a/ospf6d/ospf6_top.c
+++ b/ospf6d/ospf6_top.c
@@ -1059,15 +1059,11 @@ static int ospf6_distance_config_write(struct vty *vty)
}
for (rn = route_top(ospf6->distance_table); rn; rn = route_next(rn))
- if ((odistance = rn->info) != NULL) {
- char buf[PREFIX_STRLEN];
-
- vty_out(vty, " distance %u %s %s\n",
- odistance->distance,
- prefix2str(&rn->p, buf, sizeof(buf)),
+ if ((odistance = rn->info) != NULL)
+ vty_out(vty, " distance %u %pFX %s\n",
+ odistance->distance, &rn->p,
odistance->access_list ? odistance->access_list
: "");
- }
return 0;
}
diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c
index 62e0e149b8..c5c8ca27b9 100644
--- a/ospf6d/ospf6_zebra.c
+++ b/ospf6d/ospf6_zebra.c
@@ -99,7 +99,6 @@ void ospf6_zebra_no_redistribute(int type, vrf_id_t vrf_id)
static int ospf6_zebra_if_address_update_add(ZAPI_CALLBACK_ARGS)
{
struct connected *c;
- char buf[128];
c = zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_ADD,
zclient->ibuf, vrf_id);
@@ -107,11 +106,9 @@ static int ospf6_zebra_if_address_update_add(ZAPI_CALLBACK_ARGS)
return 0;
if (IS_OSPF6_DEBUG_ZEBRA(RECV))
- zlog_debug("Zebra Interface address add: %s %5s %s/%d",
+ zlog_debug("Zebra Interface address add: %s %5s %pFX",
c->ifp->name, prefix_family_str(c->address),
- inet_ntop(c->address->family, &c->address->u.prefix,
- buf, sizeof(buf)),
- c->address->prefixlen);
+ c->address);
if (c->address->family == AF_INET6) {
ospf6_interface_state_update(c->ifp);
@@ -123,7 +120,6 @@ static int ospf6_zebra_if_address_update_add(ZAPI_CALLBACK_ARGS)
static int ospf6_zebra_if_address_update_delete(ZAPI_CALLBACK_ARGS)
{
struct connected *c;
- char buf[128];
c = zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_DELETE,
zclient->ibuf, vrf_id);
@@ -131,11 +127,9 @@ static int ospf6_zebra_if_address_update_delete(ZAPI_CALLBACK_ARGS)
return 0;
if (IS_OSPF6_DEBUG_ZEBRA(RECV))
- zlog_debug("Zebra Interface address delete: %s %5s %s/%d",
+ zlog_debug("Zebra Interface address delete: %s %5s %pFX",
c->ifp->name, prefix_family_str(c->address),
- inet_ntop(c->address->family, &c->address->u.prefix,
- buf, sizeof(buf)),
- c->address->prefixlen);
+ c->address);
if (c->address->family == AF_INET6) {
ospf6_interface_connected_route_update(c->ifp);
@@ -169,19 +163,13 @@ static int ospf6_zebra_read_route(ZAPI_CALLBACK_ARGS)
ifindex = api.nexthops[0].ifindex;
nexthop = &api.nexthops[0].gate.ipv6;
- if (IS_OSPF6_DEBUG_ZEBRA(RECV)) {
- char prefixstr[PREFIX2STR_BUFFER], nexthopstr[128];
-
- prefix2str(&api.prefix, prefixstr, sizeof(prefixstr));
- inet_ntop(AF_INET6, nexthop, nexthopstr, sizeof(nexthopstr));
-
+ if (IS_OSPF6_DEBUG_ZEBRA(RECV))
zlog_debug(
- "Zebra Receive route %s: %s %s nexthop %s ifindex %ld tag %" ROUTE_TAG_PRI,
+ "Zebra Receive route %s: %s %pFX nexthop %pI6 ifindex %ld tag %" ROUTE_TAG_PRI,
(cmd == ZEBRA_REDISTRIBUTE_ROUTE_ADD ? "add"
: "delete"),
- zebra_route_string(api.type), prefixstr, nexthopstr,
+ zebra_route_string(api.type), &api.prefix, nexthop,
ifindex, api.tag);
- }
if (cmd == ZEBRA_REDISTRIBUTE_ROUTE_ADD)
ospf6_asbr_redistribute_add(api.type, ifindex, &api.prefix,
@@ -225,16 +213,13 @@ DEFUN (show_zebra,
static void ospf6_zebra_route_update(int type, struct ospf6_route *request)
{
struct zapi_route api;
- char buf[PREFIX2STR_BUFFER];
int nhcount;
int ret = 0;
struct prefix *dest;
- if (IS_OSPF6_DEBUG_ZEBRA(SEND)) {
- prefix2str(&request->prefix, buf, sizeof(buf));
- zlog_debug("Send %s route: %s",
- (type == REM ? "remove" : "add"), buf);
- }
+ if (IS_OSPF6_DEBUG_ZEBRA(SEND))
+ zlog_debug("Send %s route: %pFX",
+ (type == REM ? "remove" : "add"), &request->prefix);
if (zclient->sock < 0) {
if (IS_OSPF6_DEBUG_ZEBRA(SEND))
@@ -325,7 +310,6 @@ void ospf6_zebra_route_update_remove(struct ospf6_route *request)
void ospf6_zebra_add_discard(struct ospf6_route *request)
{
struct zapi_route api;
- char buf[INET6_ADDRSTRLEN];
struct prefix *dest = &request->prefix;
if (!CHECK_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED)) {
@@ -339,26 +323,20 @@ void ospf6_zebra_add_discard(struct ospf6_route *request)
zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api);
if (IS_OSPF6_DEBUG_ZEBRA(SEND))
- zlog_debug("Zebra: Route add discard %s/%d",
- inet_ntop(AF_INET6, &dest->u.prefix6, buf,
- INET6_ADDRSTRLEN),
- dest->prefixlen);
+ zlog_debug("Zebra: Route add discard %pFX", dest);
SET_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED);
} else {
if (IS_OSPF6_DEBUG_ZEBRA(SEND))
zlog_debug(
- "Zebra: Blackhole route present already %s/%d",
- inet_ntop(AF_INET6, &dest->u.prefix6, buf,
- INET6_ADDRSTRLEN),
- dest->prefixlen);
+ "Zebra: Blackhole route present already %pFX",
+ dest);
}
}
void ospf6_zebra_delete_discard(struct ospf6_route *request)
{
struct zapi_route api;
- char buf[INET6_ADDRSTRLEN];
struct prefix *dest = &request->prefix;
if (CHECK_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED)) {
@@ -372,19 +350,14 @@ void ospf6_zebra_delete_discard(struct ospf6_route *request)
zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api);
if (IS_OSPF6_DEBUG_ZEBRA(SEND))
- zlog_debug("Zebra: Route delete discard %s/%d",
- inet_ntop(AF_INET6, &dest->u.prefix6, buf,
- INET6_ADDRSTRLEN),
- dest->prefixlen);
+ zlog_debug("Zebra: Route delete discard %pFX", dest);
UNSET_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED);
} else {
if (IS_OSPF6_DEBUG_ZEBRA(SEND))
zlog_debug(
- "Zebra: Blackhole route already deleted %s/%d",
- inet_ntop(AF_INET6, &dest->u.prefix6, buf,
- INET6_ADDRSTRLEN),
- dest->prefixlen);
+ "Zebra: Blackhole route already deleted %pFX",
+ dest);
}
}
diff --git a/ospfclient/ospfclient.c b/ospfclient/ospfclient.c
index f5f994517e..3ca1e132bd 100644
--- a/ospfclient/ospfclient.c
+++ b/ospfclient/ospfclient.c
@@ -30,6 +30,7 @@
#include "prefix.h" /* needed by ospf_asbr.h */
#include "privs.h"
#include "log.h"
+#include "lib/printfrr.h"
/* work around gcc bug 69981, disable MTYPEs in libospf */
#define _QUAGGA_OSPF_MEMORY_H
@@ -186,8 +187,8 @@ static void lsa_update_callback(struct in_addr ifaddr, struct in_addr area_id,
struct lsa_header *lsa)
{
printf("lsa_update_callback: ");
- printf("ifaddr: %s ", inet_ntoa(ifaddr));
- printf("area: %s\n", inet_ntoa(area_id));
+ printfrr("ifaddr: %pI4 ", &ifaddr);
+ printfrr("area: %pI4\n", &area_id);
printf("is_self_origin: %u\n", is_self_originated);
/* It is important to note that lsa_header does indeed include the
@@ -211,8 +212,8 @@ static void lsa_delete_callback(struct in_addr ifaddr, struct in_addr area_id,
struct lsa_header *lsa)
{
printf("lsa_delete_callback: ");
- printf("ifaddr: %s ", inet_ntoa(ifaddr));
- printf("area: %s\n", inet_ntoa(area_id));
+ printf("ifaddr: %pI4 ", &ifaddr);
+ printf("area: %pI4\n", &area_id);
printf("is_self_origin: %u\n", is_self_originated);
ospf_lsa_header_dump(lsa);
@@ -221,8 +222,8 @@ static void lsa_delete_callback(struct in_addr ifaddr, struct in_addr area_id,
static void ready_callback(uint8_t lsa_type, uint8_t opaque_type,
struct in_addr addr)
{
- printf("ready_callback: lsa_type: %d opaque_type: %d addr=%s\n",
- lsa_type, opaque_type, inet_ntoa(addr));
+ printfrr("ready_callback: lsa_type: %d opaque_type: %d addr=%pI4\n",
+ lsa_type, opaque_type, &addr);
/* Schedule opaque LSA originate in 5 secs */
thread_add_timer(master, lsa_inject, oclient, 5, NULL);
@@ -236,20 +237,20 @@ static void ready_callback(uint8_t lsa_type, uint8_t opaque_type,
static void new_if_callback(struct in_addr ifaddr, struct in_addr area_id)
{
- printf("new_if_callback: ifaddr: %s ", inet_ntoa(ifaddr));
- printf("area_id: %s\n", inet_ntoa(area_id));
+ printfrr("new_if_callback: ifaddr: %pI4 ", &ifaddr);
+ printfrr("area_id: %pI4\n", &area_id);
}
static void del_if_callback(struct in_addr ifaddr)
{
- printf("new_if_callback: ifaddr: %s\n ", inet_ntoa(ifaddr));
+ printfrr("new_if_callback: ifaddr: %pI4\n ", &ifaddr);
}
static void ism_change_callback(struct in_addr ifaddr, struct in_addr area_id,
uint8_t state)
{
- printf("ism_change: ifaddr: %s ", inet_ntoa(ifaddr));
- printf("area_id: %s\n", inet_ntoa(area_id));
+ printfrr("ism_change: ifaddr: %pI4 ", &ifaddr);
+ printfrr("area_id: %pI4\n", &area_id);
printf("state: %d [%s]\n", state,
lookup_msg(ospf_ism_state_msg, state, NULL));
}
@@ -257,9 +258,9 @@ static void ism_change_callback(struct in_addr ifaddr, struct in_addr area_id,
static void nsm_change_callback(struct in_addr ifaddr, struct in_addr nbraddr,
struct in_addr router_id, uint8_t state)
{
- printf("nsm_change: ifaddr: %s ", inet_ntoa(ifaddr));
- printf("nbraddr: %s\n", inet_ntoa(nbraddr));
- printf("router_id: %s\n", inet_ntoa(router_id));
+ printfrr("nsm_change: ifaddr: %pI4 ", &ifaddr);
+ printfrr("nbraddr: %pI4\n", &nbraddr);
+ printfrr("router_id: %pI4\n", &router_id);
printf("state: %d [%s]\n", state,
lookup_msg(ospf_nsm_state_msg, state, NULL));
}
diff --git a/ospfd/ospf_abr.c b/ospfd/ospf_abr.c
index 2131c8ee9d..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) : "<none>");
+ (best) ? inet_ntop(AF_INET, best, buf, sizeof(buf)) :
+ "<none>");
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,37 +634,41 @@ 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;
}
/* try find existing AS-External LSA for this prefix */
-
old = ospf_external_info_find_lsa(area->ospf, &p);
- if (old) {
- /* Do not continue if type 5 LSA not approved */
- if (!CHECK_FLAG(old->flags, OSPF_LSA_APPROVED)) {
+ if (CHECK_FLAG(lsa->flags, OSPF_LSA_IN_MAXAGE)) {
+ /* if type-7 is removed, remove old translated type-5 lsa */
+ if (old) {
+ UNSET_FLAG(old->flags, OSPF_LSA_APPROVED);
if (IS_DEBUG_OSPF_NSSA)
zlog_debug(
- "ospf_abr_translate_nssa(): LSA Id %s type 5 is not approved",
- inet_ntoa(old->data->id));
- return 1;
+ "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 */
+ return 1;
+ }
+ 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
@@ -672,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;
}
}
@@ -736,14 +742,10 @@ void ospf_abr_announce_network_to_area(struct prefix_ipv4 *p, uint32_t cost,
lsa = ospf_lsa_refresh(area->ospf, old);
if (!lsa) {
- char buf[PREFIX2STR_BUFFER];
-
- prefix2str((struct prefix *)p, buf,
- sizeof(buf));
flog_warn(EC_OSPF_LSA_MISSING,
- "%s: Could not refresh %s to %s",
- __func__, buf,
- inet_ntoa(area->area_id));
+ "%s: Could not refresh %pFX to %pI4",
+ __func__, (struct prefix *)p,
+ &area->area_id);
return;
}
@@ -758,12 +760,10 @@ void ospf_abr_announce_network_to_area(struct prefix_ipv4 *p, uint32_t cost,
/* This will flood through area. */
if (!lsa) {
- char buf[PREFIX2STR_BUFFER];
-
- prefix2str((struct prefix *)p, buf, sizeof(buf));
flog_warn(EC_OSPF_LSA_MISSING,
- "%s: Could not originate %s to %s", __func__,
- buf, inet_ntoa(area->area_id));
+ "%s: Could not originate %pFX to %pi4",
+ __func__, (struct prefix *)p,
+ &area->area_id);
return;
}
@@ -856,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;
@@ -868,16 +868,16 @@ static void ospf_abr_announce_network(struct ospf *ospf, struct prefix_ipv4 *p,
if (!ospf_abr_should_accept(p, area)) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_announce_network(): prefix %s/%d was denied by import-list",
- inet_ntoa(p->prefix), p->prefixlen);
+ "ospf_abr_announce_network(): prefix %pFX was denied by import-list",
+ p);
continue;
}
if (!ospf_abr_plist_in_check(area, or, p)) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_announce_network(): prefix %s/%d was denied by prefix-list",
- inet_ntoa(p->prefix), p->prefixlen);
+ "ospf_abr_announce_network(): prefix %pFX was denied by prefix-list",
+ p);
continue;
}
@@ -885,16 +885,16 @@ 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;
}
if (or->path_type == OSPF_PATH_INTER_AREA) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_announce_network(): this is inter-area route to %s/%d",
- inet_ntoa(p->prefix), p->prefixlen);
+ "ospf_abr_announce_network(): this is inter-area route to %pFX",
+ p);
if (!OSPF_IS_AREA_BACKBONE(area))
ospf_abr_announce_network_to_area(p, or->cost,
@@ -904,8 +904,8 @@ static void ospf_abr_announce_network(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_network(): this is intra-area route to %s/%d",
- inet_ntoa(p->prefix), p->prefixlen);
+ "ospf_abr_announce_network(): this is intra-area route to %pFX",
+ p);
if ((range = ospf_area_range_match(or_area, p))
&& !ospf_area_is_transit(area))
ospf_abr_update_aggregate(range, or, area);
@@ -964,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);
@@ -993,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(
@@ -1114,12 +1114,10 @@ static void ospf_abr_announce_rtr_to_area(struct prefix_ipv4 *p, uint32_t cost,
} else
lsa = ospf_summary_asbr_lsa_originate(p, cost, area);
if (!lsa) {
- char buf[PREFIX2STR_BUFFER];
-
- prefix2str((struct prefix *)p, buf, sizeof(buf));
flog_warn(EC_OSPF_LSA_MISSING,
- "%s: Could not refresh/originate %s to %s",
- __func__, buf, inet_ntoa(area->area_id));
+ "%s: Could not refresh/originate %pFX to %pI4",
+ __func__, (struct prefix *)p,
+ &area->area_id);
return;
}
@@ -1153,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;
@@ -1166,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);
@@ -1192,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);
}
}
@@ -1224,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;
}
@@ -1314,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)
@@ -1335,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);
}
@@ -1350,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);
}
}
@@ -1396,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)) {
@@ -1415,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)) {
@@ -1486,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)
@@ -1509,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)) {
@@ -1557,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))
@@ -1569,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);
}
@@ -1584,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);
@@ -1625,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 8fb6402c7e..fac85c9dca 100644
--- a/ospfd/ospf_asbr.c
+++ b/ospfd/ospf_asbr.c
@@ -53,8 +53,7 @@ void ospf_external_route_remove(struct ospf *ospf, struct prefix_ipv4 *p)
rn = route_node_lookup(ospf->old_external_route, (struct prefix *)p);
if (rn)
if ((or = rn->info)) {
- zlog_info("Route[%s/%d]: external path deleted",
- inet_ntoa(p->prefix), p->prefixlen);
+ zlog_info("Route[%pFX]: external path deleted", p);
/* Remove route from zebra. */
if (or->type == OSPF_DESTINATION_NETWORK)
@@ -69,8 +68,7 @@ void ospf_external_route_remove(struct ospf *ospf, struct prefix_ipv4 *p)
return;
}
- zlog_info("Route[%s/%d]: no such external path", inet_ntoa(p->prefix),
- p->prefixlen);
+ zlog_info("Route[%pFX]: no such external path", p);
}
/* Add an External info for AS-external-LSA. */
@@ -133,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);
}
@@ -157,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 d2c5090f2f..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);
@@ -217,12 +217,9 @@ static int ospf_bfd_interface_dest_update(ZAPI_CALLBACK_ARGS)
if ((ifp == NULL) || (p.family != AF_INET))
return 0;
- if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE)) {
- char buf[PREFIX2STR_BUFFER];
- prefix2str(&p, buf, sizeof(buf));
- zlog_debug("Zebra: interface %s bfd destination %s %s",
- ifp->name, buf, bfd_get_status_str(status));
- }
+ if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE))
+ zlog_debug("Zebra: interface %s bfd destination %pFX %s",
+ ifp->name, &p, bfd_get_status_str(status));
params = IF_DEF_PARAMS(ifp);
if (!params->bfd_info)
@@ -269,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 87929e4369..f805899b81 100644
--- a/ospfd/ospf_ia.c
+++ b/ospfd/ospf_ia.c
@@ -76,8 +76,8 @@ static void ospf_ia_network_route(struct ospf *ospf, struct route_table *rt,
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_ia_network_route(): processing summary route to %s/%d",
- inet_ntoa(p->prefix), p->prefixlen);
+ "ospf_ia_network_route(): processing summary route to %pFX",
+ p);
/* Find a route to the same dest */
if ((rn1 = route_node_lookup(rt, (struct prefix *)p))) {
@@ -113,8 +113,8 @@ static void ospf_ia_network_route(struct ospf *ospf, struct route_table *rt,
else { /* no route */
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_ia_network_route(): add new route to %s/%d",
- inet_ntoa(p->prefix), p->prefixlen);
+ "ospf_ia_network_route(): add new route to %pFX",
+ p);
ospf_route_add(rt, p, new_or, abr_or);
}
}
@@ -129,8 +129,8 @@ static void ospf_ia_router_route(struct ospf *ospf, struct route_table *rtrs,
int ret;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_ia_router_route(): considering %s/%d",
- inet_ntoa(p->prefix), p->prefixlen);
+ zlog_debug("ospf_ia_router_route(): considering %pFX", p);
+
/* Find a route to the same dest */
rn = route_node_get(rtrs, (struct prefix *)p);
@@ -202,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);
@@ -524,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 0200bf5e26..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);
}
@@ -2117,9 +2115,8 @@ void ospf_nssa_lsa_flush(struct ospf *ospf, struct prefix_ipv4 *p)
if (!lsa) {
if (IS_DEBUG_OSPF(lsa, LSA_FLOODING))
zlog_debug(
- "LSA: There is no such AS-NSSA-LSA %s/%d in LSDB",
- inet_ntoa(p->prefix),
- p->prefixlen);
+ "LSA: There is no such AS-NSSA-LSA %pFX in LSDB",
+ p);
continue;
}
ospf_ls_retransmit_delete_nbr_area(area, lsa);
@@ -2139,15 +2136,14 @@ void ospf_external_lsa_flush(struct ospf *ospf, uint8_t type,
struct ospf_lsa *lsa;
if (IS_DEBUG_OSPF(lsa, LSA_FLOODING))
- zlog_debug("LSA: Flushing AS-external-LSA %s/%d",
- inet_ntoa(p->prefix), p->prefixlen);
+ zlog_debug("LSA: Flushing AS-external-LSA %pFX", p);
/* First lookup LSA from LSDB. */
if (!(lsa = ospf_external_info_find_lsa(ospf, p))) {
if (IS_DEBUG_OSPF(lsa, LSA_FLOODING))
zlog_debug(
- "LSA: There is no such AS-external-LSA %s/%d in LSDB",
- inet_ntoa(p->prefix), p->prefixlen);
+ "LSA: There is no such AS-external-LSA %pFX in LSDB",
+ p);
return;
}
@@ -2256,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;
@@ -2266,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;
}
@@ -2281,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;
}
@@ -2307,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);
}
@@ -2683,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:
@@ -2694,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;
}
}
@@ -2711,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);
}
@@ -2788,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))
@@ -2814,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);
}
}
@@ -2873,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;
}
@@ -3109,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;
}
@@ -3206,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);
@@ -3244,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);
@@ -3259,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);
@@ -3363,8 +3355,8 @@ struct in_addr ospf_lsa_unique_id(struct ospf *ospf, struct ospf_lsdb *lsdb,
if (ip_masklen(al->mask) == p->prefixlen) {
if (IS_DEBUG_OSPF(lsa, LSA_GENERATE))
zlog_debug(
- "ospf_lsa_unique_id(): Can't get Link State ID for %s/%d",
- inet_ntoa(p->prefix), p->prefixlen);
+ "ospf_lsa_unique_id(): Can't get Link State ID for %pFX",
+ p);
/* id.s_addr = 0; */
id.s_addr = 0xffffffff;
return id;
@@ -3380,9 +3372,8 @@ struct in_addr ospf_lsa_unique_id(struct ospf *ospf, struct ospf_lsdb *lsdb,
if (lsa) {
if (IS_DEBUG_OSPF(lsa, LSA_GENERATE))
zlog_debug(
- "ospf_lsa_unique_id(): Can't get Link State ID for %s/%d",
- inet_ntoa(p->prefix),
- p->prefixlen);
+ "ospf_lsa_unique_id(): Can't get Link State ID for %pFX",
+ p);
/* id.s_addr = 0; */
id.s_addr = 0xffffffff;
return id;
@@ -3530,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])
@@ -3543,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);
}
}
@@ -3615,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 b0ff40afe5..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,8 +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), rn->lock);
+ "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;
@@ -401,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);
}
@@ -459,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 3b049555ba..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;
@@ -989,9 +988,7 @@ int ospf_add_discard_route(struct ospf *ospf, struct route_table *rt,
}
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_add_discard_route(): adding %s/%d",
- inet_ntoa(p->prefix), p->prefixlen);
+ zlog_debug("ospf_add_discard_route(): adding %pFX", p);
new_or = ospf_route_new();
new_or->type = OSPF_DESTINATION_DISCARD;
@@ -1014,9 +1011,7 @@ void ospf_delete_discard_route(struct ospf *ospf, struct route_table *rt,
struct ospf_route * or ;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_delete_discard_route(): deleting %s/%d",
- inet_ntoa(p->prefix), p->prefixlen);
+ zlog_debug("ospf_delete_discard_route(): deleting %pFX", p);
rn = route_node_lookup(rt, (struct prefix *)p);
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 5c82e11393..bef9490efc 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -34,6 +34,7 @@
#include "zclient.h"
#include <lib/json.h>
#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,14 +3467,15 @@ 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);
} else
- vty_out(vty, " Internet Address %s/%d,",
- inet_ntoa(oi->address->u.prefix4),
- oi->address->prefixlen);
+ vty_out(vty, " Internet Address %pFX,",
+ oi->address);
/* For Vlinks, showing the peer address is
* probably more informative than the local
@@ -3494,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",
@@ -3511,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]);
@@ -3535,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);
@@ -3562,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);
}
}
}
@@ -4174,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;
@@ -4200,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);
@@ -4234,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));
@@ -4259,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),
@@ -4470,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;
@@ -4525,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);
}
}
@@ -4815,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)
@@ -4825,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) {
@@ -4898,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 &&
@@ -4909,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);
@@ -4928,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) {
@@ -5013,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) {
@@ -5789,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. */
@@ -5808,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:
@@ -5820,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;
@@ -5899,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));
@@ -5940,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));
@@ -5983,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");
}
@@ -6043,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",
@@ -6069,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");
@@ -6095,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",
@@ -6318,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");
}
@@ -6359,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) {
@@ -6609,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)
@@ -9215,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)
@@ -9230,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) {
@@ -9264,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) {
@@ -9379,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
@@ -9407,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",
@@ -9434,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);
}
}
@@ -9576,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;
@@ -9584,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();
@@ -9609,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) {
@@ -9636,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:
@@ -9689,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",
@@ -9699,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));
@@ -9727,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;
@@ -9741,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)) {
@@ -9761,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");
@@ -9774,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
@@ -9828,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",
@@ -9838,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));
@@ -9865,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;
@@ -9878,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);
@@ -9954,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(
@@ -9963,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));
@@ -10276,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) {
@@ -10306,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);
}
}
@@ -10388,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");
}
}
@@ -10425,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");
}
@@ -10436,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");
}
@@ -10449,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");
}
}
@@ -10461,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");
}
@@ -10472,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");
}
@@ -10494,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");
}
@@ -10506,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");
}
@@ -10519,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");
}
@@ -10531,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");
}
@@ -10550,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");
}
@@ -10567,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");
}
@@ -10632,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;
@@ -10705,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)
@@ -10720,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");
@@ -10755,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)
@@ -10799,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 */
@@ -10822,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);
}
}
@@ -10875,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;
}
@@ -10886,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");
@@ -10975,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
: "");
}
@@ -11010,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)
@@ -11108,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 dc8a8dccd2..9fa6a59a72 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -73,12 +73,9 @@ static int ospf_router_id_update_zebra(ZAPI_CALLBACK_ARGS)
struct prefix router_id;
zebra_router_id_update_read(zclient->ibuf, &router_id);
- if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE)) {
- char buf[PREFIX2STR_BUFFER];
- prefix2str(&router_id, buf, sizeof(buf));
- zlog_debug("Zebra rcvd: router id update %s vrf %s id %u", buf,
- ospf_vrf_id_to_name(vrf_id), vrf_id);
- }
+ if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE))
+ zlog_debug("Zebra rcvd: router id update %pFX vrf %s id %u",
+ &router_id, ospf_vrf_id_to_name(vrf_id), vrf_id);
ospf = ospf_lookup_by_vrf_id(vrf_id);
@@ -86,15 +83,11 @@ static int ospf_router_id_update_zebra(ZAPI_CALLBACK_ARGS)
ospf->router_id_zebra = router_id.u.prefix4;
ospf_router_id_update(ospf);
} else {
- if (IS_DEBUG_OSPF_EVENT) {
- char buf[PREFIX2STR_BUFFER];
-
- prefix2str(&router_id, buf, sizeof(buf));
+ if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "%s: ospf instance not found for vrf %s id %u router_id %s",
+ "%s: ospf instance not found for vrf %s id %u router_id %pFX",
__func__, ospf_vrf_id_to_name(vrf_id), vrf_id,
- buf);
- }
+ &router_id);
}
return 0;
}
@@ -110,13 +103,10 @@ static int ospf_interface_address_add(ZAPI_CALLBACK_ARGS)
if (c == NULL)
return 0;
- if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE)) {
- char buf[PREFIX2STR_BUFFER];
- prefix2str(c->address, buf, sizeof(buf));
- zlog_debug("Zebra: interface %s address add %s vrf %s id %u",
- c->ifp->name, buf, ospf_vrf_id_to_name(vrf_id),
- vrf_id);
- }
+ if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE))
+ zlog_debug("Zebra: interface %s address add %pFX vrf %s id %u",
+ c->ifp->name, c->address,
+ ospf_vrf_id_to_name(vrf_id), vrf_id);
ospf = ospf_lookup_by_vrf_id(vrf_id);
if (!ospf)
@@ -142,12 +132,9 @@ static int ospf_interface_address_delete(ZAPI_CALLBACK_ARGS)
if (c == NULL)
return 0;
- if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE)) {
- char buf[PREFIX2STR_BUFFER];
- prefix2str(c->address, buf, sizeof(buf));
- zlog_debug("Zebra: interface %s address delete %s",
- c->ifp->name, buf);
- }
+ if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE))
+ zlog_debug("Zebra: interface %s address delete %pFX",
+ c->ifp->name, c->address);
ifp = c->ifp;
p = *c->address;
@@ -279,17 +266,14 @@ void ospf_zebra_add(struct ospf *ospf, struct prefix_ipv4 *p,
count++;
if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) {
- char buf[2][PREFIX2STR_BUFFER];
struct interface *ifp;
ifp = if_lookup_by_index(path->ifindex, ospf->vrf_id);
zlog_debug(
- "Zebra: Route add %s nexthop %s, ifindex=%d %s",
- prefix2str(p, buf[0], sizeof(buf[0])),
- inet_ntop(AF_INET, &path->nexthop,
- buf[1], sizeof(buf[1])),
- path->ifindex, ifp ? ifp->name : " ");
+ "Zebra: Route add %pFX nexthop %pI4, ifindex=%d %s",
+ p, &path->nexthop, path->ifindex,
+ ifp ? ifp->name : " ");
}
}
api.nexthop_num = count;
@@ -309,11 +293,8 @@ void ospf_zebra_delete(struct ospf *ospf, struct prefix_ipv4 *p,
api.safi = SAFI_UNICAST;
memcpy(&api.prefix, p, sizeof(*p));
- if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) {
- char buf[PREFIX2STR_BUFFER];
- zlog_debug("Zebra: Route delete %s",
- prefix2str(p, buf, sizeof(buf)));
- }
+ if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE))
+ zlog_debug("Zebra: Route delete %pFX", p);
zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api);
}
@@ -332,11 +313,8 @@ void ospf_zebra_add_discard(struct ospf *ospf, struct prefix_ipv4 *p)
zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api);
- if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) {
- char buf[PREFIX2STR_BUFFER];
- zlog_debug("Zebra: Route add discard %s",
- prefix2str(p, buf, sizeof(buf)));
- }
+ if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE))
+ zlog_debug("Zebra: Route add discard %pFX", p);
}
void ospf_zebra_delete_discard(struct ospf *ospf, struct prefix_ipv4 *p)
@@ -353,11 +331,8 @@ void ospf_zebra_delete_discard(struct ospf *ospf, struct prefix_ipv4 *p)
zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api);
- if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) {
- char buf[PREFIX2STR_BUFFER];
- zlog_debug("Zebra: Route delete discard %s",
- prefix2str(p, buf, sizeof(buf)));
- }
+ if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE))
+ zlog_debug("Zebra: Route delete discard %pFX", p);
}
struct ospf_external *ospf_external_lookup(struct ospf *ospf, uint8_t type,
@@ -433,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;
}
@@ -875,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;
}
@@ -968,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;
}
@@ -1015,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
@@ -1061,13 +1036,10 @@ int ospf_redistribute_check(struct ospf *ospf, struct external_info *ei,
if (DISTRIBUTE_LIST(ospf, type))
if (access_list_apply(DISTRIBUTE_LIST(ospf, type), p)
== FILTER_DENY) {
- if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) {
- char buf[PREFIX2STR_BUFFER];
+ if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE))
zlog_debug(
- "Redistribute[%s]: %s filtered by distribute-list.",
- ospf_redist_string(type),
- prefix2str(p, buf, sizeof(buf)));
- }
+ "Redistribute[%s]: %pFX filtered by distribute-list.",
+ ospf_redist_string(type), p);
return 0;
}
@@ -1088,13 +1060,10 @@ int ospf_redistribute_check(struct ospf *ospf, struct external_info *ei,
if (ret == RMAP_DENYMATCH) {
ei->route_map_set = save_values;
- if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) {
- char buf[PREFIX2STR_BUFFER];
+ if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE))
zlog_debug(
- "Redistribute[%s]: %s filtered by route-map.",
- ospf_redist_string(type),
- prefix2str(p, buf, sizeof(buf)));
- }
+ "Redistribute[%s]: %pFX filtered by route-map.",
+ ospf_redist_string(type), p);
return 0;
}
@@ -1171,14 +1140,10 @@ static int ospf_zebra_read_route(ZAPI_CALLBACK_ARGS)
if (is_prefix_default(&p))
rt_type = DEFAULT_ROUTE;
- if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) {
- char buf_prefix[PREFIX_STRLEN];
- prefix2str(&api.prefix, buf_prefix, sizeof(buf_prefix));
-
- zlog_debug("%s: cmd %s from client %s: vrf_id %d, p %s",
+ if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE))
+ zlog_debug("%s: cmd %s from client %s: vrf_id %d, p %pFX",
__func__, zserv_command_string(cmd),
- zebra_route_string(api.type), vrf_id, buf_prefix);
- }
+ zebra_route_string(api.type), vrf_id, &api.prefix);
if (cmd == ZEBRA_REDISTRIBUTE_ROUTE_ADD) {
/* XXX|HACK|TODO|FIXME:
@@ -1227,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) {
diff --git a/pbrd/pbr_nht.c b/pbrd/pbr_nht.c
index 3fb3759049..ce7780ed49 100644
--- a/pbrd/pbr_nht.c
+++ b/pbrd/pbr_nht.c
@@ -827,16 +827,14 @@ static void pbr_nht_individual_nexthop_update_lookup(struct hash_bucket *b,
{
struct pbr_nexthop_cache *pnhc = b->data;
struct pbr_nht_individual *pnhi = data;
- char buf[PREFIX_STRLEN];
bool old_valid;
old_valid = pnhc->valid;
pbr_nht_individual_nexthop_update(pnhc, pnhi);
- DEBUGD(&pbr_dbg_nht, "\tFound %s: old: %d new: %d",
- prefix2str(&pnhi->nhr->prefix, buf, sizeof(buf)), old_valid,
- pnhc->valid);
+ DEBUGD(&pbr_dbg_nht, "\tFound %pFX: old: %d new: %d",
+ &pnhi->nhr->prefix, old_valid, pnhc->valid);
if (pnhc->valid)
pnhi->valid = true;
diff --git a/pbrd/pbr_vty.c b/pbrd/pbr_vty.c
index c423668ebd..eb51516c24 100644
--- a/pbrd/pbr_vty.c
+++ b/pbrd/pbr_vty.c
@@ -648,7 +648,6 @@ pbrms_nexthop_group_write_individual_nexthop(
static void vty_show_pbrms(struct vty *vty,
const struct pbr_map_sequence *pbrms, bool detail)
{
- char buf[PREFIX_STRLEN];
char rbuf[64];
if (pbrms->reason)
@@ -666,11 +665,9 @@ static void vty_show_pbrms(struct vty *vty,
pbrms->reason ? rbuf : "Valid");
if (pbrms->src)
- vty_out(vty, " SRC Match: %s\n",
- prefix2str(pbrms->src, buf, sizeof(buf)));
+ vty_out(vty, " SRC Match: %pFX\n", pbrms->src);
if (pbrms->dst)
- vty_out(vty, " DST Match: %s\n",
- prefix2str(pbrms->dst, buf, sizeof(buf)));
+ vty_out(vty, " DST Match: %pFX\n", pbrms->dst);
if (pbrms->dsfield & PBR_DSFIELD_DSCP)
vty_out(vty, " DSCP Match: %u\n",
(pbrms->dsfield & PBR_DSFIELD_DSCP) >> 2);
@@ -1058,17 +1055,13 @@ static int pbr_vty_map_config_write_sequence(struct vty *vty,
struct pbr_map *pbrm,
struct pbr_map_sequence *pbrms)
{
- char buff[PREFIX_STRLEN];
-
vty_out(vty, "pbr-map %s seq %u\n", pbrm->name, pbrms->seqno);
if (pbrms->src)
- vty_out(vty, " match src-ip %s\n",
- prefix2str(pbrms->src, buff, sizeof(buff)));
+ vty_out(vty, " match src-ip %pFX\n", pbrms->src);
if (pbrms->dst)
- vty_out(vty, " match dst-ip %s\n",
- prefix2str(pbrms->dst, buff, sizeof(buff)));
+ vty_out(vty, " match dst-ip %pFX\n", pbrms->dst);
if (pbrms->dsfield & PBR_DSFIELD_DSCP)
vty_out(vty, " match dscp %u\n",
diff --git a/pbrd/pbr_zebra.c b/pbrd/pbr_zebra.c
index 866f27136e..b8ee974635 100644
--- a/pbrd/pbr_zebra.c
+++ b/pbrd/pbr_zebra.c
@@ -102,15 +102,14 @@ static int interface_address_add(ZAPI_CALLBACK_ARGS)
static int interface_address_delete(ZAPI_CALLBACK_ARGS)
{
struct connected *c;
- char buf[PREFIX_STRLEN];
c = zebra_interface_address_read(cmd, zclient->ibuf, vrf_id);
if (!c)
return 0;
- DEBUGD(&pbr_dbg_zebra, "%s: %s deleted %s", __func__, c->ifp->name,
- prefix2str(c->address, buf, sizeof(buf)));
+ DEBUGD(&pbr_dbg_zebra, "%s: %s deleted %pFX", __func__, c->ifp->name,
+ c->address);
connected_free(&c);
return 0;
@@ -162,40 +161,37 @@ static int route_notify_owner(ZAPI_CALLBACK_ARGS)
struct prefix p;
enum zapi_route_notify_owner note;
uint32_t table_id;
- char buf[PREFIX_STRLEN];
if (!zapi_route_notify_decode(zclient->ibuf, &p, &table_id, &note))
return -1;
- prefix2str(&p, buf, sizeof(buf));
-
switch (note) {
case ZAPI_ROUTE_FAIL_INSTALL:
DEBUGD(&pbr_dbg_zebra,
- "%s: [%s] Route install failure for table: %u", __func__,
- buf, table_id);
+ "%s: [%pFX] Route install failure for table: %u",
+ __func__, &p, table_id);
break;
case ZAPI_ROUTE_BETTER_ADMIN_WON:
DEBUGD(&pbr_dbg_zebra,
- "%s: [%s] Route better admin distance won for table: %u",
- __func__, buf, table_id);
+ "%s: [%pFX] Route better admin distance won for table: %u",
+ __func__, &p, table_id);
break;
case ZAPI_ROUTE_INSTALLED:
DEBUGD(&pbr_dbg_zebra,
- "%s: [%s] Route installed succeeded for table: %u",
- __func__, buf, table_id);
+ "%s: [%pFX] Route installed succeeded for table: %u",
+ __func__, &p, table_id);
pbr_nht_route_installed_for_table(table_id);
break;
case ZAPI_ROUTE_REMOVED:
DEBUGD(&pbr_dbg_zebra,
- "%s: [%s] Route Removed succeeded for table: %u",
- __func__, buf, table_id);
+ "%s: [%pFX] Route Removed succeeded for table: %u",
+ __func__, &p, table_id);
pbr_nht_route_removed_for_table(table_id);
break;
case ZAPI_ROUTE_REMOVE_FAIL:
DEBUGD(&pbr_dbg_zebra,
- "%s: [%s] Route remove fail for table: %u", __func__,
- buf, table_id);
+ "%s: [%pFX] Route remove fail for table: %u", __func__,
+ &p, table_id);
break;
}
@@ -259,14 +255,12 @@ static void route_add_helper(struct zapi_route *api, struct nexthop_group nhg,
uint8_t install_afi)
{
struct zapi_nexthop *api_nh;
- char buf[PREFIX_STRLEN];
struct nexthop *nhop;
int i;
api->prefix.family = install_afi;
- DEBUGD(&pbr_dbg_zebra, "\tEncoding %s",
- prefix2str(&api->prefix, buf, sizeof(buf)));
+ DEBUGD(&pbr_dbg_zebra, "\tEncoding %pFX", &api->prefix);
i = 0;
for (ALL_NEXTHOPS(nhg, nhop)) {
@@ -397,7 +391,6 @@ void route_delete(struct pbr_nexthop_group_cache *pnhgc, afi_t afi)
static int pbr_zebra_nexthop_update(ZAPI_CALLBACK_ARGS)
{
struct zapi_route nhr;
- char buf[PREFIX2STR_BUFFER];
uint32_t i;
if (!zapi_nexthop_update_decode(zclient->ibuf, &nhr)) {
@@ -407,8 +400,8 @@ static int pbr_zebra_nexthop_update(ZAPI_CALLBACK_ARGS)
if (DEBUG_MODE_CHECK(&pbr_dbg_zebra, DEBUG_MODE_ALL)) {
- DEBUGD(&pbr_dbg_zebra, "%s: Received Nexthop update: %s",
- __func__, prefix2str(&nhr.prefix, buf, sizeof(buf)));
+ DEBUGD(&pbr_dbg_zebra, "%s: Received Nexthop update: %pFX",
+ __func__, &nhr.prefix);
DEBUGD(&pbr_dbg_zebra, "%s: (\tNexthops(%u)", __func__,
nhr.nexthop_num);
diff --git a/pimd/mtracebis.c b/pimd/mtracebis.c
index 1b812de92c..3b69964960 100644
--- a/pimd/mtracebis.c
+++ b/pimd/mtracebis.c
@@ -26,7 +26,6 @@
#include "checksum.h"
#include "prefix.h"
#include "mtracebis_routeget.h"
-
#include <sys/select.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@@ -64,13 +63,14 @@ static void version(void)
static void print_host(struct in_addr addr)
{
struct hostent *h;
+ char buf[PREFIX_STRLEN];
h = gethostbyaddr(&addr, sizeof(addr), AF_INET);
if (h == NULL)
printf("?");
else
printf("%s", h->h_name);
- printf(" (%s) ", inet_ntoa(addr));
+ printf(" (%s) ", inet_ntop(AF_INET, &addr, buf, sizeof(buf)));
}
static void print_line_no(int i)
diff --git a/pimd/pim_bfd.c b/pimd/pim_bfd.c
index 146b53fa8f..1d653cdc3f 100644
--- a/pimd/pim_bfd.c
+++ b/pimd/pim_bfd.c
@@ -244,12 +244,9 @@ static int pim_bfd_interface_dest_update(ZAPI_CALLBACK_ARGS)
return 0;
}
- if (PIM_DEBUG_PIM_TRACE) {
- char buf[PREFIX2STR_BUFFER];
- prefix2str(&p, buf, sizeof(buf));
- zlog_debug("%s: interface %s bfd destination %s %s", __func__,
- ifp->name, buf, bfd_get_status_str(status));
- }
+ if (PIM_DEBUG_PIM_TRACE)
+ zlog_debug("%s: interface %s bfd destination %pFX %s", __func__,
+ ifp->name, &p, bfd_get_status_str(status));
for (ALL_LIST_ELEMENTS(pim_ifp->pim_neighbor_list, neigh_node,
neigh_nextnode, neigh)) {
diff --git a/pimd/pim_bsm.c b/pimd/pim_bsm.c
index f542b2eafa..1acfece895 100644
--- a/pimd/pim_bsm.c
+++ b/pimd/pim_bsm.c
@@ -170,7 +170,6 @@ static int pim_on_bs_timer(struct thread *t)
struct bsgrp_node *bsgrp_node;
struct bsm_rpinfo *bsrp;
struct prefix nht_p;
- char buf[PREFIX2STR_BUFFER];
bool is_bsr_tracking = true;
scope = THREAD_ARG(t);
@@ -184,11 +183,9 @@ static int pim_on_bs_timer(struct thread *t)
nht_p.family = AF_INET;
nht_p.prefixlen = IPV4_MAX_BITLEN;
nht_p.u.prefix4 = scope->current_bsr;
- if (PIM_DEBUG_BSM) {
- prefix2str(&nht_p, buf, sizeof(buf));
- zlog_debug("%s: Deregister BSR addr %s with Zebra NHT",
- __func__, buf);
- }
+ if (PIM_DEBUG_BSM)
+ zlog_debug("%s: Deregister BSR addr %pFX with Zebra NHT",
+ __func__, &nht_p);
pim_delete_tracked_nexthop(scope->pim, &nht_p, NULL, NULL,
is_bsr_tracking);
@@ -377,15 +374,12 @@ static void pim_g2rp_timer_start(struct bsm_rpinfo *bsrp, int hold_time)
return;
}
THREAD_OFF(bsrp->g2rp_timer);
- if (PIM_DEBUG_BSM) {
- char buf[48];
-
+ if (PIM_DEBUG_BSM)
zlog_debug(
- "%s : starting g2rp timer for grp: %s - rp: %s with timeout %d secs(Actual Hold time : %d secs)",
- __func__, prefix2str(&bsrp->bsgrp_node->group, buf, 48),
- inet_ntoa(bsrp->rp_address), hold_time,
+ "%s : starting g2rp timer for grp: %pFX - rp: %pI4 with timeout %d secs(Actual Hold time : %d secs)",
+ __func__, &bsrp->bsgrp_node->group,
+ &bsrp->rp_address, hold_time,
bsrp->rp_holdtime);
- }
thread_add_timer(router->master, pim_on_g2rp_timer, bsrp, hold_time,
&bsrp->g2rp_timer);
@@ -402,14 +396,10 @@ static void pim_g2rp_timer_stop(struct bsm_rpinfo *bsrp)
if (!bsrp)
return;
- if (PIM_DEBUG_BSM) {
- char buf[48];
-
- zlog_debug("%s : stopping g2rp timer for grp: %s - rp: %s",
- __func__,
- prefix2str(&bsrp->bsgrp_node->group, buf, 48),
- inet_ntoa(bsrp->rp_address));
- }
+ if (PIM_DEBUG_BSM)
+ zlog_debug("%s : stopping g2rp timer for grp: %pFX - rp: %pI4",
+ __func__, &bsrp->bsgrp_node->group,
+ &bsrp->rp_address);
THREAD_OFF(bsrp->g2rp_timer);
}
@@ -616,7 +606,6 @@ static void pim_bsm_update(struct pim_instance *pim, struct in_addr bsr,
if (bsr.s_addr != pim->global_scope.current_bsr.s_addr) {
struct prefix nht_p;
- char buf[PREFIX2STR_BUFFER];
bool is_bsr_tracking = true;
/* De-register old BSR and register new BSR with Zebra NHT */
@@ -625,23 +614,19 @@ static void pim_bsm_update(struct pim_instance *pim, struct in_addr bsr,
if (pim->global_scope.current_bsr.s_addr != INADDR_ANY) {
nht_p.u.prefix4 = pim->global_scope.current_bsr;
- if (PIM_DEBUG_BSM) {
- prefix2str(&nht_p, buf, sizeof(buf));
+ if (PIM_DEBUG_BSM)
zlog_debug(
- "%s: Deregister BSR addr %s with Zebra NHT",
- __func__, buf);
- }
+ "%s: Deregister BSR addr %pFX with Zebra NHT",
+ __func__, &nht_p);
pim_delete_tracked_nexthop(pim, &nht_p, NULL, NULL,
is_bsr_tracking);
}
nht_p.u.prefix4 = bsr;
- if (PIM_DEBUG_BSM) {
- prefix2str(&nht_p, buf, sizeof(buf));
+ if (PIM_DEBUG_BSM)
zlog_debug(
- "%s: NHT Register BSR addr %s with Zebra NHT",
- __func__, buf);
- }
+ "%s: NHT Register BSR addr %pFX with Zebra NHT",
+ __func__, &nht_p);
memset(&pnc, 0, sizeof(struct pim_nexthop_cache));
pim_find_or_track_nexthop(pim, &nht_p, NULL, NULL,
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c
index 38123cc8f6..2a7ff4e7f8 100644
--- a/pimd/pim_cmd.c
+++ b/pimd/pim_cmd.c
@@ -199,6 +199,7 @@ static void pim_show_assert_helper(struct vty *vty,
struct in_addr ifaddr;
char uptime[10];
char timer[10];
+ char buf[PREFIX_STRLEN];
ifaddr = pim_ifp->primary_address;
@@ -211,9 +212,10 @@ static void pim_show_assert_helper(struct vty *vty,
pim_time_timer_to_mmss(timer, sizeof(timer), ch->t_ifassert_timer);
vty_out(vty, "%-16s %-15s %-15s %-15s %-6s %-15s %-8s %-5s\n",
- ch->interface->name, inet_ntoa(ifaddr), ch_src_str, ch_grp_str,
- pim_ifchannel_ifassert_name(ch->ifassert_state), winner_str,
- uptime, timer);
+ ch->interface->name,
+ inet_ntop(AF_INET, &ifaddr, buf, sizeof(buf)), ch_src_str,
+ ch_grp_str, pim_ifchannel_ifassert_name(ch->ifassert_state),
+ winner_str, uptime, timer);
}
static void pim_show_assert(struct pim_instance *pim, struct vty *vty)
@@ -246,13 +248,16 @@ static void pim_show_assert_internal_helper(struct vty *vty,
char ch_src_str[INET_ADDRSTRLEN];
char ch_grp_str[INET_ADDRSTRLEN];
struct in_addr ifaddr;
+ char buf[PREFIX_STRLEN];
ifaddr = pim_ifp->primary_address;
pim_inet4_dump("<ch_src?>", ch->sg.src, ch_src_str, sizeof(ch_src_str));
pim_inet4_dump("<ch_grp?>", ch->sg.grp, ch_grp_str, sizeof(ch_grp_str));
vty_out(vty, "%-16s %-15s %-15s %-15s %-3s %-3s %-3s %-4s\n",
- ch->interface->name, inet_ntoa(ifaddr), ch_src_str, ch_grp_str,
+ ch->interface->name,
+ inet_ntop(AF_INET, &ifaddr, buf, sizeof(buf)),
+ ch_src_str, ch_grp_str,
PIM_IF_FLAG_TEST_COULD_ASSERT(ch->flags) ? "yes" : "no",
pim_macro_ch_could_assert_eval(ch) ? "yes" : "no",
PIM_IF_FLAG_TEST_ASSERT_TRACKING_DESIRED(ch->flags) ? "yes"
@@ -294,6 +299,7 @@ static void pim_show_assert_metric_helper(struct vty *vty,
char addr_str[INET_ADDRSTRLEN];
struct pim_assert_metric am;
struct in_addr ifaddr;
+ char buf[PREFIX_STRLEN];
ifaddr = pim_ifp->primary_address;
@@ -305,9 +311,10 @@ static void pim_show_assert_metric_helper(struct vty *vty,
pim_inet4_dump("<addr?>", am.ip_address, addr_str, sizeof(addr_str));
vty_out(vty, "%-16s %-15s %-15s %-15s %-3s %4u %6u %-15s\n",
- ch->interface->name, inet_ntoa(ifaddr), ch_src_str, ch_grp_str,
- am.rpt_bit_flag ? "yes" : "no", am.metric_preference,
- am.route_metric, addr_str);
+ ch->interface->name,
+ inet_ntop(AF_INET, &ifaddr, buf, sizeof(buf)),
+ ch_src_str, ch_grp_str, am.rpt_bit_flag ? "yes" : "no",
+ am.metric_preference, am.route_metric, addr_str);
}
static void pim_show_assert_metric(struct pim_instance *pim, struct vty *vty)
@@ -341,6 +348,7 @@ static void pim_show_assert_winner_metric_helper(struct vty *vty,
struct in_addr ifaddr;
char pref_str[16];
char metr_str[16];
+ char buf[PREFIX_STRLEN];
ifaddr = pim_ifp->primary_address;
@@ -362,8 +370,10 @@ static void pim_show_assert_winner_metric_helper(struct vty *vty,
snprintf(metr_str, sizeof(metr_str), "%6u", am->route_metric);
vty_out(vty, "%-16s %-15s %-15s %-15s %-3s %-4s %-6s %-15s\n",
- ch->interface->name, inet_ntoa(ifaddr), ch_src_str, ch_grp_str,
- am->rpt_bit_flag ? "yes" : "no", pref_str, metr_str, addr_str);
+ ch->interface->name,
+ inet_ntop(AF_INET, &ifaddr, buf, sizeof(buf)), ch_src_str,
+ ch_grp_str, am->rpt_bit_flag ? "yes" : "no", pref_str, metr_str,
+ addr_str);
}
static void pim_show_assert_winner_metric(struct pim_instance *pim,
@@ -391,12 +401,14 @@ static void json_object_pim_ifp_add(struct json_object *json,
struct interface *ifp)
{
struct pim_interface *pim_ifp;
+ char buf[PREFIX_STRLEN];
pim_ifp = ifp->info;
json_object_string_add(json, "name", ifp->name);
json_object_string_add(json, "state", if_is_up(ifp) ? "up" : "down");
json_object_string_add(json, "address",
- inet_ntoa(pim_ifp->primary_address));
+ inet_ntop(AF_INET, &pim_ifp->primary_address,
+ buf, sizeof(buf)));
json_object_int_add(json, "index", ifp->ifindex);
if (if_is_multicast(ifp))
@@ -569,6 +581,7 @@ static void igmp_show_interfaces(struct pim_instance *pim, struct vty *vty,
{
struct interface *ifp;
time_t now;
+ char buf[PREFIX_STRLEN];
json_object *json = NULL;
json_object *json_row = NULL;
@@ -632,7 +645,8 @@ static void igmp_show_interfaces(struct pim_instance *pim, struct vty *vty,
? (igmp->mtrace_only ? "mtrc"
: "up")
: "down",
- inet_ntoa(igmp->ifaddr),
+ inet_ntop(AF_INET, &igmp->ifaddr,
+ buf, sizeof(buf)),
pim_ifp->igmp_version,
igmp->t_igmp_query_timer ? "local"
: "other",
@@ -797,8 +811,8 @@ static void igmp_show_interfaces_single(struct pim_instance *pim,
? (igmp->mtrace_only ? "mtrace"
: "up")
: "down");
- vty_out(vty, "Address : %s\n",
- inet_ntoa(pim_ifp->primary_address));
+ vty_out(vty, "Address : %pI4\n",
+ &pim_ifp->primary_address);
vty_out(vty, "Uptime : %s\n", uptime);
vty_out(vty, "Version : %d\n",
pim_ifp->igmp_version);
@@ -940,6 +954,7 @@ static void pim_show_interfaces_single(struct pim_instance *pim,
int mloop = 0;
int found_ifname = 0;
int print_header;
+ char buf[PREFIX_STRLEN];
json_object *json = NULL;
json_object *json_row = NULL;
json_object *json_pim_neighbor = NULL;
@@ -992,7 +1007,9 @@ static void pim_show_interfaces_single(struct pim_instance *pim,
if (pim_ifp->update_source.s_addr != INADDR_ANY) {
json_object_string_add(
json_row, "useSource",
- inet_ntoa(pim_ifp->update_source));
+ inet_ntop(AF_INET,
+ &pim_ifp->update_source,
+ buf, sizeof(buf)));
}
if (pim_ifp->sec_addr_list) {
json_object *sec_list = NULL;
@@ -1160,23 +1177,20 @@ static void pim_show_interfaces_single(struct pim_instance *pim,
vty_out(vty, "State : %s\n",
if_is_up(ifp) ? "up" : "down");
if (pim_ifp->update_source.s_addr != INADDR_ANY) {
- vty_out(vty, "Use Source : %s\n",
- inet_ntoa(pim_ifp->update_source));
+ vty_out(vty, "Use Source : %pI4\n",
+ &pim_ifp->update_source);
}
if (pim_ifp->sec_addr_list) {
- char pbuf[PREFIX2STR_BUFFER];
- vty_out(vty, "Address : %s (primary)\n",
- inet_ntoa(ifaddr));
+ vty_out(vty, "Address : %pI4 (primary)\n",
+ &ifaddr);
for (ALL_LIST_ELEMENTS_RO(
pim_ifp->sec_addr_list, sec_node,
- sec_addr)) {
- vty_out(vty, " %s\n",
- prefix2str(&sec_addr->addr,
- pbuf, sizeof(pbuf)));
- }
+ sec_addr))
+ vty_out(vty, " %pFX\n",
+ &sec_addr->addr);
} else {
- vty_out(vty, "Address : %s\n",
- inet_ntoa(ifaddr));
+ vty_out(vty, "Address : %pI4\n",
+ &ifaddr);
}
vty_out(vty, "\n");
@@ -1400,6 +1414,7 @@ static void pim_show_interfaces(struct pim_instance *pim, struct vty *vty,
int fhr = 0;
int pim_nbrs = 0;
int pim_ifchannels = 0;
+ char buf[PREFIX_STRLEN];
json_object *json = NULL;
json_object *json_row = NULL;
json_object *json_tmp;
@@ -1430,7 +1445,9 @@ static void pim_show_interfaces(struct pim_instance *pim, struct vty *vty,
json_object_int_add(json_row, "pimIfChannels", pim_ifchannels);
json_object_int_add(json_row, "firstHopRouterCount", fhr);
json_object_string_add(json_row, "pimDesignatedRouter",
- inet_ntoa(pim_ifp->pim_dr_addr));
+ inet_ntop(AF_INET,
+ &pim_ifp->pim_dr_addr, buf,
+ sizeof(buf)));
if (pim_ifp->pim_dr_addr.s_addr
== pim_ifp->primary_address.s_addr)
@@ -1685,6 +1702,7 @@ static void pim_show_join_helper(struct vty *vty, struct pim_interface *pim_ifp,
char uptime[10];
char expire[10];
char prune[10];
+ char buf[PREFIX_STRLEN];
ifaddr = pim_ifp->primary_address;
@@ -1733,8 +1751,9 @@ static void pim_show_join_helper(struct vty *vty, struct pim_interface *pim_ifp,
json_object_object_add(json_grp, ch_src_str, json_row);
} else {
vty_out(vty, "%-16s %-15s %-15s %-15s %-10s %8s %-6s %5s\n",
- ch->interface->name, inet_ntoa(ifaddr), ch_src_str,
- ch_grp_str,
+ ch->interface->name,
+ inet_ntop(AF_INET, &ifaddr, buf, sizeof(buf)),
+ ch_src_str, ch_grp_str,
pim_ifchannel_ifjoin_name(ch->ifjoin_state, ch->flags),
uptime, expire, prune);
}
@@ -2307,6 +2326,7 @@ static void pim_show_neighbors_secondary(struct pim_instance *pim,
struct in_addr ifaddr;
struct listnode *neighnode;
struct pim_neighbor *neigh;
+ char buf[PREFIX_STRLEN];
pim_ifp = ifp->info;
@@ -2331,16 +2351,12 @@ static void pim_show_neighbors_secondary(struct pim_instance *pim,
neigh_src_str, sizeof(neigh_src_str));
for (ALL_LIST_ELEMENTS_RO(neigh->prefix_list,
- prefix_node, p)) {
- char neigh_sec_str[PREFIX2STR_BUFFER];
-
- prefix2str(p, neigh_sec_str,
- sizeof(neigh_sec_str));
-
- vty_out(vty, "%-16s %-15s %-15s %-15s\n",
- ifp->name, inet_ntoa(ifaddr),
- neigh_src_str, neigh_sec_str);
- }
+ prefix_node, p))
+ vty_out(vty, "%-16s %-15s %-15s %-15pFX\n",
+ ifp->name,
+ inet_ntop(AF_INET, &ifaddr,
+ buf, sizeof(buf)),
+ neigh_src_str, p);
}
}
}
@@ -2984,14 +3000,17 @@ static int pim_print_pnc_cache_walkcb(struct hash_bucket *bucket, void *arg)
struct nexthop *nh_node = NULL;
ifindex_t first_ifindex;
struct interface *ifp = NULL;
+ char buf[PREFIX_STRLEN];
for (nh_node = pnc->nexthop; nh_node; nh_node = nh_node->next) {
first_ifindex = nh_node->ifindex;
ifp = if_lookup_by_index(first_ifindex, pim->vrf_id);
- vty_out(vty, "%-15s ", inet_ntoa(pnc->rpf.rpf_addr.u.prefix4));
+ vty_out(vty, "%-15s ", inet_ntop(AF_INET,
+ &pnc->rpf.rpf_addr.u.prefix4,
+ buf, sizeof(buf)));
vty_out(vty, "%-16s ", ifp ? ifp->name : "NULL");
- vty_out(vty, "%s ", inet_ntoa(nh_node->gate.ipv4));
+ vty_out(vty, "%pI4 ", &nh_node->gate.ipv4);
vty_out(vty, "\n");
}
return CMD_SUCCESS;
@@ -3215,7 +3234,7 @@ static void pim_show_group_rp_mappings_info(struct pim_instance *pim,
json_group);
}
} else {
- vty_out(vty, "Group Address %s\n", grp_str);
+ vty_out(vty, "Group Address %pFX\n", &bsgrp->group);
vty_out(vty, "--------------------------\n");
vty_out(vty, "%-15s %-15s %-15s %-15s\n", "Rp Address",
"priority", "Holdtime", "Hash");
@@ -5665,6 +5684,7 @@ static void show_multicast_interfaces(struct pim_instance *pim, struct vty *vty,
bool uj)
{
struct interface *ifp;
+ char buf[PREFIX_STRLEN];
json_object *json = NULL;
json_object *json_row = NULL;
@@ -5705,7 +5725,8 @@ static void show_multicast_interfaces(struct pim_instance *pim, struct vty *vty,
if_is_up(ifp) ? "up" : "down");
json_object_string_add(
json_row, "address",
- inet_ntoa(pim_ifp->primary_address));
+ inet_ntop(AF_INET, &pim_ifp->primary_address,
+ buf, sizeof(buf)));
json_object_int_add(json_row, "ifIndex", ifp->ifindex);
json_object_int_add(json_row, "vif",
pim_ifp->mroute_vif_index);
@@ -5721,8 +5742,9 @@ static void show_multicast_interfaces(struct pim_instance *pim, struct vty *vty,
} else {
vty_out(vty,
"%-16s %-15s %3d %3d %7lu %7lu %10lu %10lu\n",
- ifp->name, inet_ntoa(ifaddr), ifp->ifindex,
- pim_ifp->mroute_vif_index,
+ ifp->name,
+ inet_ntop(AF_INET, &ifaddr, buf, sizeof(buf)),
+ ifp->ifindex, pim_ifp->mroute_vif_index,
(unsigned long)vreq.icount,
(unsigned long)vreq.ocount,
(unsigned long)vreq.ibytes,
diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c
index 0caa360df9..cff237f965 100644
--- a/pimd/pim_iface.c
+++ b/pimd/pim_iface.c
@@ -518,15 +518,12 @@ void pim_if_addr_add(struct connected *ifc)
if (!if_is_operative(ifp))
return;
- if (PIM_DEBUG_ZEBRA) {
- char buf[BUFSIZ];
- prefix2str(ifc->address, buf, BUFSIZ);
- zlog_debug("%s: %s ifindex=%d connected IP address %s %s",
- __func__, ifp->name, ifp->ifindex, buf,
+ if (PIM_DEBUG_ZEBRA)
+ zlog_debug("%s: %s ifindex=%d connected IP address %pFX %s",
+ __func__, ifp->name, ifp->ifindex, ifc->address,
CHECK_FLAG(ifc->flags, ZEBRA_IFA_SECONDARY)
? "secondary"
: "primary");
- }
ifaddr = ifc->address->u.prefix4;
@@ -715,15 +712,12 @@ void pim_if_addr_del(struct connected *ifc, int force_prim_as_any)
ifp = ifc->ifp;
zassert(ifp);
- if (PIM_DEBUG_ZEBRA) {
- char buf[BUFSIZ];
- prefix2str(ifc->address, buf, BUFSIZ);
- zlog_debug("%s: %s ifindex=%d disconnected IP address %s %s",
- __func__, ifp->name, ifp->ifindex, buf,
+ if (PIM_DEBUG_ZEBRA)
+ zlog_debug("%s: %s ifindex=%d disconnected IP address %pFX %s",
+ __func__, ifp->name, ifp->ifindex, ifc->address,
CHECK_FLAG(ifc->flags, ZEBRA_IFA_SECONDARY)
? "secondary"
: "primary");
- }
detect_address_change(ifp, force_prim_as_any, __func__);
diff --git a/pimd/pim_igmp.c b/pimd/pim_igmp.c
index d4d47377bd..19d7817577 100644
--- a/pimd/pim_igmp.c
+++ b/pimd/pim_igmp.c
@@ -63,8 +63,8 @@ static int igmp_sock_open(struct in_addr ifaddr, struct interface *ifp,
++join;
} else {
zlog_warn(
- "%s %s: IGMP socket fd=%d interface %s: could not solve %s to group address: errno=%d: %s",
- __FILE__, __func__, fd, inet_ntoa(ifaddr),
+ "%s %s: IGMP socket fd=%d interface %pI4: could not solve %s to group address: errno=%d: %s",
+ __FILE__, __func__, fd, &ifaddr,
PIM_ALL_ROUTERS, errno, safe_strerror(errno));
}
}
@@ -79,8 +79,8 @@ static int igmp_sock_open(struct in_addr ifaddr, struct interface *ifp,
++join;
} else {
zlog_warn(
- "%s %s: IGMP socket fd=%d interface %s: could not solve %s to group address: errno=%d: %s",
- __FILE__, __func__, fd, inet_ntoa(ifaddr),
+ "%s %s: IGMP socket fd=%d interface %pI4: could not solve %s to group address: errno=%d: %s",
+ __FILE__, __func__, fd, &ifaddr,
PIM_ALL_SYSTEMS, errno, safe_strerror(errno));
}
@@ -90,16 +90,16 @@ static int igmp_sock_open(struct in_addr ifaddr, struct interface *ifp,
}
} else {
zlog_warn(
- "%s %s: IGMP socket fd=%d interface %s: could not solve %s to group address: errno=%d: %s",
- __FILE__, __func__, fd, inet_ntoa(ifaddr),
+ "%s %s: IGMP socket fd=%d interface %pI4: could not solve %s to group address: errno=%d: %s",
+ __FILE__, __func__, fd, &ifaddr,
PIM_ALL_IGMP_ROUTERS, errno, safe_strerror(errno));
}
if (!join) {
flog_err_sys(
EC_LIB_SOCKET,
- "IGMP socket fd=%d could not join any group on interface address %s",
- fd, inet_ntoa(ifaddr));
+ "IGMP socket fd=%d could not join any group on interface address %pI4",
+ fd, &ifaddr);
close(fd);
fd = -1;
}
@@ -117,8 +117,8 @@ static void igmp_sock_dump(array_t *igmp_sock_array)
struct igmp_sock *igmp = array_get(igmp_sock_array, i);
- zlog_debug("%s %s: [%d/%d] igmp_addr=%s fd=%d", __FILE__,
- __func__, i, size, inet_ntoa(igmp->ifaddr),
+ zlog_debug("%s %s: [%d/%d] igmp_addr=%pI4 fd=%d", __FILE__,
+ __func__, i, size, &igmp->ifaddr,
igmp->fd);
}
}
@@ -701,8 +701,8 @@ static void sock_close(struct igmp_sock *igmp)
if (PIM_DEBUG_IGMP_TRACE_DETAIL) {
if (igmp->t_igmp_read) {
zlog_debug(
- "Cancelling READ event on IGMP socket %s fd=%d on interface %s",
- inet_ntoa(igmp->ifaddr), igmp->fd,
+ "Cancelling READ event on IGMP socket %pI4 fd=%d on interface %s",
+ &igmp->ifaddr, igmp->fd,
igmp->interface->name);
}
}
@@ -711,14 +711,14 @@ static void sock_close(struct igmp_sock *igmp)
if (close(igmp->fd)) {
flog_err(
EC_LIB_SOCKET,
- "Failure closing IGMP socket %s fd=%d on interface %s: errno=%d: %s",
- inet_ntoa(igmp->ifaddr), igmp->fd,
+ "Failure closing IGMP socket %pI4 fd=%d on interface %s: errno=%d: %s",
+ &igmp->ifaddr, igmp->fd,
igmp->interface->name, errno, safe_strerror(errno));
}
if (PIM_DEBUG_IGMP_TRACE_DETAIL) {
- zlog_debug("Deleted IGMP socket %s fd=%d on interface %s",
- inet_ntoa(igmp->ifaddr), igmp->fd,
+ zlog_debug("Deleted IGMP socket %pI4 fd=%d on interface %s",
+ &igmp->ifaddr, igmp->fd,
igmp->interface->name);
}
}
@@ -900,8 +900,8 @@ static struct igmp_sock *igmp_sock_new(int fd, struct in_addr ifaddr,
if (PIM_DEBUG_IGMP_TRACE) {
zlog_debug(
- "Creating IGMP socket fd=%d for address %s on interface %s",
- fd, inet_ntoa(ifaddr), ifp->name);
+ "Creating IGMP socket fd=%d for address %pI4 on interface %s",
+ fd, &ifaddr, ifp->name);
}
igmp = XCALLOC(MTYPE_PIM_IGMP_SOCKET, sizeof(*igmp));
@@ -1000,8 +1000,8 @@ struct igmp_sock *pim_igmp_sock_add(struct list *igmp_sock_list,
fd = igmp_sock_open(ifaddr, ifp, pim_ifp->options);
if (fd < 0) {
- zlog_warn("Could not open IGMP socket for %s on %s",
- inet_ntoa(ifaddr), ifp->name);
+ zlog_warn("Could not open IGMP socket for %pI4 on %s",
+ &ifaddr, ifp->name);
return NULL;
}
@@ -1009,8 +1009,8 @@ struct igmp_sock *pim_igmp_sock_add(struct list *igmp_sock_list,
sin.sin_addr = ifaddr;
sin.sin_port = 0;
if (bind(fd, (struct sockaddr *) &sin, sizeof(sin)) != 0) {
- zlog_warn("Could not bind IGMP socket for %s on %s",
- inet_ntoa(ifaddr), ifp->name);
+ zlog_warn("Could not bind IGMP socket for %pI4 on %s",
+ &ifaddr, ifp->name);
close(fd);
return NULL;
@@ -1153,8 +1153,8 @@ struct igmp_group *igmp_add_group_by_addr(struct igmp_sock *igmp,
if (pim_is_group_224_0_0_0_24(group_addr)) {
if (PIM_DEBUG_IGMP_TRACE)
zlog_debug(
- "%s: Group specified %s is part of 224.0.0.0/24",
- __func__, inet_ntoa(group_addr));
+ "%s: Group specified %pI4 is part of 224.0.0.0/24",
+ __func__, &group_addr);
return NULL;
}
/*
diff --git a/pimd/pim_igmp_mtrace.c b/pimd/pim_igmp_mtrace.c
index 9e78b76008..e95a1d11e8 100644
--- a/pimd/pim_igmp_mtrace.c
+++ b/pimd/pim_igmp_mtrace.c
@@ -447,8 +447,8 @@ static int mtrace_un_forward_packet(struct pim_instance *pim, struct ip *ip_hdr,
}
if (PIM_DEBUG_MTRACE) {
- zlog_debug("Fwd mtrace packet len=%u to %s ttl=%u",
- ntohs(ip_hdr->ip_len), inet_ntoa(ip_hdr->ip_dst),
+ zlog_debug("Fwd mtrace packet len=%u to %pI4 ttl=%u",
+ ntohs(ip_hdr->ip_len), &ip_hdr->ip_dst,
ip_hdr->ip_ttl);
}
@@ -472,9 +472,9 @@ static int mtrace_mc_forward_packet(struct pim_instance *pim, struct ip *ip_hdr)
if (c_oil == NULL) {
if (PIM_DEBUG_MTRACE) {
zlog_debug(
- "Dropping mtrace multicast packet len=%u to %s ttl=%u",
+ "Dropping mtrace multicast packet len=%u to %pI4 ttl=%u",
ntohs(ip_hdr->ip_len),
- inet_ntoa(ip_hdr->ip_dst), ip_hdr->ip_ttl);
+ &ip_hdr->ip_dst, ip_hdr->ip_ttl);
}
return -1;
}
@@ -523,9 +523,9 @@ static int mtrace_send_mc_response(struct pim_instance *pim,
if (c_oil == NULL) {
if (PIM_DEBUG_MTRACE) {
zlog_debug(
- "Dropping mtrace multicast response packet len=%u to %s",
+ "Dropping mtrace multicast response packet len=%u to %pI4",
(unsigned int)mtrace_len,
- inet_ntoa(mtracep->rsp_addr));
+ &mtracep->rsp_addr);
}
return -1;
}
@@ -716,8 +716,8 @@ int igmp_mtrace_recv_qry_req(struct igmp_sock *igmp, struct ip *ip_hdr,
&& !IPV4_MC_LINKLOCAL(ntohl(ip_hdr->ip_dst.s_addr))) {
if (PIM_DEBUG_MTRACE)
zlog_warn(
- "Recv mtrace packet from %s on %s: not link-local multicast %s",
- from_str, ifp->name, inet_ntoa(ip_hdr->ip_dst));
+ "Recv mtrace packet from %s on %s: not link-local multicast %pI4",
+ from_str, ifp->name, &ip_hdr->ip_dst);
return -1;
}
diff --git a/pimd/pim_igmpv3.c b/pimd/pim_igmpv3.c
index 8eaca75821..22767a8629 100644
--- a/pimd/pim_igmpv3.c
+++ b/pimd/pim_igmpv3.c
@@ -1921,10 +1921,10 @@ int igmp_v3_recv_report(struct igmp_sock *igmp, struct in_addr from,
if (PIM_DEBUG_IGMP_PACKETS) {
zlog_debug(
- " Recv IGMP report v3 from %s on %s: record=%d type=%d auxdatalen=%d sources=%d group=%s",
+ " Recv IGMP report v3 from %s on %s: record=%d type=%d auxdatalen=%d sources=%d group=%pI4",
from_str, ifp->name, i, rec_type,
rec_auxdatalen, rec_num_sources,
- inet_ntoa(rec_group));
+ &rec_group);
}
/* Scan sources */
@@ -1949,9 +1949,9 @@ int igmp_v3_recv_report(struct igmp_sock *igmp, struct in_addr from,
"<source?>");
zlog_debug(
- " Recv IGMP report v3 from %s on %s: record=%d group=%s source=%s",
+ " Recv IGMP report v3 from %s on %s: record=%d group=%pI4 source=%s",
from_str, ifp->name, i,
- inet_ntoa(rec_group), src_str);
+ &rec_group, src_str);
}
} /* for (sources) */
@@ -1969,8 +1969,8 @@ int igmp_v3_recv_report(struct igmp_sock *igmp, struct in_addr from,
if (PIM_DEBUG_IGMP_PACKETS && filtered)
zlog_debug(
- "Filtering IGMPv3 group record %s from %s on %s per prefix-list %s",
- inet_ntoa(rec_group), from_str, ifp->name,
+ "Filtering IGMPv3 group record %pI4 from %s on %s per prefix-list %s",
+ &rec_group, from_str, ifp->name,
pim_ifp->boundary_oil_plist);
/*
diff --git a/pimd/pim_nht.c b/pimd/pim_nht.c
index f06d4ae605..f691e8b755 100644
--- a/pimd/pim_nht.c
+++ b/pimd/pim_nht.c
@@ -26,6 +26,8 @@
#include "hash.h"
#include "jhash.h"
+#include "lib/printfrr.h"
+
#include "pimd.h"
#include "pimd/pim_nht.h"
#include "log.h"
@@ -56,15 +58,12 @@ void pim_sendmsg_zebra_rnh(struct pim_instance *pim, struct zclient *zclient,
if (ret < 0)
zlog_warn("sendmsg_nexthop: zclient_send_message() failed");
- if (PIM_DEBUG_PIM_NHT) {
- char buf[PREFIX2STR_BUFFER];
- prefix2str(p, buf, sizeof(buf));
+ if (PIM_DEBUG_PIM_NHT)
zlog_debug(
- "%s: NHT %sregistered addr %s(%s) with Zebra ret:%d ",
+ "%s: NHT %sregistered addr %pFX(%s) with Zebra ret:%d ",
__func__,
- (command == ZEBRA_NEXTHOP_REGISTER) ? " " : "de", buf,
+ (command == ZEBRA_NEXTHOP_REGISTER) ? " " : "de", p,
pim->vrf->name, ret);
- }
return;
}
@@ -89,7 +88,6 @@ static struct pim_nexthop_cache *pim_nexthop_cache_add(struct pim_instance *pim,
{
struct pim_nexthop_cache *pnc;
char hash_name[64];
- char buf1[64];
pnc = XCALLOC(MTYPE_PIM_NEXTHOP_CACHE,
sizeof(struct pim_nexthop_cache));
@@ -103,8 +101,8 @@ static struct pim_nexthop_cache *pim_nexthop_cache_add(struct pim_instance *pim,
pnc->rp_list = list_new();
pnc->rp_list->cmp = pim_rp_list_cmp;
- snprintf(hash_name, sizeof(hash_name), "PNC %s(%s) Upstream Hash",
- prefix2str(&pnc->rpf.rpf_addr, buf1, 64), pim->vrf->name);
+ snprintfrr(hash_name, sizeof(hash_name), "PNC %pFX(%s) Upstream Hash",
+ &pnc->rpf.rpf_addr, pim->vrf->name);
pnc->upstream_hash = hash_create_size(8192, pim_upstream_hash_key,
pim_upstream_equal, hash_name);
@@ -140,13 +138,10 @@ int pim_find_or_track_nexthop(struct pim_instance *pim, struct prefix *addr,
pnc = pim_nexthop_cache_add(pim, &rpf);
pim_sendmsg_zebra_rnh(pim, zclient, pnc,
ZEBRA_NEXTHOP_REGISTER);
- if (PIM_DEBUG_PIM_NHT) {
- char buf[PREFIX2STR_BUFFER];
- prefix2str(addr, buf, sizeof(buf));
+ if (PIM_DEBUG_PIM_NHT)
zlog_debug(
- "%s: NHT cache and zebra notification added for %s(%s)",
- __func__, buf, pim->vrf->name);
- }
+ "%s: NHT cache and zebra notification added for %pFX(%s)",
+ __func__, addr, pim->vrf->name);
}
if (rp != NULL) {
@@ -215,14 +210,11 @@ void pim_delete_tracked_nexthop(struct pim_instance *pim, struct prefix *addr,
if (del_bsr_tracking)
pnc->bsr_tracking = false;
- if (PIM_DEBUG_PIM_NHT) {
- char buf[PREFIX_STRLEN];
- prefix2str(addr, buf, sizeof(buf));
+ if (PIM_DEBUG_PIM_NHT)
zlog_debug(
- "%s: NHT %s(%s) rp_list count:%d upstream count:%ld",
- __func__, buf, pim->vrf->name,
+ "%s: NHT %pFX(%s) rp_list count:%d upstream count:%ld",
+ __func__, addr, pim->vrf->name,
pnc->rp_list->count, pnc->upstream_hash->count);
- }
if (pnc->rp_list->count == 0
&& pnc->upstream_hash->count == 0
@@ -744,13 +736,10 @@ int pim_parse_nexthop_update(ZAPI_CALLBACK_ARGS)
prefix_copy(&rpf.rpf_addr, &nhr.prefix);
pnc = pim_nexthop_cache_find(pim, &rpf);
if (!pnc) {
- if (PIM_DEBUG_PIM_NHT) {
- char buf[PREFIX2STR_BUFFER];
- prefix2str(&rpf.rpf_addr, buf, sizeof(buf));
+ if (PIM_DEBUG_PIM_NHT)
zlog_debug(
- "%s: Skipping NHT update, addr %s is not in local cached DB.",
- __func__, buf);
- }
+ "%s: Skipping NHT update, addr %pFX is not in local cached DB.",
+ __func__, &rpf.rpf_addr);
return 0;
}
} else {
@@ -819,17 +808,13 @@ int pim_parse_nexthop_update(ZAPI_CALLBACK_ARGS)
continue;
}
- if (PIM_DEBUG_PIM_NHT) {
- char p_str[PREFIX2STR_BUFFER];
-
- prefix2str(&nhr.prefix, p_str, sizeof(p_str));
+ if (PIM_DEBUG_PIM_NHT)
zlog_debug(
- "%s: NHT addr %s(%s) %d-nhop via %s(%s) type %d distance:%u metric:%u ",
- __func__, p_str, pim->vrf->name, i + 1,
- inet_ntoa(nexthop->gate.ipv4),
+ "%s: NHT addr %pFX(%s) %d-nhop via %pI4(%s) type %d distance:%u metric:%u ",
+ __func__, &nhr.prefix, pim->vrf->name,
+ i + 1, &nexthop->gate.ipv4,
ifp->name, nexthop->type, nhr.distance,
nhr.metric);
- }
if (!ifp->info) {
/*
@@ -879,15 +864,12 @@ int pim_parse_nexthop_update(ZAPI_CALLBACK_ARGS)
}
SET_FLAG(pnc->flags, PIM_NEXTHOP_ANSWER_RECEIVED);
- if (PIM_DEBUG_PIM_NHT) {
- char buf[PREFIX2STR_BUFFER];
- prefix2str(&nhr.prefix, buf, sizeof(buf));
+ if (PIM_DEBUG_PIM_NHT)
zlog_debug(
- "%s: NHT Update for %s(%s) num_nh %d num_pim_nh %d vrf:%u up %ld rp %d",
- __func__, buf, pim->vrf->name, nhr.nexthop_num,
+ "%s: NHT Update for %pFX(%s) num_nh %d num_pim_nh %d vrf:%u up %ld rp %d",
+ __func__, &nhr.prefix, pim->vrf->name, nhr.nexthop_num,
pnc->nexthop_num, vrf_id, pnc->upstream_hash->count,
listcount(pnc->rp_list));
- }
pim_rpf_set_refresh_time(pim);
diff --git a/pimd/pim_register.c b/pimd/pim_register.c
index 19e15f3ede..90b69a54f2 100644
--- a/pimd/pim_register.c
+++ b/pimd/pim_register.c
@@ -75,8 +75,8 @@ void pim_register_stop_send(struct interface *ifp, struct prefix_sg *sg,
struct prefix p;
if (PIM_DEBUG_PIM_REG) {
- zlog_debug("Sending Register stop for %s to %s on %s",
- pim_str_sg_dump(sg), inet_ntoa(originator),
+ zlog_debug("Sending Register stop for %s to %pI4 on %s",
+ pim_str_sg_dump(sg), &originator,
ifp->name);
}
@@ -170,9 +170,9 @@ void pim_register_send(const uint8_t *buf, int buf_size, struct in_addr src,
struct interface *ifp;
if (PIM_DEBUG_PIM_REG) {
- zlog_debug("Sending %s %sRegister Packet to %s", up->sg_str,
+ zlog_debug("Sending %s %sRegister Packet to %pI4", up->sg_str,
null_register ? "NULL " : "",
- inet_ntoa(rpg->rpf_addr.u.prefix4));
+ &rpg->rpf_addr.u.prefix4);
}
ifp = rpg->source_nexthop.interface;
@@ -192,12 +192,9 @@ void pim_register_send(const uint8_t *buf, int buf_size, struct in_addr src,
}
if (PIM_DEBUG_PIM_REG) {
- char rp_str[INET_ADDRSTRLEN];
- strlcpy(rp_str, inet_ntoa(rpg->rpf_addr.u.prefix4),
- sizeof(rp_str));
- zlog_debug("%s: Sending %s %sRegister Packet to %s on %s",
+ zlog_debug("%s: Sending %s %sRegister Packet to %pI4 on %s",
__func__, up->sg_str, null_register ? "NULL " : "",
- rp_str, ifp->name);
+ &rpg->rpf_addr.u.prefix4, ifp->name);
}
memset(buffer, 0, 10000);
diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c
index 93fe787a93..7246482f02 100644
--- a/pimd/pim_rp.c
+++ b/pimd/pim_rp.c
@@ -134,7 +134,7 @@ void pim_rp_init(struct pim_instance *pim)
if (PIM_DEBUG_PIM_TRACE)
zlog_debug(
"Allocated: %p for rp_info: %p(224.0.0.0/4) Lock: %d",
- rn, rp_info, rn->lock);
+ rn, rp_info, route_node_get_lock_count(rn));
}
void pim_rp_free(struct pim_instance *pim)
@@ -248,14 +248,10 @@ struct rp_info *pim_rp_find_match_group(struct pim_instance *pim,
}
rp_info = rn->info;
- if (PIM_DEBUG_PIM_TRACE) {
- char buf[PREFIX_STRLEN];
-
- zlog_debug("Lookedup: %p for rp_info: %p(%s) Lock: %d", rn,
- rp_info,
- prefix2str(&rp_info->group, buf, sizeof(buf)),
- rn->lock);
- }
+ if (PIM_DEBUG_PIM_TRACE)
+ zlog_debug("Lookedup: %p for rp_info: %p(%pFX) Lock: %d", rn,
+ rp_info, &rp_info->group,
+ route_node_get_lock_count(rn));
route_unlock_node(rn);
@@ -354,8 +350,8 @@ void pim_upstream_update(struct pim_instance *pim, struct pim_upstream *up)
up->sg.grp);
if (PIM_DEBUG_PIM_TRACE)
- zlog_debug("%s: pim upstream update for old upstream %s",
- __func__, inet_ntoa(old_upstream_addr));
+ zlog_debug("%s: pim upstream update for old upstream %pI4",
+ __func__, &old_upstream_addr);
if (old_upstream_addr.s_addr == new_upstream_addr.s_addr)
return;
@@ -370,14 +366,10 @@ void pim_upstream_update(struct pim_instance *pim, struct pim_upstream *up)
nht_p.family = AF_INET;
nht_p.prefixlen = IPV4_MAX_BITLEN;
nht_p.u.prefix4 = old_upstream_addr;
- if (PIM_DEBUG_PIM_TRACE) {
- char buf[PREFIX2STR_BUFFER];
-
- prefix2str(&nht_p, buf, sizeof(buf));
+ if (PIM_DEBUG_PIM_TRACE)
zlog_debug(
- "%s: Deregister upstream %s addr %s with Zebra NHT",
- __func__, up->sg_str, buf);
- }
+ "%s: Deregister upstream %s addr %pFX with Zebra NHT",
+ __func__, up->sg_str, &nht_p);
pim_delete_tracked_nexthop(pim, &nht_p, up, NULL, false);
}
@@ -547,15 +539,10 @@ int pim_rp_new(struct pim_instance *pim, struct in_addr rp_addr,
nht_p.prefixlen = IPV4_MAX_BITLEN;
nht_p.u.prefix4 =
rp_all->rp.rpf_addr.u.prefix4; // RP address
- if (PIM_DEBUG_PIM_NHT_RP) {
- char buf[PREFIX2STR_BUFFER];
- char buf1[PREFIX2STR_BUFFER];
- prefix2str(&nht_p, buf, sizeof(buf));
- prefix2str(&rp_all->group, buf1, sizeof(buf1));
+ if (PIM_DEBUG_PIM_NHT_RP)
zlog_debug(
- "%s: NHT Register rp_all addr %s grp %s ",
- __func__, buf, buf1);
- }
+ "%s: NHT Register rp_all addr %pFX grp %pFX ",
+ __func__, &nht_p, &rp_all->group);
frr_each (rb_pim_upstream, &pim->upstream_head, up) {
/* Find (*, G) upstream whose RP is not
@@ -643,14 +630,10 @@ int pim_rp_new(struct pim_instance *pim, struct in_addr rp_addr,
rn = route_node_get(pim->rp_table, &rp_info->group);
rn->info = rp_info;
- if (PIM_DEBUG_PIM_TRACE) {
- char buf[PREFIX_STRLEN];
-
- zlog_debug("Allocated: %p for rp_info: %p(%s) Lock: %d", rn,
- rp_info,
- prefix2str(&rp_info->group, buf, sizeof(buf)),
- rn->lock);
- }
+ if (PIM_DEBUG_PIM_TRACE)
+ zlog_debug("Allocated: %p for rp_info: %p(%pFX) Lock: %d", rn,
+ rp_info, &rp_info->group,
+ route_node_get_lock_count(rn));
frr_each (rb_pim_upstream, &pim->upstream_head, up) {
if (up->sg.src.s_addr == INADDR_ANY) {
@@ -674,14 +657,9 @@ int pim_rp_new(struct pim_instance *pim, struct in_addr rp_addr,
nht_p.family = AF_INET;
nht_p.prefixlen = IPV4_MAX_BITLEN;
nht_p.u.prefix4 = rp_info->rp.rpf_addr.u.prefix4;
- if (PIM_DEBUG_PIM_NHT_RP) {
- char buf[PREFIX2STR_BUFFER];
- char buf1[PREFIX2STR_BUFFER];
- prefix2str(&nht_p, buf, sizeof(buf));
- prefix2str(&rp_info->group, buf1, sizeof(buf1));
- zlog_debug("%s: NHT Register RP addr %s grp %s with Zebra ",
- __func__, buf, buf1);
- }
+ if (PIM_DEBUG_PIM_NHT_RP)
+ zlog_debug("%s: NHT Register RP addr %pFX grp %pFX with Zebra ",
+ __func__, &nht_p, &rp_info->group);
pim_find_or_track_nexthop(pim, &nht_p, NULL, rp_info, false, NULL);
if (!pim_ecmp_nexthop_lookup(pim, &rp_info->rp.source_nexthop, &nht_p,
&rp_info->group, 1))
@@ -727,12 +705,10 @@ int pim_rp_del(struct pim_instance *pim, struct in_addr rp_addr,
struct pim_upstream *up;
struct bsgrp_node *bsgrp = NULL;
struct bsm_rpinfo *bsrp = NULL;
- char grp_str[PREFIX2STR_BUFFER];
char rp_str[INET_ADDRSTRLEN];
if (!inet_ntop(AF_INET, &rp_addr, rp_str, sizeof(rp_str)))
snprintf(rp_str, sizeof(rp_str), "<rp?>");
- prefix2str(&group, grp_str, sizeof(grp_str));
if (plist)
rp_info = pim_rp_find_prefix_list(pim, rp_addr, plist);
@@ -748,8 +724,8 @@ int pim_rp_del(struct pim_instance *pim, struct in_addr rp_addr,
}
if (PIM_DEBUG_PIM_TRACE)
- zlog_debug("%s: Delete RP %s for the group %s", __func__,
- rp_str, grp_str);
+ zlog_debug("%s: Delete RP %s for the group %pFX", __func__,
+ rp_str, &group);
/* While static RP is getting deleted, we need to check if dynamic RP
* present for the same group in BSM RP table, then install the dynamic
@@ -771,8 +747,8 @@ int pim_rp_del(struct pim_instance *pim, struct in_addr rp_addr,
"<bsrp?>");
zlog_debug(
- "%s: BSM RP %s found for the group %s",
- __func__, bsrp_str, grp_str);
+ "%s: BSM RP %s found for the group %pFX",
+ __func__, bsrp_str, &group);
}
return pim_rp_change(pim, bsrp->rp_address,
group, RP_SRC_BSR);
@@ -780,8 +756,8 @@ int pim_rp_del(struct pim_instance *pim, struct in_addr rp_addr,
} else {
if (PIM_DEBUG_PIM_TRACE)
zlog_debug(
- "%s: BSM RP not found for the group %s",
- __func__, grp_str);
+ "%s: BSM RP not found for the group %pFX",
+ __func__, &group);
}
}
@@ -789,12 +765,9 @@ int pim_rp_del(struct pim_instance *pim, struct in_addr rp_addr,
nht_p.family = AF_INET;
nht_p.prefixlen = IPV4_MAX_BITLEN;
nht_p.u.prefix4 = rp_info->rp.rpf_addr.u.prefix4;
- if (PIM_DEBUG_PIM_NHT_RP) {
- char buf[PREFIX2STR_BUFFER];
- prefix2str(&nht_p, buf, sizeof(buf));
- zlog_debug("%s: Deregister RP addr %s with Zebra ", __func__,
- buf);
- }
+ if (PIM_DEBUG_PIM_NHT_RP)
+ zlog_debug("%s: Deregister RP addr %pFX with Zebra ", __func__,
+ &nht_p);
pim_delete_tracked_nexthop(pim, &nht_p, NULL, rp_info, false);
if (!str2prefix("224.0.0.0/4", &g_all))
@@ -837,16 +810,12 @@ int pim_rp_del(struct pim_instance *pim, struct in_addr rp_addr,
EC_LIB_DEVELOPMENT,
"Expected rn->info to be equal to rp_info");
- if (PIM_DEBUG_PIM_TRACE) {
- char buf[PREFIX_STRLEN];
-
+ if (PIM_DEBUG_PIM_TRACE)
zlog_debug(
- "%s:Found for Freeing: %p for rp_info: %p(%s) Lock: %d",
- __func__, rn, rp_info,
- prefix2str(&rp_info->group, buf,
- sizeof(buf)),
- rn->lock);
- }
+ "%s:Found for Freeing: %p for rp_info: %p(%pFX) Lock: %d",
+ __func__, rn, rp_info, &rp_info->group,
+ route_node_get_lock_count(rn));
+
rn->info = NULL;
route_unlock_node(rn);
route_unlock_node(rn);
@@ -925,13 +894,9 @@ int pim_rp_change(struct pim_instance *pim, struct in_addr new_rp_addr,
/* Deregister old RP addr with Zebra NHT */
if (rp_info->rp.rpf_addr.u.prefix4.s_addr != INADDR_ANY) {
nht_p.u.prefix4 = rp_info->rp.rpf_addr.u.prefix4;
- if (PIM_DEBUG_PIM_NHT_RP) {
- char buf[PREFIX2STR_BUFFER];
-
- prefix2str(&nht_p, buf, sizeof(buf));
- zlog_debug("%s: Deregister RP addr %s with Zebra ",
- __func__, buf);
- }
+ if (PIM_DEBUG_PIM_NHT_RP)
+ zlog_debug("%s: Deregister RP addr %pFX with Zebra ",
+ __func__, &nht_p);
pim_delete_tracked_nexthop(pim, &nht_p, NULL, rp_info, false);
}
@@ -961,15 +926,9 @@ int pim_rp_change(struct pim_instance *pim, struct in_addr new_rp_addr,
/* Register new RP addr with Zebra NHT */
nht_p.u.prefix4 = rp_info->rp.rpf_addr.u.prefix4;
- if (PIM_DEBUG_PIM_NHT_RP) {
- char buf[PREFIX2STR_BUFFER];
- char buf1[PREFIX2STR_BUFFER];
-
- prefix2str(&nht_p, buf, sizeof(buf));
- prefix2str(&rp_info->group, buf1, sizeof(buf1));
- zlog_debug("%s: NHT Register RP addr %s grp %s with Zebra ",
- __func__, buf, buf1);
- }
+ if (PIM_DEBUG_PIM_NHT_RP)
+ zlog_debug("%s: NHT Register RP addr %pFX grp %pFX with Zebra ",
+ __func__, &nht_p, &rp_info->group);
pim_find_or_track_nexthop(pim, &nht_p, NULL, rp_info, false, NULL);
if (!pim_ecmp_nexthop_lookup(pim, &rp_info->rp.source_nexthop, &nht_p,
@@ -1145,15 +1104,10 @@ struct pim_rpf *pim_rp_g(struct pim_instance *pim, struct in_addr group)
nht_p.family = AF_INET;
nht_p.prefixlen = IPV4_MAX_BITLEN;
nht_p.u.prefix4 = rp_info->rp.rpf_addr.u.prefix4;
- if (PIM_DEBUG_PIM_NHT_RP) {
- char buf[PREFIX2STR_BUFFER];
- char buf1[PREFIX2STR_BUFFER];
- prefix2str(&nht_p, buf, sizeof(buf));
- prefix2str(&rp_info->group, buf1, sizeof(buf1));
+ if (PIM_DEBUG_PIM_NHT_RP)
zlog_debug(
- "%s: NHT Register RP addr %s grp %s with Zebra",
- __func__, buf, buf1);
- }
+ "%s: NHT Register RP addr %pFX grp %pFX with Zebra",
+ __func__, &nht_p, &rp_info->group);
pim_find_or_track_nexthop(pim, &nht_p, NULL, rp_info, false,
NULL);
pim_rpf_set_refresh_time(pim);
@@ -1208,7 +1162,6 @@ int pim_rp_config_write(struct pim_instance *pim, struct vty *vty,
struct listnode *node;
struct rp_info *rp_info;
char rp_buffer[32];
- char group_buffer[32];
int count = 0;
for (ALL_LIST_ELEMENTS_RO(pim->rp_list, node, rp_info)) {
@@ -1225,11 +1178,11 @@ int pim_rp_config_write(struct pim_instance *pim, struct vty *vty,
rp_buffer, 32),
rp_info->plist);
else
- vty_out(vty, "%sip pim rp %s %s\n", spaces,
+ vty_out(vty, "%sip pim rp %s %pFX\n", spaces,
inet_ntop(AF_INET,
&rp_info->rp.rpf_addr.u.prefix4,
rp_buffer, 32),
- prefix2str(&rp_info->group, group_buffer, 32));
+ &rp_info->group);
count++;
}
@@ -1251,6 +1204,7 @@ void pim_rp_show_information(struct pim_instance *pim, struct vty *vty, bool uj)
struct rp_info *prev_rp_info = NULL;
struct listnode *node;
char source[7];
+ char buf[PREFIX_STRLEN];
json_object *json = NULL;
json_object *json_rp_rows = NULL;
@@ -1283,9 +1237,11 @@ void pim_rp_show_information(struct pim_instance *pim, struct vty *vty, bool uj)
.s_addr) {
json_object_object_add(
json,
- inet_ntoa(prev_rp_info->rp
+ inet_ntop(AF_INET,
+ &prev_rp_info->rp
.rpf_addr.u
- .prefix4),
+ .prefix4,
+ buf, sizeof(buf)),
json_rp_rows);
json_rp_rows = NULL;
}
@@ -1296,8 +1252,10 @@ void pim_rp_show_information(struct pim_instance *pim, struct vty *vty, bool uj)
json_row = json_object_new_object();
json_object_string_add(
json_row, "rpAddress",
- inet_ntoa(rp_info->rp.rpf_addr.u
- .prefix4));
+ inet_ntop(AF_INET,
+ &rp_info->rp.rpf_addr.u
+ .prefix4,
+ buf, sizeof(buf)));
if (rp_info->rp.source_nexthop.interface)
json_object_string_add(
json_row, "outboundInterface",
@@ -1329,15 +1287,16 @@ void pim_rp_show_information(struct pim_instance *pim, struct vty *vty, bool uj)
json_object_array_add(json_rp_rows, json_row);
} else {
vty_out(vty, "%-15s ",
- inet_ntoa(rp_info->rp.rpf_addr.u
- .prefix4));
+ inet_ntop(AF_INET,
+ &rp_info->rp.rpf_addr.u
+ .prefix4,
+ buf, sizeof(buf)));
if (rp_info->plist)
vty_out(vty, "%-18s ", rp_info->plist);
else
- vty_out(vty, "%-18s ",
- prefix2str(&rp_info->group, buf,
- 48));
+ vty_out(vty, "%-18pFX ",
+ &rp_info->group);
if (rp_info->rp.source_nexthop.interface)
vty_out(vty, "%-16s ",
@@ -1361,7 +1320,9 @@ void pim_rp_show_information(struct pim_instance *pim, struct vty *vty, bool uj)
if (prev_rp_info && json_rp_rows)
json_object_object_add(
json,
- inet_ntoa(prev_rp_info->rp.rpf_addr.u.prefix4),
+ inet_ntop(AF_INET,
+ &prev_rp_info->rp.rpf_addr.u.prefix4,
+ buf, sizeof(buf)),
json_rp_rows);
vty_out(vty, "%s\n", json_object_to_json_string_ext(
diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c
index d3fb0d46de..6bb25c436a 100644
--- a/pimd/pim_upstream.c
+++ b/pimd/pim_upstream.c
@@ -267,13 +267,10 @@ struct pim_upstream *pim_upstream_del(struct pim_instance *pim,
nht_p.family = AF_INET;
nht_p.prefixlen = IPV4_MAX_BITLEN;
nht_p.u.prefix4 = up->upstream_addr;
- if (PIM_DEBUG_PIM_TRACE) {
- char buf[PREFIX2STR_BUFFER];
- prefix2str(&nht_p, buf, sizeof(buf));
+ if (PIM_DEBUG_PIM_TRACE)
zlog_debug(
- "%s: Deregister upstream %s addr %s with Zebra NHT",
- __func__, up->sg_str, buf);
- }
+ "%s: Deregister upstream %s addr %pFX with Zebra NHT",
+ __func__, up->sg_str, &nht_p);
pim_delete_tracked_nexthop(pim, &nht_p, up, NULL, false);
}
@@ -954,8 +951,8 @@ static struct pim_upstream *pim_upstream_new(struct pim_instance *pim,
if (PIM_DEBUG_PIM_TRACE) {
zlog_debug(
- "%s: Created Upstream %s upstream_addr %s ref count %d increment",
- __func__, up->sg_str, inet_ntoa(up->upstream_addr),
+ "%s: Created Upstream %s upstream_addr %pI4 ref count %d increment",
+ __func__, up->sg_str, &up->upstream_addr,
up->ref_count);
}
@@ -1062,15 +1059,13 @@ struct pim_upstream *pim_upstream_add(struct pim_instance *pim,
}
if (PIM_DEBUG_PIM_TRACE) {
- if (up) {
- char buf[PREFIX2STR_BUFFER];
- prefix2str(&up->rpf.rpf_addr, buf, sizeof(buf));
- zlog_debug("%s(%s): %s, iif %s (%s) found: %d: ref_count: %d",
+ if (up)
+ zlog_debug("%s(%s): %s, iif %pFX (%s) found: %d: ref_count: %d",
__func__, name,
- up->sg_str, buf, up->rpf.source_nexthop.interface ?
+ up->sg_str, &up->rpf.rpf_addr, up->rpf.source_nexthop.interface ?
up->rpf.source_nexthop.interface->name : "Unknown" ,
found, up->ref_count);
- } else
+ else
zlog_debug("%s(%s): (%s) failure to create", __func__,
name, pim_str_sg_dump(sg));
}
diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c
index d089dfda51..f0eae955cc 100644
--- a/pimd/pim_zebra.c
+++ b/pimd/pim_zebra.c
@@ -98,8 +98,8 @@ static void dump_if_address(struct interface *ifp)
if (p->family != AF_INET)
continue;
- zlog_debug("%s %s: interface %s address %s %s", __FILE__,
- __func__, ifp->name, inet_ntoa(p->u.prefix4),
+ zlog_debug("%s %s: interface %s address %pI4 %s", __FILE__,
+ __func__, ifp->name, &p->u.prefix4,
CHECK_FLAG(ifc->flags, ZEBRA_IFA_SECONDARY)
? "secondary"
: "primary");
@@ -130,10 +130,8 @@ static int pim_zebra_if_address_add(ZAPI_CALLBACK_ARGS)
p = c->address;
if (PIM_DEBUG_ZEBRA) {
- char buf[BUFSIZ];
- prefix2str(p, buf, BUFSIZ);
- zlog_debug("%s: %s(%u) connected IP address %s flags %u %s",
- __func__, c->ifp->name, vrf_id, buf, c->flags,
+ zlog_debug("%s: %s(%u) connected IP address %pFX flags %u %s",
+ __func__, c->ifp->name, vrf_id, p, c->flags,
CHECK_FLAG(c->flags, ZEBRA_IFA_SECONDARY)
? "secondary"
: "primary");
@@ -149,17 +147,10 @@ static int pim_zebra_if_address_add(ZAPI_CALLBACK_ARGS)
struct in_addr primary_addr = pim_find_primary_addr(c->ifp);
if (p->family != AF_INET
|| primary_addr.s_addr != p->u.prefix4.s_addr) {
- if (PIM_DEBUG_ZEBRA) {
- /* but we had a primary address already */
-
- char buf[BUFSIZ];
-
- prefix2str(p, buf, BUFSIZ);
-
+ if (PIM_DEBUG_ZEBRA)
zlog_warn(
- "%s: %s : forcing secondary flag on %s",
- __func__, c->ifp->name, buf);
- }
+ "%s: %s : forcing secondary flag on %pFX",
+ __func__, c->ifp->name, p);
SET_FLAG(c->flags, ZEBRA_IFA_SECONDARY);
}
}
@@ -211,11 +202,9 @@ static int pim_zebra_if_address_del(ZAPI_CALLBACK_ARGS)
p = c->address;
if (p->family == AF_INET) {
if (PIM_DEBUG_ZEBRA) {
- char buf[BUFSIZ];
- prefix2str(p, buf, BUFSIZ);
zlog_debug(
- "%s: %s(%u) disconnected IP address %s flags %u %s",
- __func__, c->ifp->name, vrf_id, buf, c->flags,
+ "%s: %s(%u) disconnected IP address %pFX flags %u %s",
+ __func__, c->ifp->name, vrf_id, p, c->flags,
CHECK_FLAG(c->flags, ZEBRA_IFA_SECONDARY)
? "secondary"
: "primary");
@@ -848,9 +837,9 @@ void pim_forward_start(struct pim_ifchannel *ch)
sizeof(group_str));
pim_inet4_dump("<upstream?>", up->upstream_addr, upstream_str,
sizeof(upstream_str));
- zlog_debug("%s: (S,G)=(%s,%s) oif=%s (%s)", __func__,
+ zlog_debug("%s: (S,G)=(%s,%s) oif=%s (%pI4)", __func__,
source_str, group_str, ch->interface->name,
- inet_ntoa(up->upstream_addr));
+ &up->upstream_addr);
}
if (PIM_IF_FLAG_TEST_PROTO_IGMP(ch->flags))
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c
index aab756aee9..c2cee4d69d 100644
--- a/ripd/rip_interface.c
+++ b/ripd/rip_interface.c
@@ -172,8 +172,8 @@ static void rip_request_interface_send(struct interface *ifp, uint8_t version)
continue;
if (IS_RIP_DEBUG_EVENT)
- zlog_debug("SEND request to %s",
- inet_ntoa(to.sin_addr));
+ zlog_debug("SEND request to %pI4",
+ &to.sin_addr);
rip_request_send(&to, ifp, version, connected);
}
@@ -603,8 +603,7 @@ int rip_interface_address_add(ZAPI_CALLBACK_ARGS)
if (p->family == AF_INET) {
if (IS_RIP_DEBUG_ZEBRA)
- zlog_debug("connected address %s/%d is added",
- inet_ntoa(p->u.prefix4), p->prefixlen);
+ zlog_debug("connected address %pFX is added", p);
rip_enable_apply(ifc->ifp);
/* Check if this prefix needs to be redistributed */
@@ -653,9 +652,8 @@ int rip_interface_address_delete(ZAPI_CALLBACK_ARGS)
p = ifc->address;
if (p->family == AF_INET) {
if (IS_RIP_DEBUG_ZEBRA)
- zlog_debug("connected address %s/%d is deleted",
- inet_ntoa(p->u.prefix4),
- p->prefixlen);
+ zlog_debug("connected address %pFX is deleted",
+ p);
hook_call(rip_ifaddr_del, ifc);
@@ -1176,9 +1174,7 @@ int rip_show_network_config(struct vty *vty, struct rip *rip)
for (node = route_top(rip->enable_network); node;
node = route_next(node))
if (node->info)
- vty_out(vty, " %s/%u\n",
- inet_ntoa(node->p.u.prefix4),
- node->p.prefixlen);
+ vty_out(vty, " %pFX\n", &node->p);
/* Interface name RIP enable statement. */
for (i = 0; i < vector_active(rip->enable_interface); i++)
@@ -1188,7 +1184,7 @@ int rip_show_network_config(struct vty *vty, struct rip *rip)
/* RIP neighbors listing. */
for (node = route_top(rip->neighbor); node; node = route_next(node))
if (node->info)
- vty_out(vty, " %s\n", inet_ntoa(node->p.u.prefix4));
+ vty_out(vty, " %pI4\n", &node->p.u.prefix4);
return 0;
}
diff --git a/ripd/rip_peer.c b/ripd/rip_peer.c
index 77c73ab398..4c5233c82c 100644
--- a/ripd/rip_peer.c
+++ b/ripd/rip_peer.c
@@ -155,8 +155,8 @@ void rip_peer_display(struct vty *vty, struct rip *rip)
char timebuf[RIP_UPTIME_LEN];
for (ALL_LIST_ELEMENTS(rip->peer_list, node, nnode, peer)) {
- vty_out(vty, " %-16s %9d %9d %9d %s\n",
- inet_ntoa(peer->addr), peer->recv_badpackets,
+ vty_out(vty, " %-16pI4 %9d %9d %9d %s\n",
+ &peer->addr, peer->recv_badpackets,
peer->recv_badroutes, ZEBRA_RIP_DISTANCE_DEFAULT,
rip_peer_uptime(peer, timebuf, RIP_UPTIME_LEN));
}
diff --git a/ripd/rip_zebra.c b/ripd/rip_zebra.c
index e07d218860..074370dc26 100644
--- a/ripd/rip_zebra.c
+++ b/ripd/rip_zebra.c
@@ -88,18 +88,16 @@ static void rip_zebra_ipv4_send(struct rip *rip, struct route_node *rp,
if (IS_RIP_DEBUG_ZEBRA) {
if (rip->ecmp)
- zlog_debug("%s: %s/%d nexthops %d",
+ zlog_debug("%s: %pFX nexthops %d",
(cmd == ZEBRA_ROUTE_ADD)
? "Install into zebra"
: "Delete from zebra",
- inet_ntoa(rp->p.u.prefix4), rp->p.prefixlen,
- count);
+ &rp->p, count);
else
- zlog_debug("%s: %s/%d",
+ zlog_debug("%s: %pFX",
(cmd == ZEBRA_ROUTE_ADD)
? "Install into zebra"
- : "Delete from zebra",
- inet_ntoa(rp->p.u.prefix4), rp->p.prefixlen);
+ : "Delete from zebra", &rp->p);
}
rip->counters.route_changes++;
diff --git a/ripd/ripd.c b/ripd/ripd.c
index 389a54f224..07f24b5a99 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -45,6 +45,7 @@
#include "lib_errors.h"
#include "northbound_cli.h"
#include "network.h"
+#include "lib/printfrr.h"
#include "ripd/ripd.h"
#include "ripd/rip_nb.h"
@@ -337,8 +338,7 @@ static int rip_filter(int rip_distribute, struct prefix_ipv4 *p,
(struct prefix *)p)
== FILTER_DENY) {
if (IS_RIP_DEBUG_PACKET)
- zlog_debug("%s/%d filtered by distribute %s",
- inet_ntoa(p->prefix), p->prefixlen,
+ zlog_debug("%pFX filtered by distribute %s", p,
inout);
return -1;
}
@@ -348,8 +348,7 @@ static int rip_filter(int rip_distribute, struct prefix_ipv4 *p,
(struct prefix *)p)
== PREFIX_DENY) {
if (IS_RIP_DEBUG_PACKET)
- zlog_debug("%s/%d filtered by prefix-list %s",
- inet_ntoa(p->prefix), p->prefixlen,
+ zlog_debug("%pFX filtered by prefix-list %s", p,
inout);
return -1;
}
@@ -367,9 +366,8 @@ static int rip_filter(int rip_distribute, struct prefix_ipv4 *p,
== FILTER_DENY) {
if (IS_RIP_DEBUG_PACKET)
zlog_debug(
- "%s/%d filtered by distribute %s",
- inet_ntoa(p->prefix),
- p->prefixlen, inout);
+ "%pFX filtered by distribute %s",
+ p, inout);
return -1;
}
}
@@ -383,9 +381,8 @@ static int rip_filter(int rip_distribute, struct prefix_ipv4 *p,
== PREFIX_DENY) {
if (IS_RIP_DEBUG_PACKET)
zlog_debug(
- "%s/%d filtered by prefix-list %s",
- inet_ntoa(p->prefix),
- p->prefixlen, inout);
+ "%pFX filtered by prefix-list %s",
+ p, inout);
return -1;
}
}
@@ -470,8 +467,8 @@ static void rip_rte_process(struct rte *rte, struct sockaddr_in *from,
if (ret == RMAP_DENYMATCH) {
if (IS_RIP_DEBUG_PACKET)
zlog_debug(
- "RIP %s/%d is filtered by route-map in",
- inet_ntoa(p.prefix), p.prefixlen);
+ "RIP %pFX is filtered by route-map in",
+ &p);
return;
}
@@ -506,8 +503,8 @@ static void rip_rte_process(struct rte *rte, struct sockaddr_in *from,
/* Check if nexthop address is myself, then do nothing. */
if (rip_nexthop_check(rip, nexthop) < 0) {
if (IS_RIP_DEBUG_PACKET)
- zlog_debug("Nexthop address %s is myself",
- inet_ntoa(*nexthop));
+ zlog_debug("Nexthop address %pI4 is myself",
+ nexthop);
return;
}
@@ -834,8 +831,8 @@ static int rip_auth_simple_password(struct rte *rte, struct sockaddr_in *from,
}
if (IS_RIP_DEBUG_EVENT)
- zlog_debug("RIPv2 simple password authentication from %s",
- inet_ntoa(from->sin_addr));
+ zlog_debug("RIPv2 simple password authentication from %pI4",
+ &from->sin_addr);
ri = ifp->info;
@@ -882,8 +879,8 @@ static int rip_auth_md5(struct rip_packet *packet, struct sockaddr_in *from,
char auth_str[RIP_AUTH_MD5_SIZE] = {};
if (IS_RIP_DEBUG_EVENT)
- zlog_debug("RIPv2 MD5 authentication from %s",
- inet_ntoa(from->sin_addr));
+ zlog_debug("RIPv2 MD5 authentication from %pI4",
+ &from->sin_addr);
ri = ifp->info;
md5 = (struct rip_md5_info *)&packet->rte;
@@ -1164,8 +1161,8 @@ static void rip_response_process(struct rip_packet *packet, int size,
rip->vrf->vrf_id)
== NULL) {
zlog_info(
- "This datagram doesn't came from a valid neighbor: %s",
- inet_ntoa(from->sin_addr));
+ "This datagram doesn't come from a valid neighbor: %pI4",
+ &from->sin_addr);
rip_peer_bad_packet(rip, from);
return;
}
@@ -1194,9 +1191,9 @@ static void rip_response_process(struct rip_packet *packet, int size,
if (rte->family != htons(AF_INET)) {
/* Address family check. RIP only supports AF_INET. */
- zlog_info("Unsupported family %d from %s.",
+ zlog_info("Unsupported family %d from %pI4",
ntohs(rte->family),
- inet_ntoa(from->sin_addr));
+ &from->sin_addr);
continue;
}
@@ -1222,8 +1219,8 @@ static void rip_response_process(struct rip_packet *packet, int size,
/* RIPv1 does not have nexthop value. */
if (packet->version == RIPv1
&& rte->nexthop.s_addr != INADDR_ANY) {
- zlog_info("RIPv1 packet with nexthop value %s",
- inet_ntoa(rte->nexthop));
+ zlog_info("RIPv1 packet with nexthop value %pI4",
+ &rte->nexthop);
rip_peer_bad_route(rip, from);
continue;
}
@@ -1240,8 +1237,8 @@ static void rip_response_process(struct rip_packet *packet, int size,
addrval = ntohl(rte->nexthop.s_addr);
if (IN_CLASSD(addrval)) {
zlog_info(
- "Nexthop %s is multicast address, skip this rte",
- inet_ntoa(rte->nexthop));
+ "Nexthop %pI4 is multicast address, skip this rte",
+ &rte->nexthop);
continue;
}
@@ -1261,16 +1258,14 @@ static void rip_response_process(struct rip_packet *packet, int size,
== RIP_ROUTE_RTE) {
if (IS_RIP_DEBUG_EVENT)
zlog_debug(
- "Next hop %s is on RIP network. Set nexthop to the packet's originator",
- inet_ntoa(
- rte->nexthop));
+ "Next hop %pI4 is on RIP network. Set nexthop to the packet's originator",
+ &rte->nexthop);
rte->nexthop = rinfo->from;
} else {
if (IS_RIP_DEBUG_EVENT)
zlog_debug(
- "Next hop %s is not directly reachable. Treat it as 0.0.0.0",
- inet_ntoa(
- rte->nexthop));
+ "Next hop %pI4 is not directly reachable. Treat it as 0.0.0.0",
+ &rte->nexthop);
rte->nexthop.s_addr =
INADDR_ANY;
}
@@ -1279,9 +1274,8 @@ static void rip_response_process(struct rip_packet *packet, int size,
} else {
if (IS_RIP_DEBUG_EVENT)
zlog_debug(
- "Next hop %s is not directly reachable. Treat it as 0.0.0.0",
- inet_ntoa(
- rte->nexthop));
+ "Next hop %pI4 is not directly reachable. Treat it as 0.0.0.0",
+ &rte->nexthop);
rte->nexthop.s_addr = INADDR_ANY;
}
}
@@ -1335,8 +1329,8 @@ static void rip_response_process(struct rip_packet *packet, int size,
!= rte->prefix.s_addr)
masklen2ip(32, &rte->mask);
if (IS_RIP_DEBUG_EVENT)
- zlog_debug("Subnetted route %s",
- inet_ntoa(rte->prefix));
+ zlog_debug("Subnetted route %pI4",
+ &rte->prefix);
} else {
if ((rte->prefix.s_addr & rte->mask.s_addr)
!= rte->prefix.s_addr)
@@ -1344,10 +1338,10 @@ static void rip_response_process(struct rip_packet *packet, int size,
}
if (IS_RIP_DEBUG_EVENT) {
- zlog_debug("Resultant route %s",
- inet_ntoa(rte->prefix));
- zlog_debug("Resultant mask %s",
- inet_ntoa(rte->mask));
+ zlog_debug("Resultant route %pI4",
+ &rte->prefix);
+ zlog_debug("Resultant mask %pI4",
+ &rte->mask);
}
}
@@ -1358,8 +1352,8 @@ static void rip_response_process(struct rip_packet *packet, int size,
&& ((rte->prefix.s_addr & rte->mask.s_addr)
!= rte->prefix.s_addr)) {
zlog_warn(
- "RIPv2 address %s is not mask /%d applied one",
- inet_ntoa(rte->prefix), ip_masklen(rte->mask));
+ "RIPv2 address %pI4 is not mask /%d applied one",
+ &rte->prefix, ip_masklen(rte->mask));
rip_peer_bad_route(rip, from);
continue;
}
@@ -1422,8 +1416,8 @@ int rip_create_socket(struct vrf *vrf)
frr_with_privs(&ripd_privs) {
if ((ret = bind(sock, (struct sockaddr *)&addr, sizeof(addr)))
< 0) {
- zlog_err("%s: Can't bind socket %d to %s port %d: %s",
- __func__, sock, inet_ntoa(addr.sin_addr),
+ zlog_err("%s: Can't bind socket %d to %pI4 port %d: %s",
+ __func__, sock, &addr.sin_addr,
(int)ntohs(addr.sin_port),
safe_strerror(errno));
@@ -1463,14 +1457,14 @@ static int rip_send_packet(uint8_t *buf, int size, struct sockaddr_in *to,
char dst[ADDRESS_SIZE];
if (to) {
- strlcpy(dst, inet_ntoa(to->sin_addr), sizeof(dst));
+ inet_ntop(AF_INET, &to->sin_addr, dst, sizeof(dst));
} else {
sin.sin_addr.s_addr = htonl(INADDR_RIP_GROUP);
- strlcpy(dst, inet_ntoa(sin.sin_addr), sizeof(dst));
+ inet_ntop(AF_INET, &sin.sin_addr, dst, sizeof(dst));
}
#undef ADDRESS_SIZE
- zlog_debug("rip_send_packet %s > %s (%s)",
- inet_ntoa(ifc->address->u.prefix4), dst,
+ zlog_debug("rip_send_packet %pI4 > %s (%s)",
+ &ifc->address->u.prefix4, dst,
ifc->ifp->name);
}
@@ -1537,7 +1531,7 @@ static int rip_send_packet(uint8_t *buf, int size, struct sockaddr_in *to,
ret = sendmsg(rip->sock, &msg, 0);
if (IS_RIP_DEBUG_EVENT)
- zlog_debug("SEND to %s.%d", inet_ntoa(sin.sin_addr),
+ zlog_debug("SEND to %pI4%d", &sin.sin_addr,
ntohs(sin.sin_port));
if (ret < 0)
@@ -1603,8 +1597,7 @@ void rip_redistribute_add(struct rip *rip, int type, int sub_type,
(void)rip_ecmp_add(rip, &newinfo);
if (IS_RIP_DEBUG_EVENT) {
- zlog_debug("Redistribute new prefix %s/%d",
- inet_ntoa(p->prefix), p->prefixlen);
+ zlog_debug("Redistribute new prefix %pFX", p);
}
rip_event(rip, RIP_TRIGGERED_UPDATE, 0);
@@ -1641,9 +1634,8 @@ void rip_redistribute_delete(struct rip *rip, int type, int sub_type,
if (IS_RIP_DEBUG_EVENT)
zlog_debug(
- "Poison %s/%d on the interface %s with an infinity metric [delete]",
- inet_ntoa(p->prefix),
- p->prefixlen,
+ "Poison %pFX on the interface %s with an infinity metric [delete]",
+ p,
ifindex2ifname(
ifindex,
rip->vrf->vrf_id));
@@ -1788,15 +1780,15 @@ static int rip_read(struct thread *t)
/* RIP packet received */
if (IS_RIP_DEBUG_EVENT)
- zlog_debug("RECV packet from %s port %d on %s (VRF %s)",
- inet_ntoa(from.sin_addr), ntohs(from.sin_port),
+ zlog_debug("RECV packet from %pI4 port %d on %s (VRF %s)",
+ &from.sin_addr, ntohs(from.sin_port),
ifp ? ifp->name : "unknown", rip->vrf_name);
/* If this packet come from unknown interface, ignore it. */
if (ifp == NULL) {
zlog_info(
- "rip_read: cannot find interface for packet from %s port %d (VRF %s)",
- inet_ntoa(from.sin_addr), ntohs(from.sin_port),
+ "rip_read: cannot find interface for packet from %pI4 port %d (VRF %s)",
+ &from.sin_addr, ntohs(from.sin_port),
rip->vrf_name);
return -1;
}
@@ -1809,8 +1801,8 @@ static int rip_read(struct thread *t)
if (ifc == NULL) {
zlog_info(
- "rip_read: cannot find connected address for packet from %s port %d on interface %s (VRF %s)",
- inet_ntoa(from.sin_addr), ntohs(from.sin_port),
+ "rip_read: cannot find connected address for packet from %pI4 port %d on interface %s (VRF %s)",
+ &from.sin_addr, ntohs(from.sin_port),
ifp->name, rip->vrf_name);
return -1;
}
@@ -2083,8 +2075,8 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to,
/* Logging output event. */
if (IS_RIP_DEBUG_EVENT) {
if (to)
- zlog_debug("update routes to neighbor %s",
- inet_ntoa(to->sin_addr));
+ zlog_debug("update routes to neighbor %pI4",
+ &to->sin_addr);
else
zlog_debug("update routes on interface %s ifindex %d",
ifc->ifp->name, ifc->ifp->ifindex);
@@ -2149,9 +2141,8 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to,
if (IS_RIP_DEBUG_PACKET)
zlog_debug(
- "RIPv1 mask check, %s/%d considered for output",
- inet_ntoa(rp->p.u.prefix4),
- rp->p.prefixlen);
+ "RIPv1 mask check, %pFX considered for output",
+ &rp->p);
if (subnetted
&& prefix_match(
@@ -2172,9 +2163,8 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to,
}
if (IS_RIP_DEBUG_PACKET)
zlog_debug(
- "RIPv1 mask check, %s/%d made it through",
- inet_ntoa(rp->p.u.prefix4),
- rp->p.prefixlen);
+ "RIPv1 mask check, %pFX made it through",
+ &rp->p);
} else
p = (struct prefix_ipv4 *)&rp->p;
@@ -2266,9 +2256,8 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to,
if (ret == RMAP_DENYMATCH) {
if (IS_RIP_DEBUG_PACKET)
zlog_debug(
- "RIP %s/%d is filtered by route-map out",
- inet_ntoa(p->prefix),
- p->prefixlen);
+ "RIP %pFX is filtered by route-map out",
+ p);
continue;
}
}
@@ -2283,9 +2272,8 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to,
if (ret == RMAP_DENYMATCH) {
if (IS_RIP_DEBUG_PACKET)
zlog_debug(
- "%s/%d is filtered by route-map",
- inet_ntoa(p->prefix),
- p->prefixlen);
+ "%pFX is filtered by route-map",
+ p);
continue;
}
}
@@ -2460,10 +2448,10 @@ static void rip_update_interface(struct connected *ifc, uint8_t version,
to.sin_port = htons(RIP_PORT_DEFAULT);
if (IS_RIP_DEBUG_EVENT)
- zlog_debug("%s announce to %s on %s",
+ zlog_debug("%s announce to %pI4 on %s",
CONNECTED_PEER(ifc) ? "unicast"
: "broadcast",
- inet_ntoa(to.sin_addr), ifp->name);
+ &to.sin_addr, ifp->name);
rip_output_process(ifc, &to, route_type, version);
}
@@ -2538,8 +2526,8 @@ static void rip_update_process(struct rip *rip, int route_type)
rip->vrf->vrf_id);
if (!connected) {
zlog_warn(
- "Neighbor %s doesn't have connected interface!",
- inet_ntoa(p->u.prefix4));
+ "Neighbor %pI4 doesn't have connected interface!",
+ &p->u.prefix4);
continue;
}
@@ -2674,9 +2662,8 @@ void rip_redistribute_withdraw(struct rip *rip, int type)
(struct prefix_ipv4 *)&rp->p;
zlog_debug(
- "Poisone %s/%d on the interface %s with an infinity metric [withdraw]",
- inet_ntoa(p->prefix),
- p->prefixlen,
+ "Poisone %pFX on the interface %s with an infinity metric [withdraw]",
+ p,
ifindex2ifname(
rinfo->nh.ifindex,
rip->vrf->vrf_id));
@@ -2966,8 +2953,7 @@ static void rip_distance_show(struct vty *vty, struct rip *rip)
" Address Distance List\n");
header = 0;
}
- snprintf(buf, sizeof(buf), "%s/%d",
- inet_ntoa(rn->p.u.prefix4), rn->p.prefixlen);
+ snprintfrr(buf, sizeof(buf), "%pFX", &rn->p);
vty_out(vty, " %-20s %4d %s\n", buf,
rdistance->distance,
rdistance->access_list ? rdistance->access_list
@@ -3094,12 +3080,11 @@ DEFUN (show_ip_rip,
int len;
len = vty_out(
- vty, "%c(%s) %s/%d",
+ vty, "%c(%s) %pFX",
/* np->lock, For debugging. */
zebra_route_char(rinfo->type),
rip_route_type_print(rinfo->sub_type),
- inet_ntoa(np->p.u.prefix4),
- np->p.prefixlen);
+ &np->p);
len = 24 - len;
@@ -3109,8 +3094,8 @@ DEFUN (show_ip_rip,
switch (rinfo->nh.type) {
case NEXTHOP_TYPE_IPV4:
case NEXTHOP_TYPE_IPV4_IFINDEX:
- vty_out(vty, "%-20s %2d ",
- inet_ntoa(rinfo->nh.gate.ipv4),
+ vty_out(vty, "%-20pI4 %2d ",
+ &rinfo->nh.gate.ipv4,
rinfo->metric);
break;
case NEXTHOP_TYPE_IFINDEX:
@@ -3134,8 +3119,8 @@ DEFUN (show_ip_rip,
/* Route which exist in kernel routing table. */
if ((rinfo->type == ZEBRA_ROUTE_RIP)
&& (rinfo->sub_type == RIP_ROUTE_RTE)) {
- vty_out(vty, "%-15s ",
- inet_ntoa(rinfo->from));
+ vty_out(vty, "%-15pI4 ",
+ &rinfo->from);
vty_out(vty, "%3" ROUTE_TAG_PRI " ",
(route_tag_t)rinfo->tag);
rip_vty_out_uptime(vty, rinfo);
diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c
index 03c93668b9..16859c2d29 100644
--- a/ripngd/ripng_interface.c
+++ b/ripngd/ripng_interface.c
@@ -375,8 +375,7 @@ int ripng_interface_address_add(ZAPI_CALLBACK_ARGS)
struct ripng_interface *ri = c->ifp->info;
if (IS_RIPNG_DEBUG_ZEBRA)
- zlog_debug("RIPng connected address %s/%d add",
- inet6_ntoa(p->u.prefix6), p->prefixlen);
+ zlog_debug("RIPng connected address %pFX add", p);
/* Check is this prefix needs to be redistributed. */
ripng_apply_address_add(c);
@@ -428,7 +427,6 @@ int ripng_interface_address_delete(ZAPI_CALLBACK_ARGS)
{
struct connected *ifc;
struct prefix *p;
- char buf[INET6_ADDRSTRLEN];
ifc = zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_DELETE,
zclient->ibuf, vrf_id);
@@ -439,10 +437,8 @@ int ripng_interface_address_delete(ZAPI_CALLBACK_ARGS)
if (p->family == AF_INET6) {
if (IS_RIPNG_DEBUG_ZEBRA)
zlog_debug(
- "RIPng connected address %s/%d delete",
- inet_ntop(AF_INET6, &p->u.prefix6, buf,
- INET6_ADDRSTRLEN),
- p->prefixlen);
+ "RIPng connected address %pFX delete",
+ p);
/* Check wether this prefix needs to be removed. */
ripng_apply_address_del(ifc);
diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c
index c2eb7c6ee4..060477010b 100644
--- a/ripngd/ripngd.c
+++ b/ripngd/ripngd.c
@@ -643,8 +643,7 @@ static int ripng_filter(int ripng_distribute, struct prefix_ipv6 *p,
(struct prefix *)p)
== FILTER_DENY) {
if (IS_RIPNG_DEBUG_PACKET)
- zlog_debug("%s/%d filtered by distribute %s",
- inet6_ntoa(p->prefix), p->prefixlen,
+ zlog_debug("%pFX filtered by distribute %s", p,
inout);
return -1;
}
@@ -654,8 +653,7 @@ static int ripng_filter(int ripng_distribute, struct prefix_ipv6 *p,
(struct prefix *)p)
== PREFIX_DENY) {
if (IS_RIPNG_DEBUG_PACKET)
- zlog_debug("%s/%d filtered by prefix-list %s",
- inet6_ntoa(p->prefix), p->prefixlen,
+ zlog_debug("%pFX filtered by prefix-list %s", p,
inout);
return -1;
}
@@ -673,9 +671,8 @@ static int ripng_filter(int ripng_distribute, struct prefix_ipv6 *p,
== FILTER_DENY) {
if (IS_RIPNG_DEBUG_PACKET)
zlog_debug(
- "%s/%d filtered by distribute %s",
- inet6_ntoa(p->prefix),
- p->prefixlen, inout);
+ "%pFX filtered by distribute %s",
+ p, inout);
return -1;
}
}
@@ -689,9 +686,8 @@ static int ripng_filter(int ripng_distribute, struct prefix_ipv6 *p,
== PREFIX_DENY) {
if (IS_RIPNG_DEBUG_PACKET)
zlog_debug(
- "%s/%d filtered by prefix-list %s",
- inet6_ntoa(p->prefix),
- p->prefixlen, inout);
+ "%pFX filtered by prefix-list %s",
+ p, inout);
return -1;
}
}
@@ -997,14 +993,12 @@ void ripng_redistribute_add(struct ripng *ripng, int type, int sub_type,
if (IS_RIPNG_DEBUG_EVENT) {
if (!nexthop)
zlog_debug(
- "Redistribute new prefix %s/%d on the interface %s",
- inet6_ntoa(p->prefix), p->prefixlen,
- ifindex2ifname(ifindex, ripng->vrf->vrf_id));
+ "Redistribute new prefix %pFX on the interface %s",
+ p, ifindex2ifname(ifindex, ripng->vrf->vrf_id));
else
zlog_debug(
- "Redistribute new prefix %s/%d with nexthop %s on the interface %s",
- inet6_ntoa(p->prefix), p->prefixlen,
- inet6_ntoa(*nexthop),
+ "Redistribute new prefix %pFX with nexthop %s on the interface %s",
+ p, inet6_ntoa(*nexthop),
ifindex2ifname(ifindex, ripng->vrf->vrf_id));
}
@@ -1047,9 +1041,8 @@ void ripng_redistribute_delete(struct ripng *ripng, int type, int sub_type,
if (IS_RIPNG_DEBUG_EVENT)
zlog_debug(
- "Poisone %s/%d on the interface %s with an infinity metric [delete]",
- inet6_ntoa(p->prefix),
- p->prefixlen,
+ "Poisone %pFX on the interface %s with an infinity metric [delete]",
+ p,
ifindex2ifname(
ifindex,
ripng->vrf->vrf_id));
@@ -1091,9 +1084,8 @@ void ripng_redistribute_withdraw(struct ripng *ripng, int type)
agg_node_get_prefix(rp);
zlog_debug(
- "Poisone %s/%d on the interface %s [withdraw]",
- inet6_ntoa(p->prefix),
- p->prefixlen,
+ "Poisone %pFX on the interface %s [withdraw]",
+ p,
ifindex2ifname(
rinfo->ifindex,
ripng->vrf->vrf_id));
@@ -1680,9 +1672,8 @@ void ripng_output_process(struct interface *ifp, struct sockaddr_in6 *to,
if (ret == RMAP_DENYMATCH) {
if (IS_RIPNG_DEBUG_PACKET)
zlog_debug(
- "RIPng %s/%d is filtered by route-map out",
- inet6_ntoa(p->prefix),
- p->prefixlen);
+ "RIPng %pFX is filtered by route-map out",
+ p);
continue;
}
}
@@ -1697,9 +1688,8 @@ void ripng_output_process(struct interface *ifp, struct sockaddr_in6 *to,
if (ret == RMAP_DENYMATCH) {
if (IS_RIPNG_DEBUG_PACKET)
zlog_debug(
- "RIPng %s/%d is filtered by route-map",
- inet6_ntoa(p->prefix),
- p->prefixlen);
+ "RIPng %pFX is filtered by route-map",
+ p);
continue;
}
}
@@ -1795,9 +1785,8 @@ void ripng_output_process(struct interface *ifp, struct sockaddr_in6 *to,
if (ret == RMAP_DENYMATCH) {
if (IS_RIPNG_DEBUG_PACKET)
zlog_debug(
- "RIPng %s/%d is filtered by route-map out",
- inet6_ntoa(p->prefix),
- p->prefixlen);
+ "RIPng %pFX is filtered by route-map out",
+ p);
continue;
}
diff --git a/sharpd/sharp_nht.c b/sharpd/sharp_nht.c
index 077e2b29eb..bed0ebfa27 100644
--- a/sharpd/sharp_nht.c
+++ b/sharpd/sharp_nht.c
@@ -60,14 +60,9 @@ void sharp_nh_tracker_dump(struct vty *vty)
struct listnode *node;
struct sharp_nh_tracker *nht;
- for (ALL_LIST_ELEMENTS_RO(sg.nhs, node, nht)) {
- char buf[PREFIX_STRLEN];
-
- vty_out(vty, "%s: Nexthops: %u Updates: %u\n",
- prefix2str(&nht->p, buf, sizeof(buf)),
- nht->nhop_num,
- nht->updates);
- }
+ for (ALL_LIST_ELEMENTS_RO(sg.nhs, node, nht))
+ vty_out(vty, "%pFX: Nexthops: %u Updates: %u\n", &nht->p,
+ nht->nhop_num, nht->updates);
}
PREDECL_RBTREE_UNIQ(sharp_nhg_rb);
diff --git a/sharpd/sharp_vty.c b/sharpd/sharp_vty.c
index 0c3bf7af78..45c0799fa7 100644
--- a/sharpd/sharp_vty.c
+++ b/sharpd/sharp_vty.c
@@ -146,16 +146,12 @@ DEFPY (install_routes_data_dump,
"Data about what is going on\n"
"Route Install/Removal Information\n")
{
- char buf[PREFIX_STRLEN];
struct timeval r;
timersub(&sg.r.t_end, &sg.r.t_start, &r);
- vty_out(vty, "Prefix: %s Total: %u %u %u Time: %jd.%ld\n",
- prefix2str(&sg.r.orig_prefix, buf, sizeof(buf)),
- sg.r.total_routes,
- sg.r.installed_routes,
- sg.r.removed_routes,
- (intmax_t)r.tv_sec, (long)r.tv_usec);
+ vty_out(vty, "Prefix: %pFX Total: %u %u %u Time: %jd.%ld\n",
+ &sg.r.orig_prefix, sg.r.total_routes, sg.r.installed_routes,
+ sg.r.removed_routes, (intmax_t)r.tv_sec, (long)r.tv_usec);
return CMD_SUCCESS;
}
diff --git a/staticd/static_vty.c b/staticd/static_vty.c
index 6608811cc6..e2eb8cb7af 100644
--- a/staticd/static_vty.c
+++ b/staticd/static_vty.c
@@ -365,8 +365,7 @@ int static_config(struct vty *vty, struct static_vrf *svrf, afi_t afi,
switch (nh->type) {
case STATIC_IPV4_GATEWAY:
- vty_out(vty, " %s",
- inet_ntoa(nh->addr.ipv4));
+ vty_out(vty, " %pI4", &nh->addr.ipv4);
break;
case STATIC_IPV6_GATEWAY:
vty_out(vty, " %s",
diff --git a/staticd/static_zebra.c b/staticd/static_zebra.c
index efde3babd1..a9b570de83 100644
--- a/staticd/static_zebra.c
+++ b/staticd/static_zebra.c
@@ -109,24 +109,21 @@ static int route_notify_owner(ZAPI_CALLBACK_ARGS)
struct prefix p;
enum zapi_route_notify_owner note;
uint32_t table_id;
- char buf[PREFIX_STRLEN];
if (!zapi_route_notify_decode(zclient->ibuf, &p, &table_id, &note))
return -1;
- prefix2str(&p, buf, sizeof(buf));
-
switch (note) {
case ZAPI_ROUTE_FAIL_INSTALL:
static_nht_mark_state(&p, vrf_id, STATIC_NOT_INSTALLED);
- zlog_warn("%s: Route %s failed to install for table: %u",
- __func__, buf, table_id);
+ zlog_warn("%s: Route %pFX failed to install for table: %u",
+ __func__, &p, table_id);
break;
case ZAPI_ROUTE_BETTER_ADMIN_WON:
static_nht_mark_state(&p, vrf_id, STATIC_NOT_INSTALLED);
zlog_warn(
- "%s: Route %s over-ridden by better route for table: %u",
- __func__, buf, table_id);
+ "%s: Route %pFX over-ridden by better route for table: %u",
+ __func__, &p, table_id);
break;
case ZAPI_ROUTE_INSTALLED:
static_nht_mark_state(&p, vrf_id, STATIC_INSTALLED);
@@ -136,8 +133,8 @@ static int route_notify_owner(ZAPI_CALLBACK_ARGS)
break;
case ZAPI_ROUTE_REMOVE_FAIL:
static_nht_mark_state(&p, vrf_id, STATIC_INSTALLED);
- zlog_warn("%s: Route %s failure to remove for table: %u",
- __func__, buf, table_id);
+ zlog_warn("%s: Route %pFX failure to remove for table: %u",
+ __func__, &p, table_id);
break;
}
diff --git a/tests/bgpd/test_bgp_table.c b/tests/bgpd/test_bgp_table.c
index 4eb132df55..e899e5b359 100644
--- a/tests/bgpd/test_bgp_table.c
+++ b/tests/bgpd/test_bgp_table.c
@@ -109,10 +109,7 @@ static void check_lookup_result(struct bgp_dest *match, va_list arglist)
if (bgp_dest_has_bgp_path_info_data(dest)
&& !prefix_in_array(dest_p, prefixes, prefix_count)) {
- char buf[PREFIX2STR_BUFFER];
-
- prefix2str(dest_p, buf, PREFIX2STR_BUFFER);
- printf("prefix %s was not expected!\n", buf);
+ printf("prefix %pFX was not expected!\n", dest_p);
assert(0);
}
}
diff --git a/tests/lib/cli/test_cli.c b/tests/lib/cli/test_cli.c
index 8f062d8b5e..8dba1e29f0 100644
--- a/tests/lib/cli/test_cli.c
+++ b/tests/lib/cli/test_cli.c
@@ -47,12 +47,10 @@ DEFPY(magic_test, magic_test_cmd,
"magic (0-100) {ipv4net A.B.C.D/M|X:X::X:X$ipv6}",
"1\n2\n3\n4\n5\n")
{
- char buf[256];
vty_out(vty, "def: %s\n", self->string);
vty_out(vty, "num: %ld\n", magic);
- vty_out(vty, "ipv4: %s\n", prefix2str(ipv4net, buf, sizeof(buf)));
- vty_out(vty, "ipv6: %s\n",
- inet_ntop(AF_INET6, &ipv6, buf, sizeof(buf)));
+ vty_out(vty, "ipv4: %pFX\n", ipv4net);
+ vty_out(vty, "ipv6: %pI6\n", &ipv6);
return CMD_SUCCESS;
}
diff --git a/tests/lib/test_srcdest_table.c b/tests/lib/test_srcdest_table.c
index dbfe853365..097da113ab 100644
--- a/tests/lib/test_srcdest_table.c
+++ b/tests/lib/test_srcdest_table.c
@@ -271,7 +271,7 @@ static void test_state_verify(struct test_state *test)
associated with rn */
expected_lock++;
- if (rn->lock != expected_lock)
+ if (route_node_get_lock_count(rn) != expected_lock)
test_failed(
test,
"Dest rnode lock count doesn't match expected count!",
@@ -283,7 +283,7 @@ static void test_state_verify(struct test_state *test)
!= NULL) /* The route node is not internal */
expected_lock++;
- if (rn->lock != expected_lock) {
+ if (route_node_get_lock_count(rn) != expected_lock) {
srcdest_rnode_prefixes(
rn, (const struct prefix **)&dst_p,
(const struct prefix **)&src_p);
diff --git a/tests/lib/test_table.c b/tests/lib/test_table.c
index 90d6c76bf1..290657bd56 100644
--- a/tests/lib/test_table.c
+++ b/tests/lib/test_table.c
@@ -104,7 +104,6 @@ static void add_nodes(struct route_table *table, ...)
static void print_subtree(struct route_node *rn, const char *legend,
int indent_level)
{
- char buf[PREFIX2STR_BUFFER];
int i;
/*
@@ -114,8 +113,7 @@ static void print_subtree(struct route_node *rn, const char *legend,
printf(" ");
}
- prefix2str(&rn->p, buf, sizeof(buf));
- printf("%s: %s", legend, buf);
+ printf("%s: %pFX", legend, &rn->p);
if (!rn->info) {
printf(" (internal)");
}
diff --git a/tests/topotests/bfd-isis-topo1/rt1/isisd.conf b/tests/topotests/bfd-isis-topo1/rt1/isisd.conf
index 3219371d2e..8026aad49d 100644
--- a/tests/topotests/bfd-isis-topo1/rt1/isisd.conf
+++ b/tests/topotests/bfd-isis-topo1/rt1/isisd.conf
@@ -30,6 +30,7 @@ interface eth-rt3
isis bfd
!
router isis 1
+ lsp-gen-interval 2
net 49.0000.0000.0000.0001.00
is-type level-1
!
diff --git a/tests/topotests/bfd-isis-topo1/rt2/isisd.conf b/tests/topotests/bfd-isis-topo1/rt2/isisd.conf
index 63ccb640a4..b0fde64a5e 100644
--- a/tests/topotests/bfd-isis-topo1/rt2/isisd.conf
+++ b/tests/topotests/bfd-isis-topo1/rt2/isisd.conf
@@ -25,6 +25,7 @@ interface eth-rt5
isis hello-multiplier 3
!
router isis 1
+ lsp-gen-interval 2
net 49.0000.0000.0000.0002.00
is-type level-1
!
diff --git a/tests/topotests/bfd-isis-topo1/rt3/isisd.conf b/tests/topotests/bfd-isis-topo1/rt3/isisd.conf
index 928f1e1a2b..5c36e96c0f 100644
--- a/tests/topotests/bfd-isis-topo1/rt3/isisd.conf
+++ b/tests/topotests/bfd-isis-topo1/rt3/isisd.conf
@@ -26,6 +26,7 @@ interface eth-rt4
isis hello-multiplier 3
!
router isis 1
+ lsp-gen-interval 2
net 49.0000.0000.0000.0003.00
is-type level-1
!
diff --git a/tests/topotests/bfd-isis-topo1/rt4/isisd.conf b/tests/topotests/bfd-isis-topo1/rt4/isisd.conf
index fde97478a9..3eac407776 100644
--- a/tests/topotests/bfd-isis-topo1/rt4/isisd.conf
+++ b/tests/topotests/bfd-isis-topo1/rt4/isisd.conf
@@ -24,6 +24,7 @@ interface eth-rt5
isis hello-multiplier 3
!
router isis 1
+ lsp-gen-interval 2
net 49.0000.0000.0000.0004.00
is-type level-1
!
diff --git a/tests/topotests/bfd-isis-topo1/rt5/isisd.conf b/tests/topotests/bfd-isis-topo1/rt5/isisd.conf
index fd00cb1ddb..5d449f6f93 100644
--- a/tests/topotests/bfd-isis-topo1/rt5/isisd.conf
+++ b/tests/topotests/bfd-isis-topo1/rt5/isisd.conf
@@ -24,6 +24,7 @@ interface eth-rt4
isis hello-multiplier 3
!
router isis 1
+ lsp-gen-interval 2
net 49.0000.0000.0000.0005.00
is-type level-1
!
diff --git a/tests/topotests/bfd-profiles-topo1/r3/isisd.conf b/tests/topotests/bfd-profiles-topo1/r3/isisd.conf
index d27a783adf..ca965e3956 100644
--- a/tests/topotests/bfd-profiles-topo1/r3/isisd.conf
+++ b/tests/topotests/bfd-profiles-topo1/r3/isisd.conf
@@ -11,6 +11,7 @@ interface r3-eth1
isis bfd profile fasttx
!
router isis lan
+ lsp-gen-interval 2
net 10.0000.0000.0000.0000.0000.0000.0000.0000.0001.00
redistribute ipv6 connected level-1
!
diff --git a/tests/topotests/bfd-profiles-topo1/r4/isisd.conf b/tests/topotests/bfd-profiles-topo1/r4/isisd.conf
index 01e197bed5..d8ffc9bc2c 100644
--- a/tests/topotests/bfd-profiles-topo1/r4/isisd.conf
+++ b/tests/topotests/bfd-profiles-topo1/r4/isisd.conf
@@ -11,6 +11,7 @@ interface r4-eth0
isis bfd profile DOES_NOT_EXIST
!
router isis lan
+ lsp-gen-interval 2
net 10.0000.0000.0000.0000.0000.0000.0000.0000.0002.00
redistribute ipv6 connected level-1
!
diff --git a/tests/topotests/isis-sr-topo1/rt1/isisd.conf b/tests/topotests/isis-sr-topo1/rt1/isisd.conf
index 26ec4eb261..f441527597 100644
--- a/tests/topotests/isis-sr-topo1/rt1/isisd.conf
+++ b/tests/topotests/isis-sr-topo1/rt1/isisd.conf
@@ -19,9 +19,9 @@ interface eth-sw1
isis hello-multiplier 3
!
router isis 1
+ lsp-gen-interval 2
net 49.0000.0000.0000.0001.00
is-type level-1
- lsp-gen-interval 2
topology ipv6-unicast
segment-routing on
segment-routing global-block 16000 23999
diff --git a/tests/topotests/isis-sr-topo1/rt2/isisd.conf b/tests/topotests/isis-sr-topo1/rt2/isisd.conf
index 8704a28b6c..796b6ed32c 100644
--- a/tests/topotests/isis-sr-topo1/rt2/isisd.conf
+++ b/tests/topotests/isis-sr-topo1/rt2/isisd.conf
@@ -30,9 +30,9 @@ interface eth-rt4-2
isis hello-multiplier 3
!
router isis 1
+ lsp-gen-interval 2
net 49.0000.0000.0000.0002.00
is-type level-1
- lsp-gen-interval 2
topology ipv6-unicast
segment-routing on
segment-routing global-block 16000 23999
diff --git a/tests/topotests/isis-sr-topo1/rt3/isisd.conf b/tests/topotests/isis-sr-topo1/rt3/isisd.conf
index 5a0add22a9..cc2aa1782b 100644
--- a/tests/topotests/isis-sr-topo1/rt3/isisd.conf
+++ b/tests/topotests/isis-sr-topo1/rt3/isisd.conf
@@ -30,9 +30,9 @@ interface eth-rt5-2
isis hello-multiplier 3
!
router isis 1
+ lsp-gen-interval 2
net 49.0000.0000.0000.0003.00
is-type level-1
- lsp-gen-interval 2
topology ipv6-unicast
segment-routing on
segment-routing global-block 17000 24999
diff --git a/tests/topotests/isis-sr-topo1/rt4/isisd.conf b/tests/topotests/isis-sr-topo1/rt4/isisd.conf
index 39003b9d7b..5a110b75fe 100644
--- a/tests/topotests/isis-sr-topo1/rt4/isisd.conf
+++ b/tests/topotests/isis-sr-topo1/rt4/isisd.conf
@@ -37,9 +37,9 @@ interface eth-rt6
isis hello-multiplier 3
!
router isis 1
+ lsp-gen-interval 2
net 49.0000.0000.0000.0004.00
is-type level-1
- lsp-gen-interval 2
topology ipv6-unicast
segment-routing on
segment-routing global-block 16000 23999
diff --git a/tests/topotests/isis-sr-topo1/rt5/isisd.conf b/tests/topotests/isis-sr-topo1/rt5/isisd.conf
index e693ca156c..6845e5bb82 100644
--- a/tests/topotests/isis-sr-topo1/rt5/isisd.conf
+++ b/tests/topotests/isis-sr-topo1/rt5/isisd.conf
@@ -37,9 +37,9 @@ interface eth-rt6
isis hello-multiplier 3
!
router isis 1
+ lsp-gen-interval 2
net 49.0000.0000.0000.0005.00
is-type level-1
- lsp-gen-interval 2
topology ipv6-unicast
segment-routing on
segment-routing global-block 16000 23999
diff --git a/tests/topotests/isis-sr-topo1/rt6/isisd.conf b/tests/topotests/isis-sr-topo1/rt6/isisd.conf
index 3b85dbae4e..a29b78f0a4 100644
--- a/tests/topotests/isis-sr-topo1/rt6/isisd.conf
+++ b/tests/topotests/isis-sr-topo1/rt6/isisd.conf
@@ -25,9 +25,9 @@ interface eth-rt5
isis hello-multiplier 3
!
router isis 1
+ lsp-gen-interval 2
net 49.0000.0000.0000.0006.00
is-type level-1
- lsp-gen-interval 2
topology ipv6-unicast
segment-routing on
segment-routing global-block 16000 23999
diff --git a/tests/topotests/isis-topo1-vrf/r1/isisd.conf b/tests/topotests/isis-topo1-vrf/r1/isisd.conf
index 4ac4597015..5fb4c14d0b 100755
--- a/tests/topotests/isis-topo1-vrf/r1/isisd.conf
+++ b/tests/topotests/isis-topo1-vrf/r1/isisd.conf
@@ -8,6 +8,7 @@ interface r1-eth0
isis circuit-type level-2-only
!
router isis 1 vrf r1-cust1
+ lsp-gen-interval 2
net 10.0000.0000.0000.0000.0000.0000.0000.0000.0000.00
metric-style wide
redistribute ipv4 connected level-2
diff --git a/tests/topotests/isis-topo1-vrf/r2/isisd.conf b/tests/topotests/isis-topo1-vrf/r2/isisd.conf
index 4c68540265..0d2bc7ab72 100755
--- a/tests/topotests/isis-topo1-vrf/r2/isisd.conf
+++ b/tests/topotests/isis-topo1-vrf/r2/isisd.conf
@@ -8,6 +8,7 @@ interface r2-eth0
isis circuit-type level-2-only
!
router isis 1 vrf r2-cust1
+ lsp-gen-interval 2
net 10.0000.0000.0000.0000.0000.0000.0000.0000.0001.00
metric-style wide
redistribute ipv4 connected level-2
diff --git a/tests/topotests/isis-topo1-vrf/r3/isisd.conf b/tests/topotests/isis-topo1-vrf/r3/isisd.conf
index ca01876690..66092407ab 100755
--- a/tests/topotests/isis-topo1-vrf/r3/isisd.conf
+++ b/tests/topotests/isis-topo1-vrf/r3/isisd.conf
@@ -13,6 +13,7 @@ interface r3-eth1
isis circuit-type level-1
!
router isis 1 vrf r3-cust1
+ lsp-gen-interval 2
net 10.0000.0000.0000.0000.0000.0000.0000.0000.0002.00
metric-style wide
redistribute ipv4 connected level-1
diff --git a/tests/topotests/isis-topo1-vrf/r4/isisd.conf b/tests/topotests/isis-topo1-vrf/r4/isisd.conf
index 74b1603d85..05815e8418 100755
--- a/tests/topotests/isis-topo1-vrf/r4/isisd.conf
+++ b/tests/topotests/isis-topo1-vrf/r4/isisd.conf
@@ -16,6 +16,7 @@ interface r4-eth1
isis circuit-type level-1
!
router isis 1 vrf r4-cust1
+ lsp-gen-interval 2
net 10.0000.0000.0000.0000.0000.0000.0000.0000.0004.00
metric-style wide
redistribute ipv4 connected level-1
diff --git a/tests/topotests/isis-topo1-vrf/r5/isisd.conf b/tests/topotests/isis-topo1-vrf/r5/isisd.conf
index 9e9b030455..f663c33fe9 100755
--- a/tests/topotests/isis-topo1-vrf/r5/isisd.conf
+++ b/tests/topotests/isis-topo1-vrf/r5/isisd.conf
@@ -13,6 +13,7 @@ interface r5-eth1
isis circuit-type level-1
!
router isis 1 vrf r5-cust1
+ lsp-gen-interval 2
net 10.0000.0000.0000.0000.0000.0000.0000.0000.0005.00
metric-style wide
is-type level-1
diff --git a/tests/topotests/isis-topo1/r1/isisd.conf b/tests/topotests/isis-topo1/r1/isisd.conf
index ee7dba3692..4e3761e5a1 100644
--- a/tests/topotests/isis-topo1/r1/isisd.conf
+++ b/tests/topotests/isis-topo1/r1/isisd.conf
@@ -4,10 +4,12 @@ debug isis events
debug isis update-packets
interface r1-eth0
ip router isis 1
+ isis hello-interval 2
ipv6 router isis 1
isis circuit-type level-2-only
!
router isis 1
+ lsp-gen-interval 2
net 10.0000.0000.0000.0000.0000.0000.0000.0000.0000.00
metric-style wide
redistribute ipv4 connected level-2
diff --git a/tests/topotests/isis-topo1/r2/isisd.conf b/tests/topotests/isis-topo1/r2/isisd.conf
index f6fee6c845..14db0940ec 100644
--- a/tests/topotests/isis-topo1/r2/isisd.conf
+++ b/tests/topotests/isis-topo1/r2/isisd.conf
@@ -4,10 +4,12 @@ debug isis events
debug isis update-packets
interface r2-eth0
ip router isis 1
+ isis hello-interval 2
ipv6 router isis 1
isis circuit-type level-2-only
!
router isis 1
+ lsp-gen-interval 2
net 10.0000.0000.0000.0000.0000.0000.0000.0000.0001.00
metric-style wide
redistribute ipv4 connected level-2
diff --git a/tests/topotests/isis-topo1/r3/isisd.conf b/tests/topotests/isis-topo1/r3/isisd.conf
index 4ae56b4af4..6f36c0fa36 100644
--- a/tests/topotests/isis-topo1/r3/isisd.conf
+++ b/tests/topotests/isis-topo1/r3/isisd.conf
@@ -4,6 +4,7 @@ debug isis events
debug isis update-packets
interface r3-eth0
ip router isis 1
+ isis hello-interval 2
ipv6 router isis 1
isis circuit-type level-2-only
!
@@ -13,6 +14,7 @@ interface r3-eth1
isis circuit-type level-1
!
router isis 1
+ lsp-gen-interval 2
net 10.0000.0000.0000.0000.0000.0000.0000.0000.0002.00
metric-style wide
redistribute ipv4 connected level-1
diff --git a/tests/topotests/isis-topo1/r4/isisd.conf b/tests/topotests/isis-topo1/r4/isisd.conf
index bf9653387e..502e035f50 100644
--- a/tests/topotests/isis-topo1/r4/isisd.conf
+++ b/tests/topotests/isis-topo1/r4/isisd.conf
@@ -4,6 +4,7 @@ debug isis events
debug isis update-packets
interface r4-eth0
ip router isis 1
+ isis hello-interval 2
ipv6 router isis 1
isis circuit-type level-2-only
!
@@ -13,6 +14,7 @@ interface r4-eth1
isis circuit-type level-1
!
router isis 1
+ lsp-gen-interval 2
net 10.0000.0000.0000.0000.0000.0000.0000.0000.0004.00
metric-style wide
redistribute ipv4 connected level-1
diff --git a/tests/topotests/isis-topo1/r5/isisd.conf b/tests/topotests/isis-topo1/r5/isisd.conf
index 5a044988a9..42493a4991 100644
--- a/tests/topotests/isis-topo1/r5/isisd.conf
+++ b/tests/topotests/isis-topo1/r5/isisd.conf
@@ -4,6 +4,7 @@ debug isis events
debug isis update-packets
interface r5-eth0
ip router isis 1
+ isis hello-interval 2
ipv6 router isis 1
isis circuit-type level-1
!
@@ -13,6 +14,7 @@ interface r5-eth1
isis circuit-type level-1
!
router isis 1
+ lsp-gen-interval 2
net 10.0000.0000.0000.0000.0000.0000.0000.0000.0005.00
metric-style wide
is-type level-1
diff --git a/tests/topotests/ldp-sync-isis-topo1/r1/isisd.conf b/tests/topotests/ldp-sync-isis-topo1/r1/isisd.conf
index af8d117bc1..da2970d94e 100644
--- a/tests/topotests/ldp-sync-isis-topo1/r1/isisd.conf
+++ b/tests/topotests/ldp-sync-isis-topo1/r1/isisd.conf
@@ -6,6 +6,7 @@ debug isis update-packets
debug isis ldp-sync
!
router isis 1
+ lsp-gen-interval 2
net 10.0000.0000.0000.0000.0000.0000.0000.0000.0001.00
metric-style wide
redistribute ipv4 connected level-1
diff --git a/tests/topotests/ldp-sync-isis-topo1/r2/isisd.conf b/tests/topotests/ldp-sync-isis-topo1/r2/isisd.conf
index e477bce827..b29a2b93ee 100644
--- a/tests/topotests/ldp-sync-isis-topo1/r2/isisd.conf
+++ b/tests/topotests/ldp-sync-isis-topo1/r2/isisd.conf
@@ -6,6 +6,7 @@ debug isis update-packets
debug isis ldp-sync
!
router isis 1
+ lsp-gen-interval 2
net 10.0000.0000.0000.0000.0000.0000.0000.0000.0002.00
metric-style wide
redistribute ipv4 connected level-1
diff --git a/tests/topotests/ldp-sync-isis-topo1/r3/isisd.conf b/tests/topotests/ldp-sync-isis-topo1/r3/isisd.conf
index e50fb077ba..4c8499f23d 100644
--- a/tests/topotests/ldp-sync-isis-topo1/r3/isisd.conf
+++ b/tests/topotests/ldp-sync-isis-topo1/r3/isisd.conf
@@ -6,6 +6,7 @@ debug isis update-packets
debug isis ldp-sync
!
router isis 1
+ lsp-gen-interval 2
net 10.0000.0000.0000.0000.0000.0000.0000.0000.0003.00
metric-style wide
redistribute ipv4 connected level-1
diff --git a/yang/frr-nexthop.yang b/yang/frr-nexthop.yang
index 52155dcd16..619514de7d 100644
--- a/yang/frr-nexthop.yang
+++ b/yang/frr-nexthop.yang
@@ -275,7 +275,7 @@ module frr-nexthop {
description
"List of nexthop groups, each contains group of nexthops";
leaf name {
- type nexthop-group-ref;
+ type string;
description
"The nexthop-group name.";
}
diff --git a/zebra/connected.c b/zebra/connected.c
index 8c4ba163bd..6a1efc3e65 100644
--- a/zebra/connected.c
+++ b/zebra/connected.c
@@ -259,14 +259,10 @@ void connected_up(struct interface *ifp, struct connected *ifc)
/* Schedule LSP forwarding entries for processing, if appropriate. */
if (zvrf->vrf->vrf_id == VRF_DEFAULT) {
- if (IS_ZEBRA_DEBUG_MPLS) {
- char buf[PREFIX_STRLEN];
-
+ if (IS_ZEBRA_DEBUG_MPLS)
zlog_debug(
- "%u: IF %s IP %s address add/up, scheduling MPLS processing",
- zvrf->vrf->vrf_id, ifp->name,
- prefix2str(&p, buf, sizeof(buf)));
- }
+ "%u: IF %s IP %pFX address add/up, scheduling MPLS processing",
+ zvrf->vrf->vrf_id, ifp->name, &p);
mpls_mark_lsps_for_processing(zvrf, &p);
}
}
@@ -312,8 +308,8 @@ void connected_add_ipv4(struct interface *ifp, int flags, struct in_addr *addr,
if (IPV4_ADDR_SAME(addr, dest))
flog_warn(
EC_ZEBRA_IFACE_SAME_LOCAL_AS_PEER,
- "warning: interface %s has same local and peer address %s, routing protocols may malfunction",
- ifp->name, inet_ntoa(*addr));
+ "warning: interface %s has same local and peer address %pI4, routing protocols may malfunction",
+ ifp->name, addr);
} else {
zlog_debug(
"warning: %s called for interface %s with peer flag set, but no peer address supplied",
@@ -326,8 +322,8 @@ void connected_add_ipv4(struct interface *ifp, int flags, struct in_addr *addr,
if (!dest && (prefixlen == IPV4_MAX_PREFIXLEN)
&& if_is_pointopoint(ifp))
zlog_debug(
- "warning: PtP interface %s with addr %s/%d needs a peer address",
- ifp->name, inet_ntoa(*addr), prefixlen);
+ "warning: PtP interface %s with addr %pI4/%d needs a peer address",
+ ifp->name, addr, prefixlen);
/* Label of this address. */
if (label)
@@ -400,14 +396,10 @@ void connected_down(struct interface *ifp, struct connected *ifc)
/* Schedule LSP forwarding entries for processing, if appropriate. */
if (zvrf->vrf->vrf_id == VRF_DEFAULT) {
- if (IS_ZEBRA_DEBUG_MPLS) {
- char buf[PREFIX_STRLEN];
-
+ if (IS_ZEBRA_DEBUG_MPLS)
zlog_debug(
- "%u: IF %s IP %s address down, scheduling MPLS processing",
- zvrf->vrf->vrf_id, ifp->name,
- prefix2str(&p, buf, sizeof(buf)));
- }
+ "%u: IF %s IP %pFX address down, scheduling MPLS processing",
+ zvrf->vrf->vrf_id, ifp->name, &p);
mpls_mark_lsps_for_processing(zvrf, &p);
}
}
@@ -424,14 +416,10 @@ static void connected_delete_helper(struct connected *ifc, struct prefix *p)
/* Schedule LSP forwarding entries for processing, if appropriate. */
if (ifp->vrf_id == VRF_DEFAULT) {
- if (IS_ZEBRA_DEBUG_MPLS) {
- char buf[PREFIX_STRLEN];
-
+ if (IS_ZEBRA_DEBUG_MPLS)
zlog_debug(
- "%u: IF %s IP %s address delete, scheduling MPLS processing",
- ifp->vrf_id, ifp->name,
- prefix2str(p, buf, sizeof(buf)));
- }
+ "%u: IF %s IP %pFX address delete, scheduling MPLS processing",
+ ifp->vrf_id, ifp->name, p);
mpls_mark_lsps_for_processing(vrf_info_lookup(ifp->vrf_id), p);
}
}
diff --git a/zebra/interface.c b/zebra/interface.c
index 3210855801..3b7d6f2432 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -1296,8 +1296,6 @@ static void ifs_dump_brief_vty(struct vty *vty, struct vrf *vrf)
bool print_header = true;
FOR_ALL_INTERFACES (vrf, ifp) {
- char global_pfx[PREFIX_STRLEN] = {0};
- char buf[PREFIX_STRLEN] = {0};
bool first_pfx_printed = false;
if (print_header) {
@@ -1329,17 +1327,17 @@ static void ifs_dump_brief_vty(struct vty *vty, struct vrf *vrf)
if (!CHECK_FLAG(connected->flags,
ZEBRA_IFA_SECONDARY)) {
p = connected->address;
- prefix2str(p, buf, sizeof(buf));
if (first_pfx_printed) {
- /* padding to prepare row only for ip addr */
+ /* padding to prepare row only
+ * for ip addr */
vty_out(vty, "%-40s", "");
if (list_size > 1)
vty_out(vty, "+ ");
- vty_out(vty, "%s\n", buf);
+ vty_out(vty, "%pFX\n", p);
} else {
if (list_size > 1)
vty_out(vty, "+ ");
- vty_out(vty, "%s\n", buf);
+ vty_out(vty, "%pFX\n", p);
}
first_pfx_printed = true;
break;
@@ -1361,17 +1359,17 @@ static void ifs_dump_brief_vty(struct vty *vty, struct vrf *vrf)
p = connected->address;
/* Don't print link local pfx */
if (!IN6_IS_ADDR_LINKLOCAL(&p->u.prefix6)) {
- prefix2str(p, global_pfx, PREFIX_STRLEN);
if (first_pfx_printed) {
- /* padding to prepare row only for ip addr */
+ /* padding to prepare row only
+ * for ip addr */
vty_out(vty, "%-40s", "");
if (v6_list_size > 1)
vty_out(vty, "+ ");
- vty_out(vty, "%s\n", global_pfx);
+ vty_out(vty, "%pFX\n", p);
} else {
if (v6_list_size > 1)
vty_out(vty, "+ ");
- vty_out(vty, "%s\n", global_pfx);
+ vty_out(vty, "%pFX\n", p);
}
first_pfx_printed = true;
break;
@@ -1496,14 +1494,14 @@ static void if_dump_vty(struct vty *vty, struct interface *ifp)
vxlan_info = &zebra_if->l2info.vxl;
vty_out(vty, " VxLAN Id %u", vxlan_info->vni);
if (vxlan_info->vtep_ip.s_addr != INADDR_ANY)
- vty_out(vty, " VTEP IP: %s",
- inet_ntoa(vxlan_info->vtep_ip));
+ vty_out(vty, " VTEP IP: %pI4",
+ &vxlan_info->vtep_ip);
if (vxlan_info->access_vlan)
vty_out(vty, " Access VLAN Id %u\n",
vxlan_info->access_vlan);
if (vxlan_info->mcast_grp.s_addr != INADDR_ANY)
- vty_out(vty, " Mcast Group %s",
- inet_ntoa(vxlan_info->mcast_grp));
+ vty_out(vty, " Mcast Group %pI4",
+ &vxlan_info->mcast_grp);
if (vxlan_info->ifindex_link &&
(vxlan_info->link_nsid != NS_UNKNOWN)) {
struct interface *ifp;
@@ -1609,8 +1607,8 @@ static void if_dump_vty(struct vty *vty, struct interface *ifp)
vty_out(vty, " Utilized Bandwidth %g (Byte/s)\n",
iflp->use_bw);
if (IS_PARAM_SET(iflp, LP_RMT_AS))
- vty_out(vty, " Neighbor ASBR IP: %s AS: %u \n",
- inet_ntoa(iflp->rmt_ip), iflp->rmt_as);
+ vty_out(vty, " Neighbor ASBR IP: %pI4 AS: %u \n",
+ &iflp->rmt_ip, iflp->rmt_as);
}
hook_call(zebra_if_extra_info, vty, ifp);
@@ -3498,7 +3496,7 @@ static int link_params_config_write(struct vty *vty, struct interface *ifp)
if (IS_PARAM_SET(iflp, LP_USE_BW))
vty_out(vty, " use-bw %g\n", iflp->use_bw);
if (IS_PARAM_SET(iflp, LP_RMT_AS))
- vty_out(vty, " neighbor %s as %u\n", inet_ntoa(iflp->rmt_ip),
+ vty_out(vty, " neighbor %pI4 as %u\n", &iflp->rmt_ip,
iflp->rmt_as);
vty_out(vty, " exit-link-params\n");
return 0;
diff --git a/zebra/irdp_main.c b/zebra/irdp_main.c
index b868d23a94..710a32c452 100644
--- a/zebra/irdp_main.c
+++ b/zebra/irdp_main.c
@@ -175,7 +175,6 @@ static void irdp_send(struct interface *ifp, struct prefix *p, struct stream *s)
{
struct zebra_if *zi = ifp->info;
struct irdp_interface *irdp = zi->irdp;
- char buf[PREFIX_STRLEN];
uint32_t dst;
uint32_t ttl = 1;
@@ -190,10 +189,11 @@ static void irdp_send(struct interface *ifp, struct prefix *p, struct stream *s)
dst = htonl(INADDR_ALLHOSTS_GROUP);
if (irdp->flags & IF_DEBUG_MESSAGES)
- zlog_debug("IRDP: TX Advert on %s %s Holdtime=%d Preference=%d",
- ifp->name, prefix2str(p, buf, sizeof(buf)),
- irdp->flags & IF_SHUTDOWN ? 0 : irdp->Lifetime,
- get_pref(irdp, p));
+ zlog_debug(
+ "IRDP: TX Advert on %s %pFX Holdtime=%d Preference=%d",
+ ifp->name, p,
+ irdp->flags & IF_SHUTDOWN ? 0 : irdp->Lifetime,
+ get_pref(irdp, p));
send_packet(ifp, s, dst, p, ttl);
}
diff --git a/zebra/irdp_packet.c b/zebra/irdp_packet.c
index 502a2f277c..56fd35a736 100644
--- a/zebra/irdp_packet.c
+++ b/zebra/irdp_packet.c
@@ -79,6 +79,7 @@ static void parse_irdp_packet(char *p, int len, struct interface *ifp)
struct zebra_if *zi;
struct irdp_interface *irdp;
uint16_t saved_chksum;
+ char buf[PREFIX_STRLEN];
zi = ifp->info;
if (!zi)
@@ -104,8 +105,8 @@ static void parse_irdp_packet(char *p, int len, struct interface *ifp)
if (iplen < ICMP_MINLEN) {
flog_err(EC_ZEBRA_IRDP_LEN_MISMATCH,
- "IRDP: RX ICMP packet too short from %s\n",
- inet_ntoa(src));
+ "IRDP: RX ICMP packet too short from %pI4\n",
+ &src);
return;
}
@@ -115,8 +116,8 @@ static void parse_irdp_packet(char *p, int len, struct interface *ifp)
len of IP-header) 14+20 */
if (iplen > IRDP_RX_BUF - 34) {
flog_err(EC_ZEBRA_IRDP_LEN_MISMATCH,
- "IRDP: RX ICMP packet too long from %s\n",
- inet_ntoa(src));
+ "IRDP: RX ICMP packet too long from %pI4\n",
+ &src);
return;
}
@@ -128,8 +129,8 @@ static void parse_irdp_packet(char *p, int len, struct interface *ifp)
if (in_cksum(icmp, datalen) != saved_chksum) {
flog_warn(
EC_ZEBRA_IRDP_BAD_CHECKSUM,
- "IRDP: RX ICMP packet from %s. Bad checksum, silently ignored",
- inet_ntoa(src));
+ "IRDP: RX ICMP packet from %pI4 Bad checksum, silently ignored",
+ &src);
return;
}
@@ -141,8 +142,8 @@ static void parse_irdp_packet(char *p, int len, struct interface *ifp)
if (icmp->code != 0) {
flog_warn(
EC_ZEBRA_IRDP_BAD_TYPE_CODE,
- "IRDP: RX packet type %d from %s. Bad ICMP type code, silently ignored",
- icmp->type, inet_ntoa(src));
+ "IRDP: RX packet type %d from %pI4 Bad ICMP type code, silently ignored",
+ icmp->type, &src);
return;
}
@@ -152,11 +153,12 @@ static void parse_irdp_packet(char *p, int len, struct interface *ifp)
&& !(irdp->flags & IF_BROADCAST))) {
flog_warn(
EC_ZEBRA_IRDP_BAD_RX_FLAGS,
- "IRDP: RX illegal from %s to %s while %s operates in %s; Please correct settings\n",
- inet_ntoa(src),
+ "IRDP: RX illegal from %pI4 to %s while %s operates in %s; Please correct settings\n",
+ &src,
ntohl(ip->ip_dst.s_addr) == INADDR_ALLRTRS_GROUP
? "multicast"
- : inet_ntoa(ip->ip_dst),
+ : inet_ntop(AF_INET, &ip->ip_dst,
+ buf, sizeof(buf)),
ifp->name,
irdp->flags & IF_BROADCAST ? "broadcast" : "multicast");
return;
@@ -169,8 +171,8 @@ static void parse_irdp_packet(char *p, int len, struct interface *ifp)
case ICMP_ROUTERSOLICIT:
if (irdp->flags & IF_DEBUG_MESSAGES)
- zlog_debug("IRDP: RX Solicit on %s from %s",
- ifp->name, inet_ntoa(src));
+ zlog_debug("IRDP: RX Solicit on %s from %pI4",
+ ifp->name, &src);
process_solicit(ifp);
break;
@@ -178,8 +180,8 @@ static void parse_irdp_packet(char *p, int len, struct interface *ifp)
default:
flog_warn(
EC_ZEBRA_IRDP_BAD_TYPE_CODE,
- "IRDP: RX packet type %d from %s. Bad ICMP type code, silently ignored",
- icmp->type, inet_ntoa(src));
+ "IRDP: RX packet type %d from %pI4 Bad ICMP type code, silently ignored",
+ icmp->type, &src);
}
}
diff --git a/zebra/redistribute.c b/zebra/redistribute.c
index c0f89e6afe..1f075cfb4b 100644
--- a/zebra/redistribute.c
+++ b/zebra/redistribute.c
@@ -119,18 +119,17 @@ static void zebra_redistribute(struct zserv *client, int type,
for (rn = route_top(table); rn; rn = srcdest_route_next(rn))
RNODE_FOREACH_RE (rn, newre) {
const struct prefix *dst_p, *src_p;
- char buf[PREFIX_STRLEN];
srcdest_rnode_prefixes(rn, &dst_p, &src_p);
if (IS_ZEBRA_DEBUG_RIB)
zlog_debug(
- "%s: client %s %s(%u) checking: selected=%d, type=%d, distance=%d, metric=%d zebra_check_addr=%d",
+ "%s: client %s %pFX(%u) checking: selected=%d, type=%d, distance=%d, metric=%d zebra_check_addr=%d",
__func__,
zebra_route_string(client->proto),
- prefix2str(dst_p, buf, sizeof(buf)),
- vrf_id, CHECK_FLAG(newre->flags,
- ZEBRA_FLAG_SELECTED),
+ dst_p, vrf_id,
+ CHECK_FLAG(newre->flags,
+ ZEBRA_FLAG_SELECTED),
newre->type, newre->distance,
newre->metric, zebra_check_addr(dst_p));
@@ -196,15 +195,13 @@ void redistribute_update(const struct prefix *p, const struct prefix *src_p,
struct listnode *node, *nnode;
struct zserv *client;
int afi;
- char buf[PREFIX_STRLEN];
- if (IS_ZEBRA_DEBUG_RIB) {
+ if (IS_ZEBRA_DEBUG_RIB)
zlog_debug(
- "(%u:%u):%s: Redist update re %p (%s), old %p (%s)",
- re->vrf_id, re->table, prefix2str(p, buf, sizeof(buf)),
- re, zebra_route_string(re->type), prev_re,
+ "(%u:%u):%pFX: Redist update re %p (%s), old %p (%s)",
+ re->vrf_id, re->table, p, re,
+ zebra_route_string(re->type), prev_re,
prev_re ? zebra_route_string(prev_re->type) : "None");
- }
afi = family2afi(p->family);
if (!afi) {
@@ -214,8 +211,7 @@ void redistribute_update(const struct prefix *p, const struct prefix *src_p,
}
if (!zebra_check_addr(p)) {
if (IS_ZEBRA_DEBUG_RIB)
- zlog_debug("Redist update filter prefix %s",
- prefix2str(p, buf, sizeof(buf)));
+ zlog_debug("Redist update filter prefix %pFX", p);
return;
}
@@ -224,10 +220,9 @@ void redistribute_update(const struct prefix *p, const struct prefix *src_p,
if (zebra_redistribute_check(re, client, p, afi)) {
if (IS_ZEBRA_DEBUG_RIB) {
zlog_debug(
- "%s: client %s %s(%u:%u), type=%d, distance=%d, metric=%d",
+ "%s: client %s %pFX(%u:%u), type=%d, distance=%d, metric=%d",
__func__,
- zebra_route_string(client->proto),
- prefix2str(p, buf, sizeof(buf)),
+ zebra_route_string(client->proto), p,
re->vrf_id, re->table, re->type,
re->distance, re->metric);
}
@@ -254,7 +249,6 @@ void redistribute_delete(const struct prefix *p, const struct prefix *src_p,
struct listnode *node, *nnode;
struct zserv *client;
int afi;
- char buf[PREFIX_STRLEN];
vrf_id_t vrfid;
if (old_re)
@@ -265,13 +259,11 @@ void redistribute_delete(const struct prefix *p, const struct prefix *src_p,
return;
if (IS_ZEBRA_DEBUG_RIB) {
- zlog_debug(
- "%u:%s: Redist del: re %p (%s), new re %p (%s)",
- vrfid, prefix2str(p, buf, sizeof(buf)),
- old_re,
- old_re ? zebra_route_string(old_re->type) : "None",
- new_re,
- new_re ? zebra_route_string(new_re->type) : "None");
+ zlog_debug("%u:%pFX: Redist del: re %p (%s), new re %p (%s)",
+ vrfid, p, old_re,
+ old_re ? zebra_route_string(old_re->type) : "None",
+ new_re,
+ new_re ? zebra_route_string(new_re->type) : "None");
}
/* Add DISTANCE_INFINITY check. */
@@ -293,8 +285,8 @@ void redistribute_delete(const struct prefix *p, const struct prefix *src_p,
if (!zebra_check_addr(p)) {
if (IS_ZEBRA_DEBUG_RIB) {
zlog_debug(
- "%u:%s: Redist del old: skipping invalid prefix",
- vrfid, prefix2str(p, buf, sizeof(buf)));
+ "%u:%pFX: Redist del old: skipping invalid prefix",
+ vrfid, p);
}
return;
}
@@ -541,12 +533,10 @@ void zebra_interface_address_add_update(struct interface *ifp,
struct prefix *p;
if (IS_ZEBRA_DEBUG_EVENT) {
- char buf[PREFIX_STRLEN];
-
p = ifc->address;
- zlog_debug("MESSAGE: ZEBRA_INTERFACE_ADDRESS_ADD %s on %s(%u)",
- prefix2str(p, buf, sizeof(buf)), ifp->name,
- ifp->vrf_id);
+ zlog_debug(
+ "MESSAGE: ZEBRA_INTERFACE_ADDRESS_ADD %pFX on %s(%u)",
+ p, ifp->name, ifp->vrf_id);
}
if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_REAL))
@@ -580,12 +570,10 @@ void zebra_interface_address_delete_update(struct interface *ifp,
struct prefix *p;
if (IS_ZEBRA_DEBUG_EVENT) {
- char buf[PREFIX_STRLEN];
-
p = ifc->address;
- zlog_debug("MESSAGE: ZEBRA_INTERFACE_ADDRESS_DELETE %s on %s(%u)",
- prefix2str(p, buf, sizeof(buf)),
- ifp->name, ifp->vrf_id);
+ zlog_debug(
+ "MESSAGE: ZEBRA_INTERFACE_ADDRESS_DELETE %pFX on %s(%u)",
+ p, ifp->name, ifp->vrf_id);
}
zebra_vxlan_add_del_gw_macip(ifp, ifc->address, 0);
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index 1ce3c435fe..da0eeb364e 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -731,11 +731,10 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
p.prefixlen = rtm->rtm_dst_len;
if (rtm->rtm_src_len != 0) {
- char buf[PREFIX_STRLEN];
flog_warn(
EC_ZEBRA_UNSUPPORTED_V4_SRCDEST,
- "unsupported IPv4 sourcedest route (dest %s vrf %u)",
- prefix2str(&p, buf, sizeof(buf)), vrf_id);
+ "unsupported IPv4 sourcedest route (dest %pFX vrf %u)",
+ &p, vrf_id);
return 0;
}
@@ -786,12 +785,11 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
}
if (IS_ZEBRA_DEBUG_KERNEL) {
- char buf[PREFIX_STRLEN];
char buf2[PREFIX_STRLEN];
+
zlog_debug(
- "%s %s%s%s vrf %s(%u) table_id: %u metric: %d Admin Distance: %d",
- nl_msg_type_to_str(h->nlmsg_type),
- prefix2str(&p, buf, sizeof(buf)),
+ "%s %pFX%s%s vrf %s(%u) table_id: %u metric: %d Admin Distance: %d",
+ nl_msg_type_to_str(h->nlmsg_type), &p,
src_p.prefixlen ? " from " : "",
src_p.prefixlen ? prefix2str(&src_p, buf2, sizeof(buf2))
: "",
@@ -905,8 +903,6 @@ static int netlink_route_change_read_multicast(struct nlmsghdr *h,
int count;
int oif[256];
int oif_count = 0;
- char sbuf[40];
- char gbuf[40];
char oif_list[256] = "\0";
vrf_id_t vrf;
int table;
@@ -968,8 +964,6 @@ static int netlink_route_change_read_multicast(struct nlmsghdr *h,
struct interface *ifp = NULL;
struct zebra_vrf *zvrf = NULL;
- strlcpy(sbuf, inet_ntoa(m->sg.src), sizeof(sbuf));
- strlcpy(gbuf, inet_ntoa(m->sg.grp), sizeof(gbuf));
for (count = 0; count < oif_count; count++) {
ifp = if_lookup_by_index(oif[count], vrf);
char temp[256];
@@ -981,9 +975,10 @@ static int netlink_route_change_read_multicast(struct nlmsghdr *h,
zvrf = zebra_vrf_lookup_by_id(vrf);
ifp = if_lookup_by_index(iif, vrf);
zlog_debug(
- "MCAST VRF: %s(%d) %s (%s,%s) IIF: %s(%d) OIF: %s jiffies: %lld",
+ "MCAST VRF: %s(%d) %s (%pI4,%pI4) IIF: %s(%d) OIF: %s jiffies: %lld",
zvrf_name(zvrf), vrf, nl_msg_type_to_str(h->nlmsg_type),
- sbuf, gbuf, ifp ? ifp->name : "Unknown", iif, oif_list,
+ &m->sg.src, &m->sg.grp, ifp ? ifp->name : "Unknown",
+ iif, oif_list,
m->lastused);
}
return 0;
@@ -2892,8 +2887,8 @@ static int netlink_macfdb_change(struct nlmsghdr *h, int len, ns_id_t ns_id)
dst_present = 1;
memcpy(&vtep_ip.s_addr, RTA_DATA(tb[NDA_DST]),
IPV4_MAX_BYTELEN);
- snprintf(dst_buf, sizeof(dst_buf), " dst %s",
- inet_ntoa(vtep_ip));
+ snprintfrr(dst_buf, sizeof(dst_buf), " dst %pI4",
+ &vtep_ip);
}
if (tb[NDA_NH_ID])
@@ -3950,8 +3945,8 @@ static int netlink_fdb_nh_update(uint32_t nh_id, struct in_addr vtep_ip)
return -1;
if (IS_ZEBRA_DEBUG_KERNEL || IS_ZEBRA_DEBUG_EVPN_MH_NH) {
- zlog_debug("Tx %s fdb-nh 0x%x %s",
- nl_msg_type_to_str(cmd), nh_id, inet_ntoa(vtep_ip));
+ zlog_debug("Tx %s fdb-nh 0x%x %pI4",
+ nl_msg_type_to_str(cmd), nh_id, &vtep_ip);
}
return netlink_talk(netlink_talk_filter, &req.n, &zns->netlink_cmd, zns,
diff --git a/zebra/rt_socket.c b/zebra/rt_socket.c
index a2e15cbd2b..a0f401c334 100644
--- a/zebra/rt_socket.c
+++ b/zebra/rt_socket.c
@@ -80,19 +80,15 @@ static int kernel_rtm(int cmd, const struct prefix *p,
bool gate = false;
int error;
char gate_buf[INET6_BUFSIZ];
- char prefix_buf[PREFIX_STRLEN];
enum blackhole_type bh_type = BLACKHOLE_UNSPEC;
- prefix2str(p, prefix_buf, sizeof(prefix_buf));
-
/*
* We only have the ability to ADD or DELETE at this point
* in time.
*/
if (cmd != RTM_ADD && cmd != RTM_DELETE) {
if (IS_ZEBRA_DEBUG_KERNEL)
- zlog_debug("%s: %s odd command %s",
- __func__, prefix_buf,
+ zlog_debug("%s: %pFX odd command %s", __func__, p,
lookup_msg(rtm_type_str, cmd, NULL));
return 0;
}
@@ -237,8 +233,8 @@ static int kernel_rtm(int cmd, const struct prefix *p,
if (IS_ZEBRA_DEBUG_KERNEL) {
if (!gate) {
zlog_debug(
- "%s: %s: attention! gate not found for re",
- __func__, prefix_buf);
+ "%s: %pFX: attention! gate not found for re",
+ __func__, p);
} else {
switch (p->family) {
case AF_INET:
@@ -266,8 +262,8 @@ static int kernel_rtm(int cmd, const struct prefix *p,
case ZEBRA_ERR_NOERROR:
nexthop_num++;
if (IS_ZEBRA_DEBUG_KERNEL)
- zlog_debug("%s: %s: successfully did NH %s",
- __func__, prefix_buf, gate_buf);
+ zlog_debug("%s: %pFX: successfully did NH %s",
+ __func__, p, gate_buf);
if (cmd == RTM_ADD)
SET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);
break;
@@ -289,8 +285,8 @@ static int kernel_rtm(int cmd, const struct prefix *p,
default:
flog_err(
EC_LIB_SYSTEM_CALL,
- "%s: %s: rtm_write() unexpectedly returned %d for command %s",
- __func__, prefix_buf, error,
+ "%s: %pFX: rtm_write() unexpectedly returned %d for command %s",
+ __func__, p, error,
lookup_msg(rtm_type_str, cmd, NULL));
break;
}
@@ -300,8 +296,8 @@ static int kernel_rtm(int cmd, const struct prefix *p,
if (nexthop_num == 0) {
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug(
- "%s: No useful nexthops were found in RIB prefix %s",
- __func__, prefix_buf);
+ "%s: No useful nexthops were found in RIB prefix %pFX",
+ __func__, p);
return 1;
}
diff --git a/zebra/rtadv.c b/zebra/rtadv.c
index 13b7c150a3..c3add16c56 100644
--- a/zebra/rtadv.c
+++ b/zebra/rtadv.c
@@ -2337,7 +2337,6 @@ static int rtadv_config_write(struct vty *vty, struct interface *ifp)
struct rtadv_prefix *rprefix;
struct rtadv_rdnss *rdnss;
struct rtadv_dnssl *dnssl;
- char buf[PREFIX_STRLEN];
int interval;
zif = ifp->info;
@@ -2408,8 +2407,7 @@ static int rtadv_config_write(struct vty *vty, struct interface *ifp)
for (ALL_LIST_ELEMENTS_RO(zif->rtadv.AdvPrefixList, node, rprefix)) {
if ((rprefix->AdvPrefixCreate == PREFIX_SRC_MANUAL)
|| (rprefix->AdvPrefixCreate == PREFIX_SRC_BOTH)) {
- vty_out(vty, " ipv6 nd prefix %s",
- prefix2str(&rprefix->prefix, buf, sizeof(buf)));
+ vty_out(vty, " ipv6 nd prefix %pFX", &rprefix->prefix);
if ((rprefix->AdvValidLifetime != RTADV_VALID_LIFETIME)
|| (rprefix->AdvPreferredLifetime
!= RTADV_PREFERRED_LIFETIME)) {
diff --git a/zebra/rule_netlink.c b/zebra/rule_netlink.c
index d6a34327a6..a63504992e 100644
--- a/zebra/rule_netlink.c
+++ b/zebra/rule_netlink.c
@@ -75,8 +75,6 @@ netlink_rule_msg_encode(int cmd, const struct zebra_dplane_ctx *ctx,
} *req = buf;
const char *ifname = dplane_ctx_rule_get_ifname(ctx);
- char buf1[PREFIX_STRLEN];
- char buf2[PREFIX_STRLEN];
if (buflen < sizeof(*req))
return 0;
@@ -141,11 +139,9 @@ netlink_rule_msg_encode(int cmd, const struct zebra_dplane_ctx *ctx,
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug(
- "Tx %s family %s IF %s Pref %u Fwmark %u Src %s Dst %s Table %u",
+ "Tx %s family %s IF %s Pref %u Fwmark %u Src %pFX Dst %pFX Table %u",
nl_msg_type_to_str(cmd), nl_family_to_str(family),
- ifname, priority, fwmark,
- prefix2str(src_ip, buf1, sizeof(buf1)),
- prefix2str(dst_ip, buf2, sizeof(buf2)), table);
+ ifname, priority, fwmark, src_ip, dst_ip, table);
return NLMSG_ALIGN(req->n.nlmsg_len);
}
@@ -231,8 +227,6 @@ int netlink_rule_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
int len;
char *ifname;
struct zebra_pbr_rule rule = {};
- char buf1[PREFIX_STRLEN];
- char buf2[PREFIX_STRLEN];
uint8_t proto = 0;
/* Basic validation followed by extracting attributes. */
@@ -324,17 +318,14 @@ int netlink_rule_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
ret = dplane_pbr_rule_delete(&rule);
zlog_debug(
- "%s: %s leftover rule: family %s IF %s Pref %u Src %s Dst %s Table %u",
+ "%s: %s leftover rule: family %s IF %s Pref %u Src %pFX Dst %pFX Table %u",
__func__,
((ret == ZEBRA_DPLANE_REQUEST_FAILURE)
? "Failed to remove"
: "Removed"),
nl_family_to_str(frh->family), rule.ifname,
- rule.rule.priority,
- prefix2str(&rule.rule.filter.src_ip, buf1,
- sizeof(buf1)),
- prefix2str(&rule.rule.filter.dst_ip, buf2,
- sizeof(buf2)),
+ rule.rule.priority, &rule.rule.filter.src_ip,
+ &rule.rule.filter.dst_ip,
rule.rule.action.table);
}
@@ -350,15 +341,11 @@ int netlink_rule_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug(
- "Rx %s family %s IF %s Pref %u Src %s Dst %s Table %u",
+ "Rx %s family %s IF %s Pref %u Src %pFX Dst %pFX Table %u",
nl_msg_type_to_str(h->nlmsg_type),
nl_family_to_str(frh->family), rule.ifname,
- rule.rule.priority,
- prefix2str(&rule.rule.filter.src_ip, buf1,
- sizeof(buf1)),
- prefix2str(&rule.rule.filter.dst_ip, buf2,
- sizeof(buf2)),
- rule.rule.action.table);
+ rule.rule.priority, &rule.rule.filter.src_ip,
+ &rule.rule.filter.dst_ip, rule.rule.action.table);
return kernel_pbr_rule_del(&rule);
}
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c
index c33bca3d86..18017c9700 100644
--- a/zebra/zapi_msg.c
+++ b/zebra/zapi_msg.c
@@ -644,17 +644,12 @@ int zsend_redistribute_route(int cmd, struct zserv *client,
return -1;
}
- if (IS_ZEBRA_DEBUG_SEND) {
- char buf_prefix[PREFIX_STRLEN];
-
- prefix2str(&api.prefix, buf_prefix, sizeof(buf_prefix));
-
- zlog_debug("%s: %s to client %s: type %s, vrf_id %d, p %s",
+ if (IS_ZEBRA_DEBUG_SEND)
+ zlog_debug("%s: %s to client %s: type %s, vrf_id %d, p %pFX",
__func__, zserv_command_string(cmd),
zebra_route_string(client->proto),
zebra_route_string(api.type), api.vrf_id,
- buf_prefix);
- }
+ &api.prefix);
return zserv_send_message(client, s);
}
@@ -755,26 +750,18 @@ static int route_notify_internal(const struct prefix *p, int type,
client = zserv_find_client(type, instance);
if (!client || !client->notify_owner) {
- if (IS_ZEBRA_DEBUG_PACKET) {
- char buff[PREFIX_STRLEN];
-
+ if (IS_ZEBRA_DEBUG_PACKET)
zlog_debug(
- "Not Notifying Owner: %s about prefix %s(%u) %d vrf: %u",
- zebra_route_string(type),
- prefix2str(p, buff, sizeof(buff)), table_id,
- note, vrf_id);
- }
+ "Not Notifying Owner: %s about prefix %pFX(%u) %d vrf: %u",
+ zebra_route_string(type), p, table_id, note,
+ vrf_id);
return 0;
}
- if (IS_ZEBRA_DEBUG_PACKET) {
- char buff[PREFIX_STRLEN];
-
- zlog_debug("Notifying Owner: %s about prefix %s(%u) %d vrf: %u",
- zebra_route_string(type),
- prefix2str(p, buff, sizeof(buff)), table_id, note,
- vrf_id);
- }
+ if (IS_ZEBRA_DEBUG_PACKET)
+ zlog_debug(
+ "Notifying Owner: %s about prefix %pFX(%u) %d vrf: %u",
+ zebra_route_string(type), p, table_id, note, vrf_id);
s = stream_new(ZEBRA_MAX_PACKET_SIZ);
stream_reset(s);
@@ -1903,14 +1890,10 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
vrf_id = zvrf_id(zvrf);
- if (IS_ZEBRA_DEBUG_RECV) {
- char buf_prefix[PREFIX_STRLEN];
-
- prefix2str(&api.prefix, buf_prefix, sizeof(buf_prefix));
- zlog_debug("%s: p=(%u:%u)%s, msg flags=0x%x, flags=0x%x",
- __func__, vrf_id, api.tableid, buf_prefix,
+ if (IS_ZEBRA_DEBUG_RECV)
+ zlog_debug("%s: p=(%u:%u)%pFX, msg flags=0x%x, flags=0x%x",
+ __func__, vrf_id, api.tableid, &api.prefix,
(int)api.message, api.flags);
- }
/* Allocate new route. */
re = XCALLOC(MTYPE_RE, sizeof(struct route_entry));
@@ -2068,14 +2051,10 @@ static void zread_route_del(ZAPI_HANDLER_ARGS)
else
table_id = zvrf->table_id;
- if (IS_ZEBRA_DEBUG_RECV) {
- char buf_prefix[PREFIX_STRLEN];
-
- prefix2str(&api.prefix, buf_prefix, sizeof(buf_prefix));
- zlog_debug("%s: p=(%u:%u)%s, msg flags=0x%x, flags=0x%x",
- __func__, zvrf_id(zvrf), table_id, buf_prefix,
+ if (IS_ZEBRA_DEBUG_RECV)
+ zlog_debug("%s: p=(%u:%u)%pFX, msg flags=0x%x, flags=0x%x",
+ __func__, zvrf_id(zvrf), table_id, &api.prefix,
(int)api.message, api.flags);
- }
rib_delete(afi, api.safi, zvrf_id(zvrf), api.type, api.instance,
api.flags, &api.prefix, src_p, NULL, 0, table_id, api.metric,
diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c
index 76d7d00e4a..e93444d22e 100644
--- a/zebra/zebra_dplane.c
+++ b/zebra/zebra_dplane.c
@@ -2224,20 +2224,14 @@ static int dplane_ctx_rule_init(struct zebra_dplane_ctx *ctx,
struct zebra_pbr_rule *new_rule,
struct zebra_pbr_rule *old_rule)
{
- if (IS_ZEBRA_DEBUG_DPLANE_DETAIL) {
- char buf1[PREFIX_STRLEN];
- char buf2[PREFIX_STRLEN];
-
+ if (IS_ZEBRA_DEBUG_DPLANE_DETAIL)
zlog_debug(
- "init dplane ctx %s: IF %s Prio %u Fwmark %u Src %s Dst %s Table %u",
+ "init dplane ctx %s: IF %s Prio %u Fwmark %u Src %pFX Dst %pFX Table %u",
dplane_op2str(op), new_rule->ifname,
new_rule->rule.priority, new_rule->rule.filter.fwmark,
- prefix2str(&new_rule->rule.filter.src_ip, buf1,
- sizeof(buf1)),
- prefix2str(&new_rule->rule.filter.dst_ip, buf2,
- sizeof(buf2)),
+ &new_rule->rule.filter.src_ip,
+ &new_rule->rule.filter.dst_ip,
new_rule->rule.action.table);
- }
ctx->zd_op = op;
ctx->zd_status = ZEBRA_DPLANE_REQUEST_SUCCESS;
@@ -2895,15 +2889,10 @@ static enum zebra_dplane_result intf_addr_update_internal(
struct zebra_dplane_ctx *ctx = NULL;
struct zebra_ns *zns;
- if (IS_ZEBRA_DEBUG_DPLANE_DETAIL) {
- char addr_str[PREFIX_STRLEN];
-
- prefix2str(ifc->address, addr_str, sizeof(addr_str));
-
- zlog_debug("init intf ctx %s: idx %d, addr %u:%s",
+ if (IS_ZEBRA_DEBUG_DPLANE_DETAIL)
+ zlog_debug("init intf ctx %s: idx %d, addr %u:%pFX",
dplane_op2str(op), ifp->ifindex, ifp->vrf_id,
- addr_str);
- }
+ ifc->address);
ctx = dplane_ctx_alloc();
@@ -3220,8 +3209,8 @@ enum zebra_dplane_result dplane_vtep_add(const struct interface *ifp,
struct ipaddr addr;
if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_debug("Install %s into flood list for VNI %u intf %s(%u)",
- inet_ntoa(*ip), vni, ifp->name, ifp->ifindex);
+ zlog_debug("Install %pI4 into flood list for VNI %u intf %s(%u)",
+ ip, vni, ifp->name, ifp->ifindex);
SET_IPADDR_V4(&addr);
addr.ipaddr_v4 = *ip;
@@ -3245,8 +3234,8 @@ enum zebra_dplane_result dplane_vtep_delete(const struct interface *ifp,
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug(
- "Uninstall %s from flood list for VNI %u intf %s(%u)",
- inet_ntoa(*ip), vni, ifp->name, ifp->ifindex);
+ "Uninstall %pI4 from flood list for VNI %u intf %s(%u)",
+ ip, vni, ifp->name, ifp->ifindex);
SET_IPADDR_V4(&addr);
addr.ipaddr_v4 = *ip;
@@ -3773,11 +3762,9 @@ static void kernel_dplane_log_detail(struct zebra_dplane_ctx *ctx)
case DPLANE_OP_ROUTE_INSTALL:
case DPLANE_OP_ROUTE_UPDATE:
case DPLANE_OP_ROUTE_DELETE:
- prefix2str(dplane_ctx_get_dest(ctx), buf, sizeof(buf));
-
- zlog_debug("%u:%s Dplane route update ctx %p op %s",
- dplane_ctx_get_vrf(ctx), buf, ctx,
- dplane_op2str(dplane_ctx_get_op(ctx)));
+ zlog_debug("%u:%pFX Dplane route update ctx %p op %s",
+ dplane_ctx_get_vrf(ctx), dplane_ctx_get_dest(ctx),
+ ctx, dplane_op2str(dplane_ctx_get_op(ctx)));
break;
case DPLANE_OP_NH_INSTALL:
@@ -3804,11 +3791,10 @@ static void kernel_dplane_log_detail(struct zebra_dplane_ctx *ctx)
case DPLANE_OP_ADDR_INSTALL:
case DPLANE_OP_ADDR_UNINSTALL:
- prefix2str(dplane_ctx_get_intf_addr(ctx), buf, sizeof(buf));
-
- zlog_debug("Dplane intf %s, idx %u, addr %s",
+ zlog_debug("Dplane intf %s, idx %u, addr %pFX",
dplane_op2str(dplane_ctx_get_op(ctx)),
- dplane_ctx_get_ifindex(ctx), buf);
+ dplane_ctx_get_ifindex(ctx),
+ dplane_ctx_get_intf_addr(ctx));
break;
case DPLANE_OP_MAC_INSTALL:
diff --git a/zebra/zebra_evpn.c b/zebra/zebra_evpn.c
index 56699c4e83..6722af117c 100644
--- a/zebra/zebra_evpn.c
+++ b/zebra/zebra_evpn.c
@@ -109,6 +109,7 @@ void zebra_evpn_print(zebra_evpn_t *zevpn, void **ctxt)
json_object *json = NULL;
json_object *json_vtep_list = NULL;
json_object *json_ip_str = NULL;
+ char buf[PREFIX_STRLEN];
vty = ctxt[0];
json = ctxt[1];
@@ -134,18 +135,20 @@ void zebra_evpn_print(zebra_evpn_t *zevpn, void **ctxt)
if (json == NULL) {
vty_out(vty, " VxLAN interface: %s\n", zevpn->vxlan_if->name);
vty_out(vty, " VxLAN ifIndex: %u\n", zevpn->vxlan_if->ifindex);
- vty_out(vty, " Local VTEP IP: %s\n",
- inet_ntoa(zevpn->local_vtep_ip));
- vty_out(vty, " Mcast group: %s\n",
- inet_ntoa(zevpn->mcast_grp));
+ vty_out(vty, " Local VTEP IP: %pI4\n",
+ &zevpn->local_vtep_ip);
+ vty_out(vty, " Mcast group: %pI4\n",
+ &zevpn->mcast_grp);
} else {
json_object_string_add(json, "vxlanInterface",
zevpn->vxlan_if->name);
json_object_int_add(json, "ifindex", zevpn->vxlan_if->ifindex);
json_object_string_add(json, "vtepIp",
- inet_ntoa(zevpn->local_vtep_ip));
+ inet_ntop(AF_INET, &zevpn->local_vtep_ip,
+ buf, sizeof(buf)));
json_object_string_add(json, "mcastGroup",
- inet_ntoa(zevpn->mcast_grp));
+ inet_ntop(AF_INET, &zevpn->mcast_grp,
+ buf, sizeof(buf)));
json_object_string_add(json, "advertiseGatewayMacip",
zevpn->advertise_gw_macip ? "Yes" : "No");
json_object_int_add(json, "numMacs", num_macs);
@@ -165,12 +168,14 @@ void zebra_evpn_print(zebra_evpn_t *zevpn, void **ctxt)
VXLAN_FLOOD_STR_DEFAULT);
if (json == NULL) {
- vty_out(vty, " %s flood: %s\n",
- inet_ntoa(zvtep->vtep_ip),
+ vty_out(vty, " %pI4 flood: %s\n",
+ &zvtep->vtep_ip,
flood_str);
} else {
json_ip_str = json_object_new_string(
- inet_ntoa(zvtep->vtep_ip));
+ inet_ntop(AF_INET,
+ &zvtep->vtep_ip, buf,
+ sizeof(buf)));
json_object_array_add(json_vtep_list,
json_ip_str);
}
@@ -207,6 +212,7 @@ void zebra_evpn_print_hash(struct hash_bucket *bucket, void *ctxt[])
json_object *json_evpn = NULL;
json_object *json_ip_str = NULL;
json_object *json_vtep_list = NULL;
+ char buf[PREFIX_STRLEN];
vty = ctxt[0];
json = ctxt[1];
@@ -245,7 +251,8 @@ void zebra_evpn_print_hash(struct hash_bucket *bucket, void *ctxt[])
json_vtep_list = json_object_new_array();
for (zvtep = zevpn->vteps; zvtep; zvtep = zvtep->next) {
json_ip_str = json_object_new_string(
- inet_ntoa(zvtep->vtep_ip));
+ inet_ntop(AF_INET, &zvtep->vtep_ip, buf,
+ sizeof(buf)));
json_object_array_add(json_vtep_list,
json_ip_str);
}
@@ -349,7 +356,6 @@ static int ip_prefix_send_to_client(vrf_id_t vrf_id, struct prefix *p,
{
struct zserv *client = NULL;
struct stream *s = NULL;
- char buf[PREFIX_STRLEN];
client = zserv_find_client(ZEBRA_ROUTE_BGP, 0);
/* BGP may not be running. */
@@ -365,8 +371,7 @@ static int ip_prefix_send_to_client(vrf_id_t vrf_id, struct prefix *p,
stream_putw_at(s, 0, stream_get_endp(s));
if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_debug("Send ip prefix %s %s on vrf %s",
- prefix2str(p, buf, sizeof(buf)),
+ zlog_debug("Send ip prefix %pFX %s on vrf %s", p,
(cmd == ZEBRA_IP_PREFIX_ROUTE_ADD) ? "ADD" : "DEL",
vrf_id_to_name(vrf_id));
@@ -1076,8 +1081,8 @@ int zebra_evpn_send_add_to_client(zebra_evpn_t *zevpn)
stream_putw_at(s, 0, stream_get_endp(s));
if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_debug("Send EVPN_ADD %u %s tenant vrf %s to %s", zevpn->vni,
- inet_ntoa(zevpn->local_vtep_ip),
+ zlog_debug("Send EVPN_ADD %u %pI4 tenant vrf %s to %s", zevpn->vni,
+ &zevpn->local_vtep_ip,
vrf_id_to_name(zevpn->vrf_id),
zebra_route_string(client->proto));
diff --git a/zebra/zebra_evpn_mac.c b/zebra/zebra_evpn_mac.c
index 75031ddba6..8e9a1a4e8e 100644
--- a/zebra/zebra_evpn_mac.c
+++ b/zebra/zebra_evpn_mac.c
@@ -417,11 +417,11 @@ static void zebra_evpn_dup_addr_detect_for_mac(struct zebra_vrf *zvrf,
if (mac->dad_count >= zvrf->dad_max_moves) {
flog_warn(EC_ZEBRA_DUP_MAC_DETECTED,
- "VNI %u: MAC %s detected as duplicate during %s VTEP %s",
+ "VNI %u: MAC %s detected as duplicate during %s VTEP %pI4",
mac->zevpn->vni,
prefix_mac2str(&mac->macaddr, buf, sizeof(buf)),
is_local ? "local update, last" :
- "remote update, from", inet_ntoa(vtep_ip));
+ "remote update, from", &vtep_ip);
SET_FLAG(mac->flags, ZEBRA_MAC_DUPLICATE);
@@ -485,6 +485,7 @@ void zebra_evpn_print_mac(zebra_mac_t *mac, void *ctxt, json_object *json)
struct listnode *node = NULL;
char buf1[ETHER_ADDR_STRLEN];
char buf2[INET6_ADDRSTRLEN];
+ char addr_buf[PREFIX_STRLEN];
struct zebra_vrf *zvrf;
struct timeval detect_start_time = {0, 0};
char timebuf[MONOTIME_STRLEN];
@@ -518,7 +519,8 @@ void zebra_evpn_print_mac(zebra_mac_t *mac, void *ctxt, json_object *json)
json_object_string_add(json_mac, "type", "remote");
json_object_string_add(
json_mac, "remoteVtep",
- inet_ntoa(mac->fwd_info.r_vtep_ip));
+ inet_ntop(AF_INET, &mac->fwd_info.r_vtep_ip,
+ addr_buf, sizeof(addr_buf)));
} else if (CHECK_FLAG(mac->flags, ZEBRA_MAC_AUTO))
json_object_string_add(json_mac, "type", "auto");
@@ -617,8 +619,8 @@ void zebra_evpn_print_mac(zebra_mac_t *mac, void *ctxt, json_object *json)
vty_out(vty, " Remote ES: %s",
mac->es->esi_str);
else
- vty_out(vty, " Remote VTEP: %s",
- inet_ntoa(mac->fwd_info.r_vtep_ip));
+ vty_out(vty, " Remote VTEP: %pI4",
+ &mac->fwd_info.r_vtep_ip);
} else if (CHECK_FLAG(mac->flags, ZEBRA_MAC_AUTO)) {
vty_out(vty, " Auto Mac ");
}
@@ -709,6 +711,7 @@ void zebra_evpn_print_mac_hash(struct hash_bucket *bucket, void *ctxt)
json_object *json_mac_hdr = NULL, *json_mac = NULL;
zebra_mac_t *mac;
char buf1[ETHER_ADDR_STRLEN];
+ char addr_buf[PREFIX_STRLEN];
struct mac_walk_ctx *wctx = ctxt;
char flags_buf[6];
@@ -785,18 +788,22 @@ void zebra_evpn_print_mac_hash(struct hash_bucket *bucket, void *ctxt)
"Intf/Remote ES/VTEP", "VLAN",
"Seq #'s");
}
+ if (mac->es == NULL)
+ inet_ntop(AF_INET, &mac->fwd_info.r_vtep_ip,
+ addr_buf, sizeof(addr_buf));
+
vty_out(vty, "%-17s %-6s %-5s %-30s %-5s %u/%u\n", buf1,
"remote",
zebra_evpn_print_mac_flags(mac, flags_buf,
- sizeof(flags_buf)),
- mac->es ? mac->es->esi_str
- : inet_ntoa(mac->fwd_info.r_vtep_ip),
+ sizeof(flags_buf)),
+ mac->es ? mac->es->esi_str : addr_buf,
"", mac->loc_seq, mac->rem_seq);
} else {
json_object_string_add(json_mac, "type", "remote");
json_object_string_add(
json_mac, "remoteVtep",
- inet_ntoa(mac->fwd_info.r_vtep_ip));
+ inet_ntop(AF_INET, &mac->fwd_info.r_vtep_ip,
+ addr_buf, sizeof(addr_buf)));
json_object_object_add(json_mac_hdr, buf1, json_mac);
json_object_int_add(json_mac, "localSequence",
mac->loc_seq);
@@ -1769,10 +1776,10 @@ int process_mac_remote_macip_add(zebra_evpn_t *zevpn, struct zebra_vrf *zvrf,
mac = zebra_evpn_mac_add(zevpn, macaddr);
if (!mac) {
zlog_warn(
- "Failed to add MAC %s VNI %u Remote VTEP %s",
+ "Failed to add MAC %s VNI %u Remote VTEP %pI4",
prefix_mac2str(macaddr, buf,
sizeof(buf)),
- zevpn->vni, inet_ntoa(vtep_ip));
+ zevpn->vni, &vtep_ip);
return -1;
}
@@ -2028,10 +2035,10 @@ int zebra_evpn_add_update_local_mac(struct zebra_vrf *zvrf, zebra_evpn_t *zevpn,
if (CHECK_FLAG(mac->flags, ZEBRA_MAC_STICKY)) {
flog_warn(
EC_ZEBRA_STICKY_MAC_ALREADY_LEARNT,
- "MAC %s already learnt as remote sticky MAC behind VTEP %s VNI %u",
+ "MAC %s already learnt as remote sticky MAC behind VTEP %pI4 VNI %u",
prefix_mac2str(macaddr, buf,
sizeof(buf)),
- inet_ntoa(mac->fwd_info.r_vtep_ip),
+ &mac->fwd_info.r_vtep_ip,
zevpn->vni);
return 0;
}
diff --git a/zebra/zebra_evpn_mh.c b/zebra/zebra_evpn_mh.c
index a406884187..dad019731b 100644
--- a/zebra/zebra_evpn_mh.c
+++ b/zebra/zebra_evpn_mh.c
@@ -919,9 +919,9 @@ static void zebra_evpn_nh_add(struct zebra_evpn_es_vtep *es_vtep)
return;
if (IS_ZEBRA_DEBUG_EVPN_MH_NH)
- zlog_debug("es %s vtep %s nh 0x%x add",
+ zlog_debug("es %s vtep %pI4 nh 0x%x add",
es_vtep->es->esi_str,
- inet_ntoa(es_vtep->vtep_ip), es_vtep->nh_id);
+ &es_vtep->vtep_ip, es_vtep->nh_id);
/* install the NH */
kernel_upd_mac_nh(es_vtep->nh_id, es_vtep->vtep_ip);
/* add the NH to the parent NHG */
@@ -936,9 +936,9 @@ static void zebra_evpn_nh_del(struct zebra_evpn_es_vtep *es_vtep)
return;
if (IS_ZEBRA_DEBUG_EVPN_MH_NH)
- zlog_debug("es %s vtep %s nh 0x%x del",
+ zlog_debug("es %s vtep %pI4 nh 0x%x del",
es_vtep->es->esi_str,
- inet_ntoa(es_vtep->vtep_ip), es_vtep->nh_id);
+ &es_vtep->vtep_ip, es_vtep->nh_id);
nh_id = es_vtep->nh_id;
es_vtep->nh_id = 0;
@@ -1024,8 +1024,8 @@ static void zebra_evpn_es_vtep_add(struct zebra_evpn_es *es,
if (!es_vtep) {
if (IS_ZEBRA_DEBUG_EVPN_MH_ES)
- zlog_debug("es %s vtep %s add",
- es->esi_str, inet_ntoa(vtep_ip));
+ zlog_debug("es %s vtep %pI4 add",
+ es->esi_str, &vtep_ip);
es_vtep = zebra_evpn_es_vtep_new(es, vtep_ip);
/* update the L2-NHG associated with the ES */
zebra_evpn_nh_add(es_vtep);
@@ -1041,8 +1041,8 @@ static void zebra_evpn_es_vtep_del(struct zebra_evpn_es *es,
if (es_vtep) {
if (IS_ZEBRA_DEBUG_EVPN_MH_ES)
- zlog_debug("es %s vtep %s del",
- es->esi_str, inet_ntoa(vtep_ip));
+ zlog_debug("es %s vtep %pI4 del",
+ es->esi_str, &vtep_ip);
zebra_evpn_es_vtep_free(es_vtep);
}
}
@@ -1168,9 +1168,9 @@ static int zebra_evpn_es_send_add_to_client(struct zebra_evpn_es *es)
stream_putw_at(s, 0, stream_get_endp(s));
if (IS_ZEBRA_DEBUG_EVPN_MH_ES)
- zlog_debug("send add local es %s %s to %s",
+ zlog_debug("send add local es %s %pI4 to %s",
es->esi_str,
- inet_ntoa(zmh_info->es_originator_ip),
+ &zmh_info->es_originator_ip,
zebra_route_string(client->proto));
client->local_es_add_cnt++;
@@ -1498,9 +1498,8 @@ static int zebra_evpn_remote_es_del(esi_t *esi, struct in_addr vtep_ip)
struct zebra_evpn_es *es;
if (IS_ZEBRA_DEBUG_EVPN_MH_ES)
- zlog_debug("remote es %s vtep %s del",
- esi_to_str(esi, buf, sizeof(buf)),
- inet_ntoa(vtep_ip));
+ zlog_debug("remote es %s vtep %pI4 del",
+ esi_to_str(esi, buf, sizeof(buf)), &vtep_ip);
es = zebra_evpn_es_find(esi);
if (!es) {
@@ -1525,9 +1524,9 @@ static void zebra_evpn_remote_es_flush(struct zebra_evpn_es **esp)
for (ALL_LIST_ELEMENTS(es->es_vtep_list, node, nnode, es_vtep)) {
if (IS_ZEBRA_DEBUG_EVPN_MH_ES)
- zlog_debug("es %s vtep %s flush",
+ zlog_debug("es %s vtep %pI4 flush",
es->esi_str,
- inet_ntoa(es_vtep->vtep_ip));
+ &es_vtep->vtep_ip);
zebra_evpn_es_vtep_free(es_vtep);
}
zebra_evpn_es_remote_info_re_eval(esp);
@@ -1539,9 +1538,8 @@ static int zebra_evpn_remote_es_add(esi_t *esi, struct in_addr vtep_ip)
struct zebra_evpn_es *es;
if (IS_ZEBRA_DEBUG_EVPN_MH_ES)
- zlog_debug("remote es %s vtep %s add",
- esi_to_str(esi, buf, sizeof(buf)),
- inet_ntoa(vtep_ip));
+ zlog_debug("remote es %s vtep %pI4 add",
+ esi_to_str(esi, buf, sizeof(buf)), &vtep_ip);
es = zebra_evpn_es_find(esi);
if (!es) {
@@ -1756,17 +1754,20 @@ static char *zebra_evpn_es_vtep_str(char *vtep_str, struct zebra_evpn_es *es,
{
struct zebra_evpn_es_vtep *zvtep;
struct listnode *node;
+ char buf[PREFIX_STRLEN];
bool first = true;
vtep_str[0] = '\0';
for (ALL_LIST_ELEMENTS_RO(es->es_vtep_list, node, zvtep)) {
if (first) {
first = false;
- strlcat(vtep_str, inet_ntoa(zvtep->vtep_ip),
+ strlcat(vtep_str, inet_ntop(AF_INET, &zvtep->vtep_ip,
+ buf, sizeof(buf)),
vtep_str_size);
} else {
strlcat(vtep_str, ",", vtep_str_size);
- strlcat(vtep_str, inet_ntoa(zvtep->vtep_ip),
+ strlcat(vtep_str, inet_ntop(AF_INET, &zvtep->vtep_ip,
+ buf, sizeof(buf)),
vtep_str_size);
}
}
@@ -1832,8 +1833,8 @@ static void zebra_evpn_es_show_entry_detail(struct vty *vty,
vty_out(vty, " Nexthop group: 0x%x\n", es->nhg_id);
vty_out(vty, " VTEPs:\n");
for (ALL_LIST_ELEMENTS_RO(es->es_vtep_list, node, zvtep))
- vty_out(vty, " %s nh: 0x%x\n",
- inet_ntoa(zvtep->vtep_ip),
+ vty_out(vty, " %pI4 nh: 0x%x\n",
+ &zvtep->vtep_ip,
zvtep->nh_id);
vty_out(vty, "\n");
@@ -2029,8 +2030,8 @@ void zebra_evpn_es_set_base_evpn(zebra_evpn_t *zevpn)
zmh_info->es_base_evpn->local_vtep_ip.s_addr;
if (IS_ZEBRA_DEBUG_EVPN_MH_ES)
- zlog_debug("es originator ip set to %s",
- inet_ntoa(zmh_info->es_base_evpn->local_vtep_ip));
+ zlog_debug("es originator ip set to %pI4",
+ &zmh_info->es_base_evpn->local_vtep_ip);
/* if originator ip changes we need to update bgp */
for (ALL_LIST_ELEMENTS_RO(zmh_info->local_es_list, node, es)) {
diff --git a/zebra/zebra_evpn_neigh.c b/zebra/zebra_evpn_neigh.c
index 860dc5b054..bb848255d0 100644
--- a/zebra/zebra_evpn_neigh.c
+++ b/zebra/zebra_evpn_neigh.c
@@ -1283,12 +1283,12 @@ zebra_evpn_dup_addr_detect_for_neigh(struct zebra_vrf *zvrf, zebra_neigh_t *nbr,
if (nbr->dad_count >= zvrf->dad_max_moves) {
flog_warn(
EC_ZEBRA_DUP_IP_DETECTED,
- "VNI %u: MAC %s IP %s detected as duplicate during %s VTEP %s",
+ "VNI %u: MAC %s IP %s detected as duplicate during %s VTEP %pI4",
nbr->zevpn->vni,
prefix_mac2str(&nbr->emac, buf, sizeof(buf)),
ipaddr2str(&nbr->ip, buf1, sizeof(buf1)),
is_local ? "local update, last" : "remote update, from",
- inet_ntoa(vtep_ip));
+ &vtep_ip);
SET_FLAG(nbr->flags, ZEBRA_NEIGH_DUPLICATE);
@@ -1790,6 +1790,7 @@ void zebra_evpn_print_neigh(zebra_neigh_t *n, void *ctxt, json_object *json)
struct vty *vty;
char buf1[ETHER_ADDR_STRLEN];
char buf2[INET6_ADDRSTRLEN];
+ char addr_buf[PREFIX_STRLEN];
const char *type_str;
const char *state_str;
bool flags_present = false;
@@ -1867,11 +1868,13 @@ void zebra_evpn_print_neigh(zebra_neigh_t *n, void *ctxt, json_object *json)
n->mac->es->esi_str);
} else {
if (json)
- json_object_string_add(json, "remoteVtep",
- inet_ntoa(n->r_vtep_ip));
+ json_object_string_add(
+ json, "remoteVtep",
+ inet_ntop(AF_INET, &n->r_vtep_ip,
+ addr_buf, sizeof(addr_buf)));
else
- vty_out(vty, " Remote VTEP: %s\n",
- inet_ntoa(n->r_vtep_ip));
+ vty_out(vty, " Remote VTEP: %pI4\n",
+ &n->r_vtep_ip);
}
}
if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_DEF_GW)) {
@@ -1952,6 +1955,7 @@ void zebra_evpn_print_neigh_hash(struct hash_bucket *bucket, void *ctxt)
zebra_neigh_t *n;
char buf1[ETHER_ADDR_STRLEN];
char buf2[INET6_ADDRSTRLEN];
+ char addr_buf[PREFIX_STRLEN];
struct neigh_walk_ctx *wctx = ctxt;
const char *state_str;
char flags_buf[6];
@@ -2006,12 +2010,16 @@ void zebra_evpn_print_neigh_hash(struct hash_bucket *bucket, void *ctxt)
if ((wctx->flags & SHOW_REMOTE_NEIGH_FROM_VTEP)
&& (wctx->count == 0))
zebra_evpn_print_neigh_hdr(vty, wctx);
+
+ if (n->mac->es == NULL)
+ inet_ntop(AF_INET, &n->r_vtep_ip,
+ addr_buf, sizeof(addr_buf));
+
vty_out(vty, "%*s %-6s %-5s %-8s %-17s %-30s %u/%u\n",
-wctx->addr_width, buf2, "remote",
zebra_evpn_print_neigh_flags(n, flags_buf,
sizeof(flags_buf)), state_str, buf1,
- n->mac->es ? n->mac->es->esi_str
- : inet_ntoa(n->r_vtep_ip),
+ n->mac->es ? n->mac->es->esi_str : addr_buf,
n->loc_seq, n->rem_seq);
} else {
json_object_string_add(json_row, "type", "remote");
@@ -2021,8 +2029,10 @@ void zebra_evpn_print_neigh_hash(struct hash_bucket *bucket, void *ctxt)
json_object_string_add(json_row, "remoteEs",
n->mac->es->esi_str);
else
- json_object_string_add(json_row, "remoteVtep",
- inet_ntoa(n->r_vtep_ip));
+ json_object_string_add(
+ json_row, "remoteVtep",
+ inet_ntop(AF_INET, &n->r_vtep_ip,
+ addr_buf, sizeof(addr_buf)));
if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_DEF_GW))
json_object_boolean_true_add(json_row,
"defaultGateway");
@@ -2133,11 +2143,11 @@ void process_neigh_remote_macip_add(zebra_evpn_t *zevpn, struct zebra_vrf *zvrf,
mac, 0);
if (!n) {
zlog_warn(
- "Failed to add Neigh %s MAC %s VNI %u Remote VTEP %s",
+ "Failed to add Neigh %s MAC %s VNI %u Remote VTEP %pI4",
ipaddr2str(ipaddr, buf1, sizeof(buf1)),
prefix_mac2str(&mac->macaddr, buf,
sizeof(buf)),
- zevpn->vni, inet_ntoa(vtep_ip));
+ zevpn->vni, &vtep_ip);
return;
}
diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c
index f84c8c1fcc..73996c526f 100644
--- a/zebra/zebra_fpm.c
+++ b/zebra/zebra_fpm.c
@@ -1437,7 +1437,6 @@ static inline int zfpm_conn_is_up(void)
static int zfpm_trigger_update(struct route_node *rn, const char *reason)
{
rib_dest_t *dest;
- char buf[PREFIX_STRLEN];
/*
* Ignore if the connection is down. We will update the FPM about
@@ -1454,8 +1453,8 @@ static int zfpm_trigger_update(struct route_node *rn, const char *reason)
}
if (reason) {
- zfpm_debug("%s triggering update to FPM - Reason: %s",
- prefix2str(&rn->p, buf, sizeof(buf)), reason);
+ zfpm_debug("%pFX triggering update to FPM - Reason: %s", &rn->p,
+ reason);
}
SET_FLAG(dest->flags, RIB_DEST_UPDATE_FPM);
@@ -1934,7 +1933,7 @@ static int fpm_remote_srv_write(struct vty *vty)
if ((zfpm_g->fpm_server != FPM_DEFAULT_IP
&& zfpm_g->fpm_server != INADDR_ANY)
|| (zfpm_g->fpm_port != FPM_DEFAULT_PORT && zfpm_g->fpm_port != 0))
- vty_out(vty, "fpm connection ip %s port %d\n", inet_ntoa(in),
+ vty_out(vty, "fpm connection ip %pI4 port %d\n", &in,
zfpm_g->fpm_port);
return 0;
diff --git a/zebra/zebra_fpm_dt.c b/zebra/zebra_fpm_dt.c
index 81437e72f5..e392722030 100644
--- a/zebra/zebra_fpm_dt.c
+++ b/zebra/zebra_fpm_dt.c
@@ -181,6 +181,7 @@ static void zfpm_dt_log_fpm_message(Fpm__Message *msg)
char *if_name;
size_t i;
char buf[INET6_ADDRSTRLEN];
+ char addr_buf[PREFIX_STRLEN];
union g_addr nh_addr;
if (msg->type != FPM__MESSAGE__TYPE__ADD_ROUTE)
@@ -213,7 +214,9 @@ static void zfpm_dt_log_fpm_message(Fpm__Message *msg)
zfpm_debug("Nexthop - if_index: %d (%s), gateway: %s, ",
if_index, if_name ? if_name : "name not specified",
- nexthop->address ? inet_ntoa(nh_addr.ipv4) : "None");
+ nexthop->address ?
+ inet_ntop(AF_INET, &nh_addr.ipv4,
+ addr_buf, sizeof(addr_buf)) : "None");
}
}
diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c
index 2c07413638..44f574073c 100644
--- a/zebra/zebra_fpm_netlink.c
+++ b/zebra/zebra_fpm_netlink.c
@@ -44,41 +44,6 @@
#include "zebra/zebra_vxlan_private.h"
/*
- * addr_to_a
- *
- * Returns string representation of an address of the given AF.
- */
-static inline const char *addr_to_a(uint8_t af, void *addr)
-{
- if (!addr)
- return "<No address>";
-
- switch (af) {
-
- case AF_INET:
- return inet_ntoa(*((struct in_addr *)addr));
- case AF_INET6:
- return inet6_ntoa(*((struct in6_addr *)addr));
- default:
- return "<Addr in unknown AF>";
- }
-}
-
-/*
- * prefix_addr_to_a
- *
- * Convience wrapper that returns a human-readable string for the
- * address in a prefix.
- */
-static const char *prefix_addr_to_a(struct prefix *prefix)
-{
- if (!prefix)
- return "<No address>";
-
- return addr_to_a(prefix->family, &prefix->u.prefix);
-}
-
-/*
* af_addr_size
*
* The size of an address in a given address family.
@@ -525,18 +490,24 @@ static void zfpm_log_route_info(struct netlink_route_info *ri,
{
struct netlink_nh_info *nhi;
unsigned int i;
+ char buf[PREFIX_STRLEN];
- zfpm_debug("%s : %s %s/%d, Proto: %s, Metric: %u", label,
+ zfpm_debug("%s : %s %s, Proto: %s, Metric: %u", label,
nl_msg_type_to_str(ri->nlmsg_type),
- prefix_addr_to_a(ri->prefix), ri->prefix->prefixlen,
+ prefix2str(ri->prefix, buf, sizeof(buf)),
nl_rtproto_to_str(ri->rtm_protocol),
ri->metric ? *ri->metric : 0);
for (i = 0; i < ri->num_nhs; i++) {
nhi = &ri->nhs[i];
+
+ if (ri->af == AF_INET)
+ inet_ntop(AF_INET, &nhi->gateway, buf, sizeof(buf));
+ else
+ inet_ntop(AF_INET6, &nhi->gateway, buf, sizeof(buf));
+
zfpm_debug(" Intf: %u, Gateway: %s, Recursive: %s, Type: %s, Encap type: %s",
- nhi->if_index, addr_to_a(ri->af, nhi->gateway),
- nhi->recursive ? "yes" : "no",
+ nhi->if_index, buf, nhi->recursive ? "yes" : "no",
nexthop_type_to_str(nhi->type),
fpm_nh_encap_type_to_str(nhi->encap_info.encap_type)
);
@@ -621,11 +592,11 @@ int zfpm_netlink_encode_mac(struct fpm_mac_info_t *mac, char *in_buf,
assert(req->hdr.nlmsg_len < in_buf_len);
- zfpm_debug("Tx %s family %s ifindex %u MAC %s DEST %s",
+ zfpm_debug("Tx %s family %s ifindex %u MAC %s DEST %pI4",
nl_msg_type_to_str(req->hdr.nlmsg_type),
nl_family_to_str(req->ndm.ndm_family), req->ndm.ndm_ifindex,
prefix_mac2str(&mac->macaddr, buf1, sizeof(buf1)),
- inet_ntoa(mac->r_vtep_ip));
+ &mac->r_vtep_ip);
return req->hdr.nlmsg_len;
}
diff --git a/zebra/zebra_gr.c b/zebra/zebra_gr.c
index a4f32dbf39..ca6a33cd52 100644
--- a/zebra/zebra_gr.c
+++ b/zebra/zebra_gr.c
@@ -490,19 +490,15 @@ static void zebra_gr_process_route_entry(struct zserv *client,
struct route_node *rn,
struct route_entry *re)
{
- char buf[PREFIX2STR_BUFFER];
-
if ((client == NULL) || (rn == NULL) || (re == NULL))
return;
/* If the route is not refreshed after restart, delete the entry */
if (re->uptime < client->restart_time) {
- if (IS_ZEBRA_DEBUG_RIB) {
- prefix2str(&rn->p, buf, sizeof(buf));
- zlog_debug("%s: Client %s stale route %s is deleted",
+ if (IS_ZEBRA_DEBUG_RIB)
+ zlog_debug("%s: Client %s stale route %pFX is deleted",
__func__, zebra_route_string(client->proto),
- buf);
- }
+ &rn->p);
rib_delnode(rn, re);
}
}
diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c
index e0ad4f1cbe..66aea8936e 100644
--- a/zebra/zebra_mpls.c
+++ b/zebra/zebra_mpls.c
@@ -1502,7 +1502,8 @@ static json_object *nhlfe_json(zebra_nhlfe_t *nhlfe)
case NEXTHOP_TYPE_IPV4:
case NEXTHOP_TYPE_IPV4_IFINDEX:
json_object_string_add(json_nhlfe, "nexthop",
- inet_ntoa(nexthop->gate.ipv4));
+ inet_ntop(AF_INET, &nexthop->gate.ipv4,
+ buf, sizeof(buf)));
break;
case NEXTHOP_TYPE_IPV6:
case NEXTHOP_TYPE_IPV6_IFINDEX:
@@ -1560,7 +1561,7 @@ static void nhlfe_print(zebra_nhlfe_t *nhlfe, struct vty *vty,
switch (nexthop->type) {
case NEXTHOP_TYPE_IPV4:
case NEXTHOP_TYPE_IPV4_IFINDEX:
- vty_out(vty, " via %s", inet_ntoa(nexthop->gate.ipv4));
+ vty_out(vty, " via %pI4", &nexthop->gate.ipv4);
if (nexthop->ifindex)
vty_out(vty, " dev %s",
ifindex2ifname(nexthop->ifindex,
@@ -2362,10 +2363,9 @@ int zebra_mpls_fec_unregister(struct zebra_vrf *zvrf, struct prefix *p,
fec = fec_find(table, p);
if (!fec) {
- prefix2str(p, buf, BUFSIZ);
flog_err(EC_ZEBRA_FEC_RM_FAILED,
- "Failed to find FEC %s upon unregister, client %s",
- buf, zebra_route_string(client->proto));
+ "Failed to find FEC %pFX upon unregister, client %s",
+ p, zebra_route_string(client->proto));
return -1;
}
@@ -2530,9 +2530,8 @@ int zebra_mpls_static_fec_add(struct zebra_vrf *zvrf, struct prefix *p,
fec = fec_add(table, p, in_label, FEC_FLAG_CONFIGURED,
MPLS_INVALID_LABEL_INDEX);
if (!fec) {
- prefix2str(p, buf, BUFSIZ);
flog_err(EC_ZEBRA_FEC_ADD_FAILED,
- "Failed to add FEC %s upon config", buf);
+ "Failed to add FEC %pFX upon config", p);
return -1;
}
@@ -2585,8 +2584,7 @@ int zebra_mpls_static_fec_del(struct zebra_vrf *zvrf, struct prefix *p)
}
if (IS_ZEBRA_DEBUG_MPLS) {
- prefix2str(p, buf, BUFSIZ);
- zlog_debug("Delete fec %s label %u label index %u", buf,
+ zlog_debug("Delete fec %pFX label %u label index %u", p,
fec->label, fec->label_index);
}
@@ -2620,7 +2618,6 @@ int zebra_mpls_write_fec_config(struct vty *vty, struct zebra_vrf *zvrf)
struct route_node *rn;
int af;
zebra_fec_t *fec;
- char buf[BUFSIZ];
int write = 0;
for (af = AFI_IP; af < AFI_MAX; af++) {
@@ -2639,8 +2636,7 @@ int zebra_mpls_write_fec_config(struct vty *vty, struct zebra_vrf *zvrf)
continue;
write = 1;
- prefix2str(&rn->p, buf, BUFSIZ);
- vty_out(vty, "mpls label bind %s %s\n", buf,
+ vty_out(vty, "mpls label bind %pFX %s\n", &rn->p,
label2str(fec->label, lstr, BUFSIZ));
}
}
@@ -2846,7 +2842,7 @@ int mpls_zapi_labels_process(bool add_p, struct zebra_vrf *zvrf,
const struct zapi_labels *zl)
{
int i, counter, ret = 0;
- char buf[NEXTHOP_STRLEN], prefix_buf[PREFIX_STRLEN];
+ char buf[NEXTHOP_STRLEN];
const struct zapi_nexthop *znh;
struct route_table *table;
struct route_node *rn = NULL;
@@ -2910,12 +2906,10 @@ int mpls_zapi_labels_process(bool add_p, struct zebra_vrf *zvrf,
* attempted to manage LSPs before trying to
* find a route/FEC, so we'll continue that way.
*/
- if (IS_ZEBRA_DEBUG_RECV || IS_ZEBRA_DEBUG_MPLS) {
- prefix2str(prefix, prefix_buf,
- sizeof(prefix_buf));
- zlog_debug("%s: FTN update requested: no route for prefix %s",
- __func__, prefix_buf);
- }
+ if (IS_ZEBRA_DEBUG_RECV || IS_ZEBRA_DEBUG_MPLS)
+ zlog_debug(
+ "%s: FTN update requested: no route for prefix %pFX",
+ __func__, prefix);
}
}
@@ -2957,9 +2951,9 @@ int mpls_zapi_labels_process(bool add_p, struct zebra_vrf *zvrf,
counter++;
} else if (IS_ZEBRA_DEBUG_RECV | IS_ZEBRA_DEBUG_MPLS) {
zapi_nexthop2str(znh, buf, sizeof(buf));
- prefix2str(prefix, prefix_buf, sizeof(prefix_buf));
- zlog_debug("%s: Unable to update FEC: prefix %s, label %u, znh %s",
- __func__, prefix_buf, zl->local_label, buf);
+ zlog_debug(
+ "%s: Unable to update FEC: prefix %pFX, label %u, znh %s",
+ __func__, prefix, zl->local_label, buf);
}
}
@@ -3007,9 +3001,9 @@ int mpls_zapi_labels_process(bool add_p, struct zebra_vrf *zvrf,
counter++;
} else if (IS_ZEBRA_DEBUG_RECV | IS_ZEBRA_DEBUG_MPLS) {
zapi_nexthop2str(znh, buf, sizeof(buf));
- prefix2str(prefix, prefix_buf, sizeof(prefix_buf));
- zlog_debug("%s: Unable to update backup FEC: prefix %s, label %u, znh %s",
- __func__, prefix_buf, zl->local_label, buf);
+ zlog_debug(
+ "%s: Unable to update backup FEC: prefix %pFX, label %u, znh %s",
+ __func__, prefix, zl->local_label, buf);
}
}
diff --git a/zebra/zebra_mroute.c b/zebra/zebra_mroute.c
index 583b666e66..3af805558d 100644
--- a/zebra/zebra_mroute.c
+++ b/zebra/zebra_mroute.c
@@ -47,8 +47,8 @@ void zebra_ipmr_route_stats(ZAPI_HANDLER_ARGS)
char sbuf[40];
char gbuf[40];
- strlcpy(sbuf, inet_ntoa(mroute.sg.src), sizeof(sbuf));
- strlcpy(gbuf, inet_ntoa(mroute.sg.grp), sizeof(gbuf));
+ inet_ntop(AF_INET, &mroute.sg.src, sbuf, sizeof(sbuf));
+ inet_ntop(AF_INET, &mroute.sg.grp, gbuf, sizeof(gbuf));
zlog_debug("Asking for (%s,%s)[%s(%u)] mroute information",
sbuf, gbuf, zvrf->vrf->name, zvrf->vrf->vrf_id);
diff --git a/zebra/zebra_nb_config.c b/zebra/zebra_nb_config.c
index b4ed910b4d..f5a85519bb 100644
--- a/zebra/zebra_nb_config.c
+++ b/zebra/zebra_nb_config.c
@@ -21,6 +21,7 @@
#include "lib/log.h"
#include "lib/northbound.h"
+#include "lib/printfrr.h"
#include "libfrr.h"
#include "lib/command.h"
#include "lib/routemap.h"
@@ -839,7 +840,6 @@ int lib_interface_zebra_ip_addrs_create(struct nb_cb_create_args *args)
{
struct interface *ifp;
struct prefix prefix;
- char buf[PREFIX_STRLEN] = {0};
ifp = nb_running_get_entry(args->dnode, NULL, true);
// addr_family = yang_dnode_get_enum(dnode, "./address-family");
@@ -850,15 +850,13 @@ int lib_interface_zebra_ip_addrs_create(struct nb_cb_create_args *args)
case NB_EV_VALIDATE:
if (prefix.family == AF_INET
&& ipv4_martian(&prefix.u.prefix4)) {
- snprintf(args->errmsg, args->errmsg_len,
- "invalid address %s",
- prefix2str(&prefix, buf, sizeof(buf)));
+ snprintfrr(args->errmsg, args->errmsg_len,
+ "invalid address %pFX", &prefix);
return NB_ERR_VALIDATION;
} else if (prefix.family == AF_INET6
&& ipv6_martian(&prefix.u.prefix6)) {
- snprintf(args->errmsg, args->errmsg_len,
- "invalid address %s",
- prefix2str(&prefix, buf, sizeof(buf)));
+ snprintfrr(args->errmsg, args->errmsg_len,
+ "invalid address %pFX", &prefix);
return NB_ERR_VALIDATION;
}
break;
diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c
index de79c59caa..f1f6e7e2bf 100644
--- a/zebra/zebra_nhg.c
+++ b/zebra/zebra_nhg.c
@@ -56,12 +56,12 @@ static bool g_nexthops_enabled = true;
static bool proto_nexthops_only;
static struct nhg_hash_entry *depends_find(const struct nexthop *nh, afi_t afi,
- int type);
+ int type, bool from_dplane);
static void depends_add(struct nhg_connected_tree_head *head,
struct nhg_hash_entry *depend);
static struct nhg_hash_entry *
depends_find_add(struct nhg_connected_tree_head *head, struct nexthop *nh,
- afi_t afi, int type);
+ afi_t afi, int type, bool from_dplane);
static struct nhg_hash_entry *
depends_find_id_add(struct nhg_connected_tree_head *head, uint32_t id);
static void depends_decrement_free(struct nhg_connected_tree_head *head);
@@ -672,7 +672,7 @@ static void handle_recursive_depend(struct nhg_connected_tree_head *nhg_depends,
static bool zebra_nhe_find(struct nhg_hash_entry **nhe, /* return value */
struct nhg_hash_entry *lookup,
struct nhg_connected_tree_head *nhg_depends,
- afi_t afi)
+ afi_t afi, bool from_dplane)
{
bool created = false;
bool recursive = false;
@@ -680,10 +680,11 @@ static bool zebra_nhe_find(struct nhg_hash_entry **nhe, /* return value */
struct nexthop *nh = NULL;
if (IS_ZEBRA_DEBUG_NHG_DETAIL)
- zlog_debug("%s: id %u, lookup %p, vrf %d, type %d, depends %p",
- __func__, lookup->id, lookup,
- lookup->vrf_id, lookup->type,
- nhg_depends);
+ zlog_debug(
+ "%s: id %u, lookup %p, vrf %d, type %d, depends %p%s",
+ __func__, lookup->id, lookup, lookup->vrf_id,
+ lookup->type, nhg_depends,
+ (from_dplane ? " (from dplane)" : ""));
if (lookup->id)
(*nhe) = zebra_nhg_lookup_id(lookup->id);
@@ -705,7 +706,7 @@ static bool zebra_nhe_find(struct nhg_hash_entry **nhe, /* return value */
if (lookup->id == 0)
lookup->id = nhg_get_next_id();
- if (lookup->id < ZEBRA_NHG_PROTO_LOWER) {
+ if (!from_dplane && lookup->id < ZEBRA_NHG_PROTO_LOWER) {
/*
* This is a zebra hashed/owned NHG.
*
@@ -715,7 +716,8 @@ static bool zebra_nhe_find(struct nhg_hash_entry **nhe, /* return value */
zebra_nhg_insert_id(newnhe);
} else {
/*
- * This is upperproto owned NHG and should not be hashed to.
+ * This is upperproto owned NHG or one we read in from dataplane
+ * and should not be hashed to.
*
* It goes in ID table.
*/
@@ -779,7 +781,7 @@ static bool zebra_nhe_find(struct nhg_hash_entry **nhe, /* return value */
"(R)" : "");
depends_find_add(&newnhe->nhg_depends, nh, afi,
- newnhe->type);
+ newnhe->type, from_dplane);
}
}
@@ -820,7 +822,7 @@ static bool zebra_nhe_find(struct nhg_hash_entry **nhe, /* return value */
"(R)" : "");
depends_find_add(&backup_nhe->nhg_depends, nh, afi,
- backup_nhe->type);
+ backup_nhe->type, from_dplane);
}
}
@@ -838,7 +840,8 @@ done:
static bool zebra_nhg_find(struct nhg_hash_entry **nhe, uint32_t id,
struct nexthop_group *nhg,
struct nhg_connected_tree_head *nhg_depends,
- vrf_id_t vrf_id, afi_t afi, int type)
+ vrf_id_t vrf_id, afi_t afi, int type,
+ bool from_dplane)
{
struct nhg_hash_entry lookup = {};
bool created = false;
@@ -854,7 +857,7 @@ static bool zebra_nhg_find(struct nhg_hash_entry **nhe, uint32_t id,
lookup.nhg = *nhg;
lookup.vrf_id = vrf_id;
- if (lookup.nhg.nexthop->next) {
+ if (nhg_depends || lookup.nhg.nexthop->next) {
/* Groups can have all vrfs and AF's in them */
lookup.afi = AFI_UNSPEC;
} else {
@@ -882,14 +885,16 @@ static bool zebra_nhg_find(struct nhg_hash_entry **nhe, uint32_t id,
}
}
- created = zebra_nhe_find(nhe, &lookup, nhg_depends, afi);
+ created = zebra_nhe_find(nhe, &lookup, nhg_depends, afi, from_dplane);
return created;
}
/* Find/create a single nexthop */
-static struct nhg_hash_entry *
-zebra_nhg_find_nexthop(uint32_t id, struct nexthop *nh, afi_t afi, int type)
+static struct nhg_hash_entry *zebra_nhg_find_nexthop(uint32_t id,
+ struct nexthop *nh,
+ afi_t afi, int type,
+ bool from_dplane)
{
struct nhg_hash_entry *nhe = NULL;
struct nexthop_group nhg = {};
@@ -897,7 +902,7 @@ zebra_nhg_find_nexthop(uint32_t id, struct nexthop *nh, afi_t afi, int type)
nexthop_group_add_sorted(&nhg, nh);
- zebra_nhg_find(&nhe, id, &nhg, NULL, vrf_id, afi, type);
+ zebra_nhg_find(&nhe, id, &nhg, NULL, vrf_id, afi, type, from_dplane);
if (IS_ZEBRA_DEBUG_NHG_DETAIL)
zlog_debug("%s: nh %pNHv => %p (%u)",
@@ -1151,14 +1156,14 @@ static int nhg_ctx_process_new(struct nhg_ctx *ctx)
}
if (!zebra_nhg_find(&nhe, id, nhg, &nhg_depends, vrf_id, afi,
- type))
+ type, true))
depends_decrement_free(&nhg_depends);
/* These got copied over in zebra_nhg_alloc() */
nexthop_group_delete(&nhg);
} else
- nhe = zebra_nhg_find_nexthop(id, nhg_ctx_get_nh(ctx), afi,
- type);
+ nhe = zebra_nhg_find_nexthop(id, nhg_ctx_get_nh(ctx), afi, type,
+ true);
if (!nhe) {
flog_err(
@@ -1325,7 +1330,7 @@ static struct nhg_hash_entry *depends_find_recursive(const struct nexthop *nh,
lookup = nexthop_dup(nh, NULL);
- nhe = zebra_nhg_find_nexthop(0, lookup, afi, type);
+ nhe = zebra_nhg_find_nexthop(0, lookup, afi, type, false);
nexthops_free(lookup);
@@ -1333,7 +1338,8 @@ static struct nhg_hash_entry *depends_find_recursive(const struct nexthop *nh,
}
static struct nhg_hash_entry *depends_find_singleton(const struct nexthop *nh,
- afi_t afi, int type)
+ afi_t afi, int type,
+ bool from_dplane)
{
struct nhg_hash_entry *nhe;
struct nexthop lookup = {};
@@ -1343,7 +1349,7 @@ static struct nhg_hash_entry *depends_find_singleton(const struct nexthop *nh,
*/
nexthop_copy_no_recurse(&lookup, nh, NULL);
- nhe = zebra_nhg_find_nexthop(0, &lookup, afi, type);
+ nhe = zebra_nhg_find_nexthop(0, &lookup, afi, type, from_dplane);
/* The copy may have allocated labels; free them if necessary. */
nexthop_del_labels(&lookup);
@@ -1356,7 +1362,7 @@ static struct nhg_hash_entry *depends_find_singleton(const struct nexthop *nh,
}
static struct nhg_hash_entry *depends_find(const struct nexthop *nh, afi_t afi,
- int type)
+ int type, bool from_dplane)
{
struct nhg_hash_entry *nhe = NULL;
@@ -1369,7 +1375,7 @@ static struct nhg_hash_entry *depends_find(const struct nexthop *nh, afi_t afi,
if (CHECK_FLAG(nh->flags, NEXTHOP_FLAG_RECURSIVE))
nhe = depends_find_recursive(nh, afi, type);
else
- nhe = depends_find_singleton(nh, afi, type);
+ nhe = depends_find_singleton(nh, afi, type, from_dplane);
if (IS_ZEBRA_DEBUG_NHG_DETAIL) {
@@ -1402,11 +1408,11 @@ static void depends_add(struct nhg_connected_tree_head *head,
static struct nhg_hash_entry *
depends_find_add(struct nhg_connected_tree_head *head, struct nexthop *nh,
- afi_t afi, int type)
+ afi_t afi, int type, bool from_dplane)
{
struct nhg_hash_entry *depend = NULL;
- depend = depends_find(nh, afi, type);
+ depend = depends_find(nh, afi, type, from_dplane);
if (IS_ZEBRA_DEBUG_NHG_DETAIL)
zlog_debug("%s: nh %pNHv => %p",
@@ -1452,7 +1458,7 @@ struct nhg_hash_entry *zebra_nhg_rib_find(uint32_t id,
assert(nhg->nexthop);
vrf_id = !vrf_is_backend_netns() ? VRF_DEFAULT : nhg->nexthop->vrf_id;
- zebra_nhg_find(&nhe, id, nhg, NULL, vrf_id, rt_afi, type);
+ zebra_nhg_find(&nhe, id, nhg, NULL, vrf_id, rt_afi, type, false);
if (IS_ZEBRA_DEBUG_NHG_DETAIL)
zlog_debug("%s: => nhe %p (%u)",
@@ -1476,7 +1482,7 @@ zebra_nhg_rib_find_nhe(struct nhg_hash_entry *rt_nhe, afi_t rt_afi)
if (IS_ZEBRA_DEBUG_NHG_DETAIL)
zlog_debug("%s: rt_nhe %p (%u)", __func__, rt_nhe, rt_nhe->id);
- zebra_nhe_find(&nhe, rt_nhe, NULL, rt_afi);
+ zebra_nhe_find(&nhe, rt_nhe, NULL, rt_afi, false);
if (IS_ZEBRA_DEBUG_NHG_DETAIL)
zlog_debug("%s: => nhe %p (%u)",
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index cc6e9c2ad3..730042b72c 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -694,15 +694,13 @@ void zebra_rib_evaluate_rn_nexthops(struct route_node *rn, uint32_t seq)
if (IS_ZEBRA_DEBUG_NHT_DETAILED) {
char buf1[PREFIX_STRLEN];
- char buf2[PREFIX_STRLEN];
zlog_debug(
- "%s(%u):%s has Nexthop(%s) Type: %s depending on it, evaluating %u:%u",
+ "%s(%u):%s has Nexthop(%pFX) Type: %s depending on it, evaluating %u:%u",
zvrf_name(zvrf), zvrf_id(zvrf),
srcdest_rnode2str(rn, buf1,
sizeof(buf1)),
- prefix2str(p, buf2, sizeof(buf2)),
- rnh_type2str(rnh->type), seq,
+ p, rnh_type2str(rnh->type), seq,
rnh->seqno);
}
@@ -1924,11 +1922,9 @@ static void rib_process_result(struct zebra_dplane_ctx *ctx)
zsend_route_notify_owner(re, dest_pfx,
ZAPI_ROUTE_FAIL_INSTALL);
- zlog_warn("%s(%u:%u):%s: Route install failed",
+ zlog_warn("%s(%u:%u):%pFX: Route install failed",
VRF_LOGNAME(vrf), dplane_ctx_get_vrf(ctx),
- dplane_ctx_get_table(ctx),
- prefix2str(dest_pfx, dest_str,
- sizeof(dest_str)));
+ dplane_ctx_get_table(ctx), dest_pfx);
}
break;
case DPLANE_OP_ROUTE_DELETE:
@@ -1954,11 +1950,9 @@ static void rib_process_result(struct zebra_dplane_ctx *ctx)
zsend_route_notify_owner_ctx(ctx,
ZAPI_ROUTE_REMOVE_FAIL);
- zlog_warn("%s(%u:%u):%s: Route Deletion failure",
+ zlog_warn("%s(%u:%u):%pFX: Route Deletion failure",
VRF_LOGNAME(vrf), dplane_ctx_get_vrf(ctx),
- dplane_ctx_get_table(ctx),
- prefix2str(dest_pfx, dest_str,
- sizeof(dest_str)));
+ dplane_ctx_get_table(ctx), dest_pfx);
}
/*
@@ -2289,7 +2283,7 @@ static void process_subq_route(struct listnode *lnode, uint8_t qindex)
else
{
zlog_debug ("%s: called for route_node (%p, %d) with no ribs",
- __func__, rnode, rnode->lock);
+ __func__, rnode, route_node_get_lock_count(rnode));
zlog_backtrace(LOG_DEBUG);
}
#endif
@@ -2464,8 +2458,8 @@ int rib_queue_add(struct route_node *rn)
/* Pointless to queue a route_node with no RIB entries to add or remove
*/
if (!rnode_to_ribs(rn)) {
- zlog_debug("%s: called for route_node (%p, %d) with no ribs",
- __func__, (void *)rn, rn->lock);
+ zlog_debug("%s: called for route_node (%p, %u) with no ribs",
+ __func__, (void *)rn, route_node_get_lock_count(rn));
zlog_backtrace(LOG_DEBUG);
return -1;
}
@@ -2831,7 +2825,6 @@ void rib_lookup_and_dump(struct prefix_ipv4 *p, vrf_id_t vrf_id)
struct route_node *rn;
struct route_entry *re;
struct vrf *vrf;
- char prefix_buf[INET_ADDRSTRLEN];
vrf = vrf_lookup_by_id(vrf_id);
@@ -2849,10 +2842,8 @@ void rib_lookup_and_dump(struct prefix_ipv4 *p, vrf_id_t vrf_id)
/* No route for this prefix. */
if (!rn) {
- zlog_debug("%s:%s(%u) lookup failed for %s", __func__,
- VRF_LOGNAME(vrf), vrf_id,
- prefix2str((struct prefix *)p, prefix_buf,
- sizeof(prefix_buf)));
+ zlog_debug("%s:%s(%u) lookup failed for %pFX", __func__,
+ VRF_LOGNAME(vrf), vrf_id, (struct prefix *)p);
return;
}
@@ -2911,14 +2902,13 @@ void rib_lookup_and_pushup(struct prefix_ipv4 *p, vrf_id_t vrf_id)
*/
if (dest->selected_fib) {
if (IS_ZEBRA_DEBUG_RIB) {
- char buf[PREFIX_STRLEN];
struct vrf *vrf =
vrf_lookup_by_id(dest->selected_fib->vrf_id);
zlog_debug(
- "%s(%u):%s: freeing way for connected prefix",
+ "%s(%u):%pFX: freeing way for connected prefix",
VRF_LOGNAME(vrf), dest->selected_fib->vrf_id,
- prefix2str(&rn->p, buf, sizeof(buf)));
+ &rn->p);
route_entry_dump(&rn->p, NULL, dest->selected_fib);
}
rib_uninstall(rn, dest->selected_fib);
@@ -2969,14 +2959,12 @@ int rib_add_multipath_nhe(afi_t afi, safi_t safi, struct prefix *p,
/* Lookup nhe from route information */
nhe = zebra_nhg_rib_find_nhe(re_nhe, afi);
if (!nhe) {
- char buf[PREFIX_STRLEN] = "";
char buf2[PREFIX_STRLEN] = "";
flog_err(
EC_ZEBRA_TABLE_LOOKUP_FAILED,
- "Zebra failed to find or create a nexthop hash entry for %s%s%s",
- prefix2str(p, buf, sizeof(buf)),
- src_p ? " from " : "",
+ "Zebra failed to find or create a nexthop hash entry for %pFX%s%s",
+ p, src_p ? " from " : "",
src_p ? prefix2str(src_p, buf2, sizeof(buf2))
: "");
@@ -3116,9 +3104,8 @@ void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type,
/* Lookup route node. */
rn = srcdest_rnode_lookup(table, p, src_p);
if (!rn) {
- char dst_buf[PREFIX_STRLEN], src_buf[PREFIX_STRLEN];
+ char src_buf[PREFIX_STRLEN];
- prefix2str(p, dst_buf, sizeof(dst_buf));
if (src_p && src_p->prefixlen)
prefix2str(src_p, src_buf, sizeof(src_buf));
else
@@ -3127,8 +3114,8 @@ void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type,
if (IS_ZEBRA_DEBUG_RIB) {
struct vrf *vrf = vrf_lookup_by_id(vrf_id);
- zlog_debug("%s[%d]:%s%s%s doesn't exist in rib",
- vrf->name, table_id, dst_buf,
+ zlog_debug("%s[%d]:%pFX%s%s doesn't exist in rib",
+ vrf->name, table_id, p,
(src_buf[0] != '\0') ? " from " : "",
src_buf);
}
diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c
index 9c6ed44585..521f969fcc 100644
--- a/zebra/zebra_rnh.c
+++ b/zebra/zebra_rnh.c
@@ -480,7 +480,6 @@ static void zebra_rnh_eval_import_check_entry(struct zebra_vrf *zvrf, afi_t afi,
{
int state_changed = 0;
struct zserv *client;
- char bufn[INET6_ADDRSTRLEN];
struct listnode *node;
zebra_rnh_remove_from_routing_table(rnh);
@@ -506,13 +505,11 @@ static void zebra_rnh_eval_import_check_entry(struct zebra_vrf *zvrf, afi_t afi,
}
if (state_changed || force) {
- if (IS_ZEBRA_DEBUG_NHT) {
- prefix2str(&nrn->p, bufn, INET6_ADDRSTRLEN);
+ if (IS_ZEBRA_DEBUG_NHT)
zlog_debug("%s(%u):%pRN: Route import check %s %s",
VRF_LOGNAME(zvrf->vrf), zvrf->vrf->vrf_id,
nrn, rnh->state ? "passed" : "failed",
state_changed ? "(state changed)" : "");
- }
/* state changed, notify clients */
for (ALL_LIST_ELEMENTS_RO(rnh->client_list, node, client)) {
zebra_send_rnh_update(rnh, client,
@@ -1200,7 +1197,7 @@ static void print_nh(struct nexthop *nexthop, struct vty *vty)
switch (nexthop->type) {
case NEXTHOP_TYPE_IPV4:
case NEXTHOP_TYPE_IPV4_IFINDEX:
- vty_out(vty, " via %s", inet_ntoa(nexthop->gate.ipv4));
+ vty_out(vty, " via %pI4", &nexthop->gate.ipv4);
if (nexthop->ifindex)
vty_out(vty, ", %s",
ifindex2ifname_per_ns(zns, nexthop->ifindex));
diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c
index d102b02a21..b7cbf5262a 100644
--- a/zebra/zebra_vrf.c
+++ b/zebra/zebra_vrf.c
@@ -315,6 +315,9 @@ static int zebra_vrf_delete(struct vrf *vrf)
list_delete_all_node(zvrf->rid_all_sorted_list);
list_delete_all_node(zvrf->rid_lo_sorted_list);
+ list_delete_all_node(zvrf->rid6_all_sorted_list);
+ list_delete_all_node(zvrf->rid6_lo_sorted_list);
+
otable_fini(&zvrf->other_tables);
XFREE(MTYPE_ZEBRA_VRF, zvrf);
vrf->info = NULL;
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index 920fdd6baa..1a6e6032b6 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -304,8 +304,8 @@ static void show_nexthop_detail_helper(struct vty *vty,
switch (nexthop->type) {
case NEXTHOP_TYPE_IPV4:
case NEXTHOP_TYPE_IPV4_IFINDEX:
- vty_out(vty, " %s",
- inet_ntoa(nexthop->gate.ipv4));
+ vty_out(vty, " %pI4",
+ &nexthop->gate.ipv4);
if (nexthop->ifindex)
vty_out(vty, ", via %s",
ifindex2ifname(
@@ -508,7 +508,7 @@ static void show_route_nexthop_helper(struct vty *vty,
switch (nexthop->type) {
case NEXTHOP_TYPE_IPV4:
case NEXTHOP_TYPE_IPV4_IFINDEX:
- vty_out(vty, " via %s", inet_ntoa(nexthop->gate.ipv4));
+ vty_out(vty, " via %pI4", &nexthop->gate.ipv4);
if (nexthop->ifindex)
vty_out(vty, ", %s",
ifindex2ifname(nexthop->ifindex,
@@ -636,7 +636,8 @@ static void show_nexthop_json_helper(json_object *json_nexthop,
case NEXTHOP_TYPE_IPV4_IFINDEX:
json_object_string_add(
json_nexthop, "ip",
- inet_ntoa(nexthop->gate.ipv4));
+ inet_ntop(AF_INET, &nexthop->gate.ipv4,
+ buf, sizeof(buf)));
json_object_string_add(json_nexthop, "afi",
"ipv4");
@@ -1768,6 +1769,15 @@ DEFPY (show_route,
return CMD_SUCCESS;
}
+ALIAS_HIDDEN (show_route,
+ show_ro_cmd,
+ "show <ip$ipv4|ipv6$ipv6> ro",
+ SHOW_STR
+ IP_STR
+ IPV6_STR
+ "IP routing table\n");
+
+
DEFPY (show_route_detail,
show_route_detail_cmd,
"show\
@@ -3905,6 +3915,7 @@ void zebra_vty_init(void)
install_element(VIEW_NODE, &show_vrf_cmd);
install_element(VIEW_NODE, &show_vrf_vni_cmd);
install_element(VIEW_NODE, &show_route_cmd);
+ install_element(VIEW_NODE, &show_ro_cmd);
install_element(VIEW_NODE, &show_route_detail_cmd);
install_element(VIEW_NODE, &show_route_summary_cmd);
install_element(VIEW_NODE, &show_ip_nht_cmd);
diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c
index 82e871801a..cca7680953 100644
--- a/zebra/zebra_vxlan.c
+++ b/zebra/zebra_vxlan.c
@@ -310,8 +310,7 @@ static void zl3vni_print_nh(zebra_neigh_t *n, struct vty *vty,
rb_host_count(&n->host_rb));
vty_out(vty, " Prefixes:\n");
RB_FOREACH (hle, host_rb_tree_entry, &n->host_rb)
- vty_out(vty, " %s\n",
- prefix2str(&hle->p, buf2, sizeof(buf2)));
+ vty_out(vty, " %pFX\n", &hle->p);
} else {
json_hosts = json_object_new_array();
json_object_string_add(
@@ -341,20 +340,21 @@ static void zl3vni_print_rmac(zebra_mac_t *zrmac, struct vty *vty,
if (!json) {
vty_out(vty, "MAC: %s\n",
prefix_mac2str(&zrmac->macaddr, buf1, sizeof(buf1)));
- vty_out(vty, " Remote VTEP: %s\n",
- inet_ntoa(zrmac->fwd_info.r_vtep_ip));
+ vty_out(vty, " Remote VTEP: %pI4\n",
+ &zrmac->fwd_info.r_vtep_ip);
vty_out(vty, " Refcount: %d\n", rb_host_count(&zrmac->host_rb));
vty_out(vty, " Prefixes:\n");
RB_FOREACH (hle, host_rb_tree_entry, &zrmac->host_rb)
- vty_out(vty, " %s\n",
- prefix2str(&hle->p, buf2, sizeof(buf2)));
+ vty_out(vty, " %pFX\n", &hle->p);
} else {
json_hosts = json_object_new_array();
json_object_string_add(
json, "routerMac",
prefix_mac2str(&zrmac->macaddr, buf1, sizeof(buf1)));
json_object_string_add(json, "vtepIp",
- inet_ntoa(zrmac->fwd_info.r_vtep_ip));
+ inet_ntop(AF_INET,
+ &zrmac->fwd_info.r_vtep_ip,
+ buf1, sizeof(buf1)));
json_object_int_add(json, "refCount",
rb_host_count(&zrmac->host_rb));
json_object_int_add(json, "localSequence", zrmac->loc_seq);
@@ -631,7 +631,7 @@ static void zl3vni_print_rmac_hash(struct hash_bucket *bucket, void *ctx)
struct vty *vty = NULL;
struct json_object *json = NULL;
struct json_object *json_rmac = NULL;
- char buf[ETHER_ADDR_STRLEN];
+ char buf[PREFIX_STRLEN];
wctx = (struct rmac_walk_ctx *)ctx;
vty = wctx->vty;
@@ -641,15 +641,17 @@ static void zl3vni_print_rmac_hash(struct hash_bucket *bucket, void *ctx)
zrmac = (zebra_mac_t *)bucket->data;
if (!json) {
- vty_out(vty, "%-17s %-21s\n",
+ vty_out(vty, "%-17s %-21pI4\n",
prefix_mac2str(&zrmac->macaddr, buf, sizeof(buf)),
- inet_ntoa(zrmac->fwd_info.r_vtep_ip));
+ &zrmac->fwd_info.r_vtep_ip);
} else {
json_object_string_add(
json_rmac, "routerMac",
prefix_mac2str(&zrmac->macaddr, buf, sizeof(buf)));
json_object_string_add(json_rmac, "vtepIp",
- inet_ntoa(zrmac->fwd_info.r_vtep_ip));
+ inet_ntop(AF_INET,
+ &zrmac->fwd_info.r_vtep_ip,
+ buf, sizeof(buf)));
json_object_object_add(
json, prefix_mac2str(&zrmac->macaddr, buf, sizeof(buf)),
json_rmac);
@@ -659,7 +661,7 @@ static void zl3vni_print_rmac_hash(struct hash_bucket *bucket, void *ctx)
/* print a specific L3 VNI entry */
static void zl3vni_print(zebra_l3vni_t *zl3vni, void **ctx)
{
- char buf[ETHER_ADDR_STRLEN];
+ char buf[PREFIX_STRLEN];
struct vty *vty = NULL;
json_object *json = NULL;
zebra_evpn_t *zevpn = NULL;
@@ -673,8 +675,8 @@ static void zl3vni_print(zebra_l3vni_t *zl3vni, void **ctx)
vty_out(vty, "VNI: %u\n", zl3vni->vni);
vty_out(vty, " Type: %s\n", "L3");
vty_out(vty, " Tenant VRF: %s\n", zl3vni_vrf_name(zl3vni));
- vty_out(vty, " Local Vtep Ip: %s\n",
- inet_ntoa(zl3vni->local_vtep_ip));
+ vty_out(vty, " Local Vtep Ip: %pI4\n",
+ &zl3vni->local_vtep_ip);
vty_out(vty, " Vxlan-Intf: %s\n",
zl3vni_vxlan_if_name(zl3vni));
vty_out(vty, " SVI-If: %s\n", zl3vni_svi_if_name(zl3vni));
@@ -695,8 +697,10 @@ static void zl3vni_print(zebra_l3vni_t *zl3vni, void **ctx)
json_evpn_list = json_object_new_array();
json_object_int_add(json, "vni", zl3vni->vni);
json_object_string_add(json, "type", "L3");
- json_object_string_add(json, "localVtepIp",
- inet_ntoa(zl3vni->local_vtep_ip));
+ json_object_string_add(
+ json, "localVtepIp",
+ inet_ntop(AF_INET, &zl3vni->local_vtep_ip, buf,
+ sizeof(buf)));
json_object_string_add(json, "vxlanIntf",
zl3vni_vxlan_if_name(zl3vni));
json_object_string_add(json, "sviIntf",
@@ -945,9 +949,9 @@ static int zevpn_build_hash_table_zns(struct ns *ns,
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug(
- "Create L2-VNI hash for intf %s(%u) L2-VNI %u local IP %s",
+ "Create L2-VNI hash for intf %s(%u) L2-VNI %u local IP %pI4",
ifp->name, ifp->ifindex, vni,
- inet_ntoa(vxl->vtep_ip));
+ &vxl->vtep_ip);
/* EVPN hash entry is expected to exist, if the BGP process is killed */
zevpn = zebra_evpn_lookup(vni);
@@ -1270,7 +1274,6 @@ static int zl3vni_remote_rmac_add(zebra_l3vni_t *zl3vni,
{
char buf[ETHER_ADDR_STRLEN];
char buf1[INET6_ADDRSTRLEN];
- char buf2[PREFIX_STRLEN];
zebra_mac_t *zrmac = NULL;
zrmac = zl3vni_rmac_lookup(zl3vni, rmac);
@@ -1280,11 +1283,11 @@ static int zl3vni_remote_rmac_add(zebra_l3vni_t *zl3vni,
zrmac = zl3vni_rmac_add(zl3vni, rmac);
if (!zrmac) {
zlog_debug(
- "Failed to add RMAC %s L3VNI %u Remote VTEP %s, prefix %s",
+ "Failed to add RMAC %s L3VNI %u Remote VTEP %s, prefix %pFX",
prefix_mac2str(rmac, buf, sizeof(buf)),
zl3vni->vni,
ipaddr2str(vtep_ip, buf1, sizeof(buf1)),
- prefix2str(host_prefix, buf2, sizeof(buf2)));
+ host_prefix);
return -1;
}
memset(&zrmac->fwd_info, 0, sizeof(zrmac->fwd_info));
@@ -1300,12 +1303,12 @@ static int zl3vni_remote_rmac_add(zebra_l3vni_t *zl3vni,
&vtep_ip->ipaddr_v4)) {
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug(
- "L3VNI %u Remote VTEP change(%s -> %s) for RMAC %s, prefix %s",
+ "L3VNI %u Remote VTEP change(%pI4 -> %s) for RMAC %s, prefix %pFX",
zl3vni->vni,
- inet_ntoa(zrmac->fwd_info.r_vtep_ip),
+ &zrmac->fwd_info.r_vtep_ip,
ipaddr2str(vtep_ip, buf1, sizeof(buf1)),
prefix_mac2str(rmac, buf, sizeof(buf)),
- prefix2str(host_prefix, buf2, sizeof(buf2)));
+ host_prefix);
zrmac->fwd_info.r_vtep_ip = vtep_ip->ipaddr_v4;
@@ -1465,7 +1468,6 @@ static int zl3vni_remote_nh_add(zebra_l3vni_t *zl3vni,
char buf[ETHER_ADDR_STRLEN];
char buf1[ETHER_ADDR_STRLEN];
char buf2[INET6_ADDRSTRLEN];
- char buf3[PREFIX_STRLEN];
zebra_neigh_t *nh = NULL;
/* Create the next hop entry, or update its mac, if necessary. */
@@ -1474,11 +1476,10 @@ static int zl3vni_remote_nh_add(zebra_l3vni_t *zl3vni,
nh = zl3vni_nh_add(zl3vni, vtep_ip, rmac);
if (!nh) {
zlog_debug(
- "Failed to add NH %s as Neigh (RMAC %s L3-VNI %u prefix %s)",
+ "Failed to add NH %s as Neigh (RMAC %s L3-VNI %u prefix %pFX)",
ipaddr2str(vtep_ip, buf1, sizeof(buf2)),
prefix_mac2str(rmac, buf, sizeof(buf)),
- zl3vni->vni,
- prefix2str(host_prefix, buf2, sizeof(buf2)));
+ zl3vni->vni, host_prefix);
return -1;
}
@@ -1486,12 +1487,13 @@ static int zl3vni_remote_nh_add(zebra_l3vni_t *zl3vni,
zl3vni_nh_install(zl3vni, nh);
} else if (memcmp(&nh->emac, rmac, ETH_ALEN) != 0) {
if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_debug("L3VNI %u RMAC change(%s --> %s) for nexthop %s, prefix %s",
- zl3vni->vni,
- prefix_mac2str(&nh->emac, buf, sizeof(buf)),
- prefix_mac2str(rmac, buf1, sizeof(buf1)),
- ipaddr2str(vtep_ip, buf2, sizeof(buf2)),
- prefix2str(host_prefix, buf3, sizeof(buf3)));
+ zlog_debug(
+ "L3VNI %u RMAC change(%s --> %s) for nexthop %s, prefix %pFX",
+ zl3vni->vni,
+ prefix_mac2str(&nh->emac, buf, sizeof(buf)),
+ prefix_mac2str(rmac, buf1, sizeof(buf1)),
+ ipaddr2str(vtep_ip, buf2, sizeof(buf2)),
+ host_prefix);
memcpy(&nh->emac, rmac, ETH_ALEN);
/* install (update) the nh neigh in kernel */
@@ -1913,11 +1915,11 @@ static int zl3vni_send_add_to_client(zebra_l3vni_t *zl3vni)
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug(
- "Send L3_VNI_ADD %u VRF %s RMAC %s VRR %s local-ip %s filter %s to %s",
+ "Send L3_VNI_ADD %u VRF %s RMAC %s VRR %s local-ip %pI4 filter %s to %s",
zl3vni->vni, vrf_id_to_name(zl3vni_vrf_id(zl3vni)),
prefix_mac2str(&svi_rmac, buf, sizeof(buf)),
prefix_mac2str(&vrr_rmac, buf1, sizeof(buf1)),
- inet_ntoa(zl3vni->local_vtep_ip),
+ &zl3vni->local_vtep_ip,
CHECK_FLAG(zl3vni->filter, PREFIX_ROUTES_ONLY)
? "prefix-routes-only"
: "none",
@@ -3766,14 +3768,13 @@ void zebra_vxlan_remote_macip_del(ZAPI_HANDLER_ARGS)
l += res_length;
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug(
- "Recv MACIP DEL VNI %u MAC %s%s%s Remote VTEP %s from %s",
+ "Recv MACIP DEL VNI %u MAC %s%s%s Remote VTEP %pI4 from %s",
vni,
prefix_mac2str(&macaddr, buf, sizeof(buf)),
ipa_len ? " IP " : "",
ipa_len ?
ipaddr2str(&ip, buf1, sizeof(buf1)) : "",
- inet_ntoa(vtep_ip),
- zebra_route_string(client->proto));
+ &vtep_ip, zebra_route_string(client->proto));
process_remote_macip_del(vni, &macaddr, ipa_len, &ip, vtep_ip);
}
@@ -3828,7 +3829,7 @@ void zebra_vxlan_remote_macip_add(ZAPI_HANDLER_ARGS)
else
strlcpy(esi_buf, "-", ESI_STR_LEN);
zlog_debug(
- "Recv %sMACIP ADD VNI %u MAC %s%s%s flags 0x%x seq %u VTEP %s ESI %s from %s",
+ "Recv %sMACIP ADD VNI %u MAC %s%s%s flags 0x%x seq %u VTEP %pI4 ESI %s from %s",
(flags & ZEBRA_MACIP_TYPE_SYNC_PATH) ?
"sync-" : "",
vni,
@@ -3836,7 +3837,7 @@ void zebra_vxlan_remote_macip_add(ZAPI_HANDLER_ARGS)
ipa_len ? " IP " : "",
ipa_len ?
ipaddr2str(&ip, buf1, sizeof(buf1)) : "",
- flags, seq, inet_ntoa(vtep_ip), esi_buf,
+ flags, seq, &vtep_ip, esi_buf,
zebra_route_string(client->proto));
}
@@ -3887,8 +3888,8 @@ int zebra_vxlan_check_readd_vtep(struct interface *ifp,
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug(
- "Del MAC for remote VTEP %s intf %s(%u) VNI %u - readd",
- inet_ntoa(vtep_ip), ifp->name, ifp->ifindex, vni);
+ "Del MAC for remote VTEP %pI4 intf %s(%u) VNI %u - readd",
+ &vtep_ip, ifp->name, ifp->ifindex, vni);
zebra_evpn_vtep_install(zevpn, zvtep);
return 0;
@@ -4128,8 +4129,8 @@ void zebra_vxlan_remote_vtep_del(ZAPI_HANDLER_ARGS)
l += 4;
if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_debug("Recv VTEP_DEL %s VNI %u from %s",
- inet_ntoa(vtep_ip), vni,
+ zlog_debug("Recv VTEP_DEL %pI4 VNI %u from %s",
+ &vtep_ip, vni,
zebra_route_string(client->proto));
/* Locate VNI hash entry - expected to exist. */
@@ -4212,8 +4213,8 @@ void zebra_vxlan_remote_vtep_add(ZAPI_HANDLER_ARGS)
l += IPV4_MAX_BYTELEN + 4;
if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_debug("Recv VTEP_ADD %s VNI %u flood %d from %s",
- inet_ntoa(vtep_ip), vni, flood_control,
+ zlog_debug("Recv VTEP_ADD %pI4 VNI %u flood %d from %s",
+ &vtep_ip, vni, flood_control,
zebra_route_string(client->proto));
/* Locate VNI hash entry - expected to exist. */
@@ -4795,9 +4796,9 @@ int zebra_vxlan_if_update(struct interface *ifp, uint16_t chgflags)
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug(
- "Update L3-VNI %u intf %s(%u) VLAN %u local IP %s master %u chg 0x%x",
+ "Update L3-VNI %u intf %s(%u) VLAN %u local IP %pI4 master %u chg 0x%x",
vni, ifp->name, ifp->ifindex, vxl->access_vlan,
- inet_ntoa(vxl->vtep_ip),
+ &vxl->vtep_ip,
zif->brslave_info.bridge_ifindex, chgflags);
/* Removed from bridge? Cleanup and return */
@@ -4859,9 +4860,9 @@ int zebra_vxlan_if_update(struct interface *ifp, uint16_t chgflags)
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug(
- "Update L2-VNI %u intf %s(%u) VLAN %u local IP %s master %u chg 0x%x",
+ "Update L2-VNI %u intf %s(%u) VLAN %u local IP %pI4 master %u chg 0x%x",
vni, ifp->name, ifp->ifindex, vxl->access_vlan,
- inet_ntoa(vxl->vtep_ip),
+ &vxl->vtep_ip,
zif->brslave_info.bridge_ifindex, chgflags);
/* Removed from bridge? Cleanup and return */
@@ -4966,9 +4967,9 @@ int zebra_vxlan_if_add(struct interface *ifp)
/* process if-add for l3-vni*/
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug(
- "Add L3-VNI %u intf %s(%u) VLAN %u local IP %s master %u",
+ "Add L3-VNI %u intf %s(%u) VLAN %u local IP %pI4 master %u",
vni, ifp->name, ifp->ifindex, vxl->access_vlan,
- inet_ntoa(vxl->vtep_ip),
+ &vxl->vtep_ip,
zif->brslave_info.bridge_ifindex);
/* associate with vxlan_if */
diff --git a/zebra/zserv.c b/zebra/zserv.c
index 44f4641fcf..4b5791530d 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -1172,11 +1172,9 @@ static void zebra_show_stale_client_detail(struct vty *vty,
}
}
vty_out(vty, "Current AFI : %d\n", info->current_afi);
- if (info->current_prefix) {
- prefix2str(info->current_prefix, buf,
- sizeof(buf));
- vty_out(vty, "Current prefix : %s\n", buf);
- }
+ if (info->current_prefix)
+ vty_out(vty, "Current prefix : %pFX\n",
+ info->current_prefix);
}
}
vty_out(vty, "\n");