]> git.proxmox.com Git - mirror_frr.git/commitdiff
zebra: add fib nhg for backups, revise api
authorMark Stapp <mjs@voltanet.io>
Fri, 22 May 2020 20:36:30 +0000 (16:36 -0400)
committerMark Stapp <mjs@voltanet.io>
Tue, 7 Jul 2020 17:14:01 +0000 (13:14 -0400)
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>
zebra/rib.h
zebra/zebra_dplane.c
zebra/zebra_pw.c
zebra/zebra_rib.c

index a024b6dfaabe8a8eda35c8761eb66e26cbe94e90..ec992974fa5d562e853abf0f26841a5b93613ea5 100644 (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;
index 7e7bf1410cce40b74019e4a3b425f5134235d61a..290abf7b34e952f3073aa99fa9740bef12944ade 100644 (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);
index 8f0c964c18e374b170685fb131b0f78bf10500ec..2328ab650af74e162947e48275db4a1cb6345e5d 100644 (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);
index 31582dcb3d903cc97ca7012396b552b1188764b9..d07542ba669af7a5b244b867fe3d93cb8d4be0c6 100644 (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++;
        }