• James Chapman's avatar
    l2tp: store l2tpv3 sessions in per-net IDR · aa5e17e1
    James Chapman authored
    L2TPv3 sessions are currently held in one of two fixed-size hash
    lists: either a per-net hashlist (IP-encap), or a per-tunnel hashlist
    (UDP-encap), keyed by the L2TPv3 32-bit session_id.
    
    In order to lookup L2TPv3 sessions in UDP-encap tunnels efficiently
    without finding the tunnel first via sk_user_data, UDP sessions are
    now kept in a per-net session list, keyed by session ID. Convert the
    existing per-net hashlist to use an IDR for better performance when
    there are many sessions and have L2TPv3 UDP sessions use the same IDR.
    
    Although the L2TPv3 RFC states that the session ID alone identifies
    the session, our implementation has allowed the same session ID to be
    used in different L2TP UDP tunnels. To retain support for this, a new
    per-net session hashtable is used, keyed by the sock and session
    ID. If on creating a new session, a session already exists with that
    ID in the IDR, the colliding sessions are added to the new hashtable
    and the existing IDR entry is flagged. When looking up sessions, the
    approach is to first check the IDR and if no unflagged match is found,
    check the new hashtable. The sock is made available to session getters
    where session ID collisions are to be considered. In this way, the new
    hashtable is used only for session ID collisions so can be kept small.
    
    For managing session removal, we need a list of colliding sessions
    matching a given ID in order to update or remove the IDR entry of the
    ID. This is necessary to detect session ID collisions when future
    sessions are created. The list head is allocated on first collision
    of a given ID and refcounted.
    Signed-off-by: default avatarJames Chapman <jchapman@katalix.com>
    Reviewed-by: default avatarTom Parkin <tparkin@katalix.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    aa5e17e1
l2tp_core.c 49.3 KB