diff options
author | Igor Ryzhov <iryzhov@nfware.com> | 2021-02-17 11:06:56 +0100 |
---|---|---|
committer | Igor Ryzhov <iryzhov@nfware.com> | 2021-02-17 12:17:25 +0100 |
commit | ddd455157e0a390601ecdfd1db0880ec34974965 (patch) | |
tree | 20bae68b01210967643123018809ce09c2c527d2 | |
parent | Merge pull request #8015 from mjstapp/fix_topo_gen_support (diff) | |
download | frr-ddd455157e0a390601ecdfd1db0880ec34974965.tar.xz frr-ddd455157e0a390601ecdfd1db0880ec34974965.zip |
staticd: fix nexthop validation
When checking for local connected address used as a nexthop gateway, we
should check nexthop VRF, not route VRF.
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
-rw-r--r-- | staticd/static_nb_config.c | 2 | ||||
-rw-r--r-- | staticd/static_routes.c | 12 | ||||
-rw-r--r-- | staticd/static_routes.h | 2 |
3 files changed, 11 insertions, 5 deletions
diff --git a/staticd/static_nb_config.c b/staticd/static_nb_config.c index bf669957b..cbcfea77c 100644 --- a/staticd/static_nb_config.c +++ b/staticd/static_nb_config.c @@ -140,7 +140,7 @@ static bool static_nexthop_create(struct nb_cb_create_args *args, pn = nb_running_get_entry(args->dnode, NULL, true); rn = nb_running_get_entry(rn_dnode, NULL, true); - if (!static_add_nexthop_validate(info->svrf, nh_type, &ipaddr)) + if (!static_add_nexthop_validate(nh_vrf, nh_type, &ipaddr)) flog_warn( EC_LIB_NB_CB_CONFIG_VALIDATE, "Warning!! Local connected address is configured as Gateway IP((%s))", diff --git a/staticd/static_routes.c b/staticd/static_routes.c index 1c436a66b..69d424ef5 100644 --- a/staticd/static_routes.c +++ b/staticd/static_routes.c @@ -138,20 +138,26 @@ void static_del_route(struct route_node *rn, safi_t safi, vrf_reset_user_cfged(svrf->vrf); } -bool static_add_nexthop_validate(struct static_vrf *svrf, static_types type, +bool static_add_nexthop_validate(const char *nh_vrf_name, static_types type, struct ipaddr *ipaddr) { + struct vrf *vrf; + + vrf = vrf_lookup_by_name(nh_vrf_name); + if (!vrf) + return true; + switch (type) { case STATIC_IPV4_GATEWAY: case STATIC_IPV4_GATEWAY_IFNAME: if (if_lookup_exact_address(&ipaddr->ipaddr_v4, AF_INET, - svrf->vrf->vrf_id)) + vrf->vrf_id)) return false; break; case STATIC_IPV6_GATEWAY: case STATIC_IPV6_GATEWAY_IFNAME: if (if_lookup_exact_address(&ipaddr->ipaddr_v6, AF_INET6, - svrf->vrf->vrf_id)) + vrf->vrf_id)) return false; break; default: diff --git a/staticd/static_routes.h b/staticd/static_routes.h index 470afb605..0fbf0674d 100644 --- a/staticd/static_routes.h +++ b/staticd/static_routes.h @@ -192,7 +192,7 @@ extern void static_del_path(struct route_node *rn, struct static_path *pn, safi_t safi, struct static_vrf *svrf); extern void static_get_nh_type(static_types stype, char *type, size_t size); -extern bool static_add_nexthop_validate(struct static_vrf *svrf, +extern bool static_add_nexthop_validate(const char *nh_vrf_name, static_types type, struct ipaddr *ipaddr); extern struct stable_info *static_get_stable_info(struct route_node *rn); |