Skip to content

Commit

Permalink
zebra: Don't display the vrf if not using namespace based vrfs
Browse files Browse the repository at this point in the history
Currently when doing a `show ip route table XXXX`, zebra is displaying
the current default vrf as the vrf we are in.  We are displaying a
table not a vrf.  This is only true if you are not using namespace
based vrf's, so modify the output to display accordingly.

Signed-off-by: Donald Sharp <[email protected]>
  • Loading branch information
donaldsharp committed Oct 10, 2024
1 parent cc7d89a commit e700638
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
1 change: 1 addition & 0 deletions zebra/table_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ extern "C" {
#if !defined(GNU_LINUX)
/* BSD systems
*/
#define RT_TABLE_ID_MAIN 0
#else
/* Linux Systems
*/
Expand Down
2 changes: 2 additions & 0 deletions zebra/zebra_vrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ vrf_id_t zebra_vrf_lookup_by_table(uint32_t table_id, ns_id_t ns_id)

RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id) {
zvrf = vrf->info;

if (zvrf == NULL)
continue;
/* case vrf with netns : match the netnsid */
Expand All @@ -408,6 +409,7 @@ vrf_id_t zebra_vrf_lookup_by_table(uint32_t table_id, ns_id_t ns_id)
/* VRF is VRF_BACKEND_VRF_LITE */
if (zvrf->table_id != table_id)
continue;

return zvrf_id(zvrf);
}
}
Expand Down
35 changes: 30 additions & 5 deletions zebra/zebra_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -942,11 +942,36 @@ static void do_show_route_helper(struct vty *vty, struct zebra_vrf *zvrf,
if (!tableid)
vty_out(vty, "VRF %s:\n",
zvrf_name(zvrf));
else
vty_out(vty,
"VRF %s table %u:\n",
zvrf_name(zvrf),
tableid);
else {
if (vrf_is_backend_netns())
vty_out(vty,
"VRF %s table %u:\n",
zvrf_name(zvrf),
tableid);
else {
vrf_id_t vrf = zebra_vrf_lookup_by_table(
tableid,
zvrf->zns->ns_id);

if (vrf == VRF_DEFAULT &&
tableid !=
RT_TABLE_ID_MAIN)
vty_out(vty,
"table %u:\n",
tableid);
else {
struct zebra_vrf *zvrf2 =
zebra_vrf_lookup_by_id(
vrf);

vty_out(vty,
"VRF %s table %u:\n",
zvrf_name(
zvrf2),
tableid);
}
}
}
}
ctx->header_done = true;
first = 0;
Expand Down

0 comments on commit e700638

Please sign in to comment.