From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH nf-next] netfilter: nft_meta: infer ptktype from IP address from the output path
Date: Tue, 26 Oct 2021 13:25:21 +0200 [thread overview]
Message-ID: <20211026112521.1278472-1-pablo@netfilter.org> (raw)
meta pkttype always says 0 (host) from the output path. The code to
infer the packet type from the IP address is already in place for
loopback traffic, extend it to infer it the packet type from the output,
postrouting and egress path too.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nft_meta.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/net/netfilter/nft_meta.c b/net/netfilter/nft_meta.c
index 516e74635bae..58a87205be8e 100644
--- a/net/netfilter/nft_meta.c
+++ b/net/netfilter/nft_meta.c
@@ -371,7 +371,11 @@ void nft_meta_get_eval(const struct nft_expr *expr,
break;
#endif
case NFT_META_PKTTYPE:
- if (skb->pkt_type != PACKET_LOOPBACK) {
+ if (skb->pkt_type != PACKET_LOOPBACK &&
+ nft_hook(pkt) != NF_INET_LOCAL_OUT &&
+ nft_hook(pkt) != NF_INET_POST_ROUTING &&
+ (nft_pf(pkt) == NFPROTO_NETDEV &&
+ nft_hook(pkt) != NF_NETDEV_EGRESS)) {
nft_reg_store8(dest, skb->pkt_type);
break;
}
--
2.30.2
reply other threads:[~2021-10-26 11:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20211026112521.1278472-1-pablo@netfilter.org \
--to=pablo@netfilter.org \
--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).