Skip to content

Commit afe1357

Browse files
0x7f454c46NipaLocal
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 <edumazet@google.com> Signed-off-by: Dmitry Safonov <0x7f454c46@gmail.com> Signed-off-by: NipaLocal <nipa@local>
1 parent 55145bf commit afe1357

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
@@ -4481,7 +4481,6 @@ tcp_inbound_md5_hash(const struct sock *sk, const struct sk_buff *skb,
44814481

44824482
if (!key && hash_location) {
44834483
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMD5UNEXPECTED);
4484-
tcp_hash_fail("Unexpected MD5 Hash found", family, skb, "");
44854484
trace_tcp_hash_md5_unexpected(sk, skb);
44864485
return SKB_DROP_REASON_TCP_MD5UNEXPECTED;
44874486
}
@@ -4497,21 +4496,6 @@ tcp_inbound_md5_hash(const struct sock *sk, const struct sk_buff *skb,
44974496
NULL, skb);
44984497
if (genhash || memcmp(hash_location, newhash, 16) != 0) {
44994498
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMD5FAILURE);
4500-
if (family == AF_INET) {
4501-
tcp_hash_fail("MD5 Hash failed", AF_INET, skb, "%s L3 index %d",
4502-
genhash ? "tcp_v4_calc_md5_hash failed"
4503-
: "", l3index);
4504-
} else {
4505-
if (genhash) {
4506-
tcp_hash_fail("MD5 Hash failed",
4507-
AF_INET6, skb, "L3 index %d",
4508-
l3index);
4509-
} else {
4510-
tcp_hash_fail("MD5 Hash mismatch",
4511-
AF_INET6, skb, "L3 index %d",
4512-
l3index);
4513-
}
4514-
}
45154499
trace_tcp_hash_md5_mismatch(sk, skb);
45164500
return SKB_DROP_REASON_TCP_MD5FAILURE;
45174501
}
@@ -4534,8 +4518,6 @@ tcp_inbound_hash(struct sock *sk, const struct request_sock *req,
45344518

45354519
/* Invalid option or two times meet any of auth options */
45364520
if (tcp_parse_auth_options(th, &md5_location, &aoh)) {
4537-
tcp_hash_fail("TCP segment has incorrect auth options set",
4538-
family, skb, "");
45394521
trace_tcp_hash_bad_header(sk, skb);
45404522
return SKB_DROP_REASON_TCP_AUTH_HDR;
45414523
}
@@ -4553,9 +4535,6 @@ tcp_inbound_hash(struct sock *sk, const struct request_sock *req,
45534535
}
45544536

45554537
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPAOBAD);
4556-
tcp_hash_fail("TCP connection can't start/end using TCP-AO",
4557-
family, skb, "%s",
4558-
!aoh ? "missing AO" : "AO signed");
45594538
trace_tcp_ao_handshake_failure(sk, skb, keyid, rnext, maclen);
45604539
return SKB_DROP_REASON_TCP_AOFAILURE;
45614540
}
@@ -4574,15 +4553,11 @@ tcp_inbound_hash(struct sock *sk, const struct request_sock *req,
45744553
* always at least one current_key.
45754554
*/
45764555
if (tcp_ao_required(sk, saddr, family, l3index, true)) {
4577-
tcp_hash_fail("AO hash is required, but not found",
4578-
family, skb, "L3 index %d", l3index);
45794556
trace_tcp_hash_ao_required(sk, skb);
45804557
return SKB_DROP_REASON_TCP_AONOTFOUND;
45814558
}
45824559
if (unlikely(tcp_md5_do_lookup(sk, l3index, saddr, family))) {
45834560
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMD5NOTFOUND);
4584-
tcp_hash_fail("MD5 Hash not found",
4585-
family, skb, "L3 index %d", l3index);
45864561
trace_tcp_hash_md5_required(sk, skb);
45874562
return SKB_DROP_REASON_TCP_MD5NOTFOUND;
45884563
}

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)