netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: pablo@netfilter.org
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH 01/12] expr: replace PAYLOAD_PROTOCOL_EXPR by generic flag
Date: Wed,  8 Jan 2014 13:08:52 +0000	[thread overview]
Message-ID: <1389186543-6919-2-git-send-email-kaber@trash.net> (raw)
In-Reply-To: <1389186543-6919-1-git-send-email-kaber@trash.net>

Introduce a generic flag to indicate that an expression describes the
upper layer protocol as replacement for the payload specific flag.

Signed-off-by: Patrick McHardy <kaber@trash.net>
---
 include/expression.h      | 5 +++--
 include/payload.h         | 9 ---------
 src/netlink_delinearize.c | 2 +-
 src/payload.c             | 9 +++++----
 4 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/include/expression.h b/include/expression.h
index f0eb799..d8f2868 100644
--- a/include/expression.h
+++ b/include/expression.h
@@ -135,12 +135,14 @@ struct expr_ops {
  *
  * @EXPR_F_CONSTANT:		constant expression
  * @EXPR_F_SINGLETON:		singleton (implies primary and constant)
+ * @EXPR_F_PROTOCOL:		expressions describes upper layer protocol
  * @EXPR_F_INTERVAL_END:	set member ends an open interval
  */
 enum expr_flags {
 	EXPR_F_CONSTANT		= 0x1,
 	EXPR_F_SINGLETON	= 0x2,
-	EXPR_F_INTERVAL_END	= 0x4,
+	EXPR_F_PROTOCOL		= 0x4,
+	EXPR_F_INTERVAL_END	= 0x8,
 };
 
 #include <payload.h>
@@ -227,7 +229,6 @@ struct expr {
 			const struct payload_template	*tmpl;
 			enum payload_bases		base;
 			unsigned int			offset;
-			unsigned int			flags;
 		} payload;
 		struct {
 			/* EXPR_EXTHDR */
diff --git a/include/payload.h b/include/payload.h
index c9cc84f..fa8d82e 100644
--- a/include/payload.h
+++ b/include/payload.h
@@ -21,15 +21,6 @@ enum payload_bases {
 #define PAYLOAD_BASE_MAX	(__PAYLOAD_BASE_MAX - 1)
 
 /**
- * enum payload_expr_flags
- *
- * @PAYLOAD_PROTOCOL_EXPR:	payload expression contains upper layer protocol
- */
-enum payload_expr_flags {
-	PAYLOAD_PROTOCOL_EXPR		= 0x1,
-};
-
-/**
  * struct payload_template - template for a payload header expression
  *
  * @token:	parser token describing the header field
diff --git a/src/netlink_delinearize.c b/src/netlink_delinearize.c
index b771da5..8545273 100644
--- a/src/netlink_delinearize.c
+++ b/src/netlink_delinearize.c
@@ -622,7 +622,7 @@ static void payload_match_postprocess(struct rule_pp_ctx *ctx,
 			 * payload expression.
 			 */
 			if (ctx->pbase == PAYLOAD_BASE_INVALID &&
-			    left->payload.flags & PAYLOAD_PROTOCOL_EXPR) {
+			    left->flags & EXPR_F_PROTOCOL) {
 				ctx->pbase = left->payload.base;
 				ctx->pdep  = nstmt;
 			} else
diff --git a/src/payload.c b/src/payload.c
index ea0d4e2..2a60a76 100644
--- a/src/payload.c
+++ b/src/payload.c
@@ -69,7 +69,6 @@ static void payload_expr_clone(struct expr *new, const struct expr *expr)
 	new->payload.tmpl   = expr->payload.tmpl;
 	new->payload.base   = expr->payload.base;
 	new->payload.offset = expr->payload.offset;
-	new->payload.flags  = expr->payload.flags;
 }
 
 static const struct expr_ops payload_expr_ops = {
@@ -92,7 +91,7 @@ struct expr *payload_expr_alloc(const struct location *loc,
 		tmpl = &desc->templates[type];
 		base = desc->base;
 		if (type == desc->protocol_key)
-			flags = PAYLOAD_PROTOCOL_EXPR;
+			flags = EXPR_F_PROTOCOL;
 	} else {
 		tmpl = &payload_unknown_template;
 		base = PAYLOAD_BASE_INVALID;
@@ -100,11 +99,13 @@ struct expr *payload_expr_alloc(const struct location *loc,
 
 	expr = expr_alloc(loc, &payload_expr_ops, tmpl->dtype,
 			  tmpl->dtype->byteorder, tmpl->len);
+	expr->flags |= flags;
+
 	expr->payload.desc   = desc;
 	expr->payload.tmpl   = tmpl;
 	expr->payload.base   = base;
 	expr->payload.offset = tmpl->offset;
-	expr->payload.flags  = flags;
+
 	return expr;
 }
 
@@ -256,7 +257,7 @@ void payload_ctx_update(struct payload_ctx *ctx, const struct expr *expr)
 	const struct expr *left = expr->left, *right = expr->right;
 	const struct payload_desc *base, *desc;
 
-	if (!(left->payload.flags & PAYLOAD_PROTOCOL_EXPR))
+	if (!(left->flags & EXPR_F_PROTOCOL))
 		return;
 
 	assert(expr->op == OP_EQ);
-- 
1.8.4.2


  reply	other threads:[~2014-01-08 13:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-08 13:08 [PATCH 00/12] nftables: generic protocol contexts, "inet" family Patrick McHardy
2014-01-08 13:08 ` Patrick McHardy [this message]
2014-01-08 13:08 ` [PATCH 02/12] nftables: generic procotol contexts Patrick McHardy
2014-01-08 13:08 ` [PATCH 03/12] expr: add protocol context update callback Patrick McHardy
2014-01-08 13:08 ` [PATCH 04/12] proto: add helper function to update protocol context Patrick McHardy
2014-01-08 13:08 ` [PATCH 05/12] proto: add debugging for protocol context updates Patrick McHardy
2014-01-08 13:08 ` [PATCH 06/12] ct expr: protocol context updates and dynamic typing Patrick McHardy
2014-01-08 13:08 ` [PATCH 07/12] include: resync nftables.h with kernel Patrick McHardy
2014-01-08 13:08 ` [PATCH 08/12] nftables: add support for the "inet" family Patrick McHardy
2014-01-08 13:09 ` [PATCH 09/12] netlink_delinearize: remove implied meta expressions Patrick McHardy
2014-01-09 21:48   ` Arturo Borrero Gonzalez
2014-01-09 22:01     ` Patrick McHardy
2014-01-08 13:09 ` [PATCH 10/12] proto: add support for meta templates Patrick McHardy
2014-01-08 13:09 ` [PATCH 11/12] meta: add nfproto support Patrick McHardy
2014-01-08 13:09 ` [PATCH 12/12] meta: add l4proto support Patrick McHardy
  -- strict thread matches above, loose matches on Subject: below --
2014-01-06 17:27 [RFC PATCH 00/12] nftables: generic protocol contexts, "inet" family support Patrick McHardy
2014-01-06 17:27 ` [PATCH 01/12] expr: replace PAYLOAD_PROTOCOL_EXPR by generic flag Patrick McHardy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1389186543-6919-2-git-send-email-kaber@trash.net \
    --to=kaber@trash.net \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).