mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-06 14:29:47 +00:00
zebra: Always copy nhg and depends on nhe alloc
Changed our alloc function to just copy the nhg and nhg_depends. This makes the zebra_nhg_find code a little bit cleaner, hopefully preventing bugs. The only issue with this is that it makes us have to loop over the nexthops in a group an extra time for the copies. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
This commit is contained in:
parent
8f8a806fba
commit
2d6cd1f007
@ -2399,12 +2399,13 @@ int netlink_nexthop_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
|
|||||||
/* This is a new nexthop group */
|
/* This is a new nexthop group */
|
||||||
nhe = zebra_nhg_find(nhg, vrf_id, afi, id, nhg_depends,
|
nhe = zebra_nhg_find(nhg, vrf_id, afi, id, nhg_depends,
|
||||||
dep_count);
|
dep_count);
|
||||||
|
zebra_nhg_free_group_depends(nhg, nhg_depends);
|
||||||
|
|
||||||
if (!nhe) {
|
if (!nhe) {
|
||||||
flog_err(
|
flog_err(
|
||||||
EC_ZEBRA_TABLE_LOOKUP_FAILED,
|
EC_ZEBRA_TABLE_LOOKUP_FAILED,
|
||||||
"Zebra failed to find or create a nexthop hash entry for ID (%u) from the kernel",
|
"Zebra failed to find or create a nexthop hash entry for ID (%u) from the kernel",
|
||||||
id);
|
id);
|
||||||
zebra_nhg_free_group_depends(nhg, nhg_depends);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,9 +185,10 @@ static void *zebra_nhg_alloc(void *arg)
|
|||||||
nhe->nhg_depends = NULL;
|
nhe->nhg_depends = NULL;
|
||||||
|
|
||||||
if (copy->nhg_depends)
|
if (copy->nhg_depends)
|
||||||
nhe->nhg_depends = copy->nhg_depends;
|
nhe->nhg_depends = nhg_depend_dup_list(copy->nhg_depends);
|
||||||
|
|
||||||
nhe->nhg = copy->nhg;
|
nhe->nhg = nexthop_group_new();
|
||||||
|
nexthop_group_copy(nhe->nhg, copy->nhg);
|
||||||
|
|
||||||
nhe->vrf_id = copy->vrf_id;
|
nhe->vrf_id = copy->vrf_id;
|
||||||
nhe->afi = copy->afi;
|
nhe->afi = copy->afi;
|
||||||
@ -352,11 +353,8 @@ struct nhg_hash_entry *zebra_nhg_find(struct nexthop_group *nhg,
|
|||||||
else
|
else
|
||||||
nhe = hash_lookup(zrouter.nhgs, &lookup);
|
nhe = hash_lookup(zrouter.nhgs, &lookup);
|
||||||
|
|
||||||
if (!nhe) {
|
if (!nhe)
|
||||||
nhe = hash_get(zrouter.nhgs, &lookup, zebra_nhg_alloc);
|
nhe = hash_get(zrouter.nhgs, &lookup, zebra_nhg_alloc);
|
||||||
} else {
|
|
||||||
zebra_nhg_free_group_depends(nhg, nhg_depends);
|
|
||||||
}
|
|
||||||
|
|
||||||
return nhe;
|
return nhe;
|
||||||
}
|
}
|
||||||
|
@ -2662,6 +2662,7 @@ int rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p,
|
|||||||
|
|
||||||
if (nhe) {
|
if (nhe) {
|
||||||
// TODO: Add interface pointer
|
// TODO: Add interface pointer
|
||||||
|
zebra_nhg_free_group_depends(re->ng, NULL);
|
||||||
re->ng = nhe->nhg;
|
re->ng = nhe->nhg;
|
||||||
re->nhe_id = nhe->id;
|
re->nhe_id = nhe->id;
|
||||||
nhe->refcnt++;
|
nhe->refcnt++;
|
||||||
|
Loading…
Reference in New Issue
Block a user