Skip to content

Commit a272eae

Browse files
committed
zebra: Store received NHG from upper level protocol
Upper level protocols are sending down a list of nexthops that a temporary nhg was created to hold it. After route resolution is done, this NHG is thrown away. Let's keep this received NHG as a pointer off the RE. Follow the `installedNexthopGroupId` pattern for display purposes at this point in time. Signed-off-by: Donald Sharp <[email protected]>
1 parent c9de1ae commit a272eae

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

zebra/rib.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ struct route_entry {
8585
*/
8686
struct nhg_hash_entry *nhe;
8787

88+
struct nhg_hash_entry *nhe_received;
89+
8890
/* Nexthop group hash entry IDs. The "installed" id is the id
8991
* used in linux/netlink, if available.
9092
*/

zebra/zebra_rib.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,12 @@ static void route_entry_attach_ref(struct route_entry *re,
474474
zebra_nhg_increment_ref(new);
475475
}
476476

477+
static void route_entry_update_original_nhe(struct route_entry *re, struct nhg_hash_entry *nhe)
478+
{
479+
re->nhe_received = nhe;
480+
zebra_nhg_increment_ref(nhe);
481+
}
482+
477483
/* Replace (if 'new_nhghe') or clear (if that's NULL) an re's nhe. */
478484
int route_entry_update_nhe(struct route_entry *re,
479485
struct nhg_hash_entry *new_nhghe)
@@ -2693,6 +2699,9 @@ static void rib_re_nhg_free(struct route_entry *re)
26932699
nexthops_free(re->nhe->nhg.nexthop);
26942700

26952701
nexthops_free(re->fib_ng.nexthop);
2702+
2703+
if (re->nhe_received)
2704+
zebra_nhg_decrement_ref(re->nhe_received);
26962705
}
26972706

26982707
struct zebra_early_route {
@@ -2803,6 +2812,7 @@ static void process_subq_early_route_add(struct zebra_early_route *ere)
28032812
* if old_id != new_id.
28042813
*/
28052814
route_entry_update_nhe(re, nhe);
2815+
route_entry_update_original_nhe(re, nhe);
28062816

28072817
/* Make it sure prefixlen is applied to the prefix. */
28082818
apply_mask(&ere->p);

zebra/zebra_vty.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,10 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,
477477
vty_out(vty,
478478
" Installed Nexthop Group ID: %u\n",
479479
re->nhe_installed_id);
480+
481+
if (re->nhe_received)
482+
vty_out(vty, " Received Nexthop Group ID: %u\n",
483+
re->nhe_received->id);
480484
}
481485

482486
for (ALL_NEXTHOPS(re->nhe->nhg, nexthop)) {
@@ -589,6 +593,9 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
589593
json_object_int_add(json_route,
590594
"installedNexthopGroupId",
591595
re->nhe_installed_id);
596+
if (re->nhe_received)
597+
json_object_int_add(json_route, "receivedNexthopGroupId",
598+
re->nhe_received->id);
592599

593600
json_object_string_add(json_route, "uptime", up_str);
594601

0 commit comments

Comments
 (0)