• Eric Dumazet's avatar
    udp: Improve port randomization · 9088c560
    Eric Dumazet authored
    Current UDP port allocation is suboptimal.
    We select the shortest chain to chose a port (out of 512)
    that will hash in this shortest chain.
    
    First, it can lead to give not so ramdom ports and ease
    give attackers more opportunities to break the system.
    
    Second, it can consume a lot of CPU to scan all table
    in order to find the shortest chain.
    
    Third, in some pathological cases we can fail to find
    a free port even if they are plenty of them.
    
    This patch zap the search for a short chain and only
    use one random seed. Problem of getting long chains
    should be addressed in another way, since we can
    obtain long chains with non random ports.
    
    Based on a report and patch from Vitaly Mayatskikh
    Signed-off-by: default avatarEric Dumazet <dada1@cosmosbay.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    9088c560
udp.c 43 KB