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.c207
1 files changed, 110 insertions, 97 deletions
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index 9f887e8401..95ba19b1f6 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -74,7 +74,7 @@ static int zebra_static_route(struct vty *vty, afi_t afi, safi_t safi,
union g_addr gate;
union g_addr *gatep = NULL;
struct in_addr mask;
- u_char flag = 0;
+ enum blackhole_type bh_type = 0;
route_tag_t tag = 0;
struct zebra_vrf *zvrf;
u_char type;
@@ -165,28 +165,18 @@ static int zebra_static_route(struct vty *vty, afi_t afi, safi_t safi,
}
}
- /* Null0 static route. */
- if ((ifname != NULL)
- && (strncasecmp(ifname, "Null0", strlen(ifname)) == 0)) {
- if (flag_str) {
- vty_out(vty, "%% can not have flag %s with Null0\n",
- flag_str);
- return CMD_WARNING_CONFIG_FAILED;
- }
- SET_FLAG(flag, ZEBRA_FLAG_BLACKHOLE);
- ifname = NULL;
- }
-
/* Route flags */
if (flag_str) {
switch (flag_str[0]) {
case 'r':
case 'R': /* XXX */
- SET_FLAG(flag, ZEBRA_FLAG_REJECT);
+ bh_type = BLACKHOLE_REJECT;
break;
+ case 'n':
+ case 'N' /* XXX */:
case 'b':
case 'B': /* XXX */
- SET_FLAG(flag, ZEBRA_FLAG_BLACKHOLE);
+ bh_type = BLACKHOLE_NULL;
break;
default:
vty_out(vty, "%% Malformed flag %s \n", flag_str);
@@ -221,7 +211,7 @@ static int zebra_static_route(struct vty *vty, afi_t afi, safi_t safi,
if (!negate)
static_add_route(afi, safi, type, &p, src_p, gatep, ifname,
- flag, tag, distance, zvrf, &snh_label);
+ bh_type, tag, distance, zvrf, &snh_label);
else
static_delete_route(afi, safi, type, &p, src_p, gatep, ifname,
tag, distance, zvrf, &snh_label);
@@ -340,14 +330,12 @@ DEFUN (show_ip_rpf_addr,
}
/* Static route configuration. */
-DEFPY (ip_route,
- ip_route_cmd,
- "[no] ip route\
+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}\
- |null0$ifname\
- |<reject|blackhole>$flag\
+ |<null0|reject|blackhole>$flag\
>\
[{\
tag (1-4294967295)\
@@ -355,22 +343,21 @@ DEFPY (ip_route,
|vrf NAME\
|label WORD\
}]",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IP destination prefix (e.g. 10.0.0.0/8)\n"
- "IP destination prefix\n"
- "IP destination prefix mask\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Emit an ICMP unreachable when matched\n"
- "Silently discard pkts when matched\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this route\n"
- VRF_CMD_HELP_STR
- MPLS_LABEL_HELPSTR)
+ NO_STR IP_STR
+ "Establish static routes\n"
+ "IP destination prefix (e.g. 10.0.0.0/8)\n"
+ "IP destination prefix\n"
+ "IP destination prefix mask\n"
+ "IP gateway address\n"
+ "IP gateway interface name\n"
+ "Null interface\n"
+ "Emit an ICMP unreachable when matched\n"
+ "Silently discard pkts when matched\n"
+ "Set tag for this route\n"
+ "Tag value\n"
+ "Distance value for this route\n"
+ VRF_CMD_HELP_STR
+ MPLS_LABEL_HELPSTR)
{
return zebra_static_route(vty, AFI_IP, SAFI_UNICAST, no, prefix,
mask_str, NULL, gate_str, ifname, flag,
@@ -415,12 +402,6 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,
}
if (CHECK_FLAG(re->flags, ZEBRA_FLAG_SELECTED))
vty_out(vty, ", best");
- if (re->refcnt)
- vty_out(vty, ", refcnt %ld", re->refcnt);
- if (CHECK_FLAG(re->flags, ZEBRA_FLAG_BLACKHOLE))
- vty_out(vty, ", blackhole");
- if (CHECK_FLAG(re->flags, ZEBRA_FLAG_REJECT))
- vty_out(vty, ", reject");
vty_out(vty, "\n");
if (re->type == ZEBRA_ROUTE_RIP || re->type == ZEBRA_ROUTE_OSPF
@@ -485,7 +466,21 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,
re->vrf_id));
break;
case NEXTHOP_TYPE_BLACKHOLE:
- vty_out(vty, " directly connected, Null0");
+ vty_out(vty, " unreachable");
+ switch (nexthop->bh_type) {
+ case BLACKHOLE_REJECT:
+ vty_out(vty, " (ICMP unreachable)");
+ break;
+ case BLACKHOLE_ADMINPROHIB:
+ vty_out(vty,
+ " (ICMP admin-prohibited)");
+ break;
+ case BLACKHOLE_NULL:
+ vty_out(vty, " (blackhole)");
+ break;
+ case BLACKHOLE_UNSPEC:
+ break;
+ }
break;
default:
break;
@@ -580,12 +575,6 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
json_object_int_add(json_route, "metric", re->metric);
}
- if (CHECK_FLAG(re->flags, ZEBRA_FLAG_BLACKHOLE))
- json_object_boolean_true_add(json_route, "blackhole");
-
- if (CHECK_FLAG(re->flags, ZEBRA_FLAG_REJECT))
- json_object_boolean_true_add(json_route, "reject");
-
if (re->type == ZEBRA_ROUTE_RIP || re->type == ZEBRA_ROUTE_OSPF
|| re->type == ZEBRA_ROUTE_ISIS
|| re->type == ZEBRA_ROUTE_NHRP
@@ -671,7 +660,24 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
break;
case NEXTHOP_TYPE_BLACKHOLE:
json_object_boolean_true_add(json_nexthop,
- "blackhole");
+ "unreachable");
+ switch (nexthop->bh_type) {
+ case BLACKHOLE_REJECT:
+ json_object_boolean_true_add(
+ json_nexthop, "reject");
+ break;
+ case BLACKHOLE_ADMINPROHIB:
+ json_object_boolean_true_add(
+ json_nexthop,
+ "admin-prohibited");
+ break;
+ case BLACKHOLE_NULL:
+ json_object_boolean_true_add(
+ json_nexthop, "blackhole");
+ break;
+ case BLACKHOLE_UNSPEC:
+ break;
+ }
break;
default:
break;
@@ -796,7 +802,20 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
ifindex2ifname(nexthop->ifindex, re->vrf_id));
break;
case NEXTHOP_TYPE_BLACKHOLE:
- vty_out(vty, " is directly connected, Null0");
+ vty_out(vty, " unreachable");
+ switch (nexthop->bh_type) {
+ case BLACKHOLE_REJECT:
+ vty_out(vty, " (ICMP unreachable)");
+ break;
+ case BLACKHOLE_ADMINPROHIB:
+ vty_out(vty, " (ICMP admin-prohibited)");
+ break;
+ case BLACKHOLE_NULL:
+ vty_out(vty, " (blackhole)");
+ break;
+ case BLACKHOLE_UNSPEC:
+ break;
+ }
break;
default:
break;
@@ -839,11 +858,6 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
sizeof buf, 1));
}
- if (CHECK_FLAG(re->flags, ZEBRA_FLAG_BLACKHOLE))
- vty_out(vty, ", bh");
- if (CHECK_FLAG(re->flags, ZEBRA_FLAG_REJECT))
- vty_out(vty, ", rej");
-
if (re->type == ZEBRA_ROUTE_RIP || re->type == ZEBRA_ROUTE_OSPF
|| re->type == ZEBRA_ROUTE_ISIS
|| re->type == ZEBRA_ROUTE_NHRP
@@ -1181,7 +1195,10 @@ DEFUN (show_ip_route,
tag = strtoul(argv[idx + 1]->arg, NULL, 10);
else if (argv_find(argv, argc, "A.B.C.D/M", &idx)) {
- str2prefix(argv[idx]->arg, &p);
+ if (str2prefix(argv[idx]->arg, &p) <= 0) {
+ vty_out(vty, "%% Malformed prefix\n");
+ return CMD_WARNING;
+ }
longer_prefixes = true;
}
@@ -1693,12 +1710,15 @@ static int static_config(struct vty *vty, afi_t afi, safi_t safi,
case STATIC_IFNAME:
vty_out(vty, " %s", si->ifname);
break;
- /* blackhole and Null0 mean the same thing */
case STATIC_BLACKHOLE:
- if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
+ switch (si->bh_type) {
+ case BLACKHOLE_REJECT:
vty_out(vty, " reject");
- else
- vty_out(vty, " Null0");
+ break;
+ default:
+ vty_out(vty, " blackhole");
+ break;
+ }
break;
case STATIC_IPV4_GATEWAY_IFNAME:
vty_out(vty, " %s %s",
@@ -1716,19 +1736,6 @@ static int static_config(struct vty *vty, afi_t afi, safi_t safi,
break;
}
- /* 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);
@@ -1758,13 +1765,12 @@ static int static_config(struct vty *vty, afi_t afi, safi_t safi,
return write;
}
-DEFPY (ipv6_route,
- ipv6_route_cmd,
- "[no] ipv6 route X:X::X:X/M$prefix [from X:X::X:X/M]\
+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}\
- |null0$ifname\
- |<reject|blackhole>$flag\
+ |<null0|reject|blackhole>$flag\
>\
[{\
tag (1-4294967295)\
@@ -1772,22 +1778,22 @@ DEFPY (ipv6_route,
|vrf NAME\
|label WORD\
}]",
- NO_STR
- IPV6_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 source-dest route\n"
- "IPv6 source prefix\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Null interface\n"
- "Emit an ICMP unreachable when matched\n"
- "Silently discard pkts when matched\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this prefix\n"
- VRF_CMD_HELP_STR
- MPLS_LABEL_HELPSTR)
+ NO_STR
+ IPV6_STR
+ "Establish static routes\n"
+ "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
+ "IPv6 source-dest route\n"
+ "IPv6 source prefix\n"
+ "IPv6 gateway address\n"
+ "IPv6 gateway interface name\n"
+ "Null interface\n"
+ "Emit an ICMP unreachable when matched\n"
+ "Silently discard pkts when matched\n"
+ "Set tag for this route\n"
+ "Tag value\n"
+ "Distance value for this prefix\n"
+ VRF_CMD_HELP_STR
+ MPLS_LABEL_HELPSTR)
{
return zebra_static_route(vty, AFI_IP6, SAFI_UNICAST, no, prefix_str,
NULL, from_str, gate_str, ifname, flag,
@@ -1834,7 +1840,10 @@ DEFUN (show_ipv6_route,
tag = strtoul(argv[idx + 1]->arg, NULL, 10);
else if (argv_find(argv, argc, "X:X::X:X/M", &idx)) {
- str2prefix(argv[idx]->arg, &p);
+ if (str2prefix(argv[idx]->arg, &p) <= 0) {
+ vty_out(vty, "%% Malformed prefix\n");
+ return CMD_WARNING;
+ }
longer_prefixes = true;
}
@@ -2572,6 +2581,8 @@ DEFUN (ip_zebra_import_table_distance,
vty_out(vty,
"Invalid routing table ID, %d. Must be in range 1-252\n",
table_id);
+ if (rmap)
+ XFREE(MTYPE_ROUTE_MAP_NAME, rmap);
return CMD_WARNING;
}
@@ -2579,6 +2590,8 @@ DEFUN (ip_zebra_import_table_distance,
vty_out(vty,
"Invalid routing table ID, %d. Must be non-default table\n",
table_id);
+ if (rmap)
+ XFREE(MTYPE_ROUTE_MAP_NAME, rmap);
return CMD_WARNING;
}