IPv4 part of "make reject|blackhole routes work without nexthop|interface".
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index c8168c9..19ec3ae 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -128,7 +128,7 @@
distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
/* Null0 static route. */
- if (strncasecmp (gate_str, "Null0", strlen (gate_str)) == 0)
+ if ((gate_str != NULL) && (strncasecmp (gate_str, "Null0", strlen (gate_str)) == 0))
{
if (flag_str)
{
@@ -159,6 +159,16 @@
}
}
+ if (gate_str == NULL)
+ {
+ if (add_cmd)
+ static_add_ipv4 (&p, NULL, NULL, flag, distance, 0);
+ else
+ static_delete_ipv4 (&p, NULL, NULL, distance, 0);
+
+ return CMD_SUCCESS;
+ }
+
/* When gateway is A.B.C.D format, gate is treated as nexthop
address other case gate is treated as interface name. */
ret = inet_aton (gate_str, &gate);
@@ -203,6 +213,18 @@
return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], NULL);
}
+DEFUN (ip_route_flags2,
+ ip_route_flags2_cmd,
+ "ip route A.B.C.D/M (reject|blackhole)",
+ IP_STR
+ "Establish static routes\n"
+ "IP destination prefix (e.g. 10.0.0.0/8)\n"
+ "Emit an ICMP unreachable when matched\n"
+ "Silently discard pkts when matched\n")
+{
+ return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], NULL);
+}
+
/* Mask as A.B.C.D format. */
DEFUN (ip_route_mask,
ip_route_mask_cmd,
@@ -233,6 +255,19 @@
return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL);
}
+DEFUN (ip_route_mask_flags2,
+ ip_route_mask_flags2_cmd,
+ "ip route A.B.C.D A.B.C.D (reject|blackhole)",
+ IP_STR
+ "Establish static routes\n"
+ "IP destination prefix\n"
+ "IP destination prefix mask\n"
+ "Emit an ICMP unreachable when matched\n"
+ "Silently discard pkts when matched\n")
+{
+ return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], NULL);
+}
+
/* Distance option value. */
DEFUN (ip_route_distance,
ip_route_distance_cmd,
@@ -263,6 +298,19 @@
return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], argv[3]);
}
+DEFUN (ip_route_flags_distance2,
+ ip_route_flags_distance2_cmd,
+ "ip route A.B.C.D/M (reject|blackhole) <1-255>",
+ IP_STR
+ "Establish static routes\n"
+ "IP destination prefix (e.g. 10.0.0.0/8)\n"
+ "Emit an ICMP unreachable when matched\n"
+ "Silently discard pkts when matched\n"
+ "Distance value for this route\n")
+{
+ return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], argv[2]);
+}
+
DEFUN (ip_route_mask_distance,
ip_route_mask_distance_cmd,
"ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>",
@@ -294,6 +342,20 @@
return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4]);
}
+DEFUN (ip_route_mask_flags_distance2,
+ ip_route_mask_flags_distance2_cmd,
+ "ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>",
+ IP_STR
+ "Establish static routes\n"
+ "IP destination prefix\n"
+ "IP destination prefix mask\n"
+ "Distance value for this route\n"
+ "Emit an ICMP unreachable when matched\n"
+ "Silently discard pkts when matched\n")
+{
+ return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3]);
+}
+
DEFUN (no_ip_route,
no_ip_route_cmd,
"no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)",
@@ -320,6 +382,19 @@
"Emit an ICMP unreachable when matched\n"
"Silently discard pkts when matched\n")
+DEFUN (no_ip_route_flags2,
+ no_ip_route_flags2_cmd,
+ "no ip route A.B.C.D/M (reject|blackhole)",
+ NO_STR
+ IP_STR
+ "Establish static routes\n"
+ "IP destination prefix (e.g. 10.0.0.0/8)\n"
+ "Emit an ICMP unreachable when matched\n"
+ "Silently discard pkts when matched\n")
+{
+ return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, NULL, NULL);
+}
+
DEFUN (no_ip_route_mask,
no_ip_route_mask_cmd,
"no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)",
@@ -348,6 +423,20 @@
"Emit an ICMP unreachable when matched\n"
"Silently discard pkts when matched\n")
+DEFUN (no_ip_route_mask_flags2,
+ no_ip_route_mask_flags2_cmd,
+ "no ip route A.B.C.D A.B.C.D (reject|blackhole)",
+ NO_STR
+ IP_STR
+ "Establish static routes\n"
+ "IP destination prefix\n"
+ "IP destination prefix mask\n"
+ "Emit an ICMP unreachable when matched\n"
+ "Silently discard pkts when matched\n")
+{
+ return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, NULL, NULL);
+}
+
DEFUN (no_ip_route_distance,
no_ip_route_distance_cmd,
"no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>",
@@ -379,6 +468,20 @@
return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], argv[2], argv[3]);
}
+DEFUN (no_ip_route_flags_distance2,
+ no_ip_route_flags_distance2_cmd,
+ "no ip route A.B.C.D/M (reject|blackhole) <1-255>",
+ NO_STR
+ IP_STR
+ "Establish static routes\n"
+ "IP destination prefix (e.g. 10.0.0.0/8)\n"
+ "Emit an ICMP unreachable when matched\n"
+ "Silently discard pkts when matched\n"
+ "Distance value for this route\n")
+{
+ return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, argv[1], argv[2]);
+}
+
DEFUN (no_ip_route_mask_distance,
no_ip_route_mask_distance_cmd,
"no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>",
@@ -412,6 +515,21 @@
return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4]);
}
+DEFUN (no_ip_route_mask_flags_distance2,
+ no_ip_route_mask_flags_distance2_cmd,
+ "no ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>",
+ NO_STR
+ IP_STR
+ "Establish static routes\n"
+ "IP destination prefix\n"
+ "IP destination prefix mask\n"
+ "Emit an ICMP unreachable when matched\n"
+ "Silently discard pkts when matched\n"
+ "Distance value for this route\n")
+{
+ return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3]);
+}
+
/* New RIB. Detailed information for IPv4 route. */
void
vty_show_ip_route_detail (struct vty *vty, struct route_node *rn)
@@ -485,7 +603,9 @@
vty_out (vty, " directly connected, %s", nexthop->ifname);
break;
case NEXTHOP_TYPE_BLACKHOLE:
- vty_out (vty, " directly connected, via Null0");
+ vty_out (vty, " directly connected");
+ if (!rib->flags)
+ vty_out (vty, ", Null0");
break;
default:
break;
@@ -568,7 +688,9 @@
vty_out (vty, " is directly connected, %s", nexthop->ifname);
break;
case NEXTHOP_TYPE_BLACKHOLE:
- vty_out (vty, " is directly connected, Null0");
+ vty_out (vty, " is directly connected");
+ if (!rib->flags)
+ vty_out (vty, ", Null0");
break;
default:
break;
@@ -960,7 +1082,8 @@
vty_out (vty, " %s", si->gate.ifname);
break;
case STATIC_IPV4_BLACKHOLE:
- vty_out (vty, " Null0");
+ if (!si->flags)
+ vty_out (vty, " Null0");
break;
}
@@ -1805,19 +1928,27 @@
install_element (CONFIG_NODE, &ip_route_cmd);
install_element (CONFIG_NODE, &ip_route_flags_cmd);
+ install_element (CONFIG_NODE, &ip_route_flags2_cmd);
install_element (CONFIG_NODE, &ip_route_mask_cmd);
install_element (CONFIG_NODE, &ip_route_mask_flags_cmd);
+ install_element (CONFIG_NODE, &ip_route_mask_flags2_cmd);
install_element (CONFIG_NODE, &no_ip_route_cmd);
install_element (CONFIG_NODE, &no_ip_route_flags_cmd);
+ install_element (CONFIG_NODE, &no_ip_route_flags2_cmd);
install_element (CONFIG_NODE, &no_ip_route_mask_cmd);
install_element (CONFIG_NODE, &no_ip_route_mask_flags_cmd);
+ install_element (CONFIG_NODE, &no_ip_route_mask_flags2_cmd);
install_element (CONFIG_NODE, &ip_route_distance_cmd);
install_element (CONFIG_NODE, &ip_route_flags_distance_cmd);
+ install_element (CONFIG_NODE, &ip_route_flags_distance2_cmd);
install_element (CONFIG_NODE, &ip_route_mask_distance_cmd);
install_element (CONFIG_NODE, &ip_route_mask_flags_distance_cmd);
+ install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_cmd);
install_element (CONFIG_NODE, &no_ip_route_distance_cmd);
install_element (CONFIG_NODE, &no_ip_route_flags_distance_cmd);
+ install_element (CONFIG_NODE, &no_ip_route_flags_distance2_cmd);
install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_cmd);
+ install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_cmd);
install_element (VIEW_NODE, &show_ip_route_cmd);
install_element (VIEW_NODE, &show_ip_route_addr_cmd);