From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Cc: Florian Westphal <fw@strlen.de>
Subject: [PATCH nf-next 2/4] netfilter: xt_nat: drop packet earlier
Date: Wed, 2 Oct 2024 17:55:40 +0200 [thread overview]
Message-ID: <20241002155550.15016-3-fw@strlen.de> (raw)
In-Reply-To: <20241002155550.15016-1-fw@strlen.de>
Let net dropmonitor pick up a more specific location rather than the
catchall core.c:nf_hook_slow drop point.
This isn't moved into nf_nat_setup_info() because we do not pass
the skb to it.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
net/netfilter/xt_nat.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/net/netfilter/xt_nat.c b/net/netfilter/xt_nat.c
index d04f7cf6b94d..aaf31bd8381b 100644
--- a/net/netfilter/xt_nat.c
+++ b/net/netfilter/xt_nat.c
@@ -20,6 +20,7 @@ xt_nat_setup_info(struct sk_buff *skb,
{
enum ip_conntrack_info ctinfo;
struct nf_conn *ct;
+ int ret;
ct = nf_ct_get(skb, &ctinfo);
if (WARN_ON(!ct))
@@ -30,7 +31,11 @@ xt_nat_setup_info(struct sk_buff *skb,
(ctinfo == IP_CT_RELATED_REPLY && maniptype == NF_NAT_MANIP_SRC))))
return NF_ACCEPT;
- return nf_nat_setup_info(ct, range, maniptype);
+ ret = nf_nat_setup_info(ct, range, maniptype);
+ if (ret != NF_DROP)
+ return ret;
+
+ return NF_DROP_REASON(skb, SKB_DROP_REASON_NETFILTER_DROP, EPERM);
}
static int xt_nat_checkentry_v0(const struct xt_tgchk_param *par)
--
2.45.2
next prev parent reply other threads:[~2024-10-02 16:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-02 15:55 [PATCH nf-next 0/4] netfilter: use skb_drop_reason in more places Florian Westphal
2024-10-02 15:55 ` [PATCH nf-next 1/4] netfilter: xt_nat: compact nf_nat_setup_info calls Florian Westphal
2024-10-02 15:55 ` Florian Westphal [this message]
2024-10-02 15:55 ` [PATCH nf-next 3/4] netfilter: nf_nat: use skb_drop_reason Florian Westphal
2024-10-02 15:55 ` [PATCH nf-next 4/4] netfilter: nf_tables: " Florian Westphal
2024-10-12 14:09 ` [PATCH nf-next 0/4] netfilter: use skb_drop_reason in more places Pablo Neira Ayuso
2024-10-12 14:42 ` Florian Westphal
2024-10-12 15:42 ` Pablo Neira Ayuso
2024-10-12 15:54 ` Florian Westphal
2024-10-12 16:45 ` Pablo Neira Ayuso
2024-10-12 20:38 ` 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=20241002155550.15016-3-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).