Skip to content

Commit 3966a66

Browse files
0x7f454c46davem330
authored andcommitted
net/tcp: Use static_branch_tcp_{md5,ao} to drop ifdefs
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 4c8530d ("net/tcp: Only produce AO/MD5 logs if there are any keys"). Reviewed-by: Eric Dumazet <[email protected]> Signed-off-by: Dmitry Safonov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d4cea2c commit 3966a66

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

include/net/tcp.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2386,21 +2386,15 @@ static inline void tcp_get_current_key(const struct sock *sk,
23862386

23872387
static inline bool tcp_key_is_md5(const struct tcp_key *key)
23882388
{
2389-
#ifdef CONFIG_TCP_MD5SIG
2390-
if (static_branch_unlikely(&tcp_md5_needed.key) &&
2391-
key->type == TCP_KEY_MD5)
2392-
return true;
2393-
#endif
2389+
if (static_branch_tcp_md5())
2390+
return key->type == TCP_KEY_MD5;
23942391
return false;
23952392
}
23962393

23972394
static inline bool tcp_key_is_ao(const struct tcp_key *key)
23982395
{
2399-
#ifdef CONFIG_TCP_AO
2400-
if (static_branch_unlikely(&tcp_ao_needed.key) &&
2401-
key->type == TCP_KEY_AO)
2402-
return true;
2403-
#endif
2396+
if (static_branch_tcp_ao())
2397+
return key->type == TCP_KEY_AO;
24042398
return false;
24052399
}
24062400

net/ipv4/tcp_ipv4.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,12 +1054,10 @@ static void tcp_v4_timewait_ack(struct sock *sk, struct sk_buff *skb)
10541054
#else
10551055
if (0) {
10561056
#endif
1057-
#ifdef CONFIG_TCP_MD5SIG
1058-
} else if (static_branch_unlikely(&tcp_md5_needed.key)) {
1057+
} else if (static_branch_tcp_md5()) {
10591058
key.md5_key = tcp_twsk_md5_key(tcptw);
10601059
if (key.md5_key)
10611060
key.type = TCP_KEY_MD5;
1062-
#endif
10631061
}
10641062

10651063
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,
11281126
#else
11291127
if (0) {
11301128
#endif
1131-
#ifdef CONFIG_TCP_MD5SIG
1132-
} else if (static_branch_unlikely(&tcp_md5_needed.key)) {
1129+
} else if (static_branch_tcp_md5()) {
11331130
const union tcp_md5_addr *addr;
11341131
int l3index;
11351132

@@ -1138,7 +1135,6 @@ static void tcp_v4_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb,
11381135
key.md5_key = tcp_md5_do_lookup(sk, l3index, addr, AF_INET);
11391136
if (key.md5_key)
11401137
key.type = TCP_KEY_MD5;
1141-
#endif
11421138
}
11431139

11441140
tcp_v4_send_ack(sk, skb, seq,

0 commit comments

Comments
 (0)