staticd: Fix crash with NULL si

Move the call to the static_install_route to inside
of the loop, since we have changed the behavior of
how we send down routes to zebra a bit.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2018-06-29 11:09:01 -04:00
parent 8bc8de2c15
commit 0b70cb101c

View File

@ -296,12 +296,12 @@ static void static_ifindex_update_af(struct interface *ifp, bool up, afi_t afi,
continue; continue;
si->ifindex = IFINDEX_INTERNAL; si->ifindex = IFINDEX_INTERNAL;
} }
}
static_install_route(rn, si, safi); static_install_route(rn, si, safi);
} }
} }
} }
}
/* /*
* This function looks at a svrf's stable and notices if any of the * This function looks at a svrf's stable and notices if any of the
@ -321,16 +321,13 @@ static void static_fixup_vrf(struct static_vrf *svrf,
struct route_node *rn; struct route_node *rn;
struct static_route *si; struct static_route *si;
struct interface *ifp; struct interface *ifp;
bool install;
for (rn = route_top(stable); rn; rn = route_next(rn)) { for (rn = route_top(stable); rn; rn = route_next(rn)) {
install = false;
for (si = rn->info; si; si = si->next) { for (si = rn->info; si; si = si->next) {
if (strcmp(svrf->vrf->name, si->nh_vrfname) != 0) if (strcmp(svrf->vrf->name, si->nh_vrfname) != 0)
continue; continue;
si->nh_vrf_id = svrf->vrf->vrf_id; si->nh_vrf_id = svrf->vrf->vrf_id;
install = true;
if (si->ifindex) { if (si->ifindex) {
ifp = if_lookup_by_name(si->ifname, ifp = if_lookup_by_name(si->ifname,
si->nh_vrf_id); si->nh_vrf_id);
@ -339,12 +336,11 @@ static void static_fixup_vrf(struct static_vrf *svrf,
else else
continue; continue;
} }
}
if (install)
static_install_route(rn, si, safi); static_install_route(rn, si, safi);
} }
} }
}
/* /*
* This function enables static routes in a svrf as it * This function enables static routes in a svrf as it
@ -363,10 +359,8 @@ static void static_enable_vrf(struct static_vrf *svrf,
struct static_route *si; struct static_route *si;
struct interface *ifp; struct interface *ifp;
struct vrf *vrf = svrf->vrf; struct vrf *vrf = svrf->vrf;
bool install;
for (rn = route_top(stable); rn; rn = route_next(rn)) { for (rn = route_top(stable); rn; rn = route_next(rn)) {
install = false;
for (si = rn->info; si; si = si->next) { for (si = rn->info; si; si = si->next) {
si->vrf_id = vrf->vrf_id; si->vrf_id = vrf->vrf_id;
if (si->ifindex) { if (si->ifindex) {
@ -377,13 +371,10 @@ static void static_enable_vrf(struct static_vrf *svrf,
else else
continue; continue;
} }
install = true;
}
if (install)
static_install_route(rn, si, safi); static_install_route(rn, si, safi);
} }
} }
}
/* /*
* When a vrf is being enabled by the kernel, go through all the * When a vrf is being enabled by the kernel, go through all the