* [PATCH] l2tp: Support different protocol versions with same IP/port quadruple
@ 2024-05-09 20:58 Samuel Thibault
2024-05-09 21:08 ` James Chapman
2024-05-13 23:00 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Samuel Thibault @ 2024-05-09 20:58 UTC (permalink / raw)
To: linux-kernel, tparkin, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
James Chapman
Cc: Samuel Thibault, netdev
628bc3e5a1be ("l2tp: Support several sockets with same IP/port quadruple")
added support for several L2TPv2 tunnels using the same IP/port quadruple,
but if an L2TPv3 socket exists it could eat all the trafic. We thus have to
first use the version from the packet to get the proper tunnel, and only
then check that the version matches.
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
net/l2tp/l2tp_core.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
index 2ab45e3f48bf..7d519a46a844 100644
--- a/net/l2tp/l2tp_core.c
+++ b/net/l2tp/l2tp_core.c
@@ -820,13 +820,8 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb)
/* Get L2TP header flags */
hdrflags = ntohs(*(__be16 *)ptr);
- /* Check protocol version */
+ /* Get protocol version */
version = hdrflags & L2TP_HDR_VER_MASK;
- if (version != tunnel->version) {
- pr_debug_ratelimited("%s: recv protocol version mismatch: got %d expected %d\n",
- tunnel->name, version, tunnel->version);
- goto invalid;
- }
/* Get length of L2TP packet */
length = skb->len;
@@ -838,7 +833,7 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb)
/* Skip flags */
ptr += 2;
- if (tunnel->version == L2TP_HDR_VER_2) {
+ if (version == L2TP_HDR_VER_2) {
/* If length is present, skip it */
if (hdrflags & L2TP_HDRFLAG_L)
ptr += 2;
@@ -855,7 +850,7 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb)
struct l2tp_tunnel *alt_tunnel;
alt_tunnel = l2tp_tunnel_get(tunnel->l2tp_net, tunnel_id);
- if (!alt_tunnel || alt_tunnel->version != L2TP_HDR_VER_2)
+ if (!alt_tunnel)
goto pass;
tunnel = alt_tunnel;
}
@@ -869,6 +864,13 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb)
ptr += 4;
}
+ /* Check protocol version */
+ if (version != tunnel->version) {
+ pr_debug_ratelimited("%s: recv protocol version mismatch: got %d expected %d\n",
+ tunnel->name, version, tunnel->version);
+ goto invalid;
+ }
+
/* Find the session context */
session = l2tp_tunnel_get_session(tunnel, session_id);
if (!session || !session->recv_skb) {
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] l2tp: Support different protocol versions with same IP/port quadruple
2024-05-09 20:58 [PATCH] l2tp: Support different protocol versions with same IP/port quadruple Samuel Thibault
@ 2024-05-09 21:08 ` James Chapman
2024-05-13 23:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: James Chapman @ 2024-05-09 21:08 UTC (permalink / raw)
To: Samuel Thibault, linux-kernel, tparkin, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: netdev
On 09/05/2024 21:58, Samuel Thibault wrote:
> 628bc3e5a1be ("l2tp: Support several sockets with same IP/port quadruple")
> added support for several L2TPv2 tunnels using the same IP/port quadruple,
> but if an L2TPv3 socket exists it could eat all the trafic. We thus have to
> first use the version from the packet to get the proper tunnel, and only
> then check that the version matches.
>
> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
LGTM
Reviewed-by: James Chapman <jchapman@katalix.com>
> ---
> net/l2tp/l2tp_core.c | 18 ++++++++++--------
> 1 file changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
> index 2ab45e3f48bf..7d519a46a844 100644
> --- a/net/l2tp/l2tp_core.c
> +++ b/net/l2tp/l2tp_core.c
> @@ -820,13 +820,8 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb)
> /* Get L2TP header flags */
> hdrflags = ntohs(*(__be16 *)ptr);
>
> - /* Check protocol version */
> + /* Get protocol version */
> version = hdrflags & L2TP_HDR_VER_MASK;
> - if (version != tunnel->version) {
> - pr_debug_ratelimited("%s: recv protocol version mismatch: got %d expected %d\n",
> - tunnel->name, version, tunnel->version);
> - goto invalid;
> - }
>
> /* Get length of L2TP packet */
> length = skb->len;
> @@ -838,7 +833,7 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb)
> /* Skip flags */
> ptr += 2;
>
> - if (tunnel->version == L2TP_HDR_VER_2) {
> + if (version == L2TP_HDR_VER_2) {
> /* If length is present, skip it */
> if (hdrflags & L2TP_HDRFLAG_L)
> ptr += 2;
> @@ -855,7 +850,7 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb)
> struct l2tp_tunnel *alt_tunnel;
>
> alt_tunnel = l2tp_tunnel_get(tunnel->l2tp_net, tunnel_id);
> - if (!alt_tunnel || alt_tunnel->version != L2TP_HDR_VER_2)
> + if (!alt_tunnel)
> goto pass;
> tunnel = alt_tunnel;
> }
> @@ -869,6 +864,13 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb)
> ptr += 4;
> }
>
> + /* Check protocol version */
> + if (version != tunnel->version) {
> + pr_debug_ratelimited("%s: recv protocol version mismatch: got %d expected %d\n",
> + tunnel->name, version, tunnel->version);
> + goto invalid;
> + }
> +
> /* Find the session context */
> session = l2tp_tunnel_get_session(tunnel, session_id);
> if (!session || !session->recv_skb) {
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] l2tp: Support different protocol versions with same IP/port quadruple
2024-05-09 20:58 [PATCH] l2tp: Support different protocol versions with same IP/port quadruple Samuel Thibault
2024-05-09 21:08 ` James Chapman
@ 2024-05-13 23:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-05-13 23:00 UTC (permalink / raw)
To: Samuel Thibault
Cc: linux-kernel, tparkin, edumazet, kuba, pabeni, jchapman, netdev
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 9 May 2024 22:58:12 +0200 you wrote:
> 628bc3e5a1be ("l2tp: Support several sockets with same IP/port quadruple")
> added support for several L2TPv2 tunnels using the same IP/port quadruple,
> but if an L2TPv3 socket exists it could eat all the trafic. We thus have to
> first use the version from the packet to get the proper tunnel, and only
> then check that the version matches.
>
> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
>
> [...]
Here is the summary with links:
- l2tp: Support different protocol versions with same IP/port quadruple
https://git.kernel.org/netdev/net-next/c/364798056f51
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:[~2024-05-13 23:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-09 20:58 [PATCH] l2tp: Support different protocol versions with same IP/port quadruple Samuel Thibault
2024-05-09 21:08 ` James Chapman
2024-05-13 23:00 ` 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