From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Cc: Florian Westphal <fw@strlen.de>
Subject: [PATCH iptables-nft 1/3] nft: support dissection of meta pkktype mode
Date: Thu, 8 Sep 2022 17:12:40 +0200 [thread overview]
Message-ID: <20220908151242.26838-2-fw@strlen.de> (raw)
In-Reply-To: <20220908151242.26838-1-fw@strlen.de>
Makes iptables-nft-save dump 'nft meta pkttype' rules.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
iptables/nft-shared.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/iptables/nft-shared.c b/iptables/nft-shared.c
index 74e19ccad226..79c93fe82c60 100644
--- a/iptables/nft-shared.c
+++ b/iptables/nft-shared.c
@@ -25,6 +25,7 @@
#include <linux/netfilter/xt_limit.h>
#include <linux/netfilter/xt_NFLOG.h>
#include <linux/netfilter/xt_mark.h>
+#include <linux/netfilter/xt_pkttype.h>
#include <libmnl/libmnl.h>
#include <libnftnl/rule.h>
@@ -323,6 +324,27 @@ static int parse_meta_mark(struct nft_xt_ctx *ctx, struct nftnl_expr *e)
return 0;
}
+static int parse_meta_pkttype(struct nft_xt_ctx *ctx, struct nftnl_expr *e)
+{
+ struct xt_pkttype_info *pkttype;
+ struct xtables_match *match;
+ uint8_t value;
+
+ match = nft_create_match(ctx, ctx->cs, "pkttype");
+ if (!match)
+ return -1;
+
+ pkttype = (void*)match->m->data;
+
+ if (nftnl_expr_get_u32(e, NFTNL_EXPR_CMP_OP) == NFT_CMP_NEQ)
+ pkttype->invert = 1;
+
+ value = nftnl_expr_get_u8(e, NFTNL_EXPR_CMP_DATA);
+ pkttype->pkttype = value;
+
+ return 0;
+}
+
int parse_meta(struct nft_xt_ctx *ctx, struct nftnl_expr *e, uint8_t key,
char *iniface, unsigned char *iniface_mask,
char *outiface, unsigned char *outiface_mask, uint8_t *invflags)
@@ -369,6 +391,9 @@ int parse_meta(struct nft_xt_ctx *ctx, struct nftnl_expr *e, uint8_t key,
case NFT_META_MARK:
parse_meta_mark(ctx, e);
break;
+ case NFT_META_PKTTYPE:
+ parse_meta_pkttype(ctx, e);
+ break;
default:
return -1;
}
--
2.35.1
next prev parent reply other threads:[~2022-09-08 15:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-08 15:12 [PATCH iptables-nft 0/3] nft: prefer meta pkttype to libxt_pkttype Florian Westphal
2022-09-08 15:12 ` Florian Westphal [this message]
2022-09-08 15:12 ` [PATCH iptables-nft 2/3] nft: prefer native 'meta pkttype' instead of xt match Florian Westphal
2022-09-08 15:12 ` [PATCH iptables-nft 3/3] extensions: libxt_pkttype: support otherhost Florian Westphal
2022-09-08 15:37 ` [PATCH iptables-nft 0/3] nft: prefer meta pkttype to libxt_pkttype Phil Sutter
2022-09-08 15:56 ` Florian Westphal
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=20220908151242.26838-2-fw@strlen.de \
--to=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 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).