Merge pull request #7323 from ton31337/fix/inet_ntoa_to_pFX_master

bgpd: Convert inet_ntoa to %pI4
This commit is contained in:
Donald Sharp 2020-10-20 09:10:24 -04:00 committed by GitHub
commit cd7f9b1711
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 360 additions and 279 deletions

View File

@ -763,8 +763,7 @@ static void attr_show_all_iterator(struct hash_bucket *bucket, struct vty *vty)
struct attr *attr = bucket->data; struct attr *attr = bucket->data;
char sid_str[BUFSIZ]; char sid_str[BUFSIZ];
vty_out(vty, "attr[%ld] nexthop %s\n", attr->refcnt, vty_out(vty, "attr[%ld] nexthop %pI4\n", attr->refcnt, &attr->nexthop);
inet_ntoa(attr->nexthop));
sid_str[0] = '\0'; sid_str[0] = '\0';
if (attr->srv6_l3vpn) if (attr->srv6_l3vpn)

View File

@ -108,7 +108,7 @@ static void attr_parse(struct stream *s, uint16_t len)
case BGP_ATTR_NEXT_HOP: { case BGP_ATTR_NEXT_HOP: {
struct in_addr nexthop; struct in_addr nexthop;
nexthop.s_addr = stream_get_ipv4(s); nexthop.s_addr = stream_get_ipv4(s);
printf("NEXTHOP: %s\n", inet_ntoa(nexthop)); printf("NEXTHOP: %pI4\n", &nexthop);
} break; } break;
default: default:
stream_getw_from(s, length); stream_getw_from(s, length);
@ -244,7 +244,7 @@ int main(int argc, char **argv)
while (s->getp < len - 16) { while (s->getp < len - 16) {
p.prefix.s_addr = stream_get_ipv4(s); p.prefix.s_addr = stream_get_ipv4(s);
p.prefixlen = stream_getc(s); p.prefixlen = stream_getc(s);
printf("PREFIX: %s/%d\n", inet_ntoa(p.prefix), printf("PREFIX: %pI4/%d\n", &p.prefix,
p.prefixlen); p.prefixlen);
status = stream_getc(s); status = stream_getc(s);
@ -252,8 +252,7 @@ int main(int argc, char **argv)
peer.s_addr = stream_get_ipv4(s); peer.s_addr = stream_get_ipv4(s);
source_as = stream_getw(s); source_as = stream_getw(s);
printf("FROM: %s AS%d\n", inet_ntoa(peer), printf("FROM: %pI4 AS%d\n", &peer, source_as);
source_as);
printf("ORIGINATED: %s", ctime(&originated)); printf("ORIGINATED: %s", ctime(&originated));
attrlen = stream_getw(s); attrlen = stream_getw(s);
@ -278,8 +277,8 @@ int main(int argc, char **argv)
sip.s_addr = stream_get_ipv4(s); sip.s_addr = stream_get_ipv4(s);
dip.s_addr = stream_get_ipv4(s); dip.s_addr = stream_get_ipv4(s);
printf("saddr: %s\n", inet_ntoa(sip)); printf("saddr: %pI4\n", &sip);
printf("daddr: %s\n", inet_ntoa(dip)); printf("daddr: %pI4\n", &dip);
printf("\n"); printf("\n");
} }

View File

@ -21,6 +21,7 @@
#include <zebra.h> #include <zebra.h>
#include <lib/version.h> #include <lib/version.h>
#include "lib/printfrr.h"
#include "prefix.h" #include "prefix.h"
#include "linklist.h" #include "linklist.h"
#include "stream.h" #include "stream.h"
@ -380,7 +381,7 @@ bool bgp_dump_attr(struct attr *attr, char *buf, size_t size)
buf[0] = '\0'; buf[0] = '\0';
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP))) 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))) if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_ORIGIN)))
snprintf(buf + strlen(buf), size - strlen(buf), ", origin %s", snprintf(buf + strlen(buf), size - strlen(buf), ", origin %s",
@ -400,7 +401,7 @@ bool bgp_dump_attr(struct attr *attr, char *buf, size_t size)
BUFSIZ)); BUFSIZ));
if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV4) 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))) if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)))
snprintf(buf + strlen(buf), size - strlen(buf), snprintf(buf + strlen(buf), size - strlen(buf),
@ -424,13 +425,13 @@ bool bgp_dump_attr(struct attr *attr, char *buf, size_t size)
", atomic-aggregate"); ", atomic-aggregate");
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR))) if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR)))
snprintf(buf + strlen(buf), size - strlen(buf), snprintfrr(buf + strlen(buf), size - strlen(buf),
", aggregated by %u %s", attr->aggregator_as, ", aggregated by %u %pI4", attr->aggregator_as,
inet_ntoa(attr->aggregator_addr)); &attr->aggregator_addr);
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))) if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))
snprintf(buf + strlen(buf), size - strlen(buf), snprintfrr(buf + strlen(buf), size - strlen(buf),
", originator %s", inet_ntoa(attr->originator_id)); ", originator %pI4", &attr->originator_id);
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) { if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) {
int i; int i;
@ -438,8 +439,8 @@ bool bgp_dump_attr(struct attr *attr, char *buf, size_t size)
snprintf(buf + strlen(buf), size - strlen(buf), snprintf(buf + strlen(buf), size - strlen(buf),
", clusterlist"); ", clusterlist");
for (i = 0; i < attr->cluster->length / 4; i++) for (i = 0; i < attr->cluster->length / 4; i++)
snprintf(buf + strlen(buf), size - strlen(buf), " %s", snprintfrr(buf + strlen(buf), size - strlen(buf),
inet_ntoa(attr->cluster->list[i])); " %pI4", &attr->cluster->list[i]);
} }
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL))) if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL)))
@ -592,9 +593,9 @@ static void bgp_debug_print_evpn_prefix(struct vty *vty, const char *desc,
buf, PREFIX2STR_BUFFER)); buf, PREFIX2STR_BUFFER));
} }
} else if (p->u.prefix_evpn.route_type == BGP_EVPN_IMET_ROUTE) { } else if (p->u.prefix_evpn.route_type == BGP_EVPN_IMET_ROUTE) {
snprintf(evpn_desc, sizeof(evpn_desc), snprintfrr(evpn_desc, sizeof(evpn_desc),
"l2vpn evpn type multicast ip %s", "l2vpn evpn type multicast ip %pI4",
inet_ntoa(p->u.prefix_evpn.imet_addr.ip.ipaddr_v4)); &p->u.prefix_evpn.imet_addr.ip.ipaddr_v4);
} else if (p->u.prefix_evpn.route_type == BGP_EVPN_IP_PREFIX_ROUTE) { } else if (p->u.prefix_evpn.route_type == BGP_EVPN_IP_PREFIX_ROUTE) {
uint8_t family = is_evpn_prefix_ipaddr_v4( uint8_t family = is_evpn_prefix_ipaddr_v4(
(struct prefix_evpn *)p) ? AF_INET (struct prefix_evpn *)p) ? AF_INET

View File

@ -29,6 +29,8 @@
#include "jhash.h" #include "jhash.h"
#include "stream.h" #include "stream.h"
#include "lib/printfrr.h"
#include "bgpd/bgpd.h" #include "bgpd/bgpd.h"
#include "bgpd/bgp_ecommunity.h" #include "bgpd/bgp_ecommunity.h"
#include "bgpd/bgp_lcommunity.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++ << 8);
eip.val |= (*pnt++); eip.val |= (*pnt++);
len = snprintf(buf, bufsz, "%s%s:%u", prefix, inet_ntoa(eip.ip), len = snprintfrr(buf, bufsz, "%s%pI4:%u", prefix, &eip.ip,
eip.val); eip.val);
} }
/* consume value */ /* consume value */

View File

@ -31,6 +31,8 @@
#include "jhash.h" #include "jhash.h"
#include "zclient.h" #include "zclient.h"
#include "lib/printfrr.h"
#include "bgpd/bgp_attr_evpn.h" #include "bgpd/bgp_attr_evpn.h"
#include "bgpd/bgpd.h" #include "bgpd/bgpd.h"
#include "bgpd/bgp_table.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)); stream_putw_at(s, 0, stream_get_endp(s));
if (bgp_debug_zebra(NULL)) 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, 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); return zclient_send_message(zclient);
} }
@ -1722,15 +1724,14 @@ static int update_evpn_route(struct bgp *bgp, struct bgpevpn *vpn,
char buf1[PREFIX_STRLEN]; char buf1[PREFIX_STRLEN];
char buf3[ESI_STR_LEN]; char buf3[ESI_STR_LEN];
zlog_debug("VRF %s vni %u type-2 route evp %s RMAC %s nexthop %s esi %s", zlog_debug(
vpn->bgp_vrf ? "VRF %s vni %u type-2 route evp %s RMAC %s nexthop %pI4 esi %s",
vrf_id_to_name(vpn->bgp_vrf->vrf_id) : " ", vpn->bgp_vrf ? vrf_id_to_name(vpn->bgp_vrf->vrf_id)
vpn->vni, : " ",
prefix2str(p, buf1, sizeof(buf1)), vpn->vni, prefix2str(p, buf1, sizeof(buf1)),
prefix_mac2str(&attr.rmac, buf, prefix_mac2str(&attr.rmac, buf, sizeof(buf)),
sizeof(buf)), &attr.mp_nexthop_global_in,
inet_ntoa(attr.mp_nexthop_global_in), esi_to_str(esi, buf3, sizeof(buf3)));
esi_to_str(esi, buf3, sizeof(buf3)));
} }
/* router mac is only needed for type-2 routes here. */ /* router mac is only needed for type-2 routes here. */
if (p->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE) { if (p->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE) {
@ -2003,15 +2004,15 @@ static void bgp_evpn_update_type2_route_entry(struct bgp *bgp,
char buf1[PREFIX_STRLEN]; char buf1[PREFIX_STRLEN];
char buf3[ESI_STR_LEN]; char buf3[ESI_STR_LEN];
zlog_debug("VRF %s vni %u evp %s RMAC %s nexthop %s esi %s esf 0x%x from %s", zlog_debug(
vpn->bgp_vrf ? "VRF %s vni %u evp %s RMAC %s nexthop %pI4 esi %s esf 0x%x from %s",
vrf_id_to_name(vpn->bgp_vrf->vrf_id) : " ", vpn->bgp_vrf ? vrf_id_to_name(vpn->bgp_vrf->vrf_id)
vpn->vni, : " ",
prefix2str(evp, buf1, sizeof(buf1)), vpn->vni, prefix2str(evp, buf1, sizeof(buf1)),
prefix_mac2str(&attr.rmac, buf, sizeof(buf)), prefix_mac2str(&attr.rmac, buf, sizeof(buf)),
inet_ntoa(attr.mp_nexthop_global_in), &attr.mp_nexthop_global_in,
esi_to_str(&attr.esi, buf3, sizeof(buf3)), esi_to_str(&attr.esi, buf3, sizeof(buf3)),
attr.es_flags, caller); attr.es_flags, caller);
} }
/* Update the route entry. */ /* Update the route entry. */
@ -4965,8 +4966,7 @@ void bgp_evpn_derive_auto_rd(struct bgp *bgp, struct bgpevpn *vpn)
vpn->prd.family = AF_UNSPEC; vpn->prd.family = AF_UNSPEC;
vpn->prd.prefixlen = 64; vpn->prd.prefixlen = 64;
snprintf(buf, sizeof(buf), "%s:%hu", inet_ntoa(bgp->router_id), snprintfrr(buf, sizeof(buf), "%pI4:%hu", &bgp->router_id, vpn->rd_id);
vpn->rd_id);
(void)str2prefix_rd(buf, &vpn->prd); (void)str2prefix_rd(buf, &vpn->prd);
UNSET_FLAG(vpn->flags, VNI_FLAG_RD_CFGD); UNSET_FLAG(vpn->flags, VNI_FLAG_RD_CFGD);
} }

View File

@ -29,6 +29,8 @@
#include "jhash.h" #include "jhash.h"
#include "zclient.h" #include "zclient.h"
#include "lib/printfrr.h"
#include "bgpd/bgp_attr_evpn.h" #include "bgpd/bgp_attr_evpn.h"
#include "bgpd/bgpd.h" #include "bgpd/bgpd.h"
#include "bgpd/bgp_table.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) { if (remote_pi) {
flog_err( flog_err(
EC_BGP_ES_INVALID, EC_BGP_ES_INVALID,
"%u ERROR: local es route for ESI: %s Vtep %s also learnt from remote", "%u ERROR: local es route for ESI: %s Vtep %pI4 also learnt from remote",
bgp->vrf_id, es->esi_str, bgp->vrf_id, es->esi_str, &es->originator_ip);
inet_ntoa(es->originator_ip));
return -1; 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 (*route_changed) {
if (BGP_DEBUG(evpn_mh, EVPN_MH_RT)) if (BGP_DEBUG(evpn_mh, EVPN_MH_RT))
zlog_debug("local ES %s vni %u route-type %s nexthop %s updated", zlog_debug(
es->esi_str, "local ES %s vni %u route-type %s nexthop %pI4 updated",
vpn ? vpn->vni : 0, es->esi_str, vpn ? vpn->vni : 0,
evp->prefix.route_type == evp->prefix.route_type == BGP_EVPN_ES_ROUTE
BGP_EVPN_ES_ROUTE ? "esr" : ? "esr"
(vpn ? "ead-evi" : "ead-es"), : (vpn ? "ead-evi" : "ead-es"),
inet_ntoa(attr->mp_nexthop_global_in)); &attr->mp_nexthop_global_in);
} }
/* Return back the route entry. */ /* 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; return 0;
if (BGP_DEBUG(evpn_mh, EVPN_MH_RT)) if (BGP_DEBUG(evpn_mh, EVPN_MH_RT))
zlog_debug("local ES %s vni %u route-type %s nexthop %s delete", zlog_debug(
es->esi_str, "local ES %s vni %u route-type %s nexthop %pI4 delete",
vpn ? vpn->vni : 0, es->esi_str, vpn ? vpn->vni : 0,
p->prefix.route_type == BGP_EVPN_ES_ROUTE ? p->prefix.route_type == BGP_EVPN_ES_ROUTE
"esr" : (vpn ? "ead-evi" : "ead-es"), ? "esr"
inet_ntoa(es->originator_ip)); : (vpn ? "ead-evi" : "ead-es"),
&es->originator_ip);
/* Next, locate route node in the global EVPN routing table. /* Next, locate route node in the global EVPN routing table.
* Note that this table is a 2-level tree (RD-level + Prefix-level) * 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, ret = bgp_evpn_mh_route_update(bgp, es, NULL, afi, safi, dest, &attr, 1,
&pi, &route_changed); &pi, &route_changed);
if (ret != 0) { if (ret != 0) {
flog_err(EC_BGP_ES_INVALID, flog_err(
"%u ERROR: Failed to updated ES route ESI: %s VTEP %s", EC_BGP_ES_INVALID,
bgp->vrf_id, es->esi_str, "%u ERROR: Failed to updated ES route ESI: %s VTEP %pI4",
inet_ntoa(es->originator_ip)); bgp->vrf_id, es->esi_str, &es->originator_ip);
} }
assert(pi); assert(pi);
@ -878,10 +880,11 @@ static int bgp_evpn_type1_route_update(struct bgp *bgp,
ret = bgp_evpn_mh_route_update(bgp, es, vpn, afi, safi, dest, ret = bgp_evpn_mh_route_update(bgp, es, vpn, afi, safi, dest,
&attr, 1, &pi, &route_changed); &attr, 1, &pi, &route_changed);
if (ret != 0) { if (ret != 0) {
flog_err(EC_BGP_ES_INVALID, flog_err(
"%u Failed to update EAD-EVI route ESI: %s VNI %u VTEP %s", EC_BGP_ES_INVALID,
bgp->vrf_id, es->esi_str, vpn->vni, "%u Failed to update EAD-EVI route ESI: %s VNI %u VTEP %pI4",
inet_ntoa(es->originator_ip)); bgp->vrf_id, es->esi_str, vpn->vni,
&es->originator_ip);
} }
global_rd = &vpn->prd; global_rd = &vpn->prd;
} else { } else {
@ -900,10 +903,10 @@ static int bgp_evpn_type1_route_update(struct bgp *bgp,
ret = bgp_evpn_mh_route_update(bgp, es, vpn, afi, safi, dest, ret = bgp_evpn_mh_route_update(bgp, es, vpn, afi, safi, dest,
&attr, 1, &pi, &route_changed); &attr, 1, &pi, &route_changed);
if (ret != 0) { if (ret != 0) {
flog_err(EC_BGP_ES_INVALID, flog_err(
"%u ERROR: Failed to updated EAD-EVI route ESI: %s VTEP %s", EC_BGP_ES_INVALID,
bgp->vrf_id, es->esi_str, "%u ERROR: Failed to updated EAD-EVI route ESI: %s VTEP %pI4",
inet_ntoa(es->originator_ip)); bgp->vrf_id, es->esi_str, &es->originator_ip);
} }
global_rd = &es->prd; global_rd = &es->prd;
} }
@ -1167,9 +1170,8 @@ static int bgp_zebra_send_remote_es_vtep(struct bgp *bgp,
stream_putw_at(s, 0, stream_get_endp(s)); stream_putw_at(s, 0, stream_get_endp(s));
if (BGP_DEBUG(evpn_mh, EVPN_MH_ES)) if (BGP_DEBUG(evpn_mh, EVPN_MH_ES))
zlog_debug("Tx %s Remote ESI %s VTEP %s", zlog_debug("Tx %s Remote ESI %s VTEP %pI4", add ? "ADD" : "DEL",
add ? "ADD" : "DEL", es->esi_str, es->esi_str, &es_vtep->vtep_ip);
inet_ntoa(es_vtep->vtep_ip));
return zclient_send_message(zclient); return zclient_send_message(zclient);
} }
@ -1195,10 +1197,9 @@ static void bgp_evpn_es_vtep_re_eval_active(struct bgp *bgp,
return; return;
if (BGP_DEBUG(evpn_mh, EVPN_MH_ES)) if (BGP_DEBUG(evpn_mh, EVPN_MH_ES))
zlog_debug("es %s vtep %s %s", zlog_debug("es %s vtep %pI4 %s", es_vtep->es->esi_str,
es_vtep->es->esi_str, &es_vtep->vtep_ip,
inet_ntoa(es_vtep->vtep_ip), new_active ? "active" : "inactive");
new_active ? "active" : "inactive");
/* send remote ES to zebra */ /* send remote ES to zebra */
bgp_zebra_send_remote_es_vtep(bgp, es_vtep, new_active); bgp_zebra_send_remote_es_vtep(bgp, es_vtep, new_active);
@ -1218,10 +1219,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); es_vtep = bgp_evpn_es_vtep_new(es, vtep_ip);
if (BGP_DEBUG(evpn_mh, EVPN_MH_ES)) if (BGP_DEBUG(evpn_mh, EVPN_MH_ES))
zlog_debug("es %s vtep %s add %s", zlog_debug("es %s vtep %pI4 add %s", es_vtep->es->esi_str,
es_vtep->es->esi_str, &es_vtep->vtep_ip, esr ? "esr" : "ead");
inet_ntoa(es_vtep->vtep_ip),
esr ? "esr" : "ead");
if (esr) if (esr)
SET_FLAG(es_vtep->flags, BGP_EVPNES_VTEP_ESR); SET_FLAG(es_vtep->flags, BGP_EVPNES_VTEP_ESR);
@ -1237,10 +1236,8 @@ static void bgp_evpn_es_vtep_do_del(struct bgp *bgp,
struct bgp_evpn_es_vtep *es_vtep, bool esr) struct bgp_evpn_es_vtep *es_vtep, bool esr)
{ {
if (BGP_DEBUG(evpn_mh, EVPN_MH_ES)) if (BGP_DEBUG(evpn_mh, EVPN_MH_ES))
zlog_debug("es %s vtep %s del %s", zlog_debug("es %s vtep %pI4 del %s", es_vtep->es->esi_str,
es_vtep->es->esi_str, &es_vtep->vtep_ip, esr ? "esr" : "ead");
inet_ntoa(es_vtep->vtep_ip),
esr ? "esr" : "ead");
if (esr) { if (esr) {
UNSET_FLAG(es_vtep->flags, BGP_EVPNES_VTEP_ESR); UNSET_FLAG(es_vtep->flags, BGP_EVPNES_VTEP_ESR);
} else { } else {
@ -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); bf_assign_index(bm->rd_idspace, es->rd_id);
es->prd.family = AF_UNSPEC; es->prd.family = AF_UNSPEC;
es->prd.prefixlen = 64; es->prd.prefixlen = 64;
snprintf(buf, sizeof(buf), "%s:%hu", inet_ntoa(bgp->router_id), snprintfrr(buf, sizeof(buf), "%pI4:%hu", &bgp->router_id, es->rd_id);
es->rd_id);
(void)str2prefix_rd(buf, &es->prd); (void)str2prefix_rd(buf, &es->prd);
} }
@ -1533,9 +1529,8 @@ int bgp_evpn_local_es_add(struct bgp *bgp, esi_t *esi,
} }
if (BGP_DEBUG(evpn_mh, EVPN_MH_ES)) if (BGP_DEBUG(evpn_mh, EVPN_MH_ES))
zlog_debug("add local es %s orig-ip %s", zlog_debug("add local es %s orig-ip %pI4", es->esi_str,
es->esi_str, &originator_ip);
inet_ntoa(originator_ip));
es->originator_ip = originator_ip; es->originator_ip = originator_ip;
bgp_evpn_es_local_info_set(bgp, es); 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 listnode *node;
struct bgp_evpn_es_vtep *es_vtep; struct bgp_evpn_es_vtep *es_vtep;
bool first = true; bool first = true;
char vtep_ip[BUFSIZ] = {0};
vtep_str[0] = '\0'; vtep_str[0] = '\0';
for (ALL_LIST_ELEMENTS_RO(es->es_vtep_list, node, es_vtep)) { for (ALL_LIST_ELEMENTS_RO(es->es_vtep_list, node, es_vtep)) {
vtep_flag_str[0] = '\0'; vtep_flag_str[0] = '\0';
if (es_vtep->flags & BGP_EVPNES_VTEP_ESR) if (es_vtep->flags & BGP_EVPNES_VTEP_ESR)
strlcat(vtep_flag_str, "E", sizeof(vtep_flag_str)); strlcat(vtep_flag_str, "E", sizeof(vtep_flag_str));
if (es_vtep->flags & BGP_EVPNES_VTEP_ACTIVE) 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; first = false;
else else
strlcat(vtep_str, ",", vtep_str_size); 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_str_size);
strlcat(vtep_str, vtep_flag_str, vtep_str_size); strlcat(vtep_str, vtep_flag_str, vtep_str_size);
strlcat(vtep_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_vtep_entry;
json_object *json_flags; json_object *json_flags;
char vtep_ip[BUFSIZ] = {0};
json_vtep_entry = json_object_new_object(); json_vtep_entry = json_object_new_object();
json_object_string_add(json_vtep_entry, "vtep_ip", 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 | if (es_vtep->flags & (BGP_EVPNES_VTEP_ESR |
BGP_EVPNES_VTEP_ACTIVE)) { BGP_EVPNES_VTEP_ACTIVE)) {
json_flags = json_object_new_array(); 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, static void bgp_evpn_es_show_entry_detail(struct vty *vty,
struct bgp_evpn_es *es, json_object *json) struct bgp_evpn_es *es, json_object *json)
{ {
char originator_ip[BUFSIZ] = {0};
if (json) { if (json) {
json_object *json_flags; json_object *json_flags;
json_object *json_incons; 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_object_add(json, "flags", json_flags);
} }
json_object_string_add(json, "originator_ip", 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", json_object_int_add(json, "remoteVniCount",
es->remote_es_evi_cnt); es->remote_es_evi_cnt);
json_object_int_add(json, "inconsistentVniVtepCount", 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, "ESI: %s\n", es->esi_str);
vty_out(vty, " Type: %s\n", type_str); vty_out(vty, " Type: %s\n", type_str);
vty_out(vty, " RD: %s\n", buf1); vty_out(vty, " RD: %s\n", buf1);
vty_out(vty, " Originator-IP: %s\n", vty_out(vty, " Originator-IP: %pI4\n", &es->originator_ip);
inet_ntoa(es->originator_ip));
vty_out(vty, " VNI Count: %d\n", listcount(es->es_evi_list)); vty_out(vty, " VNI Count: %d\n", listcount(es->es_evi_list));
vty_out(vty, " Remote VNI Count: %d\n", vty_out(vty, " Remote VNI Count: %d\n",
es->remote_es_evi_cnt); es->remote_es_evi_cnt);
@ -1919,11 +1926,10 @@ static void bgp_evpn_es_evi_vtep_re_eval_active(struct bgp *bgp,
return; return;
if (BGP_DEBUG(evpn_mh, EVPN_MH_ES)) if (BGP_DEBUG(evpn_mh, EVPN_MH_ES))
zlog_debug("es %s evi %u vtep %s %s", zlog_debug("es %s evi %u vtep %pI4 %s",
evi_vtep->es_evi->es->esi_str, evi_vtep->es_evi->es->esi_str,
evi_vtep->es_evi->vpn->vni, evi_vtep->es_evi->vpn->vni, &evi_vtep->vtep_ip,
inet_ntoa(evi_vtep->vtep_ip), new_active ? "active" : "inactive");
new_active ? "active" : "inactive");
/* add VTEP to parent es */ /* add VTEP to parent es */
if (new_active) { 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); evi_vtep = bgp_evpn_es_evi_vtep_new(es_evi, vtep_ip);
if (BGP_DEBUG(evpn_mh, EVPN_MH_ES)) if (BGP_DEBUG(evpn_mh, EVPN_MH_ES))
zlog_debug("add es %s evi %u vtep %s %s", zlog_debug("add es %s evi %u vtep %pI4 %s",
evi_vtep->es_evi->es->esi_str, evi_vtep->es_evi->es->esi_str,
evi_vtep->es_evi->vpn->vni, evi_vtep->es_evi->vpn->vni, &evi_vtep->vtep_ip,
inet_ntoa(evi_vtep->vtep_ip), ead_es ? "ead_es" : "ead_evi");
ead_es ? "ead_es" : "ead_evi");
if (ead_es) if (ead_es)
SET_FLAG(evi_vtep->flags, BGP_EVPN_EVI_VTEP_EAD_PER_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; return;
if (BGP_DEBUG(evpn_mh, EVPN_MH_ES)) if (BGP_DEBUG(evpn_mh, EVPN_MH_ES))
zlog_debug("del es %s evi %u vtep %s %s", zlog_debug("del es %s evi %u vtep %pI4 %s",
evi_vtep->es_evi->es->esi_str, evi_vtep->es_evi->es->esi_str,
evi_vtep->es_evi->vpn->vni, evi_vtep->es_evi->vpn->vni, &evi_vtep->vtep_ip,
inet_ntoa(evi_vtep->vtep_ip), ead_es ? "ead_es" : "ead_evi");
ead_es ? "ead_es" : "ead_evi");
if (ead_es) if (ead_es)
UNSET_FLAG(evi_vtep->flags, BGP_EVPN_EVI_VTEP_EAD_PER_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; return 0;
if (BGP_DEBUG(evpn_mh, EVPN_MH_ES)) if (BGP_DEBUG(evpn_mh, EVPN_MH_ES))
zlog_debug("add remote %s es %s evi %u vtep %s", zlog_debug("add remote %s es %s evi %u vtep %pI4",
p->prefix.ead_addr.eth_tag ? p->prefix.ead_addr.eth_tag ? "ead-es" : "ead-evi",
"ead-es" : "ead-evi", esi_to_str(esi, buf, sizeof(buf)), vpn->vni,
esi_to_str(esi, buf, &p->prefix.ead_addr.ip.ipaddr_v4);
sizeof(buf)),
vpn->vni,
inet_ntoa(p->prefix.ead_addr.ip.ipaddr_v4));
es = bgp_evpn_es_find(esi); es = bgp_evpn_es_find(esi);
if (!es) { if (!es) {
@ -2348,13 +2349,11 @@ int bgp_evpn_remote_es_evi_del(struct bgp *bgp, struct bgpevpn *vpn,
return 0; return 0;
if (BGP_DEBUG(evpn_mh, EVPN_MH_ES)) if (BGP_DEBUG(evpn_mh, EVPN_MH_ES))
zlog_debug("del remote %s es %s evi %u vtep %s", zlog_debug(
p->prefix.ead_addr.eth_tag ? "del remote %s es %s evi %u vtep %pI4",
"ead-es" : "ead-evi", p->prefix.ead_addr.eth_tag ? "ead-es" : "ead-evi",
esi_to_str(&p->prefix.ead_addr.esi, buf, esi_to_str(&p->prefix.ead_addr.esi, buf, sizeof(buf)),
sizeof(buf)), vpn->vni, &p->prefix.ead_addr.ip.ipaddr_v4);
vpn->vni,
inet_ntoa(p->prefix.ead_addr.ip.ipaddr_v4));
es = bgp_evpn_es_find(&p->prefix.ead_addr.esi); es = bgp_evpn_es_find(&p->prefix.ead_addr.esi);
if (!es) if (!es)
@ -2405,6 +2404,7 @@ static char *bgp_evpn_es_evi_vteps_str(char *vtep_str,
struct listnode *node; struct listnode *node;
struct bgp_evpn_es_evi_vtep *evi_vtep; struct bgp_evpn_es_evi_vtep *evi_vtep;
bool first = true; bool first = true;
char vtep_ip[BUFSIZ] = {0};
vtep_str[0] = '\0'; vtep_str[0] = '\0';
for (ALL_LIST_ELEMENTS_RO(es_evi->es_evi_vtep_list, node, evi_vtep)) { 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; first = false;
else else
strlcat(vtep_str, ",", vtep_str_size); 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_str_size);
strlcat(vtep_str, vtep_flag_str, vtep_str_size); strlcat(vtep_str, vtep_flag_str, vtep_str_size);
strlcat(vtep_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_vtep_entry;
json_object *json_flags; json_object *json_flags;
char vtep_ip[BUFSIZ] = {0};
json_vtep_entry = json_object_new_object(); json_vtep_entry = json_object_new_object();
json_object_string_add(json_vtep_entry, json_object_string_add(json_vtep_entry, "vtep_ip",
"vtep_ip", inet_ntop(AF_INET, &evi_vtep->vtep_ip, vtep_ip,
inet_ntoa(evi_vtep->vtep_ip)); sizeof(vtep_ip)));
if (evi_vtep->flags & (BGP_EVPN_EVI_VTEP_EAD_PER_ES | if (evi_vtep->flags & (BGP_EVPN_EVI_VTEP_EAD_PER_ES |
BGP_EVPN_EVI_VTEP_EAD_PER_EVI)) { BGP_EVPN_EVI_VTEP_EAD_PER_EVI)) {
json_flags = json_object_new_array(); json_flags = json_object_new_array();

View File

@ -22,6 +22,7 @@
#include "command.h" #include "command.h"
#include "prefix.h" #include "prefix.h"
#include "lib/json.h" #include "lib/json.h"
#include "lib/printfrr.h"
#include "stream.h" #include "stream.h"
#include "bgpd/bgpd.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++ << 8);
eip.val |= (*pnt++); eip.val |= (*pnt++);
snprintf(rt_buf, sizeof(rt_buf), "%s:%u", inet_ntoa(eip.ip), snprintfrr(rt_buf, sizeof(rt_buf), "%pI4:%u", &eip.ip, eip.val);
eip.val);
if (json) if (json)
json_object_string_add(json_rt, "rt", rt_buf); 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++ << 8);
eip.val |= (*pnt++); eip.val |= (*pnt++);
snprintf(rt_buf, sizeof(rt_buf), "%s:%u", inet_ntoa(eip.ip), snprintfrr(rt_buf, sizeof(rt_buf), "%pI4:%u", &eip.ip, eip.val);
eip.val);
if (json) if (json)
json_object_string_add(json_rt, "rt", rt_buf); 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: case RD_TYPE_IP:
decode_rd_ip(pnt + 2, &rd_ip); decode_rd_ip(pnt + 2, &rd_ip);
snprintf(rd_str, len, "%s:%d", inet_ntoa(rd_ip.ip), snprintfrr(rd_str, len, "%pI4:%d", &rd_ip.ip, rd_ip.val);
rd_ip.val);
if (json) if (json)
json_object_string_add(json, "rd", rd_str); json_object_string_add(json, "rd", rd_str);
else else
@ -343,8 +341,9 @@ static void bgp_evpn_show_route_header(struct vty *vty, struct bgp *bgp,
if (json) if (json)
return; return;
vty_out(vty, "BGP table version is %" PRIu64 ", local router ID is %s\n", vty_out(vty,
tbl_ver, inet_ntoa(bgp->router_id)); "BGP table version is %" PRIu64 ", local router ID is %pI4\n",
tbl_ver, &bgp->router_id);
vty_out(vty, vty_out(vty,
"Status codes: s suppressed, d damped, h history, * valid, > best, i - internal\n"); "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal\n");
vty_out(vty, "Origin codes: i - IGP, e - EGP, ? - incomplete\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_import_rtl = NULL;
json_object *json_export_rtl = NULL; json_object *json_export_rtl = NULL;
char buf2[ETHER_ADDR_STRLEN]; char buf2[ETHER_ADDR_STRLEN];
char originator_ip[BUFSIZ] = {0};
json_import_rtl = json_export_rtl = 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_object_string_add(
json, "rd", json, "rd",
prefix_rd2str(&bgp_vrf->vrf_prd, buf1, RD_ADDRSTRLEN)); prefix_rd2str(&bgp_vrf->vrf_prd, buf1, RD_ADDRSTRLEN));
json_object_string_add(json, "originatorIp", json_object_string_add(
inet_ntoa(bgp_vrf->originator_ip)); 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, "advertiseGatewayMacip", "n/a");
json_object_string_add(json, "advertiseSviMacIp", "n/a"); json_object_string_add(json, "advertiseSviMacIp", "n/a");
json_object_to_json_string_ext(json, 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)); vrf_id_to_name(bgp_vrf->vrf_id));
vty_out(vty, " RD: %s\n", vty_out(vty, " RD: %s\n",
prefix_rd2str(&bgp_vrf->vrf_prd, buf1, RD_ADDRSTRLEN)); prefix_rd2str(&bgp_vrf->vrf_prd, buf1, RD_ADDRSTRLEN));
vty_out(vty, " Originator IP: %s\n", vty_out(vty, " Originator IP: %pI4\n",
inet_ntoa(bgp_vrf->originator_ip)); &bgp_vrf->originator_ip);
vty_out(vty, " Advertise-gw-macip : %s\n", "n/a"); vty_out(vty, " Advertise-gw-macip : %s\n", "n/a");
vty_out(vty, " Advertise-svi-macip : %s\n", "n/a"); vty_out(vty, " Advertise-svi-macip : %s\n", "n/a");
vty_out(vty, " Advertise-pip: %s\n", 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_import_rtl = NULL;
json_object *json_export_rtl = NULL; json_object *json_export_rtl = NULL;
struct bgp *bgp_evpn; struct bgp *bgp_evpn;
char buf[BUFSIZ] = {0};
bgp_evpn = bgp_get_evpn(); bgp_evpn = bgp_get_evpn();
@ -487,9 +490,11 @@ static void display_vni(struct vty *vty, struct bgpevpn *vpn, json_object *json)
json, "rd", json, "rd",
prefix_rd2str(&vpn->prd, buf1, sizeof(buf1))); prefix_rd2str(&vpn->prd, buf1, sizeof(buf1)));
json_object_string_add(json, "originatorIp", json_object_string_add(json, "originatorIp",
inet_ntoa(vpn->originator_ip)); inet_ntop(AF_INET, &vpn->originator_ip,
json_object_string_add(json, "mcastGroup", buf, sizeof(buf)));
inet_ntoa(vpn->mcast_grp)); json_object_string_add(
json, "mcastGroup",
inet_ntop(AF_INET, &vpn->mcast_grp, buf, sizeof(buf)));
/* per vni knob is enabled -- Enabled /* per vni knob is enabled -- Enabled
* Global knob is enabled -- Active * Global knob is enabled -- Active
* default -- Disabled * 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)); vrf_id_to_name(vpn->tenant_vrf_id));
vty_out(vty, " RD: %s\n", vty_out(vty, " RD: %s\n",
prefix_rd2str(&vpn->prd, buf1, sizeof(buf1))); prefix_rd2str(&vpn->prd, buf1, sizeof(buf1)));
vty_out(vty, " Originator IP: %s\n", vty_out(vty, " Originator IP: %pI4\n", &vpn->originator_ip);
inet_ntoa(vpn->originator_ip)); vty_out(vty, " Mcast group: %pI4\n", &vpn->mcast_grp);
vty_out(vty, " Mcast group: %s\n",
inet_ntoa(vpn->mcast_grp));
if (!vpn->advertise_gw_macip && if (!vpn->advertise_gw_macip &&
bgp_evpn && bgp_evpn->advertise_gw_macip) bgp_evpn && bgp_evpn->advertise_gw_macip)
vty_out(vty, " Advertise-gw-macip : %s\n", 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; json_object *json_export_rtl = NULL;
char buf1[10]; char buf1[10];
char buf2[INET6_ADDRSTRLEN]; char buf2[INET6_ADDRSTRLEN];
char buf3[BUFSIZ] = {0};
char rt_buf[25]; char rt_buf[25];
char *ecom_str; char *ecom_str;
struct listnode *node, *nnode; 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, "type", "L3");
json_object_string_add(json_vni, "inKernel", "True"); json_object_string_add(json_vni, "inKernel", "True");
json_object_string_add(json_vni, "originatorIp", 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_object_string_add(
json_vni, "rd", json_vni, "rd",
prefix_rd2str(&bgp->vrf_prd, buf2, RD_ADDRSTRLEN)); 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", json_vni, "advertisePip",
bgp->evpn_info->advertise_pip ? "Enabled" : "Disabled"); bgp->evpn_info->advertise_pip ? "Enabled" : "Disabled");
json_object_string_add(json_vni, "sysIP", 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", json_object_string_add(json_vni, "sysMAC",
prefix_mac2str(&bgp->evpn_info->pip_rmac, prefix_mac2str(&bgp->evpn_info->pip_rmac,
buf2, sizeof(buf2))); 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; struct bgpevpn *vpn = (struct bgpevpn *)bucket->data;
char buf1[10]; char buf1[10];
char buf2[RD_ADDRSTRLEN]; char buf2[RD_ADDRSTRLEN];
char buf3[BUFSIZ] = {0};
char rt_buf[25]; char rt_buf[25];
char *ecom_str; char *ecom_str;
struct listnode *node, *nnode; struct listnode *node, *nnode;
@ -980,9 +988,11 @@ static void show_vni_entry(struct hash_bucket *bucket, void *args[])
json_vni, "rd", json_vni, "rd",
prefix_rd2str(&vpn->prd, buf2, sizeof(buf2))); prefix_rd2str(&vpn->prd, buf2, sizeof(buf2)));
json_object_string_add(json_vni, "originatorIp", 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", 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 /* per vni knob is enabled -- Enabled
* Global knob is enabled -- Active * Global knob is enabled -- Active
* default -- Disabled * 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 rd_str[RD_ADDRSTRLEN];
char buf[BUFSIZ]; char buf[BUFSIZ];
int no_display; int no_display;
char router_id[BUFSIZ] = {0};
unsigned long output_count = 0; unsigned long output_count = 0;
unsigned long total_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_object_string_add(
json, json,
"bgpLocalRouterId", "bgpLocalRouterId",
inet_ntoa( inet_ntop(
bgp->router_id)); AF_INET,
&bgp->router_id,
router_id,
sizeof(router_id)));
json_object_int_add( json_object_int_add(
json, json,
"defaultLocPrf", "defaultLocPrf",
@ -5051,6 +5065,7 @@ DEFUN (show_bgp_vrf_l3vni_info,
{ {
char buf[ETHER_ADDR_STRLEN]; char buf[ETHER_ADDR_STRLEN];
char buf1[INET6_ADDRSTRLEN]; char buf1[INET6_ADDRSTRLEN];
char originator_ip[BUFSIZ] = {0};
int idx_vrf = 3; int idx_vrf = 3;
const char *name = NULL; const char *name = NULL;
struct bgp *bgp = NULL; struct bgp *bgp = NULL;
@ -5086,7 +5101,7 @@ DEFUN (show_bgp_vrf_l3vni_info,
if (!json) { if (!json) {
vty_out(vty, "BGP VRF: %s\n", name); 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, " L3-VNI: %u\n", bgp->l3vni);
vty_out(vty, " Rmac: %s\n", vty_out(vty, " Rmac: %s\n",
prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); prefix_mac2str(&bgp->rmac, buf, sizeof(buf)));
@ -5115,7 +5130,9 @@ DEFUN (show_bgp_vrf_l3vni_info,
} else { } else {
json_object_string_add(json, "vrf", name); json_object_string_add(json, "vrf", name);
json_object_string_add(json, "local-ip", 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_int_add(json, "l3vni", bgp->l3vni);
json_object_string_add( json_object_string_add(
json, "rmac", json, "rmac",

View File

@ -422,8 +422,8 @@ int bgp_nlri_parse_label(struct peer *peer, struct attr *attr,
*/ */
flog_err( flog_err(
EC_BGP_UPDATE_RCV, EC_BGP_UPDATE_RCV,
"%s: IPv4 labeled-unicast NLRI is multicast address %s, ignoring", "%s: IPv4 labeled-unicast NLRI is multicast address %pI4, ignoring",
peer->host, inet_ntoa(p.u.prefix4)); peer->host, &p.u.prefix4);
continue; continue;
} }
} }

View File

@ -566,9 +566,9 @@ void bgp_open_send(struct peer *peer)
if (bgp_debug_neighbor_events(peer)) if (bgp_debug_neighbor_events(peer))
zlog_debug( 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, peer->host, BGP_VERSION_4, local_as, send_holdtime,
inet_ntoa(peer->local_id)); &peer->local_id);
/* Dump packet if debug option is set. */ /* Dump packet if debug option is set. */
/* bgp_packet_dump (s); */ /* 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) && peer->local_as == peer->as)
flog_err( flog_err(
EC_BGP_ROUTER_ID_SAME, EC_BGP_ROUTER_ID_SAME,
"Peer's router-id %s is the same as ours", "Peer's router-id %pI4 is the same as ours",
inet_ntoa(remote_id)); &remote_id);
/* 3. Otherwise, the local system closes newly /* 3. Otherwise, the local system closes newly
created created
@ -1115,9 +1115,8 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size)
/* Receive OPEN message log */ /* Receive OPEN message log */
if (bgp_debug_neighbor_events(peer)) if (bgp_debug_neighbor_events(peer))
zlog_debug( zlog_debug(
"%s rcv OPEN, version %d, remote-as (in open) %u, holdtime %d, id %s", "%s rcv OPEN, version %d, remote-as (in open) %u, holdtime %d, id %pI4",
peer->host, version, remote_as, holdtime, peer->host, version, remote_as, holdtime, &remote_id);
inet_ntoa(remote_id));
/* BEGIN to read the capability here, but dont do it yet */ /* BEGIN to read the capability here, but dont do it yet */
mp_capability = 0; mp_capability = 0;
@ -1219,8 +1218,8 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size)
|| (peer->sort == BGP_PEER_IBGP || (peer->sort == BGP_PEER_IBGP
&& ntohl(peer->local_id.s_addr) == ntohl(remote_id.s_addr))) { && ntohl(peer->local_id.s_addr) == ntohl(remote_id.s_addr))) {
if (bgp_debug_neighbor_events(peer)) if (bgp_debug_neighbor_events(peer))
zlog_debug("%s bad OPEN, wrong router identifier %s", zlog_debug("%s bad OPEN, wrong router identifier %pI4",
peer->host, inet_ntoa(remote_id)); peer->host, &remote_id);
bgp_notify_send_with_data(peer, BGP_NOTIFY_OPEN_ERR, bgp_notify_send_with_data(peer, BGP_NOTIFY_OPEN_ERR,
BGP_NOTIFY_OPEN_BAD_BGP_IDENT, BGP_NOTIFY_OPEN_BAD_BGP_IDENT,
notify_data_remote_id, 4); notify_data_remote_id, 4);

View File

@ -29,6 +29,8 @@
#include "filter.h" #include "filter.h"
#include "frrstr.h" #include "frrstr.h"
#include "lib/printfrr.h"
#include "bgpd/bgpd.h" #include "bgpd/bgpd.h"
#include "bgpd/bgp_rd.h" #include "bgpd/bgp_rd.h"
#include "bgpd/bgp_attr.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; return buf;
} else if (type == RD_TYPE_IP) { } else if (type == RD_TYPE_IP) {
decode_rd_ip(pnt + 2, &rd_ip); decode_rd_ip(pnt + 2, &rd_ip);
snprintf(buf, size, "%s:%hu", inet_ntoa(rd_ip.ip), snprintfrr(buf, size, "%pI4:%hu", &rd_ip.ip, rd_ip.val);
rd_ip.val);
return buf; return buf;
} }
#ifdef ENABLE_BGP_VNC #ifdef ENABLE_BGP_VNC
@ -210,6 +211,6 @@ void form_auto_rd(struct in_addr router_id,
prd->family = AF_UNSPEC; prd->family = AF_UNSPEC;
prd->prefixlen = 64; 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); (void)str2prefix_rd(buf, prd);
} }

View File

@ -723,18 +723,18 @@ static int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
*reason = bgp_path_selection_evpn_lower_ip; *reason = bgp_path_selection_evpn_lower_ip;
if (debug) if (debug)
zlog_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, pfx_buf, new_buf, exist_buf, new_mm_seq,
inet_ntoa(new->attr->nexthop)); &new->attr->nexthop);
return 1; return 1;
} }
if (nh_cmp > 0) { if (nh_cmp > 0) {
*reason = bgp_path_selection_evpn_lower_ip; *reason = bgp_path_selection_evpn_lower_ip;
if (debug) if (debug)
zlog_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, pfx_buf, new_buf, exist_buf, new_mm_seq,
inet_ntoa(new->attr->nexthop)); &new->attr->nexthop);
return 0; return 0;
} }
} }
@ -4980,8 +4980,8 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr,
*/ */
flog_err( flog_err(
EC_BGP_UPDATE_RCV, EC_BGP_UPDATE_RCV,
"%s: IPv4 unicast NLRI is multicast address %s, ignoring", "%s: IPv4 unicast NLRI is multicast address %pI4, ignoring",
peer->host, inet_ntoa(p.u.prefix4)); peer->host, &p.u.prefix4);
continue; continue;
} }
} }
@ -7879,10 +7879,14 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
} }
} else if (safi == SAFI_EVPN) { } else if (safi == SAFI_EVPN) {
if (json_paths) { if (json_paths) {
char buf[BUFSIZ] = {0};
json_nexthop_global = json_object_new_object(); json_nexthop_global = json_object_new_object();
json_object_string_add(json_nexthop_global, "ip", 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) if (path->peer->hostname)
json_object_string_add(json_nexthop_global, json_object_string_add(json_nexthop_global,
@ -7910,13 +7914,16 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
} else if (safi == SAFI_FLOWSPEC) { } else if (safi == SAFI_FLOWSPEC) {
if (attr->nexthop.s_addr != INADDR_ANY) { if (attr->nexthop.s_addr != INADDR_ANY) {
if (json_paths) { if (json_paths) {
char buf[BUFSIZ] = {0};
json_nexthop_global = json_object_new_object(); json_nexthop_global = json_object_new_object();
json_object_string_add(json_nexthop_global, json_object_string_add(json_nexthop_global,
"afi", "ipv4"); "afi", "ipv4");
json_object_string_add( json_object_string_add(
json_nexthop_global, "ip", json_nexthop_global, "ip",
inet_ntoa(attr->nexthop)); inet_ntop(AF_INET, &attr->nexthop, buf,
sizeof(buf)));
if (path->peer->hostname) if (path->peer->hostname)
json_object_string_add( json_object_string_add(
@ -7946,10 +7953,14 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
} }
} else if (p->family == AF_INET && !BGP_ATTR_NEXTHOP_AFI_IP6(attr)) { } else if (p->family == AF_INET && !BGP_ATTR_NEXTHOP_AFI_IP6(attr)) {
if (json_paths) { if (json_paths) {
char buf[BUFSIZ] = {0};
json_nexthop_global = json_object_new_object(); json_nexthop_global = json_object_new_object();
json_object_string_add(json_nexthop_global, "ip", 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) if (path->peer->hostname)
json_object_string_add(json_nexthop_global, json_object_string_add(json_nexthop_global,
@ -8257,18 +8268,24 @@ void route_vty_out_tmp(struct vty *vty, const struct prefix *p,
/* Print attribute */ /* Print attribute */
if (attr) { if (attr) {
if (use_json) { if (use_json) {
char buf[BUFSIZ] = {0};
if (p->family == AF_INET if (p->family == AF_INET
&& (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP && (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) { || !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) {
if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP) if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP)
json_object_string_add( json_object_string_add(
json_net, "nextHop", json_net, "nextHop",
inet_ntoa( inet_ntop(
attr->mp_nexthop_global_in)); AF_INET,
&attr->mp_nexthop_global_in,
buf, sizeof(buf)));
else else
json_object_string_add( json_object_string_add(
json_net, "nextHop", json_net, "nextHop",
inet_ntoa(attr->nexthop)); inet_ntop(AF_INET,
&attr->nexthop, buf,
sizeof(buf)));
} else if (p->family == AF_INET6 } else if (p->family == AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr)) { || BGP_ATTR_NEXTHOP_AFI_IP6(attr)) {
char buf[BUFSIZ]; char buf[BUFSIZ];
@ -8278,11 +8295,16 @@ void route_vty_out_tmp(struct vty *vty, const struct prefix *p,
inet_ntop(AF_INET6, inet_ntop(AF_INET6,
&attr->mp_nexthop_global, buf, &attr->mp_nexthop_global, buf,
BUFSIZ)); BUFSIZ));
} else if (p->family == AF_EVPN && } else if (p->family == AF_EVPN
!BGP_ATTR_NEXTHOP_AFI_IP6(attr)) && !BGP_ATTR_NEXTHOP_AFI_IP6(attr)) {
json_object_string_add(json_net, char buf[BUFSIZ] = {0};
"nextHop", inet_ntoa(
attr->mp_nexthop_global_in)); json_object_string_add(
json_net, "nextHop",
inet_ntop(AF_INET,
&attr->mp_nexthop_global_in,
buf, sizeof(buf)));
}
if (attr->flag if (attr->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
@ -8310,15 +8332,12 @@ void route_vty_out_tmp(struct vty *vty, const struct prefix *p,
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) { || !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) {
if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP
|| safi == SAFI_EVPN) || safi == SAFI_EVPN)
vty_out(vty, "%-16s", vty_out(vty, "%-16pI4",
inet_ntoa( &attr->mp_nexthop_global_in);
attr->mp_nexthop_global_in));
else if (wide) else if (wide)
vty_out(vty, "%-41s", vty_out(vty, "%-41pI4", &attr->nexthop);
inet_ntoa(attr->nexthop));
else else
vty_out(vty, "%-16s", vty_out(vty, "%-16pI4", &attr->nexthop);
inet_ntoa(attr->nexthop));
} else if (p->family == AF_INET6 } else if (p->family == AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr)) { || BGP_ATTR_NEXTHOP_AFI_IP6(attr)) {
char buf[BUFSIZ]; char buf[BUFSIZ];
@ -8403,22 +8422,27 @@ void route_vty_out_tag(struct vty *vty, const struct prefix *p,
&& ((safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP))) && ((safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP)))
|| (safi == SAFI_EVPN && !BGP_ATTR_NEXTHOP_AFI_IP6(attr)) || (safi == SAFI_EVPN && !BGP_ATTR_NEXTHOP_AFI_IP6(attr))
|| (!BGP_ATTR_NEXTHOP_AFI_IP6(attr))) { || (!BGP_ATTR_NEXTHOP_AFI_IP6(attr))) {
char buf[BUFSIZ] = {0};
if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP
|| safi == SAFI_EVPN) { || safi == SAFI_EVPN) {
if (json) if (json)
json_object_string_add( json_object_string_add(
json_out, "mpNexthopGlobalIn", json_out, "mpNexthopGlobalIn",
inet_ntoa(attr->mp_nexthop_global_in)); inet_ntop(AF_INET,
&attr->mp_nexthop_global_in,
buf, sizeof(buf)));
else else
vty_out(vty, "%-16s", vty_out(vty, "%-16pI4",
inet_ntoa(attr->mp_nexthop_global_in)); &attr->mp_nexthop_global_in);
} else { } else {
if (json) if (json)
json_object_string_add( json_object_string_add(
json_out, "nexthop", json_out, "nexthop",
inet_ntoa(attr->nexthop)); inet_ntop(AF_INET, &attr->nexthop, buf,
sizeof(buf)));
else else
vty_out(vty, "%-16s", inet_ntoa(attr->nexthop)); vty_out(vty, "%-16pI4", &attr->nexthop);
} }
} else if (((p->family == AF_INET6) } else if (((p->family == AF_INET6)
&& ((safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP))) && ((safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP)))
@ -9044,11 +9068,14 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR))) { if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR))) {
if (json_paths) { if (json_paths) {
char buf[BUFSIZ] = {0};
json_object_int_add(json_path, "aggregatorAs", json_object_int_add(json_path, "aggregatorAs",
attr->aggregator_as); attr->aggregator_as);
json_object_string_add( json_object_string_add(json_path, "aggregatorId",
json_path, "aggregatorId", inet_ntop(AF_INET,
inet_ntoa(attr->aggregator_addr)); &attr->aggregator_addr,
buf, sizeof(buf)));
if (attr->aggregator_as == BGP_AS_ZERO) if (attr->aggregator_as == BGP_AS_ZERO)
json_object_boolean_true_add( json_object_boolean_true_add(
json_path, "aggregatorAsMalformed"); json_path, "aggregatorAsMalformed");
@ -9058,13 +9085,13 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
} else { } else {
if (attr->aggregator_as == BGP_AS_ZERO) if (attr->aggregator_as == BGP_AS_ZERO)
vty_out(vty, vty_out(vty,
", (aggregated by %u(malformed) %s)", ", (aggregated by %u(malformed) %pI4)",
attr->aggregator_as, attr->aggregator_as,
inet_ntoa(attr->aggregator_addr)); &attr->aggregator_addr);
else else
vty_out(vty, ", (aggregated by %u %s)", vty_out(vty, ", (aggregated by %u %pI4)",
attr->aggregator_as, attr->aggregator_as,
inet_ntoa(attr->aggregator_addr)); &attr->aggregator_addr);
} }
} }
@ -9111,12 +9138,16 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
|| bn_p->family == AF_EVPN) || bn_p->family == AF_EVPN)
&& (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP || safi == SAFI_EVPN && (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 if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP
|| safi == SAFI_EVPN) { || safi == SAFI_EVPN) {
if (json_paths) { if (json_paths) {
json_object_string_add( json_object_string_add(
json_nexthop_global, "ip", 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) if (path->peer->hostname)
json_object_string_add( json_object_string_add(
@ -9135,7 +9166,8 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
if (json_paths) { if (json_paths) {
json_object_string_add( json_object_string_add(
json_nexthop_global, "ip", json_nexthop_global, "ip",
inet_ntoa(attr->nexthop)); inet_ntop(AF_INET, &attr->nexthop, buf,
sizeof(buf)));
if (path->peer->hostname) if (path->peer->hostname)
json_object_string_add( json_object_string_add(
@ -9232,11 +9264,16 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
vty_out(vty, " from :: "); vty_out(vty, " from :: ");
} }
if (json_paths) if (json_paths) {
char buf[BUFSIZ] = {0};
json_object_string_add(json_peer, "routerId", json_object_string_add(json_peer, "routerId",
inet_ntoa(bgp->router_id)); inet_ntop(AF_INET,
else &bgp->router_id, buf,
vty_out(vty, "(%s)", inet_ntoa(bgp->router_id)); sizeof(buf)));
} else {
vty_out(vty, "(%pI4)", &bgp->router_id);
}
} }
/* We RXed this path from one of our peers */ /* We RXed this path from one of our peers */
@ -9289,8 +9326,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
} }
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
vty_out(vty, " (%s)", vty_out(vty, " (%pI4)", &attr->originator_id);
inet_ntoa(attr->originator_id));
else else
vty_out(vty, " (%s)", vty_out(vty, " (%s)",
inet_ntop(AF_INET, inet_ntop(AF_INET,
@ -9600,14 +9636,17 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
/* Line 7 display Originator, Cluster-id */ /* Line 7 display Originator, Cluster-id */
if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
|| (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) { || (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) {
char buf[BUFSIZ] = {0};
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) { if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) {
if (json_paths) if (json_paths)
json_object_string_add( json_object_string_add(
json_path, "originatorId", json_path, "originatorId",
inet_ntoa(attr->originator_id)); inet_ntop(AF_INET, &attr->originator_id,
buf, sizeof(buf)));
else else
vty_out(vty, " Originator: %s", vty_out(vty, " Originator: %pI4",
inet_ntoa(attr->originator_id)); &attr->originator_id);
} }
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) { if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) {
@ -9621,8 +9660,10 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
for (i = 0; i < attr->cluster->length / 4; for (i = 0; i < attr->cluster->length / 4;
i++) { i++) {
json_string = json_object_new_string( json_string = json_object_new_string(
inet_ntoa(attr->cluster inet_ntop(
->list[i])); AF_INET,
&attr->cluster->list[i],
buf, sizeof(buf)));
json_object_array_add( json_object_array_add(
json_cluster_list_list, json_cluster_list_list,
json_string); json_string);
@ -9646,9 +9687,8 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
for (i = 0; i < attr->cluster->length / 4; for (i = 0; i < attr->cluster->length / 4;
i++) { i++) {
vty_out(vty, "%s ", vty_out(vty, "%pI4 ",
inet_ntoa(attr->cluster &attr->cluster->list[i]);
->list[i]));
} }
} }
} }
@ -9872,13 +9912,14 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
} }
vty_out(vty, 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\": { ", " \"localAS\": %u,\n \"routes\": { ",
bgp->vrf_id == VRF_UNKNOWN ? -1 : (int)bgp->vrf_id, bgp->vrf_id == VRF_UNKNOWN ? -1 : (int)bgp->vrf_id,
bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT
? VRF_DEFAULT_NAME ? VRF_DEFAULT_NAME
: bgp->name, : bgp->name,
table->version, inet_ntoa(bgp->router_id), table->version, &bgp->router_id,
bgp->default_local_pref, bgp->as); bgp->default_local_pref, bgp->as);
if (rd) { if (rd) {
vty_out(vty, " \"routeDistinguishers\" : {"); vty_out(vty, " \"routeDistinguishers\" : {");
@ -10056,9 +10097,10 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
} }
if (!use_json && header) { if (!use_json && header) {
vty_out(vty, "BGP table version is %" PRIu64", local router ID is %s, vrf id ", vty_out(vty,
table->version, "BGP table version is %" PRIu64
inet_ntoa(bgp->router_id)); ", local router ID is %pI4, vrf id ",
table->version, &bgp->router_id);
if (bgp->vrf_id == VRF_UNKNOWN) if (bgp->vrf_id == VRF_UNKNOWN)
vty_out(vty, "%s", VRFID_NONE_STR); vty_out(vty, "%s", VRFID_NONE_STR);
else else
@ -12390,12 +12432,15 @@ static void show_adj_route_header(struct vty *vty, struct bgp *bgp,
json_object *json_ocode, bool wide) json_object *json_ocode, bool wide)
{ {
uint64_t version = table ? table->version : 0; uint64_t version = table ? table->version : 0;
char buf[BUFSIZ] = {0};
if (*header1) { if (*header1) {
if (json) { if (json) {
json_object_int_add(json, "bgpTableVersion", version); json_object_int_add(json, "bgpTableVersion", version);
json_object_string_add(json, "bgpLocalRouterId", 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", json_object_int_add(json, "defaultLocPrf",
bgp->default_local_pref); bgp->default_local_pref);
json_object_int_add(json, "localAS", bgp->as); json_object_int_add(json, "localAS", bgp->as);
@ -12405,8 +12450,9 @@ static void show_adj_route_header(struct vty *vty, struct bgp *bgp,
json_ocode); json_ocode);
} else { } else {
vty_out(vty, vty_out(vty,
"BGP table version is %" PRIu64 ", local router ID is %s, vrf id ", "BGP table version is %" PRIu64
version, inet_ntoa(bgp->router_id)); ", local router ID is %pI4, vrf id ",
version, &bgp->router_id);
if (bgp->vrf_id == VRF_UNKNOWN) if (bgp->vrf_id == VRF_UNKNOWN)
vty_out(vty, "%s", VRFID_NONE_STR); vty_out(vty, "%s", VRFID_NONE_STR);
else else
@ -12498,11 +12544,15 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
if (type == bgp_show_adj_route_advertised && subgrp if (type == bgp_show_adj_route_advertised && subgrp
&& CHECK_FLAG(subgrp->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) { && CHECK_FLAG(subgrp->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) {
char buf[BUFSIZ] = {0};
if (use_json) { if (use_json) {
json_object_int_add(json, "bgpTableVersion", json_object_int_add(json, "bgpTableVersion",
table->version); table->version);
json_object_string_add(json, "bgpLocalRouterId", 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", json_object_int_add(json, "defaultLocPrf",
bgp->default_local_pref); bgp->default_local_pref);
json_object_int_add(json, "localAS", bgp->as); json_object_int_add(json, "localAS", bgp->as);
@ -12514,8 +12564,10 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
json, "bgpOriginatingDefaultNetwork", json, "bgpOriginatingDefaultNetwork",
(afi == AFI_IP) ? "0.0.0.0/0" : "::/0"); (afi == AFI_IP) ? "0.0.0.0/0" : "::/0");
} else { } else {
vty_out(vty, "BGP table version is %" PRIu64", local router ID is %s, vrf id ", vty_out(vty,
table->version, inet_ntoa(bgp->router_id)); "BGP table version is %" PRIu64
", local router ID is %pI4, vrf id ",
table->version, &bgp->router_id);
if (bgp->vrf_id == VRF_UNKNOWN) if (bgp->vrf_id == VRF_UNKNOWN)
vty_out(vty, "%s", VRFID_NONE_STR); vty_out(vty, "%s", VRFID_NONE_STR);
else else

View File

@ -246,9 +246,10 @@ static void subgrp_show_adjq_vty(struct update_subgroup *subgrp,
if (adj->subgroup == subgrp) { if (adj->subgroup == subgrp) {
if (header1) { if (header1) {
vty_out(vty, 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, table->version,
inet_ntoa(bgp->router_id)); &bgp->router_id);
vty_out(vty, BGP_SHOW_SCODE_HEADER); vty_out(vty, BGP_SHOW_SCODE_HEADER);
vty_out(vty, BGP_SHOW_OCODE_HEADER); vty_out(vty, BGP_SHOW_OCODE_HEADER);
header1 = 0; header1 = 0;

View File

@ -488,10 +488,10 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
stream_put_in_addr_at(s, offset_nh, mod_v4nh); stream_put_in_addr_at(s, offset_nh, mod_v4nh);
if (bgp_debug_update(peer, NULL, NULL, 0)) 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)->update_group->id,
PAF_SUBGRP(paf)->id, peer->host, PAF_SUBGRP(paf)->id, peer->host, mod_v4nh,
inet_ntoa(*mod_v4nh),
(nhlen == BGP_ATTR_NHLEN_VPNV4 ? " and RD" (nhlen == BGP_ATTR_NHLEN_VPNV4 ? " and RD"
: "")); : ""));
} else if (nhafi == AFI_IP6) { } 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); stream_put_in_addr_at(s, vec->offset + 1, mod_v4nh);
if (bgp_debug_update(peer, NULL, NULL, 0)) 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)->update_group->id,
PAF_SUBGRP(paf)->id, peer->host, PAF_SUBGRP(paf)->id, peer->host, mod_v4nh);
inet_ntoa(*mod_v4nh));
} }
return s; return s;

View File

@ -22,6 +22,7 @@
#include "command.h" #include "command.h"
#include "prefix.h" #include "prefix.h"
#include "lib/json.h" #include "lib/json.h"
#include "lib/printfrr.h"
#include "bgpd/bgpd.h" #include "bgpd/bgpd.h"
#include "bgpd/bgp_route.h" #include "bgpd/bgp_route.h"
@ -117,11 +118,15 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer,
if (header) { if (header) {
if (use_json) { if (use_json) {
char buf[BUFSIZ] = {0};
json_object_int_add( json_object_int_add(
json, "bgpTableVersion", 0); json, "bgpTableVersion", 0);
json_object_string_add( json_object_string_add(
json, "bgpLocalRouterId", json, "bgpLocalRouterId",
inet_ntoa(bgp->router_id)); inet_ntop(AF_INET,
&bgp->router_id, buf,
sizeof(buf)));
json_object_int_add( json_object_int_add(
json, json,
"defaultLocPrf", "defaultLocPrf",
@ -137,8 +142,8 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer,
json_ocode); json_ocode);
} else { } else {
vty_out(vty, vty_out(vty,
"BGP table version is 0, local router ID is %s\n", "BGP table version is 0, local router ID is %pI4\n",
inet_ntoa(bgp->router_id)); &bgp->router_id);
vty_out(vty, "Default local pref %u, ", vty_out(vty, "Default local pref %u, ",
bgp->default_local_pref); bgp->default_local_pref);
vty_out(vty, "local AS %u\n", bgp->as); 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, "%u:%d", rd_as.as,
rd_as.val); rd_as.val);
else if (type == RD_TYPE_IP) else if (type == RD_TYPE_IP)
snprintf(rd_str, sizeof(rd_str), snprintfrr(rd_str,
"%s:%d", sizeof(rd_str),
inet_ntoa(rd_ip.ip), "%pI4:%d", &rd_ip.ip,
rd_ip.val); rd_ip.val);
json_object_string_add( json_object_string_add(
json_routes, json_routes,
"rd", rd_str); "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, vty_out(vty, "%u:%d", rd_as.as,
rd_as.val); rd_as.val);
else if (type == RD_TYPE_IP) else if (type == RD_TYPE_IP)
vty_out(vty, "%s:%d", vty_out(vty, "%pI4:%d",
inet_ntoa(rd_ip.ip), &rd_ip.ip, rd_ip.val);
rd_ip.val);
#ifdef ENABLE_BGP_VNC #ifdef ENABLE_BGP_VNC
else if (type == RD_TYPE_VNC_ETH) else if (type == RD_TYPE_VNC_ETH)
vty_out(vty, vty_out(vty,

View File

@ -9079,10 +9079,14 @@ DEFUN (show_bgp_vrfs,
int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN)
? -1 ? -1
: (int64_t)bgp->vrf_id; : (int64_t)bgp->vrf_id;
char buf[BUFSIZ] = {0};
json_object_string_add(json_vrf, "type", type); json_object_string_add(json_vrf, "type", type);
json_object_int_add(json_vrf, "vrfId", vrf_id_ui); json_object_int_add(json_vrf, "vrfId", vrf_id_ui);
json_object_string_add(json_vrf, "routerId", 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", json_object_int_add(json_vrf, "numConfiguredPeers",
peers_cfg); peers_cfg);
json_object_int_add(json_vrf, "numEstablishedPeers", json_object_int_add(json_vrf, "numEstablishedPeers",
@ -9097,13 +9101,11 @@ DEFUN (show_bgp_vrfs,
bgp->vrf_id)); bgp->vrf_id));
json_object_object_add(json_vrfs, name, json_vrf); json_object_object_add(json_vrfs, name, json_vrf);
} else { } else {
vty_out(vty, vty_out(vty, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
"%4s %-5d %-16s %-9u %-10u %-37s\n",
type, type,
bgp->vrf_id == VRF_UNKNOWN ? -1 bgp->vrf_id == VRF_UNKNOWN ? -1
: (int)bgp->vrf_id, : (int)bgp->vrf_id,
inet_ntoa(bgp->router_id), peers_cfg, &bgp->router_id, peers_cfg, peers_estb, name);
peers_estb, name);
vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", vty_out(vty,"%11s %-16u %-21s %-20s\n", " ",
bgp->l3vni, bgp->l3vni,
prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), prefix_mac2str(&bgp->rmac, buf, sizeof(buf)),
@ -9148,8 +9150,7 @@ static void show_tip_entry(struct hash_bucket *bucket, void *args)
struct vty *vty = (struct vty *)args; struct vty *vty = (struct vty *)args;
struct tip_addr *tip = (struct tip_addr *)bucket->data; struct tip_addr *tip = (struct tip_addr *)bucket->data;
vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(tip->addr), vty_out(vty, "addr: %pI4, count: %d\n", &tip->addr, tip->refcnt);
tip->refcnt);
} }
static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp)
@ -9614,9 +9615,12 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
/* Usage summary and header */ /* Usage summary and header */
if (use_json) { if (use_json) {
char buf[BUFSIZ] = {0};
json_object_string_add( json_object_string_add(
json, "routerId", 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, "as", bgp->as);
json_object_int_add(json, "vrfId", vrf_id_ui); json_object_int_add(json, "vrfId", vrf_id_ui);
json_object_string_add( json_object_string_add(
@ -9627,8 +9631,8 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
: bgp->name); : bgp->name);
} else { } else {
vty_out(vty, vty_out(vty,
"BGP router identifier %s, local AS number %u vrf-id %d", "BGP router identifier %pI4, local AS number %u vrf-id %d",
inet_ntoa(bgp->router_id), bgp->as, &bgp->router_id, bgp->as,
bgp->vrf_id == VRF_UNKNOWN bgp->vrf_id == VRF_UNKNOWN
? -1 ? -1
: (int)bgp->vrf_id); : (int)bgp->vrf_id);
@ -15892,8 +15896,8 @@ int bgp_config_write(struct vty *vty)
/* BGP router ID. */ /* BGP router ID. */
if (bgp->router_id_static.s_addr != 0) if (bgp->router_id_static.s_addr != 0)
vty_out(vty, " bgp router-id %s\n", vty_out(vty, " bgp router-id %pI4\n",
inet_ntoa(bgp->router_id_static)); &bgp->router_id_static);
/* BGP log-neighbor-changes. */ /* BGP log-neighbor-changes. */
if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES) if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES)
@ -15959,8 +15963,8 @@ int bgp_config_write(struct vty *vty)
/* BGP cluster ID. */ /* BGP cluster ID. */
if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID))
vty_out(vty, " bgp cluster-id %s\n", vty_out(vty, " bgp cluster-id %pI4\n",
inet_ntoa(bgp->cluster_id)); &bgp->cluster_id);
/* Disable ebgp connected nexthop check */ /* Disable ebgp connected nexthop check */
if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK))

View File

@ -2576,10 +2576,9 @@ static int bgp_zebra_process_local_es_add(ZAPI_CALLBACK_ARGS)
active = stream_getc(s); active = stream_getc(s);
if (BGP_DEBUG(zebra, ZEBRA)) if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("Rx add ESI %s originator-ip %s active %u", zlog_debug("Rx add ESI %s originator-ip %pI4 active %u",
esi_to_str(&esi, buf, sizeof(buf)), esi_to_str(&esi, buf, sizeof(buf)), &originator_ip,
inet_ntoa(originator_ip), active);
active);
bgp_evpn_local_es_add(bgp, &esi, originator_ip, active); bgp_evpn_local_es_add(bgp, &esi, originator_ip, active);

View File

@ -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->established_peers == 0) {
if (BGP_DEBUG(zebra, ZEBRA)) if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug( zlog_debug(
"RID change : vrf %s(%u), RTR ID %s", "RID change : vrf %s(%u), RTR ID %pI4",
bgp->name_pretty, bgp->name_pretty,
bgp->vrf_id, bgp->vrf_id, addr);
inet_ntoa(*addr));
/* /*
* if old router-id was 0x0, set flag * if old router-id was 0x0, set flag
* to use this new value * 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->established_peers == 0) {
if (BGP_DEBUG(zebra, ZEBRA)) if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug( zlog_debug(
"RID change : vrf %s(%u), RTR ID %s", "RID change : vrf %s(%u), RTR ID %pI4",
bgp->name_pretty, bgp->name_pretty,
bgp->vrf_id, bgp->vrf_id, addr);
inet_ntoa(*addr));
/* /*
* if old router-id was 0x0, set flag * if old router-id was 0x0, set flag
* to use this new value * to use this new value