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.c131
1 files changed, 85 insertions, 46 deletions
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index 12084968b7..6002b0d6fa 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -70,7 +70,7 @@ zebra_static_ipv4 (struct vty *vty, safi_t safi, int add_cmd,
struct zebra_vrf *zvrf = NULL;
unsigned int ifindex = 0;
const char *ifname = NULL;
- u_char type = STATIC_IPV4_BLACKHOLE;
+ u_char type = STATIC_BLACKHOLE;
struct static_nh_label snh_label;
memset (&snh_label, 0, sizeof (struct static_nh_label));
@@ -3690,13 +3690,13 @@ static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd)
case STATIC_IFINDEX:
vty_out (vty, " %s", si->ifname);
break;
- case STATIC_IPV4_BLACKHOLE:
+ case STATIC_BLACKHOLE:
vty_out (vty, " Null0");
break;
}
- /* flags are incompatible with STATIC_IPV4_BLACKHOLE */
- if (si->type != STATIC_IPV4_BLACKHOLE)
+ /* flags are incompatible with STATIC_BLACKHOLE */
+ if (si->type != STATIC_BLACKHOLE)
{
if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
vty_out (vty, " %s", "reject");
@@ -3742,7 +3742,7 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
struct prefix p;
struct in6_addr *gate = NULL;
struct in6_addr gate_addr;
- u_char type = 0;
+ u_char type = STATIC_BLACKHOLE;
u_char flag = 0;
route_tag_t tag = 0;
unsigned int ifindex = 0;
@@ -3760,23 +3760,6 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
/* Apply mask for given prefix. */
apply_mask (&p);
- /* Route flags */
- if (flag_str) {
- switch(flag_str[0]) {
- case 'r':
- case 'R': /* XXX */
- SET_FLAG (flag, ZEBRA_FLAG_REJECT);
- break;
- case 'b':
- case 'B': /* XXX */
- SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
- break;
- default:
- vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
-
/* Administrative distance. */
if (distance_str)
distance = atoi (distance_str);
@@ -3812,7 +3795,41 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
}
}
- if (ifname)
+ /* Null0 static route. */
+ if ((gate_str != NULL) && (strncasecmp (gate_str, "Null0", strlen (gate_str)) == 0))
+ {
+ if (flag_str)
+ {
+ vty_out (vty, "%% can not have flag %s with Null0%s", flag_str, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ if (add_cmd)
+ static_add_route (AFI_IP6, SAFI_UNICAST, type, &p, NULL, ifindex, ifname,
+ ZEBRA_FLAG_BLACKHOLE, tag, distance, zvrf, &snh_label);
+ else
+ static_delete_route (AFI_IP6, SAFI_UNICAST, type, &p, NULL, ifindex, tag,
+ distance, zvrf, &snh_label);
+ return CMD_SUCCESS;
+ }
+
+ /* Route flags */
+ if (flag_str) {
+ switch(flag_str[0]) {
+ case 'r':
+ case 'R': /* XXX */
+ SET_FLAG (flag, ZEBRA_FLAG_REJECT);
+ break;
+ case 'b':
+ case 'B': /* XXX */
+ SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
+ break;
+ default:
+ vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ }
+
+ if (ifname)
{
/* When ifname is specified. It must be come with gateway
address. */
@@ -3865,24 +3882,26 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
DEFUN (ipv6_route,
ipv6_route_cmd,
- "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
+ "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0)",
IP_STR
"Establish static routes\n"
"IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
"IPv6 gateway address\n"
- "IPv6 gateway interface name\n")
+ "IPv6 gateway interface name\n"
+ "Null interface\n")
{
return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, NULL, NULL, NULL);
}
DEFUN (ipv6_route_tag,
ipv6_route_tag_cmd,
- "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-4294967295>",
+ "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) tag <1-4294967295>",
IP_STR
"Establish static routes\n"
"IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
"IPv6 gateway address\n"
"IPv6 gateway interface name\n"
+ "Null interface\n"
"Set tag for this route\n"
"Tag value\n")
{
@@ -3976,12 +3995,13 @@ DEFUN (ipv6_route_ifname_flags_tag,
DEFUN (ipv6_route_pref,
ipv6_route_pref_cmd,
- "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
+ "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) <1-255>",
IP_STR
"Establish static routes\n"
"IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
"IPv6 gateway address\n"
"IPv6 gateway interface name\n"
+ "Null interface\n"
"Distance value for this prefix\n")
{
return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, argv[2], NULL, NULL);
@@ -3989,12 +4009,13 @@ DEFUN (ipv6_route_pref,
DEFUN (ipv6_route_pref_tag,
ipv6_route_pref_tag_cmd,
- "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-4294967295> <1-255>",
+ "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) tag <1-4294967295> <1-255>",
IP_STR
"Establish static routes\n"
"IPv6 destination prefix (e.g. 3ffe:506::/32)\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")
@@ -4096,26 +4117,28 @@ DEFUN (ipv6_route_ifname_flags_pref_tag,
DEFUN (no_ipv6_route,
no_ipv6_route_cmd,
- "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
+ "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0)",
NO_STR
IP_STR
"Establish static routes\n"
"IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
"IPv6 gateway address\n"
- "IPv6 gateway interface name\n")
+ "IPv6 gateway interface name\n"
+ "Null Interface\n")
{
return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, NULL, NULL, NULL);
}
DEFUN (no_ipv6_route_tag,
no_ipv6_route_tag_cmd,
- "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-4294967295>",
+ "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) tag <1-4294967295>",
NO_STR
IP_STR
"Establish static routes\n"
"IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
"IPv6 gateway address\n"
"IPv6 gateway interface name\n"
+ "Null interface\n"
"Set tag for this route\n"
"Tag value\n")
{
@@ -4216,13 +4239,14 @@ DEFUN (no_ipv6_route_ifname_flags_tag,
DEFUN (no_ipv6_route_pref,
no_ipv6_route_pref_cmd,
- "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
+ "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) <1-255>",
NO_STR
IP_STR
"Establish static routes\n"
"IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
"IPv6 gateway address\n"
"IPv6 gateway interface name\n"
+ "Null interface\n"
"Distance value for this prefix\n")
{
return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, argv[2], NULL, NULL);
@@ -4230,13 +4254,14 @@ DEFUN (no_ipv6_route_pref,
DEFUN (no_ipv6_route_pref_tag,
no_ipv6_route_pref_tag_cmd,
- "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-4294967295> <1-255>",
+ "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) tag <1-4294967295> <1-255>",
NO_STR
IP_STR
"Establish static routes\n"
"IPv6 destination prefix (e.g. 3ffe:506::/32)\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")
@@ -4346,12 +4371,13 @@ DEFUN (no_ipv6_route_ifname_flags_pref_tag,
DEFUN (ipv6_route_vrf,
ipv6_route_vrf_cmd,
- "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) " VRF_CMD_STR,
+ "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) " VRF_CMD_STR,
IP_STR
"Establish static routes\n"
"IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
"IPv6 gateway address\n"
"IPv6 gateway interface name\n"
+ "Null interface\n"
VRF_CMD_HELP_STR)
{
return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, NULL, argv[2], NULL);
@@ -4359,12 +4385,13 @@ DEFUN (ipv6_route_vrf,
DEFUN (ipv6_route_tag_vrf,
ipv6_route_tag_vrf_cmd,
- "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-4294967295> " VRF_CMD_STR,
+ "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) tag <1-4294967295> " VRF_CMD_STR,
IP_STR
"Establish static routes\n"
"IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
"IPv6 gateway address\n"
"IPv6 gateway interface name\n"
+ "Null interface\n"
"Set tag for this route\n"
"Tag value\n"
VRF_CMD_HELP_STR)
@@ -4465,12 +4492,13 @@ DEFUN (ipv6_route_ifname_flags_tag_vrf,
DEFUN (ipv6_route_pref_vrf,
ipv6_route_pref_vrf_cmd,
- "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255> " VRF_CMD_STR,
+ "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) <1-255> " VRF_CMD_STR,
IP_STR
"Establish static routes\n"
"IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
"IPv6 gateway address\n"
"IPv6 gateway interface name\n"
+ "Null interface\n"
"Distance value for this prefix\n"
VRF_CMD_HELP_STR)
{
@@ -4479,12 +4507,13 @@ DEFUN (ipv6_route_pref_vrf,
DEFUN (ipv6_route_pref_tag_vrf,
ipv6_route_pref_tag_vrf_cmd,
- "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-4294967295> <1-255> " VRF_CMD_STR,
+ "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) tag <1-4294967295> <1-255> " VRF_CMD_STR,
IP_STR
"Establish static routes\n"
"IPv6 destination prefix (e.g. 3ffe:506::/32)\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"
@@ -4593,13 +4622,14 @@ DEFUN (ipv6_route_ifname_flags_pref_tag_vrf,
DEFUN (no_ipv6_route_vrf,
no_ipv6_route_vrf_cmd,
- "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) " VRF_CMD_STR,
+ "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) " VRF_CMD_STR,
NO_STR
IP_STR
"Establish static routes\n"
"IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
"IPv6 gateway address\n"
"IPv6 gateway interface name\n"
+ "Null interface\n"
VRF_CMD_HELP_STR)
{
return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, NULL, argv[2], NULL);
@@ -4607,13 +4637,14 @@ DEFUN (no_ipv6_route_vrf,
DEFUN (no_ipv6_route_tag_vrf,
no_ipv6_route_tag_vrf_cmd,
- "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-4294967295> " VRF_CMD_STR,
+ "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) tag <1-4294967295> " VRF_CMD_STR,
NO_STR
IP_STR
"Establish static routes\n"
"IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
"IPv6 gateway address\n"
"IPv6 gateway interface name\n"
+ "Null interface\n"
"Set tag for this route\n"
"Tag value\n"
VRF_CMD_HELP_STR)
@@ -4721,13 +4752,14 @@ DEFUN (no_ipv6_route_ifname_flags_tag_vrf,
DEFUN (no_ipv6_route_pref_vrf,
no_ipv6_route_pref_vrf_cmd,
- "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255> " VRF_CMD_STR,
+ "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) <1-255> " VRF_CMD_STR,
NO_STR
IP_STR
"Establish static routes\n"
"IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
"IPv6 gateway address\n"
"IPv6 gateway interface name\n"
+ "Null interface\n"
"Distance value for this prefix\n"
VRF_CMD_HELP_STR)
{
@@ -4736,13 +4768,14 @@ DEFUN (no_ipv6_route_pref_vrf,
DEFUN (no_ipv6_route_pref_tag_vrf,
no_ipv6_route_pref_tag_vrf_cmd,
- "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-4294967295> <1-255> " VRF_CMD_STR,
+ "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE|null0) tag <1-4294967295> <1-255> " VRF_CMD_STR,
NO_STR
IP_STR
"Establish static routes\n"
"IPv6 destination prefix (e.g. 3ffe:506::/32)\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"
@@ -5759,6 +5792,9 @@ static_config_ipv6 (struct vty *vty)
case STATIC_IFINDEX:
vty_out (vty, " %s", si->ifname);
break;
+ case STATIC_BLACKHOLE:
+ vty_out (vty, " Null0" );
+ break;
case STATIC_IPV6_GATEWAY_IFINDEX:
vty_out (vty, " %s %s",
inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ),
@@ -5766,11 +5802,14 @@ static_config_ipv6 (struct vty *vty)
break;
}
- if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
- vty_out (vty, " %s", "reject");
-
- if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
- vty_out (vty, " %s", "blackhole");
+ /* flags are incompatible with STATIC_BLACKHOLE */
+ if (si->type != STATIC_BLACKHOLE)
+ {
+ if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
+ vty_out (vty, " %s", "reject");
+ if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
+ vty_out (vty, " %s", "blackhole");
+ }
if (si->tag)
vty_out (vty, " tag %"ROUTE_TAG_PRI, si->tag);