mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-15 03:27:25 +00:00
Merge pull request #9750 from mjstapp/zebra_installed_nhg_id
zebra: add installed nexthop-group id value
This commit is contained in:
commit
4b7d297d4b
@ -108,8 +108,11 @@ struct route_entry {
|
|||||||
struct nexthop_group fib_ng;
|
struct nexthop_group fib_ng;
|
||||||
struct nexthop_group fib_backup_ng;
|
struct nexthop_group fib_backup_ng;
|
||||||
|
|
||||||
/* Nexthop group hash entry ID */
|
/* Nexthop group hash entry IDs. The "installed" id is the id
|
||||||
|
* used in linux/netlink, if available.
|
||||||
|
*/
|
||||||
uint32_t nhe_id;
|
uint32_t nhe_id;
|
||||||
|
uint32_t nhe_installed_id;
|
||||||
|
|
||||||
/* Tag */
|
/* Tag */
|
||||||
route_tag_t tag;
|
route_tag_t tag;
|
||||||
|
@ -2448,6 +2448,8 @@ int dplane_ctx_route_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op,
|
|||||||
ret = ENOENT;
|
ret = ENOENT;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
re->nhe_installed_id = nhe->id;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_NETLINK */
|
#endif /* HAVE_NETLINK */
|
||||||
|
|
||||||
|
@ -305,35 +305,41 @@ static void route_entry_attach_ref(struct route_entry *re,
|
|||||||
{
|
{
|
||||||
re->nhe = new;
|
re->nhe = new;
|
||||||
re->nhe_id = new->id;
|
re->nhe_id = new->id;
|
||||||
|
re->nhe_installed_id = 0;
|
||||||
|
|
||||||
zebra_nhg_increment_ref(new);
|
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,
|
int route_entry_update_nhe(struct route_entry *re,
|
||||||
struct nhg_hash_entry *new_nhghe)
|
struct nhg_hash_entry *new_nhghe)
|
||||||
{
|
{
|
||||||
struct nhg_hash_entry *old;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
struct nhg_hash_entry *old_nhg = NULL;
|
||||||
|
|
||||||
if (new_nhghe == NULL) {
|
if (new_nhghe == NULL) {
|
||||||
if (re->nhe)
|
old_nhg = re->nhe;
|
||||||
zebra_nhg_decrement_ref(re->nhe);
|
|
||||||
|
re->nhe_id = 0;
|
||||||
|
re->nhe_installed_id = 0;
|
||||||
re->nhe = NULL;
|
re->nhe = NULL;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((re->nhe_id != 0) && re->nhe && (re->nhe != new_nhghe)) {
|
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);
|
route_entry_attach_ref(re, new_nhghe);
|
||||||
|
|
||||||
if (old)
|
|
||||||
zebra_nhg_decrement_ref(old);
|
|
||||||
} else if (!re->nhe)
|
} else if (!re->nhe)
|
||||||
/* This is the first time it's being attached */
|
/* This is the first time it's being attached */
|
||||||
route_entry_attach_ref(re, new_nhghe);
|
route_entry_attach_ref(re, new_nhghe);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
/* Detach / deref previous nhg */
|
||||||
|
if (old_nhg)
|
||||||
|
zebra_nhg_decrement_ref(old_nhg);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3093,7 +3099,8 @@ void rib_unlink(struct route_node *rn, struct route_entry *re)
|
|||||||
|
|
||||||
if (re->nhe && re->nhe_id) {
|
if (re->nhe && re->nhe_id) {
|
||||||
assert(re->nhe->id == 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)
|
} else if (re->nhe && re->nhe->nhg.nexthop)
|
||||||
nexthops_free(re->nhe->nhg.nexthop);
|
nexthops_free(re->nhe->nhg.nexthop);
|
||||||
|
|
||||||
|
@ -541,8 +541,14 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,
|
|||||||
|
|
||||||
vty_out(vty, " Last update %s ago\n", buf);
|
vty_out(vty, " Last update %s ago\n", buf);
|
||||||
|
|
||||||
if (show_ng)
|
if (show_ng) {
|
||||||
vty_out(vty, " Nexthop Group ID: %u\n", re->nhe_id);
|
vty_out(vty, " Nexthop Group ID: %u\n", re->nhe_id);
|
||||||
|
if (re->nhe_installed_id != 0
|
||||||
|
&& re->nhe_id != re->nhe_installed_id)
|
||||||
|
vty_out(vty,
|
||||||
|
" Installed Nexthop Group ID: %u\n",
|
||||||
|
re->nhe_installed_id);
|
||||||
|
}
|
||||||
|
|
||||||
for (ALL_NEXTHOPS(re->nhe->nhg, nexthop)) {
|
for (ALL_NEXTHOPS(re->nhe->nhg, nexthop)) {
|
||||||
/* Use helper to format each nexthop */
|
/* Use helper to format each nexthop */
|
||||||
@ -978,6 +984,11 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
|
|||||||
&(re->nhe->nhg)));
|
&(re->nhe->nhg)));
|
||||||
json_object_int_add(json_route, "nexthopGroupId", re->nhe_id);
|
json_object_int_add(json_route, "nexthopGroupId", re->nhe_id);
|
||||||
|
|
||||||
|
if (re->nhe_installed_id != 0)
|
||||||
|
json_object_int_add(json_route,
|
||||||
|
"installedNexthopGroupId",
|
||||||
|
re->nhe_installed_id);
|
||||||
|
|
||||||
json_object_string_add(json_route, "uptime", up_str);
|
json_object_string_add(json_route, "uptime", up_str);
|
||||||
|
|
||||||
for (ALL_NEXTHOPS_PTR(nhg, nexthop)) {
|
for (ALL_NEXTHOPS_PTR(nhg, nexthop)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user