diff options
| author | Mark Stapp <mstapp@nvidia.com> | 2021-10-05 15:32:23 -0400 |
|---|---|---|
| committer | Mark Stapp <mstapp@nvidia.com> | 2021-11-23 11:23:26 -0500 |
| commit | 002930f7bb68850dbff4e4d71b54ca7814f4cb86 (patch) | |
| tree | 36a4c303ae2a33b31a00f16f7ae5190ab103022b /zebra/zebra_rib.c | |
| parent | 6e5532187f9e11d10f364fdac9f8e4efb16ff9be (diff) | |
zebra: add installed nexthop-group id value
In some cases, zebra may install a nexthop-group id that is
different from the id of the nhe struct attached to a
route-entry. This happens for a singleton recursive nexthop,
for example, where a route is installed with the resolving
nexthop's id.
The installed value is the most useful value - that corresponds
to information in the kernel on linux/netlink platforms that
support nhgs. Display both values if they differ in ascii
output, and include both values in the json form.
Signed-off-by: Mark Stapp <mstapp@nvidia.com>
Diffstat (limited to 'zebra/zebra_rib.c')
| -rw-r--r-- | zebra/zebra_rib.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 3df70a3b56..625c966301 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -305,35 +305,41 @@ static void route_entry_attach_ref(struct route_entry *re, { re->nhe = new; re->nhe_id = new->id; + re->nhe_installed_id = 0; zebra_nhg_increment_ref(new); } +/* Replace (if 'new_nhghe') or clear (if that's NULL) an re's nhe. */ int route_entry_update_nhe(struct route_entry *re, struct nhg_hash_entry *new_nhghe) { - struct nhg_hash_entry *old; int ret = 0; + struct nhg_hash_entry *old_nhg = NULL; if (new_nhghe == NULL) { - if (re->nhe) - zebra_nhg_decrement_ref(re->nhe); + old_nhg = re->nhe; + + re->nhe_id = 0; + re->nhe_installed_id = 0; re->nhe = NULL; goto done; } if ((re->nhe_id != 0) && re->nhe && (re->nhe != new_nhghe)) { - old = re->nhe; + /* Capture previous nhg, if any */ + old_nhg = re->nhe; route_entry_attach_ref(re, new_nhghe); - - if (old) - zebra_nhg_decrement_ref(old); } else if (!re->nhe) /* This is the first time it's being attached */ route_entry_attach_ref(re, new_nhghe); done: + /* Detach / deref previous nhg */ + if (old_nhg) + zebra_nhg_decrement_ref(old_nhg); + return ret; } @@ -3093,7 +3099,8 @@ void rib_unlink(struct route_node *rn, struct route_entry *re) if (re->nhe && re->nhe_id) { assert(re->nhe->id == re->nhe_id); - zebra_nhg_decrement_ref(re->nhe); + + route_entry_update_nhe(re, NULL); } else if (re->nhe && re->nhe->nhg.nexthop) nexthops_free(re->nhe->nhg.nexthop); |
