netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH nf] netfilter: nfnetlink_queue: reroute reinjected packets from postrouting
@ 2024-09-12 18:58 Pablo Neira Ayuso
  2024-09-13  6:24 ` Antonio Ojea
  0 siblings, 1 reply; 13+ messages in thread
From: Pablo Neira Ayuso @ 2024-09-12 18:58 UTC (permalink / raw)
  To: netfilter-devel; +Cc: antonio.ojea.garcia

368982cd7d1b ("netfilter: nfnetlink_queue: resolve clash for unconfirmed
conntracks") adjusts NAT again in case that packet loses race to confirm
the conntrack entry.

The reinject path triggers a route lookup again for the output hook, but
not for the postrouting hook where queue to userspace is also possible.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reported-by: Antonio Ojea <antonio.ojea.garcia@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
I tried but I am not managing to make a selftest that runs reliable.
I can reproduce it manually and validate that this works.

./nft_queue -d 1000 helps by introducing a delay of 1000ms in the
userspace queue processing which helps trigger the race more easily,
socat needs to send several packets in the same UDP flow.

@Antonio: Could you try this patch meanwhile there is a testcase for
this.

 net/netfilter/nfnetlink_queue.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index e0716da256bf..aeb354271e85 100644
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -276,7 +276,8 @@ static int nf_ip_reroute(struct sk_buff *skb, const struct nf_queue_entry *entry
 #ifdef CONFIG_INET
 	const struct ip_rt_info *rt_info = nf_queue_entry_reroute(entry);
 
-	if (entry->state.hook == NF_INET_LOCAL_OUT) {
+	if (entry->state.hook == NF_INET_LOCAL_OUT ||
+	    entry->state.hook == NF_INET_POST_ROUTING) {
 		const struct iphdr *iph = ip_hdr(skb);
 
 		if (!(iph->tos == rt_info->tos &&
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-10-07  8:30 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-12 18:58 [PATCH nf] netfilter: nfnetlink_queue: reroute reinjected packets from postrouting Pablo Neira Ayuso
2024-09-13  6:24 ` Antonio Ojea
2024-09-17 22:01   ` Antonio Ojea
2024-09-18  8:30     ` Pablo Neira Ayuso
2024-09-18  8:42       ` Florian Westphal
2024-09-18  9:51         ` Antonio Ojea
2024-09-18  9:54           ` Florian Westphal
2024-09-18 20:53     ` Pablo Neira Ayuso
2024-09-18 21:42       ` Antonio Ojea
2024-09-19 12:02         ` Pablo Neira Ayuso
2024-10-06 14:44           ` Antonio Ojea
2024-10-07  8:14             ` Antonio Ojea
2024-10-07  8:30               ` Pablo Neira Ayuso

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).