summaryrefslogtreecommitdiff
path: root/include/net/tcp.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/tcp.h')
-rw-r--r--include/net/tcp.h24
1 files changed, 16 insertions, 8 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 54226d85feb8..e3617c433cf1 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -2288,14 +2288,18 @@ static inline void tcp_get_current_key(const struct sock *sk,
#if defined(CONFIG_TCP_AO) || defined(CONFIG_TCP_MD5SIG)
const struct tcp_sock *tp = tcp_sk(sk);
#endif
-#ifdef CONFIG_TCP_AO
- struct tcp_ao_info *ao;
- ao = rcu_dereference_protected(tp->ao_info, lockdep_sock_is_held(sk));
- if (ao) {
- out->ao_key = READ_ONCE(ao->current_key);
- out->type = TCP_KEY_AO;
- return;
+#ifdef CONFIG_TCP_AO
+ if (static_branch_unlikely(&tcp_ao_needed.key)) {
+ struct tcp_ao_info *ao;
+
+ ao = rcu_dereference_protected(tp->ao_info,
+ lockdep_sock_is_held(sk));
+ if (ao) {
+ out->ao_key = READ_ONCE(ao->current_key);
+ out->type = TCP_KEY_AO;
+ return;
+ }
}
#endif
#ifdef CONFIG_TCP_MD5SIG
@@ -2324,7 +2328,8 @@ static inline bool tcp_key_is_md5(const struct tcp_key *key)
static inline bool tcp_key_is_ao(const struct tcp_key *key)
{
#ifdef CONFIG_TCP_AO
- if (key->type == TCP_KEY_AO)
+ if (static_branch_unlikely(&tcp_ao_needed.key) &&
+ key->type == TCP_KEY_AO)
return true;
#endif
return false;
@@ -2718,6 +2723,9 @@ static inline bool tcp_ao_required(struct sock *sk, const void *saddr,
struct tcp_ao_info *ao_info;
struct tcp_ao_key *ao_key;
+ if (!static_branch_unlikely(&tcp_ao_needed.key))
+ return false;
+
ao_info = rcu_dereference_check(tcp_sk(sk)->ao_info,
lockdep_sock_is_held(sk));
if (!ao_info)