diff mbox series

[nft,1/6] src: add proto ctx options

Message ID 20210527154323.4003-2-fw@strlen.de
State Changes Requested
Delegated to: Pablo Neira
Headers show
Series nftables: add --optimize support | expand

Commit Message

Florian Westphal May 27, 2021, 3:43 p.m. UTC
Add new option flag member and the needed function signature changes
to initialise it.  No changes in behaviour.

Signed-off-by: Florian Westphal <fw@strlen.de>
---
 include/proto.h           | 6 ++++--
 src/evaluate.c            | 3 ++-
 src/netlink.c             | 2 +-
 src/netlink_delinearize.c | 2 +-
 src/proto.c               | 4 +++-
 5 files changed, 11 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/include/proto.h b/include/proto.h
index b9217588f3e3..001b6f9436f7 100644
--- a/include/proto.h
+++ b/include/proto.h
@@ -171,7 +171,8 @@  extern const struct proto_desc *proto_dev_desc(uint16_t type);
 /**
  * struct proto_ctx - protocol context
  *
- * debug_mask:	display debugging information
+ * @debug_mask:	display debugging information
+ * @options	option flags to control proto decoding
  * @family:	hook family
  * @location:	location of the relational expression defining the context
  * @desc:	protocol description for this layer
@@ -183,6 +184,7 @@  extern const struct proto_desc *proto_dev_desc(uint16_t type);
  */
 struct proto_ctx {
 	unsigned int			debug_mask;
+	uint8_t				options;
 	uint8_t				family;
 	union {
 		struct {
@@ -202,7 +204,7 @@  struct proto_ctx {
 };
 
 extern void proto_ctx_init(struct proto_ctx *ctx, unsigned int family,
-			   unsigned int debug_mask);
+			   unsigned int debug_mask, unsigned int proto_options);
 extern void proto_ctx_update(struct proto_ctx *ctx, enum proto_bases base,
 			     const struct location *loc,
 			     const struct proto_desc *desc);
diff --git a/src/evaluate.c b/src/evaluate.c
index 384e2fa786e0..6bfc464e677a 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -4090,7 +4090,8 @@  static int rule_evaluate(struct eval_ctx *ctx, struct rule *rule,
 	struct stmt *stmt, *tstmt = NULL;
 	struct error_record *erec;
 
-	proto_ctx_init(&ctx->pctx, rule->handle.family, ctx->nft->debug_mask);
+	proto_ctx_init(&ctx->pctx, rule->handle.family, ctx->nft->debug_mask,
+		       0);
 	memset(&ctx->ectx, 0, sizeof(ctx->ectx));
 
 	ctx->rule = rule;
diff --git a/src/netlink.c b/src/netlink.c
index 6b6fe27762d5..a307eb32c136 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -1868,7 +1868,7 @@  static void trace_print_packet(const struct nftnl_trace *nlt,
 				 meta_expr_alloc(&netlink_location,
 						 NFT_META_OIF), octx);
 
-	proto_ctx_init(&ctx, nftnl_trace_get_u32(nlt, NFTNL_TRACE_FAMILY), 0);
+	proto_ctx_init(&ctx, nftnl_trace_get_u32(nlt, NFTNL_TRACE_FAMILY), 0, 0);
 	ll_desc = ctx.protocol[PROTO_BASE_LL_HDR].desc;
 	if ((ll_desc == &proto_inet || ll_desc  == &proto_netdev) &&
 	    nftnl_trace_is_set(nlt, NFTNL_TRACE_NFPROTO)) {
diff --git a/src/netlink_delinearize.c b/src/netlink_delinearize.c
index a71d06d7fe12..6e907e95dbf1 100644
--- a/src/netlink_delinearize.c
+++ b/src/netlink_delinearize.c
@@ -2820,7 +2820,7 @@  static void rule_parse_postprocess(struct netlink_parse_ctx *ctx, struct rule *r
 	struct stmt *stmt, *next;
 
 	memset(&rctx, 0, sizeof(rctx));
-	proto_ctx_init(&rctx.pctx, rule->handle.family, ctx->debug_mask);
+	proto_ctx_init(&rctx.pctx, rule->handle.family, ctx->debug_mask, 0);
 
 	list_for_each_entry_safe(stmt, next, &rule->stmts, list) {
 		enum stmt_types type = stmt->ops->type;
diff --git a/src/proto.c b/src/proto.c
index 63727605a20a..302a51f242ed 100644
--- a/src/proto.c
+++ b/src/proto.c
@@ -169,7 +169,8 @@  static void proto_ctx_debug(const struct proto_ctx *ctx, enum proto_bases base,
  * @debug_mask:	display debugging information
  */
 void proto_ctx_init(struct proto_ctx *ctx, unsigned int family,
-		    unsigned int debug_mask)
+		    unsigned int debug_mask,
+		    unsigned int proto_options)
 {
 	const struct hook_proto_desc *h = &hook_proto_desc[family];
 
@@ -177,6 +178,7 @@  void proto_ctx_init(struct proto_ctx *ctx, unsigned int family,
 	ctx->family = family;
 	ctx->protocol[h->base].desc = h->desc;
 	ctx->debug_mask = debug_mask;
+	ctx->options = proto_options;
 
 	proto_ctx_debug(ctx, h->base, debug_mask);
 }