]> www.infradead.org Git - nvme.git/commitdiff
net/tcp: Use static_branch_tcp_{md5,ao} to drop ifdefs
authorDmitry Safonov <0x7f454c46@gmail.com>
Thu, 6 Jun 2024 23:25:55 +0000 (00:25 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 12 Jun 2024 05:39:03 +0000 (06:39 +0100)
It's possible to clean-up some ifdefs by hiding that
tcp_{md5,ao}_needed static branch is defined and compiled only
under related configs, since commit 4c8530dc7d7d ("net/tcp: Only produce
AO/MD5 logs if there are any keys").

Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Dmitry Safonov <0x7f454c46@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/tcp.h
net/ipv4/tcp_ipv4.c

index a70fc39090fe86e892137fa5b0b3362262e1c127..e5427b05129b50388099708985e0bebd539692c3 100644 (file)
@@ -2386,21 +2386,15 @@ static inline void tcp_get_current_key(const struct sock *sk,
 
 static inline bool tcp_key_is_md5(const struct tcp_key *key)
 {
-#ifdef CONFIG_TCP_MD5SIG
-       if (static_branch_unlikely(&tcp_md5_needed.key) &&
-           key->type == TCP_KEY_MD5)
-               return true;
-#endif
+       if (static_branch_tcp_md5())
+               return key->type == TCP_KEY_MD5;
        return false;
 }
 
 static inline bool tcp_key_is_ao(const struct tcp_key *key)
 {
-#ifdef CONFIG_TCP_AO
-       if (static_branch_unlikely(&tcp_ao_needed.key) &&
-           key->type == TCP_KEY_AO)
-               return true;
-#endif
+       if (static_branch_tcp_ao())
+               return key->type == TCP_KEY_AO;
        return false;
 }
 
index e61c7c97474548363959b43bd75c13d96ea17ad8..de0c8f43448ab68ee45ad5bd30e952575c113979 100644 (file)
@@ -1054,12 +1054,10 @@ static void tcp_v4_timewait_ack(struct sock *sk, struct sk_buff *skb)
 #else
        if (0) {
 #endif
-#ifdef CONFIG_TCP_MD5SIG
-       } else if (static_branch_unlikely(&tcp_md5_needed.key)) {
+       } else if (static_branch_tcp_md5()) {
                key.md5_key = tcp_twsk_md5_key(tcptw);
                if (key.md5_key)
                        key.type = TCP_KEY_MD5;
-#endif
        }
 
        tcp_v4_send_ack(sk, skb,
@@ -1128,8 +1126,7 @@ static void tcp_v4_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb,
 #else
        if (0) {
 #endif
-#ifdef CONFIG_TCP_MD5SIG
-       } else if (static_branch_unlikely(&tcp_md5_needed.key)) {
+       } else if (static_branch_tcp_md5()) {
                const union tcp_md5_addr *addr;
                int l3index;
 
@@ -1138,7 +1135,6 @@ static void tcp_v4_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb,
                key.md5_key = tcp_md5_do_lookup(sk, l3index, addr, AF_INET);
                if (key.md5_key)
                        key.type = TCP_KEY_MD5;
-#endif
        }
 
        tcp_v4_send_ack(sk, skb, seq,