All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH nf] netfilter: nft_tproxy: make it terminal
@ 2024-09-13 10:20 Pablo Neira Ayuso
  2024-09-13 10:23 ` Florian Westphal
  0 siblings, 1 reply; 14+ messages in thread
From: Pablo Neira Ayuso @ 2024-09-13 10:20 UTC (permalink / raw)
  To: netfilter-devel; +Cc: antonio.ojea.garcia, phil

tproxy action must be terminal since the intent of the user to steal the
traffic and redirect to the port.

Align this behaviour to iptables to make it easier to migrate by issuing
NF_ACCEPT for packets that are redirect to userspace process socket.
Otherwise, NF_DROP packet if socket transparent flag is not set on.

Fixes: 4ed8eb6570a4 ("netfilter: nf_tables: Add native tproxy support")
Reported-by: Antonio Ojea <antonio.ojea.garcia@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/nft_tproxy.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/net/netfilter/nft_tproxy.c b/net/netfilter/nft_tproxy.c
index 71412adb73d4..f3b563c379d8 100644
--- a/net/netfilter/nft_tproxy.c
+++ b/net/netfilter/nft_tproxy.c
@@ -74,10 +74,13 @@ static void nft_tproxy_eval_v4(const struct nft_expr *expr,
 					   skb->dev, NF_TPROXY_LOOKUP_LISTENER);
 	}
 
-	if (sk && nf_tproxy_sk_is_transparent(sk))
+	if (sk && nf_tproxy_sk_is_transparent(sk)) {
 		nf_tproxy_assign_sock(skb, sk);
-	else
-		regs->verdict.code = NFT_BREAK;
+		regs->verdict.code = NF_ACCEPT;
+		return;
+	}
+
+	regs->verdict.code = NF_DROP;
 }
 
 #if IS_ENABLED(CONFIG_NF_TABLES_IPV6)
@@ -147,10 +150,13 @@ static void nft_tproxy_eval_v6(const struct nft_expr *expr,
 	}
 
 	/* NOTE: assign_sock consumes our sk reference */
-	if (sk && nf_tproxy_sk_is_transparent(sk))
+	if (sk && nf_tproxy_sk_is_transparent(sk)) {
 		nf_tproxy_assign_sock(skb, sk);
-	else
-		regs->verdict.code = NFT_BREAK;
+		regs->verdict.code = NF_ACCEPT;
+		return;
+	}
+
+	regs->verdict.code = NF_DROP;
 }
 #endif
 
-- 
2.30.2


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

end of thread, other threads:[~2024-09-16 10:37 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-13 10:20 [PATCH nf] netfilter: nft_tproxy: make it terminal Pablo Neira Ayuso
2024-09-13 10:23 ` Florian Westphal
2024-09-13 10:28   ` Pablo Neira Ayuso
2024-09-13 10:29     ` Pablo Neira Ayuso
2024-09-13 10:41     ` Florian Westphal
2024-09-13 10:47       ` Pablo Neira Ayuso
2024-09-13 11:02         ` Antonio Ojea
2024-09-13 11:24           ` Pablo Neira Ayuso
2024-09-13 12:00             ` Phil Sutter
2024-09-13 12:36               ` Pablo Neira Ayuso
2024-09-13 14:18                 ` Florian Westphal
2024-09-13 15:38                   ` Antonio Ojea
2024-09-13 20:35                     ` Phil Sutter
2024-09-16 10:37                       ` Antonio Ojea

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.