* [PATCH net] sctp: disable BH before calling udp_tunnel_xmit_skb()
@ 2026-04-12 18:15 Xin Long
2026-04-13 12:39 ` Marcelo Ricardo Leitner
2026-04-14 0:10 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Xin Long @ 2026-04-12 18:15 UTC (permalink / raw)
To: network dev, linux-sctp
Cc: davem, kuba, Eric Dumazet, Paolo Abeni, Simon Horman,
Marcelo Ricardo Leitner, Weiming Shi
udp_tunnel_xmit_skb() / udp_tunnel6_xmit_skb() are expected to run with
BH disabled. After commit 6f1a9140ecda ("add xmit recursion limit to
tunnel xmit functions"), on the path:
udp(6)_tunnel_xmit_skb() -> ip(6)tunnel_xmit()
dev_xmit_recursion_inc()/dec() must stay balanced on the same CPU.
Without local_bh_disable(), the context may move between CPUs, which can
break the inc/dec pairing. This may lead to incorrect recursion level
detection and cause packets to be dropped in ip(6)_tunnel_xmit() or
__dev_queue_xmit().
Fix it by disabling BH around both IPv4 and IPv6 SCTP UDP xmit paths.
In my testing, after enabling the SCTP over UDP:
# ip net exec ha sysctl -w net.sctp.udp_port=9899
# ip net exec ha sysctl -w net.sctp.encap_port=9899
# ip net exec hb sysctl -w net.sctp.udp_port=9899
# ip net exec hb sysctl -w net.sctp.encap_port=9899
# ip net exec ha iperf3 -s
- without this patch:
# ip net exec hb iperf3 -c 192.168.0.1 --sctp
[ 5] 0.00-10.00 sec 37.2 MBytes 31.2 Mbits/sec sender
[ 5] 0.00-10.00 sec 37.1 MBytes 31.1 Mbits/sec receiver
- with this patch:
# ip net exec hb iperf3 -c 192.168.0.1 --sctp
[ 5] 0.00-10.00 sec 3.14 GBytes 2.69 Gbits/sec sender
[ 5] 0.00-10.00 sec 3.14 GBytes 2.69 Gbits/sec receiver
Fixes: 6f1a9140ecda ("add xmit recursion limit to tunnel xmit functions")
Fixes: 046c052b475e ("sctp: enable udp tunneling socks")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
net/sctp/ipv6.c | 2 ++
net/sctp/protocol.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index 53a5c027f8e3..cd15b695607e 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -261,9 +261,11 @@ static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *t)
skb_set_inner_ipproto(skb, IPPROTO_SCTP);
label = ip6_make_flowlabel(sock_net(sk), skb, fl6->flowlabel, true, fl6);
+ local_bh_disable();
udp_tunnel6_xmit_skb(dst, sk, skb, NULL, &fl6->saddr, &fl6->daddr,
tclass, ip6_dst_hoplimit(dst), label,
sctp_sk(sk)->udp_port, t->encap_port, false, 0);
+ local_bh_enable();
return 0;
}
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 828a59b8e7bf..5800e7ee7ea0 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -1070,10 +1070,12 @@ static inline int sctp_v4_xmit(struct sk_buff *skb, struct sctp_transport *t)
skb_reset_inner_mac_header(skb);
skb_reset_inner_transport_header(skb);
skb_set_inner_ipproto(skb, IPPROTO_SCTP);
+ local_bh_disable();
udp_tunnel_xmit_skb(dst_rtable(dst), sk, skb, fl4->saddr,
fl4->daddr, dscp, ip4_dst_hoplimit(dst), df,
sctp_sk(sk)->udp_port, t->encap_port, false, false,
0);
+ local_bh_enable();
return 0;
}
--
2.47.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] sctp: disable BH before calling udp_tunnel_xmit_skb()
2026-04-12 18:15 [PATCH net] sctp: disable BH before calling udp_tunnel_xmit_skb() Xin Long
@ 2026-04-13 12:39 ` Marcelo Ricardo Leitner
2026-04-14 0:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Marcelo Ricardo Leitner @ 2026-04-13 12:39 UTC (permalink / raw)
To: Xin Long
Cc: network dev, linux-sctp, davem, kuba, Eric Dumazet, Paolo Abeni,
Simon Horman, Weiming Shi
On Sun, Apr 12, 2026 at 02:15:27PM -0400, Xin Long wrote:
> udp_tunnel_xmit_skb() / udp_tunnel6_xmit_skb() are expected to run with
> BH disabled. After commit 6f1a9140ecda ("add xmit recursion limit to
> tunnel xmit functions"), on the path:
>
> udp(6)_tunnel_xmit_skb() -> ip(6)tunnel_xmit()
>
> dev_xmit_recursion_inc()/dec() must stay balanced on the same CPU.
>
> Without local_bh_disable(), the context may move between CPUs, which can
> break the inc/dec pairing. This may lead to incorrect recursion level
> detection and cause packets to be dropped in ip(6)_tunnel_xmit() or
> __dev_queue_xmit().
>
> Fix it by disabling BH around both IPv4 and IPv6 SCTP UDP xmit paths.
>
> In my testing, after enabling the SCTP over UDP:
>
> # ip net exec ha sysctl -w net.sctp.udp_port=9899
> # ip net exec ha sysctl -w net.sctp.encap_port=9899
> # ip net exec hb sysctl -w net.sctp.udp_port=9899
> # ip net exec hb sysctl -w net.sctp.encap_port=9899
>
> # ip net exec ha iperf3 -s
>
> - without this patch:
>
> # ip net exec hb iperf3 -c 192.168.0.1 --sctp
> [ 5] 0.00-10.00 sec 37.2 MBytes 31.2 Mbits/sec sender
> [ 5] 0.00-10.00 sec 37.1 MBytes 31.1 Mbits/sec receiver
>
> - with this patch:
>
> # ip net exec hb iperf3 -c 192.168.0.1 --sctp
> [ 5] 0.00-10.00 sec 3.14 GBytes 2.69 Gbits/sec sender
> [ 5] 0.00-10.00 sec 3.14 GBytes 2.69 Gbits/sec receiver
>
> Fixes: 6f1a9140ecda ("add xmit recursion limit to tunnel xmit functions")
> Fixes: 046c052b475e ("sctp: enable udp tunneling socks")
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
Nice catch!
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] sctp: disable BH before calling udp_tunnel_xmit_skb()
2026-04-12 18:15 [PATCH net] sctp: disable BH before calling udp_tunnel_xmit_skb() Xin Long
2026-04-13 12:39 ` Marcelo Ricardo Leitner
@ 2026-04-14 0:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-04-14 0:10 UTC (permalink / raw)
To: Xin Long
Cc: netdev, linux-sctp, davem, kuba, edumazet, pabeni, horms,
marcelo.leitner, bestswngs
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Sun, 12 Apr 2026 14:15:27 -0400 you wrote:
> udp_tunnel_xmit_skb() / udp_tunnel6_xmit_skb() are expected to run with
> BH disabled. After commit 6f1a9140ecda ("add xmit recursion limit to
> tunnel xmit functions"), on the path:
>
> udp(6)_tunnel_xmit_skb() -> ip(6)tunnel_xmit()
>
> dev_xmit_recursion_inc()/dec() must stay balanced on the same CPU.
>
> [...]
Here is the summary with links:
- [net] sctp: disable BH before calling udp_tunnel_xmit_skb()
https://git.kernel.org/netdev/net/c/2cd7e6971fc2
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-14 0:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-12 18:15 [PATCH net] sctp: disable BH before calling udp_tunnel_xmit_skb() Xin Long
2026-04-13 12:39 ` Marcelo Ricardo Leitner
2026-04-14 0:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox