diff options
| author | Stephen Worley <sworley@cumulusnetworks.com> | 2019-03-08 10:16:52 -0500 |
|---|---|---|
| committer | Stephen Worley <sworley@cumulusnetworks.com> | 2019-10-25 11:13:37 -0400 |
| commit | 8e7663796904f12ab31320d8d5a056da158483fe (patch) | |
| tree | aa577bbaaf05a53ff5154e88de61b4e6088db53e | |
| parent | 5f3c9e520c71993ca65a9aaafd9db715eda0b2e5 (diff) | |
zebra: Route entries use nexthop entry ID's instead of pointers
Switched the route entries to use ID's instead of pointers.
Perform lookups with the ID and then check if its null.
Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
| -rw-r--r-- | zebra/rib.h | 3 | ||||
| -rw-r--r-- | zebra/zebra_rib.c | 14 |
2 files changed, 12 insertions, 5 deletions
diff --git a/zebra/rib.h b/zebra/rib.h index a95bcc0550..e6d6d87447 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -93,7 +93,8 @@ struct route_entry { /* Nexthop group from FIB (optional) */ struct nexthop_group fib_ng; - struct nhg_hash_entry *nhe; + /* Nexthop group hash entry ID */ + uint32_t nhe_id; /* Tag */ route_tag_t tag; diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 3b3bf921bc..5f942a7ecf 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -2396,7 +2396,7 @@ static void rib_addnode(struct route_node *rn, void rib_unlink(struct route_node *rn, struct route_entry *re) { rib_dest_t *dest; - rib_table_info_t *info; + struct nhg_hash_entry *nhe = NULL; assert(rn && re); @@ -2411,7 +2411,9 @@ void rib_unlink(struct route_node *rn, struct route_entry *re) if (dest->selected_fib == re) dest->selected_fib = NULL; - zebra_nhg_decrement_ref(re->nhe); + nhe = zebra_nhg_lookup_id(re->nhe_id); + if (nhe) + zebra_nhg_decrement_ref(nhe); // TODO: We need to hold on nh's until refcnt is 0 right? nexthops_free(re->ng->nexthop); @@ -2638,6 +2640,7 @@ int rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p, struct route_table *table; struct route_node *rn; struct route_entry *same = NULL; + struct nhg_hash_entry *nhe = NULL; int ret = 0; if (!re) @@ -2659,8 +2662,11 @@ int rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p, if (src_p) apply_mask_ipv6(src_p); - re->nhe = zebra_nhg_find(re->ng, re->vrf_id, 0); - re->nhe->refcnt++; + nhe = zebra_nhg_find(re->ng, re->vrf_id, 0); + + re->nhe_id = nhe->id; + nhe->refcnt++; + /* Set default distance by route type. */ if (re->distance == 0) re->distance = route_distance(re->type); |
