mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-03 13:01:59 +00:00
Merge pull request #7323 from ton31337/fix/inet_ntoa_to_pFX_master
bgpd: Convert inet_ntoa to %pI4
This commit is contained in:
commit
cd7f9b1711
@ -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)
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <zebra.h>
|
||||
|
||||
#include <lib/version.h>
|
||||
#include "lib/printfrr.h"
|
||||
#include "prefix.h"
|
||||
#include "linklist.h"
|
||||
#include "stream.h"
|
||||
@ -380,7 +381,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 +401,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 +425,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 +439,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 +593,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
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
}
|
||||
@ -1722,15 +1724,14 @@ static int update_evpn_route(struct bgp *bgp, struct bgpevpn *vpn,
|
||||
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 %s RMAC %s nexthop %pI4 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)),
|
||||
&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) {
|
||||
@ -2003,15 +2004,15 @@ static void bgp_evpn_update_type2_route_entry(struct bgp *bgp,
|
||||
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 %s 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, prefix2str(evp, buf1, sizeof(buf1)),
|
||||
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. */
|
||||
@ -4965,8 +4966,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);
|
||||
}
|
||||
|
@ -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);
|
||||
@ -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,
|
||||
&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 +903,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 +1170,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 +1197,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 +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);
|
||||
|
||||
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 +1236,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 {
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
@ -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();
|
||||
|
@ -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",
|
||||
@ -5051,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;
|
||||
@ -5086,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)));
|
||||
@ -5115,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",
|
||||
|
@ -422,8 +422,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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
182
bgpd/bgp_route.c
182
bgpd/bgp_route.c
@ -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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -4980,8 +4980,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;
|
||||
}
|
||||
}
|
||||
@ -7879,10 +7879,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,
|
||||
@ -7910,13 +7914,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(
|
||||
@ -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)) {
|
||||
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,
|
||||
@ -8257,18 +8268,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];
|
||||
@ -8278,11 +8295,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))
|
||||
@ -8310,15 +8332,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];
|
||||
@ -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_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)))
|
||||
@ -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 (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");
|
||||
@ -9058,13 +9085,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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -9111,12 +9138,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(
|
||||
@ -9135,7 +9166,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(
|
||||
@ -9232,11 +9264,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 */
|
||||
@ -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))
|
||||
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,
|
||||
@ -9600,14 +9636,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)) {
|
||||
@ -9621,8 +9660,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);
|
||||
@ -9646,9 +9687,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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -9872,13 +9912,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\" : {");
|
||||
@ -10056,9 +10097,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
|
||||
@ -12390,12 +12432,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);
|
||||
@ -12405,8 +12450,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
|
||||
@ -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
|
||||
&& 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);
|
||||
@ -12514,8 +12564,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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -9079,10 +9079,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 +9101,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 +9150,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 +9615,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 +9631,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);
|
||||
@ -15892,8 +15896,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 +15963,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))
|
||||
|
@ -2576,10 +2576,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);
|
||||
|
||||
|
10
bgpd/bgpd.c
10
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
|
||||
|
Loading…
Reference in New Issue
Block a user