diff options
author | Sindhu Parvathi Gopinathan <sgopinathan@nvidia.com> | 2022-12-03 20:09:49 +0100 |
---|---|---|
committer | Chirag Shah <chirag@nvidia.com> | 2023-01-13 22:49:21 +0100 |
commit | 3cff8acb33ada54488f1df63d78c6581dfd45618 (patch) | |
tree | 6a79f2654dca7ef2e30c9e811286b4628d499afb /zebra | |
parent | Merge pull request #12635 from LabNConsulting/ziemba/topotests-lutil-wait-strict (diff) | |
download | frr-3cff8acb33ada54488f1df63d78c6581dfd45618.tar.xz frr-3cff8acb33ada54488f1df63d78c6581dfd45618.zip |
zebra: Adding FRR support for show vrf vrf-id vni
cli & json support extended for show vrf vrf-id vni
commands:
- existing: show vrf vni
- show vrf <vrf-name> vni
- show vrf all vni
- show vrf <vrf-name> vni json
- show vrf all vni json
Before:
```
tor-1# show vrf vni
VRF VNI VxLAN IF
L3-SVI State Rmac
default 100 None
None Down None
sym_1 8888 vxlan99
vlan490_l3 Up 44:38:39:ff:ff:25
sym_2 8889 vxlan99
vlan491_l3 Up 44:38:39:ff:ff:25
sym_3 8890 vxlan99
vlan492_l3 Up 44:38:39:ff:ff:25
sym_4 8891 vxlan99
vlan493_l3 Up 44:38:39:ff:ff:25
sym_5 8892 vxlan99
vlan494_l3 Up 44:38:39:ff:ff:25
tor-1#
```
After:
```
tor-1# show vrf default vni json
{
"vrfs":[
{
"vrf":"default",
"vni":100,
"vxlanIntf":"None",
"sviIntf":"None",
"state":"Down",
"routerMac":"None"
}
]
}
tor-1# show vrf default vni
VRF VNI VxLAN IF
L3-SVI State Rmac
default 100 None
None Down None
tor-1#
tor-1# show vrf all vni
VRF VNI VxLAN IF
L3-SVI State Rmac
default 100 None
None Down None
sym_1 8888 vxlan99
vlan490_l3 Up 44:38:39:ff:ff:25
sym_2 8889 vxlan99
vlan491_l3 Up 44:38:39:ff:ff:25
sym_3 8890 vxlan99
vlan492_l3 Up 44:38:39:ff:ff:25
sym_4 8891 vxlan99
vlan493_l3 Up 44:38:39:ff:ff:25
sym_5 8892 vxlan99
vlan494_l3 Up 44:38:39:ff:ff:25
tor-1#
tor-1#
tor-1#
tor-1#
tor-1#
tor-1# show vrf all vni json
{
"vrfs":[
{
"vrf":"default",
"vni":100,
"vxlanIntf":"None",
"sviIntf":"None",
"state":"Down",
"routerMac":"None"
},
{
"vrf":"sym_1",
"vni":8888,
"vxlanIntf":"vxlan99",
"sviIntf":"vlan490_l3",
"state":"Up",
"routerMac":"44:38:39:ff:ff:25"
},
{
"vrf":"sym_2",
"vni":8889,
"vxlanIntf":"vxlan99",
"sviIntf":"vlan491_l3",
"state":"Up",
"routerMac":"44:38:39:ff:ff:25"
},
{
"vrf":"sym_3",
"vni":8890,
"vxlanIntf":"vxlan99",
"sviIntf":"vlan492_l3",
"state":"Up",
"routerMac":"44:38:39:ff:ff:25"
},
{
"vrf":"sym_4",
"vni":8891,
"vxlanIntf":"vxlan99",
"sviIntf":"vlan493_l3",
"state":"Up",
"routerMac":"44:38:39:ff:ff:25"
},
{
"vrf":"sym_5",
"vni":8892,
"vxlanIntf":"vxlan99",
"sviIntf":"vlan494_l3",
"state":"Up",
"routerMac":"44:38:39:ff:ff:25"
}
]
}
tor-1#
```
Ticket:#3260835
Issue:3260835
Testing: UT done
Signed-off-by: Sindhu Parvathi Gopinathan <sgopinathan@nvidia.com>
Diffstat (limited to 'zebra')
-rw-r--r-- | zebra/zebra_vty.c | 73 |
1 files changed, 61 insertions, 12 deletions
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index d099a28d4..ccd6eb263 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -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); } |