diff options
Diffstat (limited to 'staticd/static_vty.c')
| -rw-r--r-- | staticd/static_vty.c | 92 |
1 files changed, 60 insertions, 32 deletions
diff --git a/staticd/static_vty.c b/staticd/static_vty.c index bc8a429d56..f09c304359 100644 --- a/staticd/static_vty.c +++ b/staticd/static_vty.c @@ -775,7 +775,7 @@ DEFPY(ip_route_blackhole, "Table to configure\n" "The table number to configure\n") { - if (table_str && vrf && !vrf_is_mapped_on_netns(vrf_lookup_by_name(vrf))) { + if (table_str && vrf && !vrf_is_backend_netns()) { vty_out(vty, "%% table param only available when running on netns-based vrfs\n"); return CMD_WARNING_CONFIG_FAILED; @@ -814,7 +814,7 @@ DEFPY(ip_route_blackhole_vrf, VTY_DECLVAR_CONTEXT(vrf, vrf); struct static_vrf *svrf = vrf->info; - if (table_str && !vrf_is_mapped_on_netns(vrf)) { + 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; @@ -837,7 +837,7 @@ DEFPY(ip_route_address_interface, "[no] ip route\ <A.B.C.D/M$prefix|A.B.C.D$prefix A.B.C.D$mask> \ A.B.C.D$gate \ - INTERFACE$ifname \ + <INTERFACE|Null0>$ifname \ [{ \ tag (1-4294967295) \ |(1-255)$distance \ @@ -853,8 +853,8 @@ DEFPY(ip_route_address_interface, "IP destination prefix\n" "IP destination prefix mask\n" "IP gateway address\n" - "IP gateway interface name. Specify 'Null0' (case-insensitive) for a \ - null route.\n" + "IP gateway interface name\n" + "Null interface\n" "Set tag for this route\n" "Tag value\n" "Distance value for this route\n" @@ -880,7 +880,7 @@ DEFPY(ip_route_address_interface, return CMD_WARNING_CONFIG_FAILED; } - if (table_str && vrf && !vrf_is_mapped_on_netns(vrf_lookup_by_name(vrf))) { + if (table_str && vrf && !vrf_is_backend_netns()) { vty_out(vty, "%% table param only available when running on netns-based vrfs\n"); return CMD_WARNING_CONFIG_FAILED; @@ -907,7 +907,7 @@ DEFPY(ip_route_address_interface_vrf, "[no] ip route\ <A.B.C.D/M$prefix|A.B.C.D$prefix A.B.C.D$mask> \ A.B.C.D$gate \ - INTERFACE$ifname \ + <INTERFACE|Null0>$ifname \ [{ \ tag (1-4294967295) \ |(1-255)$distance \ @@ -922,8 +922,8 @@ DEFPY(ip_route_address_interface_vrf, "IP destination prefix\n" "IP destination prefix mask\n" "IP gateway address\n" - "IP gateway interface name. Specify 'Null0' (case-insensitive) for a \ - null route.\n" + "IP gateway interface name\n" + "Null interface\n" "Set tag for this route\n" "Tag value\n" "Distance value for this route\n" @@ -938,7 +938,7 @@ DEFPY(ip_route_address_interface_vrf, struct static_vrf *svrf = vrf->info; struct static_vrf *nh_svrf; - if (table_str && !vrf_is_mapped_on_netns(vrf)) { + 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; @@ -969,7 +969,7 @@ DEFPY(ip_route, ip_route_cmd, "[no] ip route\ <A.B.C.D/M$prefix|A.B.C.D$prefix A.B.C.D$mask> \ - <A.B.C.D$gate|INTERFACE$ifname> \ + <A.B.C.D$gate|<INTERFACE|Null0>$ifname> \ [{ \ tag (1-4294967295) \ |(1-255)$distance \ @@ -985,6 +985,7 @@ DEFPY(ip_route, "IP destination prefix mask\n" "IP gateway address\n" "IP gateway interface name\n" + "Null interface\n" "Set tag for this route\n" "Tag value\n" "Distance value for this route\n" @@ -998,7 +999,7 @@ DEFPY(ip_route, struct static_vrf *nh_svrf; const char *flag = NULL; - if (table_str && vrf && !vrf_is_mapped_on_netns(vrf_lookup_by_name(vrf))) { + if (table_str && vrf && !vrf_is_backend_netns()) { vty_out(vty, "%% table param only available when running on netns-based vrfs\n"); return CMD_WARNING_CONFIG_FAILED; @@ -1035,7 +1036,7 @@ DEFPY(ip_route_vrf, ip_route_vrf_cmd, "[no] ip route\ <A.B.C.D/M$prefix|A.B.C.D$prefix A.B.C.D$mask> \ - <A.B.C.D$gate|INTERFACE$ifname> \ + <A.B.C.D$gate|<INTERFACE|Null0>$ifname> \ [{ \ tag (1-4294967295) \ |(1-255)$distance \ @@ -1050,6 +1051,7 @@ DEFPY(ip_route_vrf, "IP destination prefix mask\n" "IP gateway address\n" "IP gateway interface name\n" + "Null interface\n" "Set tag for this route\n" "Tag value\n" "Distance value for this route\n" @@ -1063,7 +1065,7 @@ DEFPY(ip_route_vrf, struct static_vrf *nh_svrf; const char *flag = NULL; - if (table_str && !vrf_is_mapped_on_netns(vrf)) { + 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; @@ -1093,7 +1095,7 @@ DEFPY(ip_route_vrf, DEFPY(ipv6_route_blackhole, ipv6_route_blackhole_cmd, "[no] ipv6 route X:X::X:X/M$prefix [from X:X::X:X/M] \ - <Null0|reject|blackhole>$flag \ + <reject|blackhole>$flag \ [{ \ tag (1-4294967295) \ |(1-255)$distance \ @@ -1107,7 +1109,6 @@ DEFPY(ipv6_route_blackhole, "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" "IPv6 source-dest route\n" "IPv6 source prefix\n" - "Null interface\n" "Emit an ICMP unreachable when matched\n" "Silently discard pkts when matched\n" "Set tag for this route\n" @@ -1118,7 +1119,7 @@ DEFPY(ipv6_route_blackhole, "Table to configure\n" "The table number to configure\n") { - if (table_str && vrf && !vrf_is_mapped_on_netns(vrf_lookup_by_name(vrf))) { + if (table_str && vrf && !vrf_is_backend_netns()) { vty_out(vty, "%% table param only available when running on netns-based vrfs\n"); return CMD_WARNING_CONFIG_FAILED; @@ -1132,7 +1133,7 @@ DEFPY(ipv6_route_blackhole, DEFPY(ipv6_route_blackhole_vrf, ipv6_route_blackhole_vrf_cmd, "[no] ipv6 route X:X::X:X/M$prefix [from X:X::X:X/M] \ - <Null0|reject|blackhole>$flag \ + <reject|blackhole>$flag \ [{ \ tag (1-4294967295) \ |(1-255)$distance \ @@ -1145,7 +1146,6 @@ DEFPY(ipv6_route_blackhole_vrf, "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" "IPv6 source-dest route\n" "IPv6 source prefix\n" - "Null interface\n" "Emit an ICMP unreachable when matched\n" "Silently discard pkts when matched\n" "Set tag for this route\n" @@ -1158,7 +1158,7 @@ DEFPY(ipv6_route_blackhole_vrf, VTY_DECLVAR_CONTEXT(vrf, vrf); struct static_vrf *svrf = vrf->info; - if (table_str && !vrf_is_mapped_on_netns(vrf)) { + 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; @@ -1180,7 +1180,7 @@ DEFPY(ipv6_route_address_interface, ipv6_route_address_interface_cmd, "[no] ipv6 route X:X::X:X/M$prefix [from X:X::X:X/M] \ X:X::X:X$gate \ - INTERFACE$ifname \ + <INTERFACE|Null0>$ifname \ [{ \ tag (1-4294967295) \ |(1-255)$distance \ @@ -1198,6 +1198,7 @@ DEFPY(ipv6_route_address_interface, "IPv6 source prefix\n" "IPv6 gateway address\n" "IPv6 gateway interface name\n" + "Null interface\n" "Set tag for this route\n" "Tag value\n" "Distance value for this prefix\n" @@ -1210,8 +1211,9 @@ DEFPY(ipv6_route_address_interface, { struct static_vrf *svrf; struct static_vrf *nh_svrf; + const char *flag = NULL; - if (table_str && vrf && !vrf_is_mapped_on_netns(vrf_lookup_by_name(vrf))) { + if (table_str && vrf && !vrf_is_backend_netns()) { vty_out(vty, "%% table param only available when running on netns-based vrfs\n"); return CMD_WARNING_CONFIG_FAILED; @@ -1233,9 +1235,14 @@ DEFPY(ipv6_route_address_interface, return CMD_WARNING_CONFIG_FAILED; } + if (ifname && !strncasecmp(ifname, "Null0", 5)) { + flag = "Null0"; + ifname = NULL; + } + return static_route_leak( vty, svrf, nh_svrf, AFI_IP6, SAFI_UNICAST, no, prefix_str, NULL, - from_str, gate_str, ifname, NULL, tag_str, distance_str, label, + from_str, gate_str, ifname, flag, tag_str, distance_str, label, table_str, !!onlink); } @@ -1243,7 +1250,7 @@ DEFPY(ipv6_route_address_interface_vrf, ipv6_route_address_interface_vrf_cmd, "[no] ipv6 route X:X::X:X/M$prefix [from X:X::X:X/M] \ X:X::X:X$gate \ - INTERFACE$ifname \ + <INTERFACE|Null0>$ifname \ [{ \ tag (1-4294967295) \ |(1-255)$distance \ @@ -1260,6 +1267,7 @@ DEFPY(ipv6_route_address_interface_vrf, "IPv6 source prefix\n" "IPv6 gateway address\n" "IPv6 gateway interface name\n" + "Null interface\n" "Set tag for this route\n" "Tag value\n" "Distance value for this prefix\n" @@ -1272,8 +1280,9 @@ DEFPY(ipv6_route_address_interface_vrf, VTY_DECLVAR_CONTEXT(vrf, vrf); struct static_vrf *svrf = vrf->info; struct static_vrf *nh_svrf; + const char *flag = NULL; - if (table_str && !vrf_is_mapped_on_netns(vrf)) { + 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; @@ -1289,16 +1298,21 @@ DEFPY(ipv6_route_address_interface_vrf, return CMD_WARNING_CONFIG_FAILED; } + if (ifname && !strncasecmp(ifname, "Null0", 5)) { + flag = "Null0"; + ifname = NULL; + } + return static_route_leak( vty, svrf, nh_svrf, AFI_IP6, SAFI_UNICAST, no, prefix_str, NULL, - from_str, gate_str, ifname, NULL, tag_str, distance_str, label, + from_str, gate_str, ifname, flag, tag_str, distance_str, label, table_str, !!onlink); } DEFPY(ipv6_route, ipv6_route_cmd, "[no] ipv6 route X:X::X:X/M$prefix [from X:X::X:X/M] \ - <X:X::X:X$gate|INTERFACE$ifname> \ + <X:X::X:X$gate|<INTERFACE|Null0>$ifname> \ [{ \ tag (1-4294967295) \ |(1-255)$distance \ @@ -1315,6 +1329,7 @@ DEFPY(ipv6_route, "IPv6 source prefix\n" "IPv6 gateway address\n" "IPv6 gateway interface name\n" + "Null interface\n" "Set tag for this route\n" "Tag value\n" "Distance value for this prefix\n" @@ -1326,8 +1341,9 @@ DEFPY(ipv6_route, { struct static_vrf *svrf; struct static_vrf *nh_svrf; + const char *flag = NULL; - if (table_str && vrf && !vrf_is_mapped_on_netns(vrf_lookup_by_name(vrf))) { + if (table_str && vrf && !vrf_is_backend_netns()) { vty_out(vty, "%% table param only available when running on netns-based vrfs\n"); return CMD_WARNING_CONFIG_FAILED; @@ -1349,16 +1365,21 @@ DEFPY(ipv6_route, return CMD_WARNING_CONFIG_FAILED; } + if (ifname && !strncasecmp(ifname, "Null0", 5)) { + flag = "Null0"; + ifname = NULL; + } + return static_route_leak( vty, svrf, nh_svrf, AFI_IP6, SAFI_UNICAST, no, prefix_str, NULL, - from_str, gate_str, ifname, NULL, tag_str, distance_str, label, + from_str, gate_str, ifname, flag, tag_str, distance_str, label, table_str, false); } DEFPY(ipv6_route_vrf, ipv6_route_vrf_cmd, "[no] ipv6 route X:X::X:X/M$prefix [from X:X::X:X/M] \ - <X:X::X:X$gate|INTERFACE$ifname> \ + <X:X::X:X$gate|<INTERFACE|Null0>$ifname> \ [{ \ tag (1-4294967295) \ |(1-255)$distance \ @@ -1374,6 +1395,7 @@ DEFPY(ipv6_route_vrf, "IPv6 source prefix\n" "IPv6 gateway address\n" "IPv6 gateway interface name\n" + "Null interface\n" "Set tag for this route\n" "Tag value\n" "Distance value for this prefix\n" @@ -1385,8 +1407,9 @@ DEFPY(ipv6_route_vrf, VTY_DECLVAR_CONTEXT(vrf, vrf); struct static_vrf *svrf = vrf->info; struct static_vrf *nh_svrf; + const char *flag = NULL; - if (table_str && !vrf_is_mapped_on_netns(vrf)) { + 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; @@ -1402,9 +1425,14 @@ DEFPY(ipv6_route_vrf, return CMD_WARNING_CONFIG_FAILED; } + if (ifname && !strncasecmp(ifname, "Null0", 5)) { + flag = "Null0"; + ifname = NULL; + } + return static_route_leak( vty, svrf, nh_svrf, AFI_IP6, SAFI_UNICAST, no, prefix_str, NULL, - from_str, gate_str, ifname, NULL, tag_str, distance_str, label, + from_str, gate_str, ifname, flag, tag_str, distance_str, label, table_str, false); } |
