• Jason A. Donenfeld's avatar
    wireguard: socket: remove errant restriction on looping to self · b673e24a
    Jason A. Donenfeld authored
    It's already possible to create two different interfaces and loop
    packets between them. This has always been possible with tunnels in the
    kernel, and isn't specific to wireguard. Therefore, the networking stack
    already needs to deal with that. At the very least, the packet winds up
    exceeding the MTU and is discarded at that point. So, since this is
    already something that happens, there's no need to forbid the not very
    exceptional case of routing a packet back to the same interface; this
    loop is no different than others, and we shouldn't special case it, but
    rather rely on generic handling of loops in general. This also makes it
    easier to do interesting things with wireguard such as onion routing.
    
    At the same time, we add a selftest for this, ensuring that both onion
    routing works and infinite routing loops do not crash the kernel. We
    also add a test case for wireguard interfaces nesting packets and
    sending traffic between each other, as well as the loop in this case
    too. We make sure to send some throughput-heavy traffic for this use
    case, to stress out any possible recursion issues with the locks around
    workqueues.
    
    Fixes: e7096c13 ("net: WireGuard secure network tunnel")
    Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    b673e24a
socket.c 10.9 KB