From: Donald Sharp Date: Tue, 27 Mar 2018 18:50:41 +0000 (-0400) Subject: zebra: Prevent installation for a nexthop vrf that is not configed yet X-Git-Tag: frr-5.0-dev~67^2~1 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=049e899eb29e0d189c2b833be6bd37b15189b457;p=matthieu%2Ffrr.git zebra: Prevent installation for a nexthop vrf that is not configed yet There are many callpaths to get to static_install_route. The nexthops each have their own vrf that may or may not be up yet. If it is allow the installation. Doing this check here to avoid having to add this all over the place. Signed-off-by: Donald Sharp --- diff --git a/zebra/zebra_static.c b/zebra/zebra_static.c index 75d625c6b5..c8e49cb293 100644 --- a/zebra/zebra_static.c +++ b/zebra/zebra_static.c @@ -46,12 +46,26 @@ void static_install_route(afi_t afi, safi_t safi, struct prefix *p, struct prefix nh_p; struct nexthop *nexthop = NULL; enum blackhole_type bh_type = 0; + struct vrf *nh_vrf; /* Lookup table. */ table = zebra_vrf_table(afi, safi, si->vrf_id); if (!table) return; + /* + * If a specific vrf is coming up and the nexthop vrf we are + * looking at using hasn't been brought up yet, just don't + * install the static route yet. + * When the nexthop vrf comes up we will get another call + * back to do the right thing. I'm putting this check + * here because we are calling static_install_route a bunch + * from a bunch of different callpaths. + */ + nh_vrf = vrf_lookup_by_id(si->nh_vrf_id); + if (!nh_vrf) + return; + memset(&nh_p, 0, sizeof(nh_p)); if (si->type == STATIC_BLACKHOLE) { switch (si->bh_type) {