• Mike Manning's avatar
    net: prefer socket bound to interface when not in VRF · 8d6c414c
    Mike Manning authored
    The commit 6da5b0f0 ("net: ensure unbound datagram socket to be
    chosen when not in a VRF") modified compute_score() so that a device
    match is always made, not just in the case of an l3mdev skb, then
    increments the score also for unbound sockets. This ensures that
    sockets bound to an l3mdev are never selected when not in a VRF.
    But as unbound and bound sockets are now scored equally, this results
    in the last opened socket being selected if there are matches in the
    default VRF for an unbound socket and a socket bound to a dev that is
    not an l3mdev. However, handling prior to this commit was to always
    select the bound socket in this case. Reinstate this handling by
    incrementing the score only for bound sockets. The required isolation
    due to choosing between an unbound socket and a socket bound to an
    l3mdev remains in place due to the device match always being made.
    The same approach is taken for compute_score() for stream sockets.
    
    Fixes: 6da5b0f0 ("net: ensure unbound datagram socket to be chosen when not in a VRF")
    Fixes: e7819058 ("net: ensure unbound stream socket to be chosen when not in a VRF")
    Signed-off-by: default avatarMike Manning <mmanning@vyatta.att-mail.com>
    Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
    Link: https://lore.kernel.org/r/cf0a8523-b362-1edf-ee78-eef63cbbb428@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    8d6c414c
inet6_hashtables.c 9.2 KB