]> git.puffer.fish Git - matthieu/frr.git/commitdiff
staticd: fix nexthop validation
authorIgor Ryzhov <iryzhov@nfware.com>
Wed, 17 Feb 2021 10:06:56 +0000 (13:06 +0300)
committerIgor Ryzhov <iryzhov@nfware.com>
Fri, 26 Feb 2021 11:31:09 +0000 (14:31 +0300)
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>
staticd/static_nb_config.c
staticd/static_routes.c
staticd/static_routes.h

index 2cdf854244c65b9b029668541764e32cf03ac2f5..5b2fe720cb02a3c7753f7bb5acc429f9aa8e35db 100644 (file)
@@ -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))",
index 18a6785616fc0df5c236a1bc69048a47f5a30f71..4237da24bdd25aa7e1f82218cc62717cdd037d9a 100644 (file)
@@ -135,20 +135,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:
index 268af7c00e5a21afea7b58897f182b671d0116f8..a3440a89eb002af1cae17209203af15010bfd5ac 100644 (file)
@@ -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);