• E
    udp: Improve port randomization · 9088c560
    Eric Dumazet 提交于
    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: NEric Dumazet <dada1@cosmosbay.com>
    Signed-off-by: NDavid S. Miller <davem@davemloft.net>
    9088c560
udp.c 43.0 KB