summaryrefslogtreecommitdiffstats
path: root/staticd
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2021-02-26 16:32:37 +0100
committerIgor Ryzhov <iryzhov@nfware.com>2021-03-03 16:06:42 +0100
commitcd07806b295c157227675a31bf47d3884ecac1b5 (patch)
treee6eb21e5c06c8f1c861242fe66ee591658b443e0 /staticd
parentMerge pull request #8183 from kuldeepkash/multicast_pim_bsm (diff)
downloadfrr-cd07806b295c157227675a31bf47d3884ecac1b5.tar.xz
frr-cd07806b295c157227675a31bf47d3884ecac1b5.zip
staticd: forbid blackhole and non-blackhole nexthops in a single route
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'staticd')
-rw-r--r--staticd/static_nb_config.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/staticd/static_nb_config.c b/staticd/static_nb_config.c
index 3f1d0aa49..db154992f 100644
--- a/staticd/static_nb_config.c
+++ b/staticd/static_nb_config.c
@@ -103,10 +103,32 @@ static void static_path_list_tag_modify(struct nb_cb_modify_args *args,
static_install_path(rn, pn, info->safi, info->svrf);
}
+struct nexthop_iter {
+ int count;
+ bool blackhole;
+};
+
+static int nexthop_iter_cb(const struct lyd_node *dnode, void *arg)
+{
+ struct nexthop_iter *iter = arg;
+ int nh_type;
+
+ nh_type = yang_dnode_get_enum(dnode, "./nh-type");
+
+ if (nh_type == STATIC_BLACKHOLE)
+ iter->blackhole = true;
+
+ iter->count++;
+
+ return YANG_ITER_CONTINUE;
+}
+
static bool static_nexthop_create(struct nb_cb_create_args *args,
const struct lyd_node *rn_dnode,
struct stable_info *info)
{
+ const struct lyd_node *pn_dnode;
+ struct nexthop_iter iter;
struct route_node *rn;
struct static_path *pn;
struct ipaddr ipaddr;
@@ -128,6 +150,20 @@ static bool static_nexthop_create(struct nb_cb_create_args *args,
return NB_ERR_VALIDATION;
}
}
+
+ iter.count = 0;
+ iter.blackhole = false;
+
+ pn_dnode = yang_dnode_get_parent(args->dnode, "path-list");
+ yang_dnode_iterate(nexthop_iter_cb, &iter, pn_dnode,
+ "./frr-nexthops/nexthop");
+
+ if (iter.blackhole && iter.count > 1) {
+ snprintf(
+ args->errmsg, args->errmsg_len,
+ "Route can not have blackhole and non-blackhole nexthops simultaneously");
+ return NB_ERR_VALIDATION;
+ }
break;
case NB_EV_PREPARE:
case NB_EV_ABORT: