Skip to content

Commit 969afb4

Browse files
committed
Merge branch 'l2tp-misc-improvements'
James Chapman says: ==================== l2tp: misc improvements This series makes several improvements to l2tp: * update documentation to be consistent with recent l2tp changes. * move l2tp_ip socket tables to per-net data. * fix handling of hash key collisions in l2tp_v3_session_get * implement and use get-next APIs for management and procfs/debugfs. * improve l2tp refcount helpers. * use per-cpu dev->tstats in l2tpeth devices. * fix a lockdep splat. * fix a race between l2tp_pre_exit_net and pppol2tp_release. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents bbfeba2 + c1b2e36 commit 969afb4

File tree

9 files changed

+437
-251
lines changed

9 files changed

+437
-251
lines changed

Documentation/networking/l2tp.rst

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -638,9 +638,8 @@ Tunnels are identified by a unique tunnel id. The id is 16-bit for
638638
L2TPv2 and 32-bit for L2TPv3. Internally, the id is stored as a 32-bit
639639
value.
640640

641-
Tunnels are kept in a per-net list, indexed by tunnel id. The tunnel
642-
id namespace is shared by L2TPv2 and L2TPv3. The tunnel context can be
643-
derived from the socket's sk_user_data.
641+
Tunnels are kept in a per-net list, indexed by tunnel id. The
642+
tunnel id namespace is shared by L2TPv2 and L2TPv3.
644643

645644
Handling tunnel socket close is perhaps the most tricky part of the
646645
L2TP implementation. If userspace closes a tunnel socket, the L2TP
@@ -652,9 +651,7 @@ socket's encap_destroy handler is invoked, which L2TP uses to initiate
652651
its tunnel close actions. For L2TPIP sockets, the socket's close
653652
handler initiates the same tunnel close actions. All sessions are
654653
first closed. Each session drops its tunnel ref. When the tunnel ref
655-
reaches zero, the tunnel puts its socket ref. When the socket is
656-
eventually destroyed, its sk_destruct finally frees the L2TP tunnel
657-
context.
654+
reaches zero, the tunnel drops its socket ref.
658655

659656
Sessions
660657
--------
@@ -667,10 +664,7 @@ pseudowire) or other data types such as PPP, ATM, HDLC or Frame
667664
Relay. Linux currently implements only Ethernet and PPP session types.
668665

669666
Some L2TP session types also have a socket (PPP pseudowires) while
670-
others do not (Ethernet pseudowires). We can't therefore use the
671-
socket reference count as the reference count for session
672-
contexts. The L2TP implementation therefore has its own internal
673-
reference counts on the session contexts.
667+
others do not (Ethernet pseudowires).
674668

675669
Like tunnels, L2TP sessions are identified by a unique
676670
session id. Just as with tunnel ids, the session id is 16-bit for
@@ -680,21 +674,19 @@ value.
680674
Sessions hold a ref on their parent tunnel to ensure that the tunnel
681675
stays extant while one or more sessions references it.
682676

683-
Sessions are kept in a per-tunnel list, indexed by session id. L2TPv3
684-
sessions are also kept in a per-net list indexed by session id,
685-
because L2TPv3 session ids are unique across all tunnels and L2TPv3
686-
data packets do not contain a tunnel id in the header. This list is
687-
therefore needed to find the session context associated with a
688-
received data packet when the tunnel context cannot be derived from
689-
the tunnel socket.
677+
Sessions are kept in a per-net list. L2TPv2 sessions and L2TPv3
678+
sessions are stored in separate lists. L2TPv2 sessions are keyed
679+
by a 32-bit key made up of the 16-bit tunnel ID and 16-bit
680+
session ID. L2TPv3 sessions are keyed by the 32-bit session ID, since
681+
L2TPv3 session ids are unique across all tunnels.
690682

691683
Although the L2TPv3 RFC specifies that L2TPv3 session ids are not
692-
scoped by the tunnel, the kernel does not police this for L2TPv3 UDP
693-
tunnels and does not add sessions of L2TPv3 UDP tunnels into the
694-
per-net session list. In the UDP receive code, we must trust that the
695-
tunnel can be identified using the tunnel socket's sk_user_data and
696-
lookup the session in the tunnel's session list instead of the per-net
697-
session list.
684+
scoped by the tunnel, the Linux implementation has historically
685+
allowed this. Such session id collisions are supported using a per-net
686+
hash table keyed by sk and session ID. When looking up L2TPv3
687+
sessions, the list entry may link to multiple sessions with that
688+
session ID, in which case the session matching the given sk (tunnel)
689+
is used.
698690

699691
PPP
700692
---
@@ -714,10 +706,9 @@ The L2TP PPP implementation handles the closing of a PPPoL2TP socket
714706
by closing its corresponding L2TP session. This is complicated because
715707
it must consider racing with netlink session create/destroy requests
716708
and pppol2tp_connect trying to reconnect with a session that is in the
717-
process of being closed. Unlike tunnels, PPP sessions do not hold a
718-
ref on their associated socket, so code must be careful to sock_hold
719-
the socket where necessary. For all the details, see commit
720-
3d609342cc04129ff7568e19316ce3d7451a27e8.
709+
process of being closed. PPP sessions hold a ref on their associated
710+
socket in order that the socket remains extants while the session
711+
references it.
721712

722713
Ethernet
723714
--------
@@ -761,15 +752,10 @@ Limitations
761752

762753
The current implementation has a number of limitations:
763754

764-
1) Multiple UDP sockets with the same 5-tuple address cannot be
765-
used. The kernel's tunnel context is identified using private
766-
data associated with the socket so it is important that each
767-
socket is uniquely identified by its address.
768-
769-
2) Interfacing with openvswitch is not yet implemented. It may be
755+
1) Interfacing with openvswitch is not yet implemented. It may be
770756
useful to map OVS Ethernet and VLAN ports into L2TPv3 tunnels.
771757

772-
3) VLAN pseudowires are implemented using an ``l2tpethN`` interface
758+
2) VLAN pseudowires are implemented using an ``l2tpethN`` interface
773759
configured with a VLAN sub-interface. Since L2TPv3 VLAN
774760
pseudowires carry one and only one VLAN, it may be better to use
775761
a single netdevice rather than an ``l2tpethN`` and ``l2tpethN``:M

0 commit comments

Comments
 (0)