Skip to content

Commit fddb7b5

Browse files
fleitnerdavem330
authored andcommitted
tcp: bind() optimize port allocation
Port autoselection finds a port and then drop the lock, then right after that, gets the hash bucket again and lock it. Fix it to go direct. Signed-off-by: Flavio Leitner <fbl@redhat.com> Signed-off-by: Marcelo Ricardo Leitner <mleitner@redhat.com> Acked-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 2b05ad3 commit fddb7b5

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

net/ipv4/inet_connection_sock.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,13 @@ int inet_csk_get_port(struct sock *sk, unsigned short snum)
123123
smallest_size = tb->num_owners;
124124
smallest_rover = rover;
125125
if (atomic_read(&hashinfo->bsockets) > (high - low) + 1) {
126-
spin_unlock(&head->lock);
127126
snum = smallest_rover;
128-
goto have_snum;
127+
goto tb_found;
129128
}
130129
}
131130
if (!inet_csk(sk)->icsk_af_ops->bind_conflict(sk, tb)) {
132-
spin_unlock(&head->lock);
133131
snum = rover;
134-
goto have_snum;
132+
goto tb_found;
135133
}
136134
goto next;
137135
}

0 commit comments

Comments
 (0)