Skip to content

Commit

Permalink
[TCP]: Optimize check in port-allocation code.
Browse files Browse the repository at this point in the history
Signed-off-by: Folkert van Heusden <folkert@vanheusden.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Folkert van Heusden authored and David S. Miller committed May 3, 2005
1 parent 20cc6be commit 0b2531b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions net/ipv4/tcp_ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,13 @@ static int tcp_v4_get_port(struct sock *sk, unsigned short snum)
int rover;

spin_lock(&tcp_portalloc_lock);
rover = tcp_port_rover;
if (tcp_port_rover < low)
rover = low;
else
rover = tcp_port_rover;
do {
rover++;
if (rover < low || rover > high)
if (rover > high)
rover = low;
head = &tcp_bhash[tcp_bhashfn(rover)];
spin_lock(&head->lock);
Expand Down

0 comments on commit 0b2531b

Please sign in to comment.