]> git.puffer.fish Git - matthieu/frr.git/commitdiff
staticd: fix late initialization of blackhole type
authoranlan_cs <anlan_cs@tom.com>
Thu, 8 Jul 2021 09:57:37 +0000 (05:57 -0400)
committermergify-bot <noreply@mergify.io>
Fri, 23 Jul 2021 09:15:28 +0000 (09:15 +0000)
If a static route is added to a not-yet-existing VRF, the blackhole type
is not initialized. Initialization must be done before the VRF existence
check.

Signed-off-by: anlan_cs <anlan_cs@tom.com>
(cherry picked from commit 7ea5c53477164104121550365557afac84df03bd)

staticd/static_routes.c

index cdafc4a76a39abd7bc064f88e44a5abdd7825fb9..58a29ad25b6f379685ae86aee8da40457b3e0569 100644 (file)
@@ -278,6 +278,9 @@ static_add_nexthop(struct route_node *rn, struct static_path *pn, safi_t safi,
        nh->type = type;
        nh->color = color;
 
+       if (nh->type == STATIC_BLACKHOLE)
+               nh->bh_type = STATIC_BLACKHOLE_NULL;
+
        nh->nh_vrf_id = nh_svrf ? nh_svrf->vrf->vrf_id : VRF_UNKNOWN;
        strlcpy(nh->nh_vrfname, nh_vrf, sizeof(nh->nh_vrfname));
 
@@ -325,6 +328,7 @@ static_add_nexthop(struct route_node *rn, struct static_path *pn, safi_t safi,
        switch (nh->type) {
        case STATIC_IPV4_GATEWAY:
        case STATIC_IPV6_GATEWAY:
+       case STATIC_BLACKHOLE:
                break;
        case STATIC_IPV4_GATEWAY_IFNAME:
        case STATIC_IPV6_GATEWAY_IFNAME:
@@ -336,9 +340,6 @@ static_add_nexthop(struct route_node *rn, struct static_path *pn, safi_t safi,
                                "Static Route using %s interface not installed because the interface does not exist in specified vrf",
                                ifname);
 
-               break;
-       case STATIC_BLACKHOLE:
-               nh->bh_type = STATIC_BLACKHOLE_NULL;
                break;
        case STATIC_IFNAME:
                ifp = if_lookup_by_name(ifname, nh->nh_vrf_id);