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:
Mark Stapp 2020-05-22 16:36:30 -04:00
parent 9d43854d94
commit 4db01e7914
4 changed files with 21 additions and 7 deletions

View File

@ -94,9 +94,11 @@ struct route_entry {
struct nhg_hash_entry *nhe;
/* 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_backup_ng;
/* Nexthop group hash entry 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
*/
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)
return &(re->fib_ng);
@ -534,6 +536,18 @@ static inline struct nexthop_group *rib_active_nhg(struct route_entry *re)
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 pid_t pid;

View File

@ -2473,7 +2473,7 @@ dplane_route_notif_update(struct route_node *rn,
new_ctx->u.rinfo.zd_ng.nexthop = NULL;
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))
UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);

View File

@ -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,
&pw->nexthop, NULL);
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",
nexthop);
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,
&pw->nexthop, NULL);
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();
snprintfrr(buf_nh, sizeof(buf_nh), "%pNHv", nexthop);
json_object_string_add(json_nexthop, "nexthop", buf_nh);

View File

@ -1931,7 +1931,7 @@ static void rib_process_dplane_notify(struct zebra_dplane_ctx *ctx)
start_count = 0;
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))
start_count++;
}
@ -1956,7 +1956,7 @@ static void rib_process_dplane_notify(struct zebra_dplane_ctx *ctx)
*/
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))
end_count++;
}