Skip to content

Commit f935122

Browse files
committed
zebra: Rearrange dplane_ctx_route_init
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>
1 parent 10388e9 commit f935122

File tree

2 files changed

+48
-20
lines changed

2 files changed

+48
-20
lines changed

zebra/zebra_dplane.c

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2782,24 +2782,15 @@ static int dplane_ctx_ns_init(struct zebra_dplane_ctx *ctx,
27822782
return AOK;
27832783
}
27842784

2785-
/*
2786-
* Initialize a context block for a route update from zebra data structs.
2787-
*/
2788-
int dplane_ctx_route_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op,
2789-
struct route_node *rn, struct route_entry *re)
2785+
int dplane_ctx_route_init_basic(struct zebra_dplane_ctx *ctx,
2786+
enum dplane_op_e op, struct route_entry *re,
2787+
const struct prefix *p,
2788+
const struct prefix *src_p, afi_t afi,
2789+
safi_t safi)
27902790
{
27912791
int ret = EINVAL;
2792-
const struct route_table *table = NULL;
2793-
const struct rib_table_info *info;
2794-
const struct prefix *p, *src_p;
2795-
struct zebra_ns *zns;
2796-
struct zebra_vrf *zvrf;
2797-
struct nexthop *nexthop;
2798-
struct zebra_l3vni *zl3vni;
2799-
const struct interface *ifp;
2800-
struct dplane_intf_extra *if_extra;
28012792

2802-
if (!ctx || !rn || !re)
2793+
if (!ctx || !re)
28032794
return ret;
28042795

28052796
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,
28102801
ctx->u.rinfo.zd_type = re->type;
28112802
ctx->u.rinfo.zd_old_type = re->type;
28122803

2813-
/* Prefixes: dest, and optional source */
2814-
srcdest_rnode_prefixes(rn, &p, &src_p);
2815-
28162804
prefix_copy(&(ctx->u.rinfo.zd_dest), p);
28172805

28182806
if (src_p)
@@ -2833,11 +2821,45 @@ int dplane_ctx_route_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op,
28332821
ctx->u.rinfo.zd_old_tag = re->tag;
28342822
ctx->u.rinfo.zd_distance = re->distance;
28352823

2824+
ctx->u.rinfo.zd_afi = afi;
2825+
ctx->u.rinfo.zd_safi = safi;
2826+
2827+
return AOK;
2828+
}
2829+
2830+
/*
2831+
* Initialize a context block for a route update from zebra data structs.
2832+
*/
2833+
int dplane_ctx_route_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op,
2834+
struct route_node *rn, struct route_entry *re)
2835+
{
2836+
int ret = EINVAL;
2837+
const struct route_table *table = NULL;
2838+
const struct rib_table_info *info;
2839+
const struct prefix *p, *src_p;
2840+
struct zebra_ns *zns;
2841+
struct zebra_vrf *zvrf;
2842+
struct nexthop *nexthop;
2843+
struct zebra_l3vni *zl3vni;
2844+
const struct interface *ifp;
2845+
struct dplane_intf_extra *if_extra;
2846+
2847+
if (!ctx || !rn || !re)
2848+
return ret;
2849+
2850+
/*
2851+
* Let's grab the data from the route_node
2852+
* so that we can call a helper function
2853+
*/
2854+
2855+
/* Prefixes: dest, and optional source */
2856+
srcdest_rnode_prefixes(rn, &p, &src_p);
28362857
table = srcdest_rnode_table(rn);
28372858
info = table->info;
28382859

2839-
ctx->u.rinfo.zd_afi = info->afi;
2840-
ctx->u.rinfo.zd_safi = info->safi;
2860+
if (dplane_ctx_route_init_basic(ctx, op, re, p, src_p, info->afi,
2861+
info->safi) != AOK)
2862+
return ret;
28412863

28422864
/* Copy nexthops; recursive info is included too */
28432865
copy_nexthops(&(ctx->u.rinfo.zd_ng.nexthop),

zebra/zebra_dplane.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,12 @@ dplane_pbr_ipset_entry_delete(struct zebra_pbr_ipset_entry *ipset);
910910
int dplane_ctx_route_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op,
911911
struct route_node *rn, struct route_entry *re);
912912

913+
int dplane_ctx_route_init_basic(struct zebra_dplane_ctx *ctx,
914+
enum dplane_op_e op, struct route_entry *re,
915+
const struct prefix *p,
916+
const struct prefix *src_p, afi_t afi,
917+
safi_t safi);
918+
913919
/* Encode next hop information into data plane context. */
914920
int dplane_ctx_nexthop_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op,
915921
struct nhg_hash_entry *nhe);

0 commit comments

Comments
 (0)