diff options
author | Eric Dumazet <edumazet@google.com> | 2018-04-23 17:46:25 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-04-24 13:20:03 -0400 |
commit | 8c2320e84c193d4d42b8446986afa2797fb411e1 (patch) | |
tree | a48a7aee60f3098f9a0f50296500556f1dec8b91 /net/ipv4/tcp_output.c | |
parent | a06ac0d67d9fda7c255476c6391032319030045d (diff) |
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>
Diffstat (limited to 'net/ipv4/tcp_output.c')
-rw-r--r-- | net/ipv4/tcp_output.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 383cac0ff0ec..95feffb6d53f 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
@@ -585,14 +585,15 @@ static unsigned int tcp_syn_options(struct sock *sk, struct sk_buff *skb, | |||
585 | unsigned int remaining = MAX_TCP_OPTION_SPACE; | 585 | unsigned int remaining = MAX_TCP_OPTION_SPACE; |
586 | struct tcp_fastopen_request *fastopen = tp->fastopen_req; | 586 | struct tcp_fastopen_request *fastopen = tp->fastopen_req; |
587 | 587 | ||
588 | *md5 = NULL; | ||
588 | #ifdef CONFIG_TCP_MD5SIG | 589 | #ifdef CONFIG_TCP_MD5SIG |
589 | *md5 = tp->af_specific->md5_lookup(sk, sk); | 590 | if (unlikely(rcu_access_pointer(tp->md5sig_info))) { |
590 | if (*md5) { | 591 | *md5 = tp->af_specific->md5_lookup(sk, sk); |
591 | opts->options |= OPTION_MD5; | 592 | if (*md5) { |
592 | remaining -= TCPOLEN_MD5SIG_ALIGNED; | 593 | opts->options |= OPTION_MD5; |
594 | remaining -= TCPOLEN_MD5SIG_ALIGNED; | ||
595 | } | ||
593 | } | 596 | } |
594 | #else | ||
595 | *md5 = NULL; | ||
596 | #endif | 597 | #endif |
597 | 598 | ||
598 | /* We always get an MSS option. The option bytes which will be seen in | 599 | /* 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 | |||
720 | 721 | ||
721 | opts->options = 0; | 722 | opts->options = 0; |
722 | 723 | ||
724 | *md5 = NULL; | ||
723 | #ifdef CONFIG_TCP_MD5SIG | 725 | #ifdef CONFIG_TCP_MD5SIG |
724 | *md5 = tp->af_specific->md5_lookup(sk, sk); | 726 | if (unlikely(rcu_access_pointer(tp->md5sig_info))) { |
725 | if (unlikely(*md5)) { | 727 | *md5 = tp->af_specific->md5_lookup(sk, sk); |
726 | opts->options |= OPTION_MD5; | 728 | if (*md5) { |
727 | size += TCPOLEN_MD5SIG_ALIGNED; | 729 | opts->options |= OPTION_MD5; |
730 | size += TCPOLEN_MD5SIG_ALIGNED; | ||
731 | } | ||
728 | } | 732 | } |
729 | #else | ||
730 | *md5 = NULL; | ||
731 | #endif | 733 | #endif |
732 | 734 | ||
733 | if (likely(tp->rx_opt.tstamp_ok)) { | 735 | if (likely(tp->rx_opt.tstamp_ok)) { |