]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: Rearrange dplane_ctx_route_init
authorDonald Sharp <sharpd@nvidia.com>
Mon, 3 Oct 2022 17:22:22 +0000 (13:22 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Mon, 12 Dec 2022 15:44:57 +0000 (10:44 -0500)
In order for a future commit to abstract the dplane_ctx_route_init
so that the kernel can use it, let's move some stuff around
and add a dplane_ctx_route_init_basic that can be used by multiple
different paths

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
create a dplane_ctx_route_init_basic so it can be used

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
zebra/zebra_dplane.c
zebra/zebra_dplane.h

index 1deac4bffe4e40ce3f35819abab0ce99edb98fc5..8e8547120b1a7c88242c4e9c8130a1e7fff1e55f 100644 (file)
@@ -2782,24 +2782,15 @@ static int dplane_ctx_ns_init(struct zebra_dplane_ctx *ctx,
        return AOK;
 }
 
-/*
- * Initialize a context block for a route update from zebra data structs.
- */
-int dplane_ctx_route_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op,
-                         struct route_node *rn, struct route_entry *re)
+int dplane_ctx_route_init_basic(struct zebra_dplane_ctx *ctx,
+                               enum dplane_op_e op, struct route_entry *re,
+                               const struct prefix *p,
+                               const struct prefix *src_p, afi_t afi,
+                               safi_t safi)
 {
        int ret = EINVAL;
-       const struct route_table *table = NULL;
-       const struct rib_table_info *info;
-       const struct prefix *p, *src_p;
-       struct zebra_ns *zns;
-       struct zebra_vrf *zvrf;
-       struct nexthop *nexthop;
-       struct zebra_l3vni *zl3vni;
-       const struct interface *ifp;
-       struct dplane_intf_extra *if_extra;
 
-       if (!ctx || !rn || !re)
+       if (!ctx || !re)
                return ret;
 
        TAILQ_INIT(&ctx->u.rinfo.intf_extra_q);
@@ -2810,9 +2801,6 @@ int dplane_ctx_route_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op,
        ctx->u.rinfo.zd_type = re->type;
        ctx->u.rinfo.zd_old_type = re->type;
 
-       /* Prefixes: dest, and optional source */
-       srcdest_rnode_prefixes(rn, &p, &src_p);
-
        prefix_copy(&(ctx->u.rinfo.zd_dest), p);
 
        if (src_p)
@@ -2833,11 +2821,45 @@ int dplane_ctx_route_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op,
        ctx->u.rinfo.zd_old_tag = re->tag;
        ctx->u.rinfo.zd_distance = re->distance;
 
+       ctx->u.rinfo.zd_afi = afi;
+       ctx->u.rinfo.zd_safi = safi;
+
+       return AOK;
+}
+
+/*
+ * Initialize a context block for a route update from zebra data structs.
+ */
+int dplane_ctx_route_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op,
+                         struct route_node *rn, struct route_entry *re)
+{
+       int ret = EINVAL;
+       const struct route_table *table = NULL;
+       const struct rib_table_info *info;
+       const struct prefix *p, *src_p;
+       struct zebra_ns *zns;
+       struct zebra_vrf *zvrf;
+       struct nexthop *nexthop;
+       struct zebra_l3vni *zl3vni;
+       const struct interface *ifp;
+       struct dplane_intf_extra *if_extra;
+
+       if (!ctx || !rn || !re)
+               return ret;
+
+       /*
+        * Let's grab the data from the route_node
+        * so that we can call a helper function
+        */
+
+       /* Prefixes: dest, and optional source */
+       srcdest_rnode_prefixes(rn, &p, &src_p);
        table = srcdest_rnode_table(rn);
        info = table->info;
 
-       ctx->u.rinfo.zd_afi = info->afi;
-       ctx->u.rinfo.zd_safi = info->safi;
+       if (dplane_ctx_route_init_basic(ctx, op, re, p, src_p, info->afi,
+                                       info->safi) != AOK)
+               return ret;
 
        /* Copy nexthops; recursive info is included too */
        copy_nexthops(&(ctx->u.rinfo.zd_ng.nexthop),
index 60d9205544aef82f92a8ad4422e3fbf0e0642d59..e392861ae0dd442e3c15b2fb7120b9fb7a006f14 100644 (file)
@@ -910,6 +910,12 @@ dplane_pbr_ipset_entry_delete(struct zebra_pbr_ipset_entry *ipset);
 int dplane_ctx_route_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op,
                          struct route_node *rn, struct route_entry *re);
 
+int dplane_ctx_route_init_basic(struct zebra_dplane_ctx *ctx,
+                               enum dplane_op_e op, struct route_entry *re,
+                               const struct prefix *p,
+                               const struct prefix *src_p, afi_t afi,
+                               safi_t safi);
+
 /* Encode next hop information into data plane context. */
 int dplane_ctx_nexthop_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op,
                            struct nhg_hash_entry *nhe);