diff --git a/zebra/interface.c b/zebra/interface.c index 49a1e49175..63e3c04b28 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -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); } diff --git a/zebra/zebra_evpn.c b/zebra/zebra_evpn.c index 4006e1fed5..f2da8dbf7d 100644 --- a/zebra/zebra_evpn.c +++ b/zebra/zebra_evpn.c @@ -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", diff --git a/zebra/zebra_evpn_mac.c b/zebra/zebra_evpn_mac.c index 6fc01925eb..5a7ec32043 100644 --- a/zebra/zebra_evpn_mac.c +++ b/zebra/zebra_evpn_mac.c @@ -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); diff --git a/zebra/zebra_evpn_mh.c b/zebra/zebra_evpn_mh.c index 3f7e6256fc..df4d48964a 100644 --- a/zebra/zebra_evpn_mh.c +++ b/zebra/zebra_evpn_mh.c @@ -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", diff --git a/zebra/zebra_evpn_neigh.c b/zebra/zebra_evpn_neigh.c index af46ea6d7a..55212f06b3 100644 --- a/zebra/zebra_evpn_neigh.c +++ b/zebra/zebra_evpn_neigh.c @@ -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"); diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index 00ac98cbc0..e32905f586 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -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", diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 85e1a4b2bf..a3faa3d3e2 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -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"); diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index 105a50e143..71503721d6 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -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",