mirror of
https://github.com/torvalds/linux.git
synced 2024-12-25 12:21:37 +00:00
[TCP]: Document non-trivial locking path in tcp_v{4,6}_get_port().
This trips up a lot of folks reading this code. Put an unlikely() around the port-exhaustion test for good measure. Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
89ebd197eb
commit
d5d283751e
@ -242,9 +242,14 @@ static int tcp_v4_get_port(struct sock *sk, unsigned short snum)
|
||||
tcp_port_rover = rover;
|
||||
spin_unlock(&tcp_portalloc_lock);
|
||||
|
||||
/* Exhausted local port range during search? */
|
||||
/* Exhausted local port range during search? It is not
|
||||
* possible for us to be holding one of the bind hash
|
||||
* locks if this test triggers, because if 'remaining'
|
||||
* drops to zero, we broke out of the do/while loop at
|
||||
* the top level, not from the 'break;' statement.
|
||||
*/
|
||||
ret = 1;
|
||||
if (remaining <= 0)
|
||||
if (unlikely(remaining <= 0))
|
||||
goto fail;
|
||||
|
||||
/* OK, here is the one we will use. HEAD is
|
||||
|
@ -158,9 +158,14 @@ static int tcp_v6_get_port(struct sock *sk, unsigned short snum)
|
||||
tcp_port_rover = rover;
|
||||
spin_unlock(&tcp_portalloc_lock);
|
||||
|
||||
/* Exhausted local port range during search? */
|
||||
/* Exhausted local port range during search? It is not
|
||||
* possible for us to be holding one of the bind hash
|
||||
* locks if this test triggers, because if 'remaining'
|
||||
* drops to zero, we broke out of the do/while loop at
|
||||
* the top level, not from the 'break;' statement.
|
||||
*/
|
||||
ret = 1;
|
||||
if (remaining <= 0)
|
||||
if (unlikely(remaining <= 0))
|
||||
goto fail;
|
||||
|
||||
/* OK, here is the one we will use. */
|
||||
|
Loading…
Reference in New Issue
Block a user