• James Chapman's avatar
    l2tp: refactor udp recv to lookup to not use sk_user_data · ff6a2ac2
    James Chapman authored
    Modify UDP decap to not use the tunnel pointer which comes from the
    sock's sk_user_data when parsing the L2TP header. By looking up the
    destination session using only the packet contents we avoid potential
    UDP 5-tuple aliasing issues which arise from depending on the socket
    that received the packet.
    
    Drop the useless error messages on short packet or on failing to find
    a session since the tunnel pointer might point to a different tunnel
    if multiple sockets use the same 5-tuple.
    
    Short packets (those not big enough to contain an L2TP header) are no
    longer counted in the tunnel's invalid counter because we can't derive
    the tunnel until we parse the l2tp header to lookup the session.
    
    l2tp_udp_encap_recv was a small wrapper around l2tp_udp_recv_core which
    used sk_user_data to derive a tunnel pointer in an RCU-safe way. But
    we no longer need the tunnel pointer, so remove that code and combine
    the two functions.
    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>
    ff6a2ac2
l2tp_core.c 48.8 KB