summaryrefslogtreecommitdiff
path: root/staticd/static_vty.c
diff options
context:
space:
mode:
Diffstat (limited to 'staticd/static_vty.c')
-rw-r--r--staticd/static_vty.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/staticd/static_vty.c b/staticd/static_vty.c
index d5fd0e3a2e..16e4cb7d83 100644
--- a/staticd/static_vty.c
+++ b/staticd/static_vty.c
@@ -58,6 +58,8 @@ struct static_route_args {
bool bfd_multi_hop;
const char *bfd_source;
const char *bfd_profile;
+
+ const char *input;
};
static int static_route_nb_run(struct vty *vty, struct static_route_args *args)
@@ -145,9 +147,20 @@ static int static_route_nb_run(struct vty *vty, struct static_route_args *args)
else
buf_gate_str = "";
- if (args->gateway == NULL && args->interface_name == NULL)
+ if (args->gateway == NULL && args->interface_name == NULL) {
type = STATIC_BLACKHOLE;
- else if (args->gateway && args->interface_name) {
+ /* If this is blackhole/reject flagged route, then
+ * specify interface_name with the value of what was really
+ * entered.
+ * interface_name will be validated later in NB functions
+ * to check if we don't create blackhole/reject routes that
+ * match the real interface names.
+ * E.g.: `ip route 10.0.0.1/32 bla` will create a blackhole
+ * route despite the real interface named `bla` exists.
+ */
+ if (args->input)
+ args->interface_name = args->input;
+ } else if (args->gateway && args->interface_name) {
if (args->afi == AFI_IP)
type = STATIC_IPV4_GATEWAY_IFNAME;
else
@@ -499,6 +512,8 @@ DEFPY_YANG(ip_route_blackhole,
"Table to configure\n"
"The table number to configure\n")
{
+ int idx_flag = 0;
+
struct static_route_args args = {
.delete = !!no,
.afi = AFI_IP,
@@ -513,6 +528,9 @@ DEFPY_YANG(ip_route_blackhole,
.vrf = vrf,
};
+ if (flag && argv_find(argv, argc, flag, &idx_flag))
+ args.input = argv[idx_flag]->arg;
+
return static_route_nb_run(vty, &args);
}
@@ -541,6 +559,8 @@ DEFPY_YANG(ip_route_blackhole_vrf,
"Table to configure\n"
"The table number to configure\n")
{
+ int idx_flag = 0;
+
struct static_route_args args = {
.delete = !!no,
.afi = AFI_IP,
@@ -562,6 +582,9 @@ DEFPY_YANG(ip_route_blackhole_vrf,
*/
assert(args.prefix);
+ if (flag && argv_find(argv, argc, flag, &idx_flag))
+ args.input = argv[idx_flag]->arg;
+
return static_route_nb_run(vty, &args);
}
@@ -852,6 +875,8 @@ DEFPY_YANG(ipv6_route_blackhole,
"Table to configure\n"
"The table number to configure\n")
{
+ int idx_flag = 0;
+
struct static_route_args args = {
.delete = !!no,
.afi = AFI_IP6,
@@ -866,6 +891,9 @@ DEFPY_YANG(ipv6_route_blackhole,
.vrf = vrf,
};
+ if (flag && argv_find(argv, argc, flag, &idx_flag))
+ args.input = argv[idx_flag]->arg;
+
return static_route_nb_run(vty, &args);
}
@@ -894,6 +922,8 @@ DEFPY_YANG(ipv6_route_blackhole_vrf,
"Table to configure\n"
"The table number to configure\n")
{
+ int idx_flag = 0;
+
struct static_route_args args = {
.delete = !!no,
.afi = AFI_IP6,
@@ -915,6 +945,9 @@ DEFPY_YANG(ipv6_route_blackhole_vrf,
*/
assert(args.prefix);
+ if (flag && argv_find(argv, argc, flag, &idx_flag))
+ args.input = argv[idx_flag]->arg;
+
return static_route_nb_run(vty, &args);
}