All of lore.kernel.org
 help / color / mirror / Atom feed
From: Manuel Messner <mm@skelett.io>
To: netfilter-devel@vger.kernel.org
Cc: Florian Westphal <fw@strlen.de>, mm@skelett.io
Subject: [PATCH nftables 5/7] payload: insert implicit meta tcp dependency when matching tcp options
Date: Tue,  7 Feb 2017 03:14:13 +0100	[thread overview]
Message-ID: <20170207021415.22460-6-mm@skelett.io> (raw)
In-Reply-To: <20170207021415.22460-1-mm@skelett.io>

From: Florian Westphal <fw@strlen.de>

nft add rule inet filter input tcp option sack 4 left 1
<cmdline>:1:28-49: Error: Cannot generate dependency: no network layer protocol specified

Users can avoid this via 'meta l4proto tcp', this enables implicit
dependency injection for the inet/bridge/netdev families.

Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Manuel Messner <mm@skelett.io>
Signed-off-by: Manuel Messner <mm@skelett.io>
---
 src/payload.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/payload.c b/src/payload.c
index efd1960..0207296 100644
--- a/src/payload.c
+++ b/src/payload.c
@@ -323,12 +323,26 @@ int exthdr_gen_dependency(struct eval_ctx *ctx, const struct expr *expr,
 	const struct proto_desc *desc;
 
 	desc = ctx->pctx.protocol[pb].desc;
-	if (desc == NULL)
+	if (desc == NULL) {
+		if (expr->exthdr.op == NFT_EXTHDR_OP_TCPOPT) {
+			switch (ctx->pctx.family) {
+			case NFPROTO_NETDEV:
+			case NFPROTO_BRIDGE:
+			case NFPROTO_INET:
+				desc = &proto_inet_service;
+				goto found;
+			default:
+				break;
+			}
+		}
+
 		return expr_error(ctx->msgs, expr,
 				  "Cannot generate dependency: "
 				  "no %s protocol specified",
 				  proto_base_names[pb]);
+	}
 
+ found:
 	return payload_add_dependency(ctx, desc, dependency, expr, res);
 }
 
-- 
2.11.1


  parent reply	other threads:[~2017-02-07  2:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-07  2:14 [PATCH nftables 0/7] TCP option matching Manuel Messner
2017-02-07  2:14 ` [PATCH nftables 1/7] include: linux: netfilter: nf_tables: copy file from nf-next Manuel Messner
2017-02-07  2:14 ` [PATCH nftables 2/7] exthdr: prepare for tcp support Manuel Messner
2017-02-07  2:14 ` [PATCH nftables 3/7] exthdr: prepare exthdr_gen_dependency " Manuel Messner
2017-02-07  2:14 ` [PATCH nftables 4/7] src: add TCP option matching Manuel Messner
2017-02-07  2:14 ` Manuel Messner [this message]
2017-02-07  2:14 ` [PATCH nftables 6/7] payload: automatically kill dependencies for exthdr and tcpopt Manuel Messner
2017-02-07  2:14 ` [PATCH nftables 7/7] tests: py: Add basic tests for ip, ip6 and inet Manuel Messner
2017-02-08  9:32 ` [PATCH nftables 0/7] TCP option matching 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=20170207021415.22460-6-mm@skelett.io \
    --to=mm@skelett.io \
    --cc=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.