Merge pull request #12449 from chiragshah6/mdev1

zebra: vrf-id support for show vrf vni json cmd
This commit is contained in:
Donatas Abraitis 2023-01-17 18:25:01 +02:00 committed by GitHub
commit 7475ed3330
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 80 additions and 13 deletions

View File

@ -509,4 +509,22 @@ Displaying EVPN information
.. clicmd:: show evpn mac vni (1-16777215) detail [json]
Display detailed information about MAC addresses for
a specified VNI.
a specified VNI.
.. clicmd:: show vrf [<NAME$vrf_name|all$vrf_all>] vni [json]
Displays VRF to L3VNI mapping. It also displays L3VNI associated
router-mac, svi interface and vxlan interface.
User can get that information as JSON format when ``json`` keyword
at the end of cli is presented.
.. code-block:: frr
tor2# show vrf vni
VRF VNI VxLAN IF L3-SVI State Rmac
sym_1 9288 vxlan21 vlan210_l3 Up 21:31:36:ff:ff:20
sym_2 9289 vxlan21 vlan210_l3 Up 21:31:36:ff:ff:20
sym_3 9290 vxlan21 vlan210_l3 Up 21:31:36:ff:ff:20
tor2# show vrf sym_1 vni
VRF VNI VxLAN IF L3-SVI State Rmac
sym_1 9288 vxlan21 vlan210_l3 Up 44:38:36:ff:ff:20

View File

@ -3169,11 +3169,11 @@ DEFUN (no_vrf_vni_mapping,
}
/* show vrf */
DEFUN (show_vrf_vni,
DEFPY (show_vrf_vni,
show_vrf_vni_cmd,
"show vrf vni [json]",
"show vrf [<NAME$vrf_name|all$vrf_all>] vni [json]",
SHOW_STR
"VRF\n"
VRF_FULL_CMD_HELP_STR
"VNI\n"
JSON_STR)
{
@ -3182,20 +3182,69 @@ DEFUN (show_vrf_vni,
json_object *json = NULL;
json_object *json_vrfs = NULL;
bool uj = use_json(argc, argv);
bool use_vrf = false;
if (uj) {
if (uj)
json = json_object_new_object();
json_vrfs = json_object_new_array();
/* show vrf vni used to display across all vrfs
* This is enhanced to support only for specific
* vrf based output.
*/
if (vrf_all || !vrf_name) {
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
zvrf = vrf->info;
if (!zvrf)
continue;
use_vrf = true;
break;
}
if (use_vrf) {
if (!uj)
vty_out(vty,
"%-37s %-10s %-20s %-20s %-5s %-18s\n",
"VRF", "VNI", "VxLAN IF", "L3-SVI",
"State", "Rmac");
else
json_vrfs = json_object_new_array();
} else {
if (uj)
vty_json(vty, json);
else
vty_out(vty, "%% VRF does not exist\n");
return CMD_WARNING;
}
}
if (!uj)
vty_out(vty, "%-37s %-10s %-20s %-20s %-5s %-18s\n", "VRF",
"VNI", "VxLAN IF", "L3-SVI", "State", "Rmac");
if (use_vrf) {
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
zvrf = vrf->info;
if (!zvrf)
continue;
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
zvrf = vrf->info;
if (!zvrf)
continue;
zebra_vxlan_print_vrf_vni(vty, zvrf, json_vrfs);
}
} else if (vrf_name) {
zvrf = zebra_vrf_lookup_by_name(vrf_name);
if (!zvrf) {
if (uj)
vty_json(vty, json);
else
vty_out(vty,
"%% VRF '%s' specified does not exist\n",
vrf_name);
return CMD_WARNING;
}
if (!uj)
vty_out(vty, "%-37s %-10s %-20s %-20s %-5s %-18s\n",
"VRF", "VNI", "VxLAN IF", "L3-SVI", "State",
"Rmac");
else
json_vrfs = json_object_new_array();
zebra_vxlan_print_vrf_vni(vty, zvrf, json_vrfs);
}