netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] xfrm: remove inherited bridge info from skb
@ 2023-01-26 12:56 wolfgang
  2023-01-26 13:55 ` Florian Westphal
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: wolfgang @ 2023-01-26 12:56 UTC (permalink / raw)
  To: steffen.klassert; +Cc: netdev, Wolfgang Nothdurft

From: Wolfgang Nothdurft <wolfgang@linogate.de>

When using a xfrm interface in a bridged setup (the outgoing device is
bridged), the incoming packets in the xfrm interface inherit the bridge
info an confuses the netfilter connection tracking.

brctl show
bridge name     bridge id               STP enabled     interfaces
br_eth1         8000.000c29fe9646       no              eth1

This messes up the connection tracking so that only the outgoing packets
show up and the connections through the xfrm interface are UNREPLIED.
When using stateful netfilter rules, the response packet will be blocked
as state invalid.

telnet 192.168.12.1 7
Trying 192.168.12.1...

conntrack -L
tcp      6 115 SYN_SENT src=192.168.11.1 dst=192.168.12.1 sport=52476
dport=7 packets=2 bytes=104 [UNREPLIED] src=192.168.12.1
dst=192.168.11.1 sport=7 dport=52476 packets=0 bytes=0 mark=0
secctx=system_u:object_r:unlabeled_t:s0 use=1

Chain INPUT (policy DROP 0 packets, 0 bytes)
    2   104 DROP_invalid all -- * * 0.0.0.0/0 0.0.0.0/0  state INVALID

Jan 26 09:28:12 defendo kernel: fw-chk drop [STATE=invalid] IN=ipsec0
OUT= PHYSIN=eth1 MAC= SRC=192.168.12.1 DST=192.168.11.1 LEN=52 TOS=0x00
PREC=0x00 TTL=64 ID=0 DF PROTO=TCP SPT=7 DPT=52476 WINDOW=64240 RES=0x00
ACK SYN URGP=0 MARK=0x1000000

This patch removes the bridge info from the incoming packets on the xfrm
interface, so the packet can be properly assigned to the connection.

Signed-off-by: Wolfgang Nothdurft <wolfgang@linogate.de>
---
 net/xfrm/xfrm_input.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c
index c06e54a10540..e2c43a5c6c4c 100644
--- a/net/xfrm/xfrm_input.c
+++ b/net/xfrm/xfrm_input.c
@@ -541,6 +541,10 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
 		goto lock;
 	}
 
+	/* strip bridge info from skb */
+	if (skb_ext_exist(skb, SKB_EXT_BRIDGE_NF))
+		skb_ext_del(skb, SKB_EXT_BRIDGE_NF);
+
 	family = XFRM_SPI_SKB_CB(skb)->family;
 
 	/* if tunnel is present override skb->mark value with tunnel i_key */
-- 
2.39.1


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

end of thread, other threads:[~2023-01-28 20:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-26 12:56 [PATCH net] xfrm: remove inherited bridge info from skb wolfgang
2023-01-26 13:55 ` Florian Westphal
2023-01-26 15:05   ` Wolfgang Nothdurft
2023-01-28 17:14 ` kernel test robot
2023-01-28 20:30 ` kernel test robot

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