From: Guillaume Nault <gnault@redhat.com>
To: Hengyu Liang <hengyul@cs.unc.edu>
Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
jchapman@katalix.com, tparkin@katalix.com
Subject: Re: [PATCH net] l2tp: only return sessions of the given tunnel in l2tp_session_get()
Date: Mon, 26 Oct 2026 17:55:07 +0100 [thread overview]
Message-ID: <at-F69h64Ineg2gp@debian> (raw)
In-Reply-To: <20261026125702.3101778-1-hengyul@cs.unc.edu>
On Mon, Oct 26, 2026 at 08:57:02AM -0400, Hengyu Liang wrote:
> Hi Guillaume,
>
> Thanks for looking at this.
>
> I wasn't sure about the intended semantics. l2tp.rst says "L2TPv3
> session ids are unique across all tunnels", but it also says Linux
> allows the same ID in different tunnels, told apart by sk, and
> l2tp_session_register() still allows that for UDP encap.
My understanding is that L2TPv3 session IDs are unique across their
network namespace. There's an exception for those that are transported
over UDP, as they're now unique for a given UDP socket (the one of
their parent's tunnel).
As a result, looking up a UDP L2TPv3 session requires a socket and a
session ID. That works when demultiplexing an incomming packet, as we
have both information in this case. But that's a problem when selecting
a session from user space.
The correct approach would be to pass both a session ID and a socket
for any L2TPv3 UDP session lookup. But the netlink interface currently
doesn't support passing a socket fd for SESSION_GET, SESSION_MODIFY
and SESSION_DELETE operations. That could be done for managed tunnels
though.
However, for unmanaged tunnels, as used by iproute2, user space doesn't
know anything about the UDP socket. In that case, all we can do is to
replace the socket parameter with a tunnel ID. Then we'd have to loop
through all the sessions that match the requested session ID and return
the one whose tunnel's socket matches the socket of the tunnel ID
passed as parameter. This last operation could maybe be simplified to a
simple tunnel ID check, as, in my understanding, we have an 1:1
relationship between tunnel IDs and their sockets (but I'm a bit wary
of such shortcuts given that code have proved to be brittle in the past).
> The patch only changes callers of l2tp_session_get() that pass a
> tunnel_id, and the result differs from v6.8:
>
> - pppol2tp_connect() for session 5 in tunnel 2 fails with EEXIST if
> tunnel 1 (another UDP socket) already has a connected session 5.
> - "ip l2tp del session tunnel_id 4 session_id 7" deletes tunnel 3's
> session 7 when only tunnel 3 has it. On v6.8 it fails. l2tp.rst
> describes CONN_ID there as the parent tunnel of the session.
> Am I misreading the documentation, is the documentation out of date, or
> is this behaviour not intended?
>
> Thanks,
> Hengyu
>
next prev parent reply other threads:[~2026-10-26 16:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-25 14:58 [PATCH net] l2tp: only return sessions of the given tunnel in l2tp_session_get() Hengyu Liang
2026-10-25 15:01 ` netdev-bot+sinfo
2026-10-26 8:47 ` Hengyu Liang
2026-10-26 11:51 ` Guillaume Nault
2026-10-26 12:57 ` Hengyu Liang
2026-10-26 16:55 ` Guillaume Nault [this message]
2026-10-27 4:32 ` Hengyu Liang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=at-F69h64Ineg2gp@debian \
--to=gnault@redhat.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hengyul@cs.unc.edu \
--cc=horms@kernel.org \
--cc=jchapman@katalix.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tparkin@katalix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox