Skip to content

Commit

Permalink
zebra: Add ability for dataplane code to understand rule ip protocols
Browse files Browse the repository at this point in the history
The zebra dplane needs to be taught about the rule ip_proto that can
be installed.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
  • Loading branch information
donaldsharp committed Jul 8, 2021
1 parent 8096bd7 commit 8ccbc77
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
6 changes: 4 additions & 2 deletions zebra/rule_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ static ssize_t netlink_rule_msg_encoder(struct zebra_dplane_ctx *ctx, void *buf,
dplane_ctx_rule_get_table(ctx), dplane_ctx_rule_get_src_ip(ctx),
dplane_ctx_rule_get_dst_ip(ctx),
dplane_ctx_rule_get_fwmark(ctx),
dplane_ctx_rule_get_dsfield(ctx), 0, buf, buflen);
dplane_ctx_rule_get_dsfield(ctx),
dplane_ctx_rule_get_ipproto(ctx), buf, buflen);
}

static ssize_t netlink_oldrule_msg_encoder(struct zebra_dplane_ctx *ctx,
Expand All @@ -184,7 +185,8 @@ static ssize_t netlink_oldrule_msg_encoder(struct zebra_dplane_ctx *ctx,
dplane_ctx_rule_get_old_src_ip(ctx),
dplane_ctx_rule_get_old_dst_ip(ctx),
dplane_ctx_rule_get_old_fwmark(ctx),
dplane_ctx_rule_get_old_dsfield(ctx), 0, buf, buflen);
dplane_ctx_rule_get_old_dsfield(ctx),
dplane_ctx_rule_get_old_ipproto(ctx), buf, buflen);
}

/* Public functions */
Expand Down
16 changes: 16 additions & 0 deletions zebra/zebra_dplane.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ struct dplane_ctx_rule {
uint8_t dsfield;
struct prefix src_ip;
struct prefix dst_ip;
uint8_t ip_proto;
char ifname[INTERFACE_NAMSIZ + 1];
};

Expand Down Expand Up @@ -1929,6 +1930,20 @@ uint32_t dplane_ctx_rule_get_old_fwmark(const struct zebra_dplane_ctx *ctx)
return ctx->u.rule.old.fwmark;
}

uint8_t dplane_ctx_rule_get_ipproto(const struct zebra_dplane_ctx *ctx)
{
DPLANE_CTX_VALID(ctx);

return ctx->u.rule.new.ip_proto;
}

uint8_t dplane_ctx_rule_get_old_ipproto(const struct zebra_dplane_ctx *ctx)
{
DPLANE_CTX_VALID(ctx);

return ctx->u.rule.old.ip_proto;
}

uint8_t dplane_ctx_rule_get_dsfield(const struct zebra_dplane_ctx *ctx)
{
DPLANE_CTX_VALID(ctx);
Expand Down Expand Up @@ -2636,6 +2651,7 @@ static void dplane_ctx_rule_init_single(struct dplane_ctx_rule *dplane_rule,
dplane_rule->filter_bm = rule->rule.filter.filter_bm;
dplane_rule->fwmark = rule->rule.filter.fwmark;
dplane_rule->dsfield = rule->rule.filter.dsfield;
dplane_rule->ip_proto = rule->rule.filter.ip_proto;
prefix_copy(&(dplane_rule->dst_ip), &rule->rule.filter.dst_ip);
prefix_copy(&(dplane_rule->src_ip), &rule->rule.filter.src_ip);
strlcpy(dplane_rule->ifname, rule->ifname, INTERFACE_NAMSIZ);
Expand Down
2 changes: 2 additions & 0 deletions zebra/zebra_dplane.h
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,8 @@ uint32_t dplane_ctx_rule_get_fwmark(const struct zebra_dplane_ctx *ctx);
uint32_t dplane_ctx_rule_get_old_fwmark(const struct zebra_dplane_ctx *ctx);
uint8_t dplane_ctx_rule_get_dsfield(const struct zebra_dplane_ctx *ctx);
uint8_t dplane_ctx_rule_get_old_dsfield(const struct zebra_dplane_ctx *ctx);
uint8_t dplane_ctx_rule_get_ipproto(const struct zebra_dplane_ctx *ctx);
uint8_t dplane_ctx_rule_get_old_ipproto(const struct zebra_dplane_ctx *ctx);
const struct prefix *
dplane_ctx_rule_get_src_ip(const struct zebra_dplane_ctx *ctx);
const struct prefix *
Expand Down

0 comments on commit 8ccbc77

Please sign in to comment.