mirror of
https://github.com/torvalds/linux.git
synced 2024-11-13 15:41:39 +00:00
tcp: md5: only call tp->af_specific->md5_lookup() for md5 sockets
RETPOLINE made calls to tp->af_specific->md5_lookup() quite expensive, given they have no result. We can omit the calls for sockets that have no md5 keys. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
a06ac0d67d
commit
8c2320e84c
@ -585,14 +585,15 @@ static unsigned int tcp_syn_options(struct sock *sk, struct sk_buff *skb,
|
||||
unsigned int remaining = MAX_TCP_OPTION_SPACE;
|
||||
struct tcp_fastopen_request *fastopen = tp->fastopen_req;
|
||||
|
||||
#ifdef CONFIG_TCP_MD5SIG
|
||||
*md5 = tp->af_specific->md5_lookup(sk, sk);
|
||||
if (*md5) {
|
||||
opts->options |= OPTION_MD5;
|
||||
remaining -= TCPOLEN_MD5SIG_ALIGNED;
|
||||
}
|
||||
#else
|
||||
*md5 = NULL;
|
||||
#ifdef CONFIG_TCP_MD5SIG
|
||||
if (unlikely(rcu_access_pointer(tp->md5sig_info))) {
|
||||
*md5 = tp->af_specific->md5_lookup(sk, sk);
|
||||
if (*md5) {
|
||||
opts->options |= OPTION_MD5;
|
||||
remaining -= TCPOLEN_MD5SIG_ALIGNED;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* We always get an MSS option. The option bytes which will be seen in
|
||||
@ -720,14 +721,15 @@ static unsigned int tcp_established_options(struct sock *sk, struct sk_buff *skb
|
||||
|
||||
opts->options = 0;
|
||||
|
||||
#ifdef CONFIG_TCP_MD5SIG
|
||||
*md5 = tp->af_specific->md5_lookup(sk, sk);
|
||||
if (unlikely(*md5)) {
|
||||
opts->options |= OPTION_MD5;
|
||||
size += TCPOLEN_MD5SIG_ALIGNED;
|
||||
}
|
||||
#else
|
||||
*md5 = NULL;
|
||||
#ifdef CONFIG_TCP_MD5SIG
|
||||
if (unlikely(rcu_access_pointer(tp->md5sig_info))) {
|
||||
*md5 = tp->af_specific->md5_lookup(sk, sk);
|
||||
if (*md5) {
|
||||
opts->options |= OPTION_MD5;
|
||||
size += TCPOLEN_MD5SIG_ALIGNED;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (likely(tp->rx_opt.tstamp_ok)) {
|
||||
|
Loading…
Reference in New Issue
Block a user