mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-28 19:03:03 +00:00
zebra: Replace inet_ntop to %pI4/6 for JSON outputs
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
This commit is contained in:
parent
b0d5264e3f
commit
08edf9c6af
@ -2062,18 +2062,14 @@ static void if_dump_vty_json(struct vty *vty, struct interface *ifp,
|
||||
vxlan_info = &zebra_if->l2info.vxl;
|
||||
json_object_int_add(json_if, "vxlanId", vxlan_info->vni);
|
||||
if (vxlan_info->vtep_ip.s_addr != INADDR_ANY)
|
||||
json_object_string_add(json_if, "vtepIp",
|
||||
inet_ntop(AF_INET,
|
||||
&vxlan_info->vtep_ip,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_if, "vtepIp", "%pI4",
|
||||
&vxlan_info->vtep_ip);
|
||||
if (vxlan_info->access_vlan)
|
||||
json_object_int_add(json_if, "accessVlanId",
|
||||
vxlan_info->access_vlan);
|
||||
if (vxlan_info->mcast_grp.s_addr != INADDR_ANY)
|
||||
json_object_string_add(json_if, "mcastGroup",
|
||||
inet_ntop(AF_INET,
|
||||
&vxlan_info->mcast_grp,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_if, "mcastGroup", "%pI4",
|
||||
&vxlan_info->mcast_grp);
|
||||
if (vxlan_info->ifindex_link
|
||||
&& (vxlan_info->link_nsid != NS_UNKNOWN)) {
|
||||
struct interface *ifp;
|
||||
@ -2090,16 +2086,12 @@ static void if_dump_vty_json(struct vty *vty, struct interface *ifp,
|
||||
|
||||
gre_info = &zebra_if->l2info.gre;
|
||||
if (gre_info->vtep_ip.s_addr != INADDR_ANY) {
|
||||
json_object_string_add(json_if, "vtepIp",
|
||||
inet_ntop(AF_INET,
|
||||
&gre_info->vtep_ip,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_if, "vtepIp", "%pI4",
|
||||
&gre_info->vtep_ip);
|
||||
if (gre_info->vtep_ip_remote.s_addr != INADDR_ANY)
|
||||
json_object_string_add(
|
||||
json_if, "vtepRemoteIp",
|
||||
inet_ntop(AF_INET,
|
||||
&gre_info->vtep_ip_remote,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(
|
||||
json_if, "vtepRemoteIp", "%pI4",
|
||||
&gre_info->vtep_ip_remote);
|
||||
}
|
||||
if (gre_info->ifindex_link
|
||||
&& (gre_info->link_nsid != NS_UNKNOWN)) {
|
||||
@ -2233,9 +2225,8 @@ static void if_dump_vty_json(struct vty *vty, struct interface *ifp,
|
||||
json_object_double_add(json_te, "utilizedBandwidth",
|
||||
iflp->use_bw);
|
||||
if (IS_PARAM_SET(iflp, LP_RMT_AS))
|
||||
json_object_string_add(json_te, "neighborAsbrIp",
|
||||
inet_ntop(AF_INET, &iflp->rmt_ip,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_te, "neighborAsbrIp",
|
||||
"%pI4", &iflp->rmt_ip);
|
||||
json_object_int_add(json_te, "neighborAsbrAs", iflp->rmt_as);
|
||||
}
|
||||
|
||||
|
@ -152,12 +152,10 @@ void zebra_evpn_print(struct zebra_evpn *zevpn, void **ctxt)
|
||||
json_object_int_add(json, "sviIfindex",
|
||||
zevpn->svi_if->ifindex);
|
||||
}
|
||||
json_object_string_add(json, "vtepIp",
|
||||
inet_ntop(AF_INET, &zevpn->local_vtep_ip,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_add(json, "mcastGroup",
|
||||
inet_ntop(AF_INET, &zevpn->mcast_grp,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json, "vtepIp", "%pI4",
|
||||
&zevpn->local_vtep_ip);
|
||||
json_object_string_addf(json, "mcastGroup", "%pI4",
|
||||
&zevpn->mcast_grp);
|
||||
json_object_string_add(json, "advertiseGatewayMacip",
|
||||
zevpn->advertise_gw_macip ? "Yes" : "No");
|
||||
json_object_string_add(json, "advertiseSviMacip",
|
||||
|
@ -658,10 +658,8 @@ void zebra_evpn_print_mac(struct zebra_mac *mac, void *ctxt, json_object *json)
|
||||
json_object_int_add(json_mac, "vlan", vid);
|
||||
} else if (CHECK_FLAG(mac->flags, ZEBRA_MAC_REMOTE)) {
|
||||
json_object_string_add(json_mac, "type", "remote");
|
||||
json_object_string_add(
|
||||
json_mac, "remoteVtep",
|
||||
inet_ntop(AF_INET, &mac->fwd_info.r_vtep_ip,
|
||||
addr_buf, sizeof(addr_buf)));
|
||||
json_object_string_addf(json_mac, "remoteVtep", "%pI4",
|
||||
&mac->fwd_info.r_vtep_ip);
|
||||
} else if (CHECK_FLAG(mac->flags, ZEBRA_MAC_AUTO))
|
||||
json_object_string_add(json_mac, "type", "auto");
|
||||
|
||||
@ -944,10 +942,8 @@ void zebra_evpn_print_mac_hash(struct hash_bucket *bucket, void *ctxt)
|
||||
"", mac->loc_seq, mac->rem_seq);
|
||||
} else {
|
||||
json_object_string_add(json_mac, "type", "remote");
|
||||
json_object_string_add(
|
||||
json_mac, "remoteVtep",
|
||||
inet_ntop(AF_INET, &mac->fwd_info.r_vtep_ip,
|
||||
addr_buf, sizeof(addr_buf)));
|
||||
json_object_string_addf(json_mac, "remoteVtep", "%pI4",
|
||||
&mac->fwd_info.r_vtep_ip);
|
||||
json_object_object_add(json_mac_hdr, buf1, json_mac);
|
||||
json_object_int_add(json_mac, "localSequence",
|
||||
mac->loc_seq);
|
||||
|
@ -1328,9 +1328,7 @@ static void zebra_evpn_es_l2_nh_show_entry(struct zebra_evpn_l2_nh *nh,
|
||||
char ip_buf[INET6_ADDRSTRLEN];
|
||||
|
||||
json = json_object_new_object();
|
||||
json_object_string_add(json, "vtep",
|
||||
inet_ntop(AF_INET, &nh->vtep_ip, ip_buf,
|
||||
sizeof(ip_buf)));
|
||||
json_object_string_addf(json, "vtep", "%pI4", &nh->vtep_ip);
|
||||
json_object_int_add(json, "nhId", nh->nh_id);
|
||||
json_object_int_add(json, "refCnt", nh->ref_cnt);
|
||||
|
||||
@ -3012,9 +3010,8 @@ static void zebra_evpn_es_json_vtep_fill(struct zebra_evpn_es *es,
|
||||
|
||||
for (ALL_LIST_ELEMENTS_RO(es->es_vtep_list, node, es_vtep)) {
|
||||
json_vtep_entry = json_object_new_object();
|
||||
json_object_string_add(json_vtep_entry, "vtep",
|
||||
inet_ntop(AF_INET, &es_vtep->vtep_ip,
|
||||
ip_buf, sizeof(ip_buf)));
|
||||
json_object_string_addf(json_vtep_entry, "vtep", "%pI4",
|
||||
&es_vtep->vtep_ip);
|
||||
if (es_vtep->flags & ZEBRA_EVPNES_VTEP_RXED_ESR) {
|
||||
json_object_string_add(
|
||||
json_vtep_entry, "dfAlgorithm",
|
||||
|
@ -1812,10 +1812,8 @@ void zebra_evpn_print_neigh(struct zebra_neigh *n, void *ctxt,
|
||||
n->mac->es->esi_str);
|
||||
} else {
|
||||
if (json)
|
||||
json_object_string_add(
|
||||
json, "remoteVtep",
|
||||
inet_ntop(AF_INET, &n->r_vtep_ip,
|
||||
addr_buf, sizeof(addr_buf)));
|
||||
json_object_string_addf(json, "remoteVtep",
|
||||
"%pI4", &n->r_vtep_ip);
|
||||
else
|
||||
vty_out(vty, " Remote VTEP: %pI4\n",
|
||||
&n->r_vtep_ip);
|
||||
@ -1974,10 +1972,8 @@ void zebra_evpn_print_neigh_hash(struct hash_bucket *bucket, void *ctxt)
|
||||
json_object_string_add(json_row, "remoteEs",
|
||||
n->mac->es->esi_str);
|
||||
else
|
||||
json_object_string_add(
|
||||
json_row, "remoteVtep",
|
||||
inet_ntop(AF_INET, &n->r_vtep_ip,
|
||||
addr_buf, sizeof(addr_buf)));
|
||||
json_object_string_addf(json_row, "remoteVtep",
|
||||
"%pI4", &n->r_vtep_ip);
|
||||
if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_DEF_GW))
|
||||
json_object_boolean_true_add(json_row,
|
||||
"defaultGateway");
|
||||
|
@ -1531,15 +1531,13 @@ static json_object *nhlfe_json(struct zebra_nhlfe *nhlfe)
|
||||
switch (nexthop->type) {
|
||||
case NEXTHOP_TYPE_IPV4:
|
||||
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
||||
json_object_string_add(json_nhlfe, "nexthop",
|
||||
inet_ntop(AF_INET, &nexthop->gate.ipv4,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_nhlfe, "nexthop", "%pI4",
|
||||
&nexthop->gate.ipv4);
|
||||
break;
|
||||
case NEXTHOP_TYPE_IPV6:
|
||||
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
||||
json_object_string_add(
|
||||
json_nhlfe, "nexthop",
|
||||
inet_ntop(AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
|
||||
json_object_string_addf(json_nhlfe, "nexthop", "%pI6",
|
||||
&nexthop->gate.ipv6);
|
||||
|
||||
if (nexthop->ifindex)
|
||||
json_object_string_add(json_nhlfe, "interface",
|
||||
|
@ -709,10 +709,8 @@ static void show_nexthop_json_helper(json_object *json_nexthop,
|
||||
switch (nexthop->type) {
|
||||
case NEXTHOP_TYPE_IPV4:
|
||||
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
||||
json_object_string_add(
|
||||
json_nexthop, "ip",
|
||||
inet_ntop(AF_INET, &nexthop->gate.ipv4,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_nexthop, "ip", "%pI4",
|
||||
&nexthop->gate.ipv4);
|
||||
json_object_string_add(json_nexthop, "afi",
|
||||
"ipv4");
|
||||
|
||||
@ -729,10 +727,8 @@ static void show_nexthop_json_helper(json_object *json_nexthop,
|
||||
break;
|
||||
case NEXTHOP_TYPE_IPV6:
|
||||
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
||||
json_object_string_add(
|
||||
json_nexthop, "ip",
|
||||
inet_ntop(AF_INET6, &nexthop->gate.ipv6,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_nexthop, "ip", "%pI6",
|
||||
&nexthop->gate.ipv6);
|
||||
json_object_string_add(json_nexthop, "afi",
|
||||
"ipv6");
|
||||
|
||||
|
@ -385,10 +385,8 @@ static void zl3vni_print_rmac(struct zebra_mac *zrmac, struct vty *vty,
|
||||
json_object_string_add(
|
||||
json, "routerMac",
|
||||
prefix_mac2str(&zrmac->macaddr, buf1, sizeof(buf1)));
|
||||
json_object_string_add(json, "vtepIp",
|
||||
inet_ntop(AF_INET,
|
||||
&zrmac->fwd_info.r_vtep_ip,
|
||||
buf1, sizeof(buf1)));
|
||||
json_object_string_addf(json, "vtepIp", "%pI4",
|
||||
&zrmac->fwd_info.r_vtep_ip);
|
||||
json_object_int_add(json, "refCount",
|
||||
rb_host_count(&zrmac->host_rb));
|
||||
RB_FOREACH (hle, host_rb_tree_entry, &zrmac->host_rb)
|
||||
@ -680,10 +678,8 @@ static void zl3vni_print_rmac_hash(struct hash_bucket *bucket, void *ctx)
|
||||
json_object_string_add(
|
||||
json_rmac, "routerMac",
|
||||
prefix_mac2str(&zrmac->macaddr, buf, sizeof(buf)));
|
||||
json_object_string_add(json_rmac, "vtepIp",
|
||||
inet_ntop(AF_INET,
|
||||
&zrmac->fwd_info.r_vtep_ip,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_rmac, "vtepIp", "%pI4",
|
||||
&zrmac->fwd_info.r_vtep_ip);
|
||||
json_object_object_add(
|
||||
json, prefix_mac2str(&zrmac->macaddr, buf, sizeof(buf)),
|
||||
json_rmac);
|
||||
@ -729,10 +725,8 @@ static void zl3vni_print(struct zebra_l3vni *zl3vni, void **ctx)
|
||||
json_evpn_list = json_object_new_array();
|
||||
json_object_int_add(json, "vni", zl3vni->vni);
|
||||
json_object_string_add(json, "type", "L3");
|
||||
json_object_string_add(
|
||||
json, "localVtepIp",
|
||||
inet_ntop(AF_INET, &zl3vni->local_vtep_ip, buf,
|
||||
sizeof(buf)));
|
||||
json_object_string_addf(json, "localVtepIp", "%pI4",
|
||||
&zl3vni->local_vtep_ip);
|
||||
json_object_string_add(json, "vxlanIntf",
|
||||
zl3vni_vxlan_if_name(zl3vni));
|
||||
json_object_string_add(json, "sviIntf",
|
||||
|
Loading…
Reference in New Issue
Block a user