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)
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);
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);
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);
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");
}
#include <zebra.h>
#include <lib/version.h>
+#include "lib/printfrr.h"
#include "prefix.h"
#include "linklist.h"
#include "stream.h"
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",
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),
", 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;
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)))
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
#include "jhash.h"
#include "stream.h"
+#include "lib/printfrr.h"
+
#include "bgpd/bgpd.h"
#include "bgpd/bgp_ecommunity.h"
#include "bgpd/bgp_lcommunity.h"
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 */
#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"
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);
}
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) {
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. */
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);
}
#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"
*/
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;
}
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. */
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)
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);
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 {
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;
}
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);
}
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);
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);
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 {
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);
}
}
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);
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)
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);
{
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();
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;
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",
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);
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) {
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);
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);
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) {
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)
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)) {
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);
{
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();
#include "command.h"
#include "prefix.h"
#include "lib/json.h"
+#include "lib/printfrr.h"
#include "stream.h"
#include "bgpd/bgpd.h"
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);
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);
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
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");
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;
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,
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",
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();
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
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",
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;
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));
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)));
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;
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
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;
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",
{
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;
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)));
} 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",
*/
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;
}
}
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); */
&& 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
/* 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;
|| (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);
#include "filter.h"
#include "frrstr.h"
+#include "lib/printfrr.h"
+
#include "bgpd/bgpd.h"
#include "bgpd/bgp_rd.h"
#include "bgpd/bgp_attr.h"
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
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);
}
*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;
}
}
*/
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;
}
}
}
} 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,
} 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(
}
} 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,
/* 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];
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))
|| !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];
&& ((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)))
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");
} 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);
}
}
|| 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(
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(
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 */
}
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,
/* 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)) {
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);
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]);
}
}
}
}
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\" : {");
}
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
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);
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
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);
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
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;
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) {
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;
#include "command.h"
#include "prefix.h"
#include "lib/json.h"
+#include "lib/printfrr.h"
#include "bgpd/bgpd.h"
#include "bgpd/bgp_route.h"
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",
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);
"%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);
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,
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",
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)),
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)
/* 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(
: 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);
/* 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)
/* 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))
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);
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
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