diff options
author | Pooja Jagadeesh Doijode <pdoijode@nvidia.com> | 2023-01-26 19:31:08 +0100 |
---|---|---|
committer | Mergify <37929162+mergify[bot]@users.noreply.github.com> | 2023-01-27 15:37:00 +0100 |
commit | 1a4a394d45653b37ddbc8e2321dd09329790ce7c (patch) | |
tree | 055b15cabef64e6c8df0b22e9a1996c7000f7e40 | |
parent | Merge pull request #12690 from opensourcerouting/feature/deny_merging_prs_wit... (diff) | |
download | frr-1a4a394d45653b37ddbc8e2321dd09329790ce7c.tar.xz frr-1a4a394d45653b37ddbc8e2321dd09329790ce7c.zip |
zebra: fix JSON fields for show evpn vni detail
Few of the JSON field in show evpn vni detail command is
confusing and a few fields were missing. Following is the
updated output.
primary# show evpn vni detail json
[
{
"vni":200,
"type":"L2",
"vrf":"default",
"tenantVrf":"default",
"vxlanInterface":"vni200",
"ifindex":19,
"vxlanIfindex":19,
"sviInterface":"br200",
"sviIfindex":18,
"vtepIp":"2.2.2.1",
"mcastGroup":"0.0.0.0",
"advertiseGatewayMacip":"No",
"advertiseSviMacip":"No",
"numMacs":0,
"numArpNd":0,
"numRemoteVteps":1,
"remoteVteps":[
{
"ip":"2.2.2.2",
"flood":"HER"
}
]
},
{
"vni":100,
"type":"L3",
"vrf":"default",
"tenantVrf":"default",
"localVtepIp":"2.2.2.1",
"vxlanIntf":"vni100",
"sviIntf":"br100",
"state":"Up",
"sysMac":"aa:bb:cc:dd:ee:f1",
"routerMac":"aa:bb:cc:dd:ee:f1",
"vniFilter":"none",
"l2Vnis":[
20,
30,
200
]
}
]
Signed-off-by: Pooja Jagadeesh Doijode <pdoijode@nvidia.com>
-rw-r--r-- | tests/topotests/bgp_evpn_vxlan_topo1/PE1/evpn.vni.json | 10 | ||||
-rw-r--r-- | tests/topotests/bgp_evpn_vxlan_topo1/PE2/evpn.vni.json | 12 | ||||
-rwxr-xr-x | tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan.py | 1 | ||||
-rw-r--r-- | zebra/zebra_evpn.c | 55 | ||||
-rw-r--r-- | zebra/zebra_vxlan.c | 7 |
5 files changed, 59 insertions, 26 deletions
diff --git a/tests/topotests/bgp_evpn_vxlan_topo1/PE1/evpn.vni.json b/tests/topotests/bgp_evpn_vxlan_topo1/PE1/evpn.vni.json index ce7915c4a..eb8668b7b 100644 --- a/tests/topotests/bgp_evpn_vxlan_topo1/PE1/evpn.vni.json +++ b/tests/topotests/bgp_evpn_vxlan_topo1/PE1/evpn.vni.json @@ -1,13 +1,17 @@ { "vni":101, "type":"L2", - "vrf":"default", + "tenantVrf":"default", "vxlanInterface":"vxlan101", "vtepIp":"10.10.10.10", "mcastGroup":"0.0.0.0", "advertiseGatewayMacip":"No", - "numRemoteVteps":[ - "10.30.30.30" + "numRemoteVteps":1, + "remoteVteps":[ + { + "ip":"10.30.30.30", + "flood":"HER" + } ] } diff --git a/tests/topotests/bgp_evpn_vxlan_topo1/PE2/evpn.vni.json b/tests/topotests/bgp_evpn_vxlan_topo1/PE2/evpn.vni.json index 6c6920264..befb41607 100644 --- a/tests/topotests/bgp_evpn_vxlan_topo1/PE2/evpn.vni.json +++ b/tests/topotests/bgp_evpn_vxlan_topo1/PE2/evpn.vni.json @@ -1,12 +1,16 @@ { "vni":101, "type":"L2", - "vrf":"default", + "tenantVrf":"default", "vxlanInterface":"vxlan101", "vtepIp":"10.30.30.30", "mcastGroup":"0.0.0.0", "advertiseGatewayMacip":"No", - "numRemoteVteps":[ - "10.10.10.10" - ] + "numRemoteVteps":1, + "remoteVteps":[ + { + "ip":"10.10.10.10", + "flood":"HER" + } + ] } diff --git a/tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan.py b/tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan.py index 5d0a326af..83ee53c4c 100755 --- a/tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan.py +++ b/tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan.py @@ -144,7 +144,6 @@ def teardown_module(mod): def show_vni_json_elide_ifindex(pe, vni, expected): output_json = pe.vtysh_cmd("show evpn vni {} json".format(vni), isjson=True) - if "ifindex" in output_json: output_json.pop("ifindex") diff --git a/zebra/zebra_evpn.c b/zebra/zebra_evpn.c index f20747744..ff9ca1ac2 100644 --- a/zebra/zebra_evpn.c +++ b/zebra/zebra_evpn.c @@ -101,14 +101,15 @@ int advertise_svi_macip_enabled(struct zebra_evpn *zevpn) */ void zebra_evpn_print(struct zebra_evpn *zevpn, void **ctxt) { - struct vty *vty; - struct zebra_vtep *zvtep; - uint32_t num_macs; - uint32_t num_neigh; + + struct vty *vty = NULL; + struct zebra_vtep *zvtep = NULL; + uint32_t num_macs = 0; + uint32_t num_neigh = 0; + uint32_t num_vteps = 0; json_object *json = NULL; json_object *json_vtep_list = NULL; - json_object *json_ip_str = NULL; - char buf[PREFIX_STRLEN]; + json_object *json_vtep = NULL; vty = ctxt[0]; json = ctxt[1]; @@ -120,13 +121,21 @@ void zebra_evpn_print(struct zebra_evpn *zevpn, void **ctxt) } else { json_object_int_add(json, "vni", zevpn->vni); json_object_string_add(json, "type", "L2"); +#if CONFDATE > 20240210 +CPP_NOTICE("Drop `vrf` from JSON output") +#endif json_object_string_add(json, "vrf", vrf_id_to_name(zevpn->vrf_id)); + json_object_string_add(json, "tenantVrf", + vrf_id_to_name(zevpn->vrf_id)); } if (!zevpn->vxlan_if) { // unexpected if (json == NULL) vty_out(vty, " VxLAN interface: unknown\n"); + else + json_object_string_add(json, "vxlanInterface", + "unknown"); return; } num_macs = num_valid_macs(zevpn); @@ -145,7 +154,12 @@ void zebra_evpn_print(struct zebra_evpn *zevpn, void **ctxt) } else { json_object_string_add(json, "vxlanInterface", zevpn->vxlan_if->name); +#if CONFDATE > 20240210 +CPP_NOTICE("Drop `ifindex` from JSON output") +#endif json_object_int_add(json, "ifindex", zevpn->vxlan_if->ifindex); + json_object_int_add(json, "vxlanIfindex", + zevpn->vxlan_if->ifindex); if (zevpn->svi_if) { json_object_string_add(json, "sviInterface", zevpn->svi_if->name); @@ -157,7 +171,8 @@ void zebra_evpn_print(struct zebra_evpn *zevpn, void **ctxt) json_object_string_addf(json, "mcastGroup", "%pI4", &zevpn->mcast_grp); json_object_string_add(json, "advertiseGatewayMacip", - zevpn->advertise_gw_macip ? "Yes" : "No"); + zevpn->advertise_gw_macip ? "Yes" + : "No"); json_object_string_add(json, "advertiseSviMacip", zevpn->advertise_svi_macip ? "Yes" : "No"); @@ -167,32 +182,38 @@ void zebra_evpn_print(struct zebra_evpn *zevpn, void **ctxt) if (!zevpn->vteps) { if (json == NULL) vty_out(vty, " No remote VTEPs known for this VNI\n"); + else + json_object_int_add(json, "numRemoteVteps", num_vteps); } else { if (json == NULL) vty_out(vty, " Remote VTEPs for this VNI:\n"); else json_vtep_list = json_object_new_array(); for (zvtep = zevpn->vteps; zvtep; zvtep = zvtep->next) { - const char *flood_str = lookup_msg(zvtep_flood_str, - zvtep->flood_control, - VXLAN_FLOOD_STR_DEFAULT); + const char *flood_str = lookup_msg( + zvtep_flood_str, zvtep->flood_control, + VXLAN_FLOOD_STR_DEFAULT); if (json == NULL) { vty_out(vty, " %pI4 flood: %s\n", &zvtep->vtep_ip, flood_str); } else { - json_ip_str = json_object_new_string( - inet_ntop(AF_INET, - &zvtep->vtep_ip, buf, - sizeof(buf))); + json_vtep = json_object_new_object(); + json_object_string_addf(json_vtep, "ip", "%pI4", + &zvtep->vtep_ip); + json_object_string_add(json_vtep, "flood", + flood_str); json_object_array_add(json_vtep_list, - json_ip_str); + json_vtep); } + num_vteps++; } - if (json) - json_object_object_add(json, "numRemoteVteps", + if (json) { + json_object_int_add(json, "numRemoteVteps", num_vteps); + json_object_object_add(json, "remoteVteps", json_vtep_list); + } } if (json == NULL) { vty_out(vty, diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index 7e86d15b4..177659f5c 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -750,6 +750,12 @@ 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"); +#if CONFDATE > 20240210 +CPP_NOTICE("Drop `vrf` from JSON outputs") +#endif + json_object_string_add(json, "vrf", zl3vni_vrf_name(zl3vni)); + json_object_string_add(json, "tenantVrf", + zl3vni_vrf_name(zl3vni)); json_object_string_addf(json, "localVtepIp", "%pI4", &zl3vni->local_vtep_ip); json_object_string_add(json, "vxlanIntf", @@ -757,7 +763,6 @@ static void zl3vni_print(struct zebra_l3vni *zl3vni, void **ctx) json_object_string_add(json, "sviIntf", zl3vni_svi_if_name(zl3vni)); json_object_string_add(json, "state", zl3vni_state2str(zl3vni)); - json_object_string_add(json, "vrf", zl3vni_vrf_name(zl3vni)); json_object_string_add( json, "sysMac", zl3vni_sysmac2str(zl3vni, buf, sizeof(buf))); |