]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: add dplane backup nhg api
authorMark Stapp <mjs@voltanet.io>
Sat, 9 May 2020 20:05:02 +0000 (16:05 -0400)
committerMark Stapp <mjs@voltanet.io>
Tue, 7 Jul 2020 17:14:01 +0000 (13:14 -0400)
Add an api to allow a dplane plugin to set a route's backup
nexthops.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
zebra/zebra_dplane.c
zebra/zebra_dplane.h

index 64383fc81ccf92cd76ef993384592cc94b85e0a1..7e7bf1410cce40b74019e4a3b425f5134235d61a 100644 (file)
@@ -1149,6 +1149,37 @@ void dplane_ctx_set_nexthops(struct zebra_dplane_ctx *ctx, struct nexthop *nh)
        nexthop_group_copy_nh_sorted(&(ctx->u.rinfo.zd_ng), nh);
 }
 
+/*
+ * Set the list of backup nexthops; their ordering is preserved (they're not
+ * re-sorted.)
+ */
+void dplane_ctx_set_backup_nhg(struct zebra_dplane_ctx *ctx,
+                              const struct nexthop_group *nhg)
+{
+       struct nexthop *nh, *last_nh, *nexthop;
+
+       DPLANE_CTX_VALID(ctx);
+
+       if (ctx->u.rinfo.backup_ng.nexthop) {
+               nexthops_free(ctx->u.rinfo.backup_ng.nexthop);
+               ctx->u.rinfo.backup_ng.nexthop = NULL;
+       }
+
+       last_nh = NULL;
+
+       /* Be careful to preserve the order of the backup list */
+       for (nh = nhg->nexthop; nh; nh = nh->next) {
+               nexthop = nexthop_dup(nh, NULL);
+
+               if (last_nh)
+                       NEXTHOP_APPEND(last_nh, nexthop);
+               else
+                       ctx->u.rinfo.backup_ng.nexthop = nexthop;
+
+               last_nh = nexthop;
+       }
+}
+
 uint32_t dplane_ctx_get_nhg_id(const struct zebra_dplane_ctx *ctx)
 {
        DPLANE_CTX_VALID(ctx);
index 9e07231fea55a9772bedf6cc2b4ebb97bb0c22c9..2c3501a5b1c209c667fd32d63d6bcb73ce2a24bb 100644 (file)
@@ -283,6 +283,8 @@ void dplane_ctx_set_distance(struct zebra_dplane_ctx *ctx, uint8_t distance);
 uint8_t dplane_ctx_get_old_distance(const struct zebra_dplane_ctx *ctx);
 
 void dplane_ctx_set_nexthops(struct zebra_dplane_ctx *ctx, struct nexthop *nh);
+void dplane_ctx_set_backup_nhg(struct zebra_dplane_ctx *ctx,
+                              const struct nexthop_group *nhg);
 
 uint32_t dplane_ctx_get_nhg_id(const struct zebra_dplane_ctx *ctx);
 const struct nexthop_group *dplane_ctx_get_ng(