diff options
author | Eric Dumazet <edumazet@google.com> | 2015-05-27 13:46:02 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-05-27 14:30:10 -0400 |
commit | e2baad9e4b153c67dddc5ccf987395b842329c84 (patch) | |
tree | f33a2c65ac5d1b832967e737e17bf19c4e79b34a /net/ipv6/inet6_hashtables.c | |
parent | 5a7e4b48104d390bba323d5cf9764cbbc9819eb7 (diff) |
tcp: connect() from bound sockets can be faster
__inet_hash_connect() does not use its third argument (port_offset)
if socket was already bound to a source port.
No need to perform useless but expensive md5 computations.
Reported-by: Crestez Dan Leonard <cdleonard@gmail.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/inet6_hashtables.c')
-rw-r--r-- | net/ipv6/inet6_hashtables.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c index 871641bc1ed4..b4fd96de97e6 100644 --- a/net/ipv6/inet6_hashtables.c +++ b/net/ipv6/inet6_hashtables.c | |||
@@ -257,7 +257,7 @@ not_unique: | |||
257 | return -EADDRNOTAVAIL; | 257 | return -EADDRNOTAVAIL; |
258 | } | 258 | } |
259 | 259 | ||
260 | static inline u32 inet6_sk_port_offset(const struct sock *sk) | 260 | static u32 inet6_sk_port_offset(const struct sock *sk) |
261 | { | 261 | { |
262 | const struct inet_sock *inet = inet_sk(sk); | 262 | const struct inet_sock *inet = inet_sk(sk); |
263 | 263 | ||
@@ -269,7 +269,11 @@ static inline u32 inet6_sk_port_offset(const struct sock *sk) | |||
269 | int inet6_hash_connect(struct inet_timewait_death_row *death_row, | 269 | int inet6_hash_connect(struct inet_timewait_death_row *death_row, |
270 | struct sock *sk) | 270 | struct sock *sk) |
271 | { | 271 | { |
272 | return __inet_hash_connect(death_row, sk, inet6_sk_port_offset(sk), | 272 | u32 port_offset = 0; |
273 | |||
274 | if (!inet_sk(sk)->inet_num) | ||
275 | port_offset = inet6_sk_port_offset(sk); | ||
276 | return __inet_hash_connect(death_row, sk, port_offset, | ||
273 | __inet6_check_established); | 277 | __inet6_check_established); |
274 | } | 278 | } |
275 | EXPORT_SYMBOL_GPL(inet6_hash_connect); | 279 | EXPORT_SYMBOL_GPL(inet6_hash_connect); |