mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 10:37:29 +00:00
zebra: add fib nhg for backups, revise api
Add an nhg for the fib-installed backup nexthops; rename an api to access the fib-installed nexthop nhg. Signed-off-by: Mark Stapp <mjs@voltanet.io>
This commit is contained in:
parent
9d43854d94
commit
4db01e7914
18
zebra/rib.h
18
zebra/rib.h
@ -94,9 +94,11 @@ struct route_entry {
|
|||||||
struct nhg_hash_entry *nhe;
|
struct nhg_hash_entry *nhe;
|
||||||
|
|
||||||
/* Nexthop group from FIB (optional), reflecting what is actually
|
/* Nexthop group from FIB (optional), reflecting what is actually
|
||||||
* installed in the FIB if that differs.
|
* installed in the FIB if that differs. The 'backup' group is used
|
||||||
|
* when backup nexthops are present in the route's nhg.
|
||||||
*/
|
*/
|
||||||
struct nexthop_group fib_ng;
|
struct nexthop_group fib_ng;
|
||||||
|
struct nexthop_group fib_backup_ng;
|
||||||
|
|
||||||
/* Nexthop group hash entry ID */
|
/* Nexthop group hash entry ID */
|
||||||
uint32_t nhe_id;
|
uint32_t nhe_id;
|
||||||
@ -526,7 +528,7 @@ DECLARE_HOOK(rib_update, (struct route_node * rn, const char *reason),
|
|||||||
/*
|
/*
|
||||||
* Access active nexthop-group, either RIB or FIB version
|
* Access active nexthop-group, either RIB or FIB version
|
||||||
*/
|
*/
|
||||||
static inline struct nexthop_group *rib_active_nhg(struct route_entry *re)
|
static inline struct nexthop_group *rib_get_fib_nhg(struct route_entry *re)
|
||||||
{
|
{
|
||||||
if (re->fib_ng.nexthop)
|
if (re->fib_ng.nexthop)
|
||||||
return &(re->fib_ng);
|
return &(re->fib_ng);
|
||||||
@ -534,6 +536,18 @@ static inline struct nexthop_group *rib_active_nhg(struct route_entry *re)
|
|||||||
return &(re->nhe->nhg);
|
return &(re->nhe->nhg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Access active nexthop-group, either RIB or FIB version
|
||||||
|
*/
|
||||||
|
static inline struct nexthop_group *rib_get_fib_backup_nhg(
|
||||||
|
struct route_entry *re)
|
||||||
|
{
|
||||||
|
if (re->fib_backup_ng.nexthop)
|
||||||
|
return &(re->fib_backup_ng);
|
||||||
|
else
|
||||||
|
return zebra_nhg_get_backup_nhg(re->nhe);
|
||||||
|
}
|
||||||
|
|
||||||
extern void zebra_vty_init(void);
|
extern void zebra_vty_init(void);
|
||||||
|
|
||||||
extern pid_t pid;
|
extern pid_t pid;
|
||||||
|
@ -2473,7 +2473,7 @@ dplane_route_notif_update(struct route_node *rn,
|
|||||||
new_ctx->u.rinfo.zd_ng.nexthop = NULL;
|
new_ctx->u.rinfo.zd_ng.nexthop = NULL;
|
||||||
|
|
||||||
copy_nexthops(&(new_ctx->u.rinfo.zd_ng.nexthop),
|
copy_nexthops(&(new_ctx->u.rinfo.zd_ng.nexthop),
|
||||||
(rib_active_nhg(re))->nexthop, NULL);
|
(rib_get_fib_nhg(re))->nexthop, NULL);
|
||||||
|
|
||||||
for (ALL_NEXTHOPS(new_ctx->u.rinfo.zd_ng, nexthop))
|
for (ALL_NEXTHOPS(new_ctx->u.rinfo.zd_ng, nexthop))
|
||||||
UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);
|
UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);
|
||||||
|
@ -550,7 +550,7 @@ static void vty_show_mpls_pseudowire_detail(struct vty *vty)
|
|||||||
re = rib_match(family2afi(pw->af), SAFI_UNICAST, pw->vrf_id,
|
re = rib_match(family2afi(pw->af), SAFI_UNICAST, pw->vrf_id,
|
||||||
&pw->nexthop, NULL);
|
&pw->nexthop, NULL);
|
||||||
if (re) {
|
if (re) {
|
||||||
for (ALL_NEXTHOPS_PTR(rib_active_nhg(re), nexthop)) {
|
for (ALL_NEXTHOPS_PTR(rib_get_fib_nhg(re), nexthop)) {
|
||||||
snprintfrr(buf_nh, sizeof(buf_nh), "%pNHv",
|
snprintfrr(buf_nh, sizeof(buf_nh), "%pNHv",
|
||||||
nexthop);
|
nexthop);
|
||||||
vty_out(vty, " Next Hop: %s\n", buf_nh);
|
vty_out(vty, " Next Hop: %s\n", buf_nh);
|
||||||
@ -604,7 +604,7 @@ static void vty_show_mpls_pseudowire(struct zebra_pw *pw, json_object *json_pws)
|
|||||||
re = rib_match(family2afi(pw->af), SAFI_UNICAST, pw->vrf_id,
|
re = rib_match(family2afi(pw->af), SAFI_UNICAST, pw->vrf_id,
|
||||||
&pw->nexthop, NULL);
|
&pw->nexthop, NULL);
|
||||||
if (re) {
|
if (re) {
|
||||||
for (ALL_NEXTHOPS_PTR(rib_active_nhg(re), nexthop)) {
|
for (ALL_NEXTHOPS_PTR(rib_get_fib_nhg(re), nexthop)) {
|
||||||
json_nexthop = json_object_new_object();
|
json_nexthop = json_object_new_object();
|
||||||
snprintfrr(buf_nh, sizeof(buf_nh), "%pNHv", nexthop);
|
snprintfrr(buf_nh, sizeof(buf_nh), "%pNHv", nexthop);
|
||||||
json_object_string_add(json_nexthop, "nexthop", buf_nh);
|
json_object_string_add(json_nexthop, "nexthop", buf_nh);
|
||||||
|
@ -1931,7 +1931,7 @@ static void rib_process_dplane_notify(struct zebra_dplane_ctx *ctx)
|
|||||||
start_count = 0;
|
start_count = 0;
|
||||||
|
|
||||||
if (CHECK_FLAG(re->status, ROUTE_ENTRY_INSTALLED)) {
|
if (CHECK_FLAG(re->status, ROUTE_ENTRY_INSTALLED)) {
|
||||||
for (ALL_NEXTHOPS_PTR(rib_active_nhg(re), nexthop)) {
|
for (ALL_NEXTHOPS_PTR(rib_get_fib_nhg(re), nexthop)) {
|
||||||
if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB))
|
if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB))
|
||||||
start_count++;
|
start_count++;
|
||||||
}
|
}
|
||||||
@ -1956,7 +1956,7 @@ static void rib_process_dplane_notify(struct zebra_dplane_ctx *ctx)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
end_count = 0;
|
end_count = 0;
|
||||||
for (ALL_NEXTHOPS_PTR(rib_active_nhg(re), nexthop)) {
|
for (ALL_NEXTHOPS_PTR(rib_get_fib_nhg(re), nexthop)) {
|
||||||
if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB))
|
if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB))
|
||||||
end_count++;
|
end_count++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user