summaryrefslogtreecommitdiff
path: root/zebra/zebra_vty.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/zebra_vty.c')
-rw-r--r--zebra/zebra_vty.c290
1 files changed, 258 insertions, 32 deletions
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index e6f80f92a7..f7548f618f 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -51,6 +51,7 @@
#include "zebra/router-id.h"
#include "zebra/ipforward.h"
#include "zebra/zebra_vxlan_private.h"
+#include "zebra/zebra_pbr.h"
extern int allow_delete;
@@ -91,6 +92,7 @@ struct static_hold_route {
char *tag_str;
char *distance_str;
char *label_str;
+ char *table_str;
/* processed & masked destination, used for config display */
struct prefix dest;
@@ -192,6 +194,11 @@ static int static_list_compare(void *arg1, void *arg2)
if (ret)
return ret;
+ ret = static_list_compare_helper(shr1->table_str,
+ shr2->table_str);
+ if (ret)
+ return ret;
+
return static_list_compare_helper(shr1->label_str, shr2->label_str);
}
@@ -202,7 +209,8 @@ static int zebra_static_route_holdem(
safi_t safi, const char *negate, struct prefix *dest,
const char *dest_str, const char *mask_str, const char *src_str,
const char *gate_str, const char *ifname, const char *flag_str,
- const char *tag_str, const char *distance_str, const char *label_str)
+ const char *tag_str, const char *distance_str, const char *label_str,
+ const char *table_str)
{
struct static_hold_route *shr, *lookup;
struct listnode *node;
@@ -235,6 +243,8 @@ static int zebra_static_route_holdem(
shr->distance_str = XSTRDUP(MTYPE_STATIC_ROUTE, distance_str);
if (label_str)
shr->label_str = XSTRDUP(MTYPE_STATIC_ROUTE, label_str);
+ if (table_str)
+ shr->table_str = XSTRDUP(MTYPE_STATIC_ROUTE, table_str);
for (ALL_LIST_ELEMENTS_RO(static_list, node, lookup)) {
if (static_list_compare(shr, lookup) == 0)
@@ -271,7 +281,7 @@ static int zebra_static_route_leak(
afi_t afi, safi_t safi, const char *negate, const char *dest_str,
const char *mask_str, const char *src_str, const char *gate_str,
const char *ifname, const char *flag_str, const char *tag_str,
- const char *distance_str, const char *label_str)
+ const char *distance_str, const char *label_str, const char *table_str)
{
int ret;
uint8_t distance;
@@ -284,6 +294,7 @@ static int zebra_static_route_leak(
route_tag_t tag = 0;
uint8_t type;
struct static_nh_label snh_label;
+ uint32_t table_id = 0;
ret = str2prefix(dest_str, &p);
if (ret <= 0) {
@@ -342,7 +353,24 @@ static int zebra_static_route_leak(
return zebra_static_route_holdem(
zvrf, nh_zvrf, afi, safi, negate, &p, dest_str,
mask_str, src_str, gate_str, ifname, flag_str, tag_str,
- distance_str, label_str);
+ distance_str, label_str, table_str);
+ }
+ if (table_str) {
+ /* table configured. check consistent with vrf config
+ */
+ if (zvrf->table_id != RT_TABLE_MAIN &&
+ zvrf->table_id != zebrad.rtm_table_default) {
+ if (vty)
+ vty_out(vty,
+ "%% Table %s overlaps vrf table %u\n",
+ table_str, zvrf->table_id);
+ else
+ zlog_warn(
+ "%s: Table %s overlaps vrf table %u",
+ __PRETTY_FUNCTION__,
+ table_str, zvrf->table_id);
+ return CMD_WARNING_CONFIG_FAILED;
+ }
}
/* Administrative distance. */
@@ -409,6 +437,9 @@ static int zebra_static_route_leak(
return CMD_WARNING_CONFIG_FAILED;
}
}
+ /* TableID */
+ if (table_str)
+ table_id = atol(table_str);
/* Null0 static route. */
if (ifname != NULL) {
@@ -485,12 +516,12 @@ static int zebra_static_route_leak(
if (!negate) {
static_add_route(afi, safi, type, &p, src_p, gatep, ifname,
bh_type, tag, distance, zvrf, nh_zvrf,
- &snh_label);
+ &snh_label, table_id);
/* Mark as having FRR configuration */
vrf_set_user_cfged(zvrf->vrf);
} else {
static_delete_route(afi, safi, type, &p, src_p, gatep, ifname,
- tag, distance, zvrf, &snh_label);
+ tag, distance, zvrf, &snh_label, table_id);
/* If no other FRR config for this VRF, mark accordingly. */
if (!zebra_vrf_has_config(zvrf))
vrf_reset_user_cfged(zvrf->vrf);
@@ -533,7 +564,7 @@ static int zebra_static_route(struct vty *vty, afi_t afi, safi_t safi,
const char *gate_str, const char *ifname,
const char *flag_str, const char *tag_str,
const char *distance_str, const char *vrf_name,
- const char *label_str)
+ const char *label_str, const char *table_str)
{
struct zebra_vrf *zvrf;
@@ -556,7 +587,8 @@ static int zebra_static_route(struct vty *vty, afi_t afi, safi_t safi,
}
return zebra_static_route_leak(
vty, zvrf, zvrf, afi, safi, negate, dest_str, mask_str, src_str,
- gate_str, ifname, flag_str, tag_str, distance_str, label_str);
+ gate_str, ifname, flag_str, tag_str, distance_str, label_str,
+ table_str);
}
void static_config_install_delayed_routes(struct zebra_vrf *zvrf)
@@ -581,7 +613,7 @@ void static_config_install_delayed_routes(struct zebra_vrf *zvrf)
NULL, ozvrf, nh_zvrf, shr->afi, shr->safi, NULL,
shr->dest_str, shr->mask_str, shr->src_str,
shr->gate_str, shr->ifname, shr->flag_str, shr->tag_str,
- shr->distance_str, shr->label_str);
+ shr->distance_str, shr->label_str, shr->table_str);
if (installed != CMD_SUCCESS)
zlog_debug(
@@ -605,7 +637,7 @@ DEFPY (ip_mroute_dist,
{
return zebra_static_route(vty, AFI_IP, SAFI_MULTICAST, no, prefix_str,
NULL, NULL, gate_str, ifname, NULL, NULL,
- distance_str, NULL, NULL);
+ distance_str, NULL, NULL, NULL);
}
DEFUN (ip_multicast_mode,
@@ -712,6 +744,7 @@ DEFPY(ip_route_blackhole,
|(1-255)$distance \
|vrf NAME \
|label WORD \
+ |table (1-4294967295) \
}]",
NO_STR IP_STR
"Establish static routes\n"
@@ -724,11 +757,18 @@ DEFPY(ip_route_blackhole,
"Tag value\n"
"Distance value for this route\n"
VRF_CMD_HELP_STR
- MPLS_LABEL_HELPSTR)
+ MPLS_LABEL_HELPSTR
+ "Table to configure\n"
+ "The table number to configure\n")
{
+ if (table_str && !vrf_is_backend_netns()) {
+ vty_out(vty,
+ "%% table param only available when running on netns-based vrfs\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
return zebra_static_route(vty, AFI_IP, SAFI_UNICAST, no, prefix,
mask_str, NULL, NULL, NULL, flag, tag_str,
- distance_str, vrf, label);
+ distance_str, vrf, label, table_str);
}
DEFPY(ip_route_blackhole_vrf,
@@ -740,6 +780,7 @@ DEFPY(ip_route_blackhole_vrf,
tag (1-4294967295) \
|(1-255)$distance \
|label WORD \
+ |table (1-4294967295) \
}]",
NO_STR IP_STR
"Establish static routes\n"
@@ -751,11 +792,18 @@ DEFPY(ip_route_blackhole_vrf,
"Set tag for this route\n"
"Tag value\n"
"Distance value for this route\n"
- MPLS_LABEL_HELPSTR)
+ MPLS_LABEL_HELPSTR
+ "Table to configure\n"
+ "The table number to configure\n")
{
VTY_DECLVAR_CONTEXT(vrf, vrf);
struct zebra_vrf *zvrf = vrf->info;
+ if (table_str && !vrf_is_backend_netns()) {
+ vty_out(vty,
+ "%% table param only available when running on netns-based vrfs\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
/*
* Coverity is complaining that prefix could
* be dereferenced, but we know that prefix will
@@ -764,7 +812,7 @@ DEFPY(ip_route_blackhole_vrf,
assert(prefix);
return zebra_static_route_leak(vty, zvrf, zvrf, AFI_IP, SAFI_UNICAST,
no, prefix, mask_str, NULL, NULL, NULL,
- flag, tag_str, distance_str, label);
+ flag, tag_str, distance_str, label, table_str);
}
DEFPY(ip_route_address_interface,
@@ -778,6 +826,7 @@ DEFPY(ip_route_address_interface,
|(1-255)$distance \
|vrf NAME \
|label WORD \
+ |table (1-4294967295) \
|nexthop-vrf NAME \
}]",
NO_STR IP_STR
@@ -793,6 +842,8 @@ DEFPY(ip_route_address_interface,
"Distance value for this route\n"
VRF_CMD_HELP_STR
MPLS_LABEL_HELPSTR
+ "Table to configure\n"
+ "The table number to configure\n"
VRF_CMD_HELP_STR)
{
struct zebra_vrf *zvrf;
@@ -810,6 +861,12 @@ DEFPY(ip_route_address_interface,
return CMD_WARNING_CONFIG_FAILED;
}
+ if (table_str && !vrf_is_backend_netns()) {
+ vty_out(vty,
+ "%% table param only available when running on netns-based vrfs\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+
if (nexthop_vrf)
nh_zvrf = zebra_vty_get_unknown_vrf(vty, nexthop_vrf);
else
@@ -822,7 +879,8 @@ DEFPY(ip_route_address_interface,
return zebra_static_route_leak(
vty, zvrf, nh_zvrf, AFI_IP, SAFI_UNICAST, no, prefix, mask_str,
- NULL, gate_str, ifname, flag, tag_str, distance_str, label);
+ NULL, gate_str, ifname, flag, tag_str, distance_str, label,
+ table_str);
}
DEFPY(ip_route_address_interface_vrf,
@@ -835,6 +893,7 @@ DEFPY(ip_route_address_interface_vrf,
tag (1-4294967295) \
|(1-255)$distance \
|label WORD \
+ |table (1-4294967295) \
|nexthop-vrf NAME \
}]",
NO_STR IP_STR
@@ -849,6 +908,8 @@ DEFPY(ip_route_address_interface_vrf,
"Tag value\n"
"Distance value for this route\n"
MPLS_LABEL_HELPSTR
+ "Table to configure\n"
+ "The table number to configure\n"
VRF_CMD_HELP_STR)
{
VTY_DECLVAR_CONTEXT(vrf, vrf);
@@ -856,6 +917,12 @@ DEFPY(ip_route_address_interface_vrf,
struct zebra_vrf *zvrf = vrf->info;
struct zebra_vrf *nh_zvrf;
+ if (table_str && !vrf_is_backend_netns()) {
+ vty_out(vty,
+ "%% table param only available when running on netns-based vrfs\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+
if (ifname && !strncasecmp(ifname, "Null0", 5)) {
flag = "Null0";
ifname = NULL;
@@ -873,7 +940,8 @@ DEFPY(ip_route_address_interface_vrf,
return zebra_static_route_leak(
vty, zvrf, nh_zvrf, AFI_IP, SAFI_UNICAST, no, prefix, mask_str,
- NULL, gate_str, ifname, flag, tag_str, distance_str, label);
+ NULL, gate_str, ifname, flag, tag_str, distance_str, label,
+ table_str);
}
DEFPY(ip_route,
@@ -886,6 +954,7 @@ DEFPY(ip_route,
|(1-255)$distance \
|vrf NAME \
|label WORD \
+ |table (1-4294967295) \
|nexthop-vrf NAME \
}]",
NO_STR IP_STR
@@ -900,12 +969,20 @@ DEFPY(ip_route,
"Distance value for this route\n"
VRF_CMD_HELP_STR
MPLS_LABEL_HELPSTR
+ "Table to configure\n"
+ "The table number to configure\n"
VRF_CMD_HELP_STR)
{
struct zebra_vrf *zvrf;
struct zebra_vrf *nh_zvrf;
const char *flag = NULL;
+ if (table_str && !vrf_is_backend_netns()) {
+ vty_out(vty,
+ "%% table param only available when running on netns-based vrfs\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+
if (ifname && !strncasecmp(ifname, "Null0", 5)) {
flag = "Null0";
ifname = NULL;
@@ -930,7 +1007,8 @@ DEFPY(ip_route,
return zebra_static_route_leak(
vty, zvrf, nh_zvrf, AFI_IP, SAFI_UNICAST, no, prefix, mask_str,
- NULL, gate_str, ifname, flag, tag_str, distance_str, label);
+ NULL, gate_str, ifname, flag, tag_str, distance_str, label,
+ table_str);
}
DEFPY(ip_route_vrf,
@@ -942,6 +1020,7 @@ DEFPY(ip_route_vrf,
tag (1-4294967295) \
|(1-255)$distance \
|label WORD \
+ |table (1-4294967295) \
|nexthop-vrf NAME \
}]",
NO_STR IP_STR
@@ -955,13 +1034,21 @@ DEFPY(ip_route_vrf,
"Tag value\n"
"Distance value for this route\n"
MPLS_LABEL_HELPSTR
+ "Table to configure\n"
+ "The table number to configure\n"
VRF_CMD_HELP_STR)
{
VTY_DECLVAR_CONTEXT(vrf, vrf);
struct zebra_vrf *zvrf = vrf->info;
struct zebra_vrf *nh_zvrf;
-
const char *flag = NULL;
+
+ if (table_str && !vrf_is_backend_netns()) {
+ vty_out(vty,
+ "%% table param only available when running on netns-based vrfs\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+
if (ifname && !strncasecmp(ifname, "Null0", 5)) {
flag = "Null0";
ifname = NULL;
@@ -979,7 +1066,8 @@ DEFPY(ip_route_vrf,
return zebra_static_route_leak(
vty, zvrf, nh_zvrf, AFI_IP, SAFI_UNICAST, no, prefix, mask_str,
- NULL, gate_str, ifname, flag, tag_str, distance_str, label);
+ NULL, gate_str, ifname, flag, tag_str, distance_str, label,
+ NULL);
}
/* New RIB. Detailed information for IPv4 route. */
@@ -1695,6 +1783,35 @@ DEFPY (show_route_table,
return CMD_SUCCESS;
}
+DEFPY (show_route_table_vrf,
+ show_route_table_vrf_cmd,
+ "show <ip$ipv4|ipv6$ipv6> route table (1-4294967295)$table vrf NAME$vrf_name [json$json]",
+ SHOW_STR
+ IP_STR
+ IP6_STR
+ "IP routing table\n"
+ "Table to display\n"
+ "The table number to display, if available\n"
+ VRF_CMD_HELP_STR
+ JSON_STR)
+{
+ afi_t afi = ipv4 ? AFI_IP : AFI_IP6;
+ struct zebra_vrf *zvrf;
+ struct route_table *t;
+ vrf_id_t vrf_id = VRF_DEFAULT;
+
+ if (vrf_name)
+ VRF_GET_ID(vrf_id, vrf_name);
+ zvrf = zebra_vrf_lookup_by_id(vrf_id);
+
+ t = zebra_ns_find_table(zvrf->zns, table, afi);
+ if (t)
+ do_show_route_helper(vty, zvrf, t, afi, false, 0, false, false,
+ 0, 0, !!json);
+
+ return CMD_SUCCESS;
+}
+
DEFUN (show_ip_nht,
show_ip_nht_cmd,
"show ip nht [vrf NAME]",
@@ -2257,6 +2374,8 @@ int static_config(struct vty *vty, struct zebra_vrf *zvrf, afi_t afi,
vty_out(vty, "%s ", shr->distance_str);
if (shr->label_str)
vty_out(vty, "label %s ", shr->label_str);
+ if (shr->table_str)
+ vty_out(vty, "table %s ", shr->table_str);
if (strcmp(shr->vrf_name, shr->nhvrf_name) != 0)
vty_out(vty, "nexthop-vrf %s", shr->nhvrf_name);
vty_out(vty, "\n");
@@ -2323,6 +2442,11 @@ int static_config(struct vty *vty, struct zebra_vrf *zvrf, afi_t afi,
vty_out(vty, " nexthop-vrf %s", si->nh_vrfname);
}
+ /* table ID from VRF overrides configured
+ */
+ if (si->table_id && zvrf->table_id == RT_TABLE_MAIN)
+ vty_out(vty, " table %u", si->table_id);
+
vty_out(vty, "\n");
write = 1;
@@ -2339,6 +2463,7 @@ DEFPY(ipv6_route_blackhole,
|(1-255)$distance \
|vrf NAME \
|label WORD \
+ |table (1-4294967295) \
}]",
NO_STR
IPV6_STR
@@ -2353,11 +2478,19 @@ DEFPY(ipv6_route_blackhole,
"Tag value\n"
"Distance value for this prefix\n"
VRF_CMD_HELP_STR
- MPLS_LABEL_HELPSTR)
+ MPLS_LABEL_HELPSTR
+ "Table to configure\n"
+ "The table number to configure\n")
{
+ if (table_str && !vrf_is_backend_netns()) {
+ vty_out(vty,
+ "%% table param only available when running on netns-based vrfs\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+
return zebra_static_route(vty, AFI_IP6, SAFI_UNICAST, no, prefix_str,
NULL, from_str, NULL, NULL, flag, tag_str,
- distance_str, vrf, label);
+ distance_str, vrf, label, table_str);
}
DEFPY(ipv6_route_blackhole_vrf,
@@ -2368,6 +2501,7 @@ DEFPY(ipv6_route_blackhole_vrf,
tag (1-4294967295) \
|(1-255)$distance \
|label WORD \
+ |table (1-4294967295) \
}]",
NO_STR
IPV6_STR
@@ -2381,11 +2515,18 @@ DEFPY(ipv6_route_blackhole_vrf,
"Set tag for this route\n"
"Tag value\n"
"Distance value for this prefix\n"
- MPLS_LABEL_HELPSTR)
+ MPLS_LABEL_HELPSTR
+ "Table to configure\n"
+ "The table number to configure\n")
{
VTY_DECLVAR_CONTEXT(vrf, vrf);
struct zebra_vrf *zvrf = vrf->info;
+ if (table_str && !vrf_is_backend_netns()) {
+ vty_out(vty,
+ "%% table param only available when running on netns-based vrfs\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
/*
* Coverity is complaining that prefix could
* be dereferenced, but we know that prefix will
@@ -2394,7 +2535,8 @@ DEFPY(ipv6_route_blackhole_vrf,
assert(prefix);
return zebra_static_route_leak(
vty, zvrf, zvrf, AFI_IP6, SAFI_UNICAST, no, prefix_str, NULL,
- from_str, NULL, NULL, flag, tag_str, distance_str, label);
+ from_str, NULL, NULL, flag, tag_str, distance_str, label,
+ table_str);
}
DEFPY(ipv6_route_address_interface,
@@ -2407,6 +2549,7 @@ DEFPY(ipv6_route_address_interface,
|(1-255)$distance \
|vrf NAME \
|label WORD \
+ |table (1-4294967295) \
|nexthop-vrf NAME \
}]",
NO_STR
@@ -2422,11 +2565,19 @@ DEFPY(ipv6_route_address_interface,
"Distance value for this prefix\n"
VRF_CMD_HELP_STR
MPLS_LABEL_HELPSTR
+ "Table to configure\n"
+ "The table number to configure\n"
VRF_CMD_HELP_STR)
{
struct zebra_vrf *zvrf;
struct zebra_vrf *nh_zvrf;
+ if (table_str && !vrf_is_backend_netns()) {
+ vty_out(vty,
+ "%% table param only available when running on netns-based vrfs\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+
zvrf = zebra_vty_get_unknown_vrf(vty, vrf);
if (!zvrf) {
vty_out(vty, "%% vrf %s is not defined\n", vrf);
@@ -2445,7 +2596,8 @@ DEFPY(ipv6_route_address_interface,
return zebra_static_route_leak(
vty, zvrf, nh_zvrf, AFI_IP6, SAFI_UNICAST, no, prefix_str, NULL,
- from_str, gate_str, ifname, NULL, tag_str, distance_str, label);
+ from_str, gate_str, ifname, NULL, tag_str, distance_str, label,
+ table_str);
}
DEFPY(ipv6_route_address_interface_vrf,
@@ -2457,6 +2609,7 @@ DEFPY(ipv6_route_address_interface_vrf,
tag (1-4294967295) \
|(1-255)$distance \
|label WORD \
+ |table (1-4294967295) \
|nexthop-vrf NAME \
}]",
NO_STR
@@ -2471,12 +2624,20 @@ DEFPY(ipv6_route_address_interface_vrf,
"Tag value\n"
"Distance value for this prefix\n"
MPLS_LABEL_HELPSTR
+ "Table to configure\n"
+ "The table number to configure\n"
VRF_CMD_HELP_STR)
{
VTY_DECLVAR_CONTEXT(vrf, vrf);
struct zebra_vrf *zvrf = vrf->info;
struct zebra_vrf *nh_zvrf;
+ if (table_str && !vrf_is_backend_netns()) {
+ vty_out(vty,
+ "%% table param only available when running on netns-based vrfs\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+
if (nexthop_vrf)
nh_zvrf = zebra_vty_get_unknown_vrf(vty, nexthop_vrf);
else
@@ -2489,7 +2650,8 @@ DEFPY(ipv6_route_address_interface_vrf,
return zebra_static_route_leak(
vty, zvrf, nh_zvrf, AFI_IP6, SAFI_UNICAST, no, prefix_str, NULL,
- from_str, gate_str, ifname, NULL, tag_str, distance_str, label);
+ from_str, gate_str, ifname, NULL, tag_str, distance_str, label,
+ table_str);
}
DEFPY(ipv6_route,
@@ -2501,6 +2663,7 @@ DEFPY(ipv6_route,
|(1-255)$distance \
|vrf NAME \
|label WORD \
+ |table (1-4294967295) \
|nexthop-vrf NAME \
}]",
NO_STR
@@ -2516,11 +2679,19 @@ DEFPY(ipv6_route,
"Distance value for this prefix\n"
VRF_CMD_HELP_STR
MPLS_LABEL_HELPSTR
+ "Table to configure\n"
+ "The table number to configure\n"
VRF_CMD_HELP_STR)
{
struct zebra_vrf *zvrf;
struct zebra_vrf *nh_zvrf;
+ if (table_str && !vrf_is_backend_netns()) {
+ vty_out(vty,
+ "%% table param only available when running on netns-based vrfs\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+
zvrf = zebra_vty_get_unknown_vrf(vty, vrf);
if (!zvrf) {
vty_out(vty, "%% vrf %s is not defined\n", vrf);
@@ -2539,7 +2710,8 @@ DEFPY(ipv6_route,
return zebra_static_route_leak(
vty, zvrf, nh_zvrf, AFI_IP6, SAFI_UNICAST, no, prefix_str, NULL,
- from_str, gate_str, ifname, NULL, tag_str, distance_str, label);
+ from_str, gate_str, ifname, NULL, tag_str, distance_str, label,
+ table_str);
}
DEFPY(ipv6_route_vrf,
@@ -2550,6 +2722,7 @@ DEFPY(ipv6_route_vrf,
tag (1-4294967295) \
|(1-255)$distance \
|label WORD \
+ |table (1-4294967295) \
|nexthop-vrf NAME \
}]",
NO_STR
@@ -2564,12 +2737,20 @@ DEFPY(ipv6_route_vrf,
"Tag value\n"
"Distance value for this prefix\n"
MPLS_LABEL_HELPSTR
+ "Table to configure\n"
+ "The table number to configure\n"
VRF_CMD_HELP_STR)
{
VTY_DECLVAR_CONTEXT(vrf, vrf);
struct zebra_vrf *zvrf = vrf->info;
struct zebra_vrf *nh_zvrf;
+ if (table_str && !vrf_is_backend_netns()) {
+ vty_out(vty,
+ "%% table param only available when running on netns-based vrfs\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+
if (nexthop_vrf)
nh_zvrf = zebra_vty_get_unknown_vrf(vty, nexthop_vrf);
else
@@ -2582,7 +2763,8 @@ DEFPY(ipv6_route_vrf,
return zebra_static_route_leak(
vty, zvrf, nh_zvrf, AFI_IP6, SAFI_UNICAST, no, prefix_str, NULL,
- from_str, gate_str, ifname, NULL, tag_str, distance_str, label);
+ from_str, gate_str, ifname, NULL, tag_str, distance_str, label,
+ table_str);
}
/*
@@ -2686,6 +2868,9 @@ DEFUN (show_vrf,
struct vrf *vrf;
struct zebra_vrf *zvrf;
+ if (vrf_is_backend_netns())
+ vty_out(vty, "netns-based vrfs\n");
+
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
if (!(zvrf = vrf->info))
continue;
@@ -3260,6 +3445,37 @@ DEFUN (show_evpn_neigh_vni_vtep,
return CMD_SUCCESS;
}
+/* policy routing contexts */
+DEFUN (show_pbr_ipset,
+ show_pbr_ipset_cmd,
+ "show pbr ipset [WORD]",
+ SHOW_STR
+ "Policy-Based Routing\n"
+ "IPset Context information\n"
+ "IPset Name information\n")
+{
+ int idx = 0;
+ int found = 0;
+ found = argv_find(argv, argc, "WORD", &idx);
+ if (!found)
+ zebra_pbr_show_ipset_list(vty, NULL);
+ else
+ zebra_pbr_show_ipset_list(vty, argv[idx]->arg);
+ return CMD_SUCCESS;
+}
+
+/* policy routing contexts */
+DEFUN (show_pbr_iptable,
+ show_pbr_iptable_cmd,
+ "show pbr iptable",
+ SHOW_STR
+ "Policy-Based Routing\n"
+ "IPtable Context information\n")
+{
+ zebra_pbr_show_iptable(vty);
+ return CMD_SUCCESS;
+}
+
/* Static ip route configuration write function. */
static int zebra_ip_config(struct vty *vty)
{
@@ -3702,11 +3918,13 @@ void zebra_vty_init(void)
install_element(CONFIG_NODE, &ip_multicast_mode_cmd);
install_element(CONFIG_NODE, &no_ip_multicast_mode_cmd);
install_element(CONFIG_NODE, &ip_route_blackhole_cmd);
+ install_element(CONFIG_NODE,
+ &ip_route_address_interface_cmd);
+ install_element(CONFIG_NODE, &ip_route_cmd);
install_element(VRF_NODE, &ip_route_blackhole_vrf_cmd);
- install_element(CONFIG_NODE, &ip_route_address_interface_cmd);
install_element(VRF_NODE, &ip_route_address_interface_vrf_cmd);
- install_element(CONFIG_NODE, &ip_route_cmd);
install_element(VRF_NODE, &ip_route_vrf_cmd);
+
install_element(CONFIG_NODE, &ip_zebra_import_table_distance_cmd);
install_element(CONFIG_NODE, &no_ip_zebra_import_table_cmd);
install_element(CONFIG_NODE, &zebra_workqueue_timer_cmd);
@@ -3718,6 +3936,8 @@ void zebra_vty_init(void)
install_element(VIEW_NODE, &show_vrf_vni_cmd);
install_element(VIEW_NODE, &show_route_cmd);
install_element(VIEW_NODE, &show_route_table_cmd);
+ if (vrf_is_backend_netns())
+ install_element(VIEW_NODE, &show_route_table_vrf_cmd);
install_element(VIEW_NODE, &show_route_detail_cmd);
install_element(VIEW_NODE, &show_route_summary_cmd);
install_element(VIEW_NODE, &show_ip_nht_cmd);
@@ -3728,11 +3948,14 @@ void zebra_vty_init(void)
install_element(VIEW_NODE, &show_ip_rpf_cmd);
install_element(VIEW_NODE, &show_ip_rpf_addr_cmd);
- install_element(CONFIG_NODE, &ipv6_route_blackhole_cmd);
- install_element(VRF_NODE, &ipv6_route_blackhole_vrf_cmd);
- install_element(CONFIG_NODE, &ipv6_route_address_interface_cmd);
- install_element(VRF_NODE, &ipv6_route_address_interface_vrf_cmd);
+ install_element(CONFIG_NODE,
+ &ipv6_route_blackhole_cmd);
+ install_element(CONFIG_NODE,
+ &ipv6_route_address_interface_cmd);
install_element(CONFIG_NODE, &ipv6_route_cmd);
+ install_element(VRF_NODE, &ipv6_route_blackhole_vrf_cmd);
+ install_element(VRF_NODE,
+ &ipv6_route_address_interface_vrf_cmd);
install_element(VRF_NODE, &ipv6_route_vrf_cmd);
install_element(CONFIG_NODE, &ip_nht_default_route_cmd);
install_element(CONFIG_NODE, &no_ip_nht_default_route_cmd);
@@ -3762,6 +3985,9 @@ void zebra_vty_init(void)
install_element(VIEW_NODE, &show_evpn_neigh_vni_neigh_cmd);
install_element(VIEW_NODE, &show_evpn_neigh_vni_vtep_cmd);
+ install_element(VIEW_NODE, &show_pbr_ipset_cmd);
+ install_element(VIEW_NODE, &show_pbr_iptable_cmd);
+
install_element(CONFIG_NODE, &default_vrf_vni_mapping_cmd);
install_element(CONFIG_NODE, &no_default_vrf_vni_mapping_cmd);
install_element(VRF_NODE, &vrf_vni_mapping_cmd);