]> git.baikalelectronics.ru Git - kernel.git/commit
udp: Improve port randomization
authorEric Dumazet <dada1@cosmosbay.com>
Wed, 8 Oct 2008 18:44:17 +0000 (11:44 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 8 Oct 2008 18:44:17 +0000 (11:44 -0700)
commitb057d9b8ed4d1fb0f84987c79f38f7e12deac1a6
tree270a8d4d853825b7ff169b4153816372fca00ea1
parent6769653a94fe3ee5e38e5576059302f6db970b7e
udp: Improve port randomization

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: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/udp.c