]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: add init api for dplane lsp context
authorMark Stapp <mjs@voltanet.io>
Tue, 2 Jun 2020 15:04:56 +0000 (11:04 -0400)
committerMark Stapp <mjs@voltanet.io>
Tue, 7 Jul 2020 17:14:01 +0000 (13:14 -0400)
Add an init api (based on what had been a private/static api)
to allow a caller to init a context and use it to generate LSP
updates. This might be useful for testing, or from a dplane
plugin.

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

index 68e068cb6591259fc5760884ae55c18cb143f662..e34b6f23ffeee8e92e210106d8dd6eed65242208 100644 (file)
@@ -1952,18 +1952,12 @@ done:
 /*
  * Capture information for an LSP update in a dplane context.
  */
-static int dplane_ctx_lsp_init(struct zebra_dplane_ctx *ctx,
-                              enum dplane_op_e op,
-                              zebra_lsp_t *lsp)
+int dplane_ctx_lsp_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op,
+                       zebra_lsp_t *lsp)
 {
        int ret = AOK;
        zebra_nhlfe_t *nhlfe, *new_nhlfe;
 
-       if (IS_ZEBRA_DEBUG_DPLANE_DETAIL)
-               zlog_debug("init dplane ctx %s: in-label %u ecmp# %d",
-                          dplane_op2str(op), lsp->ile.in_label,
-                          lsp->num_ecmp);
-
        ctx->zd_op = op;
        ctx->zd_status = ZEBRA_DPLANE_REQUEST_SUCCESS;
 
@@ -1975,6 +1969,20 @@ static int dplane_ctx_lsp_init(struct zebra_dplane_ctx *ctx,
 
        nhlfe_list_init(&(ctx->u.lsp.nhlfe_list));
        nhlfe_list_init(&(ctx->u.lsp.backup_nhlfe_list));
+
+       /* This may be called to create/init a dplane context, not necessarily
+        * to copy an lsp object.
+        */
+       if (lsp == NULL) {
+               ret = AOK;
+               goto done;
+       }
+
+       if (IS_ZEBRA_DEBUG_DPLANE_DETAIL)
+               zlog_debug("init dplane ctx %s: in-label %u ecmp# %d",
+                          dplane_op2str(op), lsp->ile.in_label,
+                          lsp->num_ecmp);
+
        ctx->u.lsp.ile = lsp->ile;
        ctx->u.lsp.addr_family = lsp->addr_family;
        ctx->u.lsp.num_ecmp = lsp->num_ecmp;
index 46d556bfce9c8867df994c22f595a316568628e9..8e873886df42bc61f6da97bbb6d8927b7cc6b7de 100644 (file)
@@ -310,6 +310,14 @@ dplane_ctx_get_nhe_nh_grp(const struct zebra_dplane_ctx *ctx);
 uint8_t dplane_ctx_get_nhe_nh_grp_count(const struct zebra_dplane_ctx *ctx);
 
 /* Accessors for LSP information */
+
+/* Init the internal LSP data struct - necessary before adding to it.
+ * If 'lsp' is non-NULL, info will be copied from it to the internal
+ * context data area.
+ */
+int dplane_ctx_lsp_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op,
+                       zebra_lsp_t *lsp);
+
 mpls_label_t dplane_ctx_get_in_label(const struct zebra_dplane_ctx *ctx);
 void dplane_ctx_set_in_label(struct zebra_dplane_ctx *ctx,
                             mpls_label_t label);