Skip to content

Commit 78b1b27

Browse files
0x7f454c46davem330
authored andcommitted
net/tcp: Remove tcp_hash_fail()
Now there are tracepoints, that cover all functionality of tcp_hash_fail(), but also wire up missing places They are also faster, can be disabled and provide filtering. This potentially may create a regression if a userspace depends on dmesg logs. Fingers crossed, let's see if anyone complains in reality. Reviewed-by: Eric Dumazet <[email protected]> Signed-off-by: Dmitry Safonov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 96be3dc commit 78b1b27

File tree

3 files changed

+0
-71
lines changed

3 files changed

+0
-71
lines changed

include/net/tcp_ao.h

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -149,43 +149,6 @@ extern struct static_key_false_deferred tcp_ao_needed;
149149
#define static_branch_tcp_ao() false
150150
#endif
151151

152-
static inline bool tcp_hash_should_produce_warnings(void)
153-
{
154-
return static_branch_tcp_md5() || static_branch_tcp_ao();
155-
}
156-
157-
#define tcp_hash_fail(msg, family, skb, fmt, ...) \
158-
do { \
159-
const struct tcphdr *th = tcp_hdr(skb); \
160-
char hdr_flags[6]; \
161-
char *f = hdr_flags; \
162-
\
163-
if (!tcp_hash_should_produce_warnings()) \
164-
break; \
165-
if (th->fin) \
166-
*f++ = 'F'; \
167-
if (th->syn) \
168-
*f++ = 'S'; \
169-
if (th->rst) \
170-
*f++ = 'R'; \
171-
if (th->psh) \
172-
*f++ = 'P'; \
173-
if (th->ack) \
174-
*f++ = '.'; \
175-
*f = 0; \
176-
if ((family) == AF_INET) { \
177-
net_info_ratelimited("%s for %pI4.%d->%pI4.%d [%s] " fmt "\n", \
178-
msg, &ip_hdr(skb)->saddr, ntohs(th->source), \
179-
&ip_hdr(skb)->daddr, ntohs(th->dest), \
180-
hdr_flags, ##__VA_ARGS__); \
181-
} else { \
182-
net_info_ratelimited("%s for [%pI6c].%d->[%pI6c].%d [%s]" fmt "\n", \
183-
msg, &ipv6_hdr(skb)->saddr, ntohs(th->source), \
184-
&ipv6_hdr(skb)->daddr, ntohs(th->dest), \
185-
hdr_flags, ##__VA_ARGS__); \
186-
} \
187-
} while (0)
188-
189152
#ifdef CONFIG_TCP_AO
190153
/* TCP-AO structures and functions */
191154
struct tcp4_ao_context {

net/ipv4/tcp.c

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4484,7 +4484,6 @@ tcp_inbound_md5_hash(const struct sock *sk, const struct sk_buff *skb,
44844484

44854485
if (!key && hash_location) {
44864486
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMD5UNEXPECTED);
4487-
tcp_hash_fail("Unexpected MD5 Hash found", family, skb, "");
44884487
trace_tcp_hash_md5_unexpected(sk, skb);
44894488
return SKB_DROP_REASON_TCP_MD5UNEXPECTED;
44904489
}
@@ -4500,21 +4499,6 @@ tcp_inbound_md5_hash(const struct sock *sk, const struct sk_buff *skb,
45004499
NULL, skb);
45014500
if (genhash || memcmp(hash_location, newhash, 16) != 0) {
45024501
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMD5FAILURE);
4503-
if (family == AF_INET) {
4504-
tcp_hash_fail("MD5 Hash failed", AF_INET, skb, "%s L3 index %d",
4505-
genhash ? "tcp_v4_calc_md5_hash failed"
4506-
: "", l3index);
4507-
} else {
4508-
if (genhash) {
4509-
tcp_hash_fail("MD5 Hash failed",
4510-
AF_INET6, skb, "L3 index %d",
4511-
l3index);
4512-
} else {
4513-
tcp_hash_fail("MD5 Hash mismatch",
4514-
AF_INET6, skb, "L3 index %d",
4515-
l3index);
4516-
}
4517-
}
45184502
trace_tcp_hash_md5_mismatch(sk, skb);
45194503
return SKB_DROP_REASON_TCP_MD5FAILURE;
45204504
}
@@ -4545,8 +4529,6 @@ tcp_inbound_hash(struct sock *sk, const struct request_sock *req,
45454529

45464530
/* Invalid option or two times meet any of auth options */
45474531
if (tcp_parse_auth_options(th, &md5_location, &aoh)) {
4548-
tcp_hash_fail("TCP segment has incorrect auth options set",
4549-
family, skb, "");
45504532
trace_tcp_hash_bad_header(sk, skb);
45514533
return SKB_DROP_REASON_TCP_AUTH_HDR;
45524534
}
@@ -4564,9 +4546,6 @@ tcp_inbound_hash(struct sock *sk, const struct request_sock *req,
45644546
}
45654547

45664548
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPAOBAD);
4567-
tcp_hash_fail("TCP connection can't start/end using TCP-AO",
4568-
family, skb, "%s",
4569-
!aoh ? "missing AO" : "AO signed");
45704549
trace_tcp_ao_handshake_failure(sk, skb, keyid, rnext, maclen);
45714550
return SKB_DROP_REASON_TCP_AOFAILURE;
45724551
}
@@ -4585,15 +4564,11 @@ tcp_inbound_hash(struct sock *sk, const struct request_sock *req,
45854564
* always at least one current_key.
45864565
*/
45874566
if (tcp_ao_required(sk, saddr, family, l3index, true)) {
4588-
tcp_hash_fail("AO hash is required, but not found",
4589-
family, skb, "L3 index %d", l3index);
45904567
trace_tcp_hash_ao_required(sk, skb);
45914568
return SKB_DROP_REASON_TCP_AONOTFOUND;
45924569
}
45934570
if (unlikely(tcp_md5_do_lookup(sk, l3index, saddr, family))) {
45944571
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMD5NOTFOUND);
4595-
tcp_hash_fail("MD5 Hash not found",
4596-
family, skb, "L3 index %d", l3index);
45974572
trace_tcp_hash_md5_required(sk, skb);
45984573
return SKB_DROP_REASON_TCP_MD5NOTFOUND;
45994574
}

net/ipv4/tcp_ao.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -893,9 +893,6 @@ tcp_ao_verify_hash(const struct sock *sk, const struct sk_buff *skb,
893893
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPAOBAD);
894894
atomic64_inc(&info->counters.pkt_bad);
895895
atomic64_inc(&key->pkt_bad);
896-
tcp_hash_fail("AO hash wrong length", family, skb,
897-
"%u != %d L3index: %d", maclen,
898-
tcp_ao_maclen(key), l3index);
899896
trace_tcp_ao_wrong_maclen(sk, skb, aoh->keyid,
900897
aoh->rnext_keyid, maclen);
901898
return SKB_DROP_REASON_TCP_AOFAILURE;
@@ -912,8 +909,6 @@ tcp_ao_verify_hash(const struct sock *sk, const struct sk_buff *skb,
912909
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPAOBAD);
913910
atomic64_inc(&info->counters.pkt_bad);
914911
atomic64_inc(&key->pkt_bad);
915-
tcp_hash_fail("AO hash mismatch", family, skb,
916-
"L3index: %d", l3index);
917912
trace_tcp_ao_mismatch(sk, skb, aoh->keyid,
918913
aoh->rnext_keyid, maclen);
919914
kfree(hash_buf);
@@ -945,8 +940,6 @@ tcp_inbound_ao_hash(struct sock *sk, const struct sk_buff *skb,
945940
info = rcu_dereference(tcp_sk(sk)->ao_info);
946941
if (!info) {
947942
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPAOKEYNOTFOUND);
948-
tcp_hash_fail("AO key not found", family, skb,
949-
"keyid: %u L3index: %d", aoh->keyid, l3index);
950943
trace_tcp_ao_key_not_found(sk, skb, aoh->keyid,
951944
aoh->rnext_keyid, maclen);
952945
return SKB_DROP_REASON_TCP_AOUNEXPECTED;
@@ -1057,8 +1050,6 @@ tcp_inbound_ao_hash(struct sock *sk, const struct sk_buff *skb,
10571050
key_not_found:
10581051
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPAOKEYNOTFOUND);
10591052
atomic64_inc(&info->counters.key_not_found);
1060-
tcp_hash_fail("Requested by the peer AO key id not found",
1061-
family, skb, "L3index: %d", l3index);
10621053
trace_tcp_ao_key_not_found(sk, skb, aoh->keyid,
10631054
aoh->rnext_keyid, maclen);
10641055
return SKB_DROP_REASON_TCP_AOKEYNOTFOUND;

0 commit comments

Comments
 (0)