netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: [iptables PATCH v4 11/12] nft: Support parsing lookup expression
Date: Thu, 21 Nov 2019 18:36:46 +0100	[thread overview]
Message-ID: <20191121173647.31488-12-phil@nwl.cc> (raw)
In-Reply-To: <20191121173647.31488-1-phil@nwl.cc>

Add required glue code to support family specific lookup expression
parsers implemented as family_ops callback.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
Changes since v2:
- Remove call to add_nft_among() which is implemented in next patch to
  not temporarily break builds.
---
 iptables/nft-shared.c | 9 +++++++++
 iptables/nft-shared.h | 2 ++
 iptables/nft.c        | 3 ++-
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/iptables/nft-shared.c b/iptables/nft-shared.c
index 19630c1e2990c..78e422781723f 100644
--- a/iptables/nft-shared.c
+++ b/iptables/nft-shared.c
@@ -588,6 +588,13 @@ static void nft_parse_limit(struct nft_xt_ctx *ctx, struct nftnl_expr *e)
 		ctx->h->ops->parse_match(match, ctx->cs);
 }
 
+static void nft_parse_lookup(struct nft_xt_ctx *ctx, struct nft_handle *h,
+			     struct nftnl_expr *e)
+{
+	if (ctx->h->ops->parse_lookup)
+		ctx->h->ops->parse_lookup(ctx, e, NULL);
+}
+
 void nft_rule_to_iptables_command_state(struct nft_handle *h,
 					const struct nftnl_rule *r,
 					struct iptables_command_state *cs)
@@ -628,6 +635,8 @@ void nft_rule_to_iptables_command_state(struct nft_handle *h,
 			nft_parse_target(&ctx, expr);
 		else if (strcmp(name, "limit") == 0)
 			nft_parse_limit(&ctx, expr);
+		else if (strcmp(name, "lookup") == 0)
+			nft_parse_lookup(&ctx, h, expr);
 
 		expr = nftnl_expr_iter_next(iter);
 	}
diff --git a/iptables/nft-shared.h b/iptables/nft-shared.h
index 91762d2ed8a3e..bee99a7dd0c93 100644
--- a/iptables/nft-shared.h
+++ b/iptables/nft-shared.h
@@ -86,6 +86,8 @@ struct nft_family_ops {
 			      void *data);
 	void (*parse_cmp)(struct nft_xt_ctx *ctx, struct nftnl_expr *e,
 			  void *data);
+	void (*parse_lookup)(struct nft_xt_ctx *ctx, struct nftnl_expr *e,
+			     void *data);
 	void (*parse_immediate)(const char *jumpto, bool nft_goto, void *data);
 
 	void (*print_table_header)(const char *tablename);
diff --git a/iptables/nft.c b/iptables/nft.c
index a8e7694f86781..2bc94ff92e294 100644
--- a/iptables/nft.c
+++ b/iptables/nft.c
@@ -3114,7 +3114,8 @@ static const char *supported_exprs[] = {
 	"cmp",
 	"bitwise",
 	"counter",
-	"immediate"
+	"immediate",
+	"lookup",
 };
 
 
-- 
2.24.0


  parent reply	other threads:[~2019-11-21 17:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-21 17:36 [iptables PATCH v4 00/12] Implement among match support Phil Sutter
2019-11-21 17:36 ` [iptables PATCH v4 01/12] nft: family_ops: Pass nft_handle to 'add' callback Phil Sutter
2019-11-21 17:36 ` [iptables PATCH v4 02/12] nft: family_ops: Pass nft_handle to 'rule_find' callback Phil Sutter
2019-11-21 17:36 ` [iptables PATCH v4 03/12] nft: family_ops: Pass nft_handle to 'print_rule' callback Phil Sutter
2019-11-21 17:36 ` [iptables PATCH v4 04/12] nft: family_ops: Pass nft_handle to 'rule_to_cs' callback Phil Sutter
2019-11-21 17:36 ` [iptables PATCH v4 05/12] nft: Keep nft_handle pointer in nft_xt_ctx Phil Sutter
2019-11-21 17:36 ` [iptables PATCH v4 06/12] nft: Eliminate pointless calls to nft_family_ops_lookup() Phil Sutter
2019-11-21 17:36 ` [iptables PATCH v4 07/12] nft: Introduce NFT_CL_SETS cache level Phil Sutter
2019-11-21 17:36 ` [iptables PATCH v4 08/12] nft: Support NFT_COMPAT_SET_ADD Phil Sutter
2019-11-21 17:36 ` [iptables PATCH v4 09/12] nft: Bore up nft_parse_payload() Phil Sutter
2019-11-21 17:36 ` [iptables PATCH v4 10/12] nft: Embed rule's table name in nft_xt_ctx Phil Sutter
2019-11-21 17:36 ` Phil Sutter [this message]
2019-11-21 17:36 ` [iptables PATCH v4 12/12] nft: bridge: Rudimental among extension support Phil Sutter
2019-11-25 20:41 ` [iptables PATCH v4 00/12] Implement among match support Pablo Neira Ayuso

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=20191121173647.31488-12-phil@nwl.cc \
    --to=phil@nwl.cc \
    --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).