Skip to content

Commit c2cb5e8

Browse files
fomichevborkmann
authored andcommitted
bpf: add icsk_retransmits to bpf_tcp_sock
Add some inet_connection_sock fields to bpf_tcp_sock that might be useful for debugging congestion control issues. Cc: Eric Dumazet <edumazet@google.com> Cc: Priyaranjan Jha <priyarjha@google.com> Cc: Yuchung Cheng <ycheng@google.com> Cc: Soheil Hassas Yeganeh <soheil@google.com> Acked-by: Soheil Hassas Yeganeh <soheil@google.com> Acked-by: Yuchung Cheng <ycheng@google.com> Signed-off-by: Stanislav Fomichev <sdf@google.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
1 parent 0357746 commit c2cb5e8

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

‎include/uapi/linux/bpf.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3078,6 +3078,7 @@ struct bpf_tcp_sock {
30783078
*/
30793079
__u32 delivered; /* Total data packets delivered incl. rexmits */
30803080
__u32 delivered_ce; /* Like the above but only ECE marked packets */
3081+
__u32 icsk_retransmits; /* Number of unrecovered [RTO] timeouts */
30813082
};
30823083

30833084
struct bpf_sock_tuple {

‎net/core/filter.c‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5544,7 +5544,8 @@ static const struct bpf_func_proto bpf_sock_addr_sk_lookup_udp_proto = {
55445544
bool bpf_tcp_sock_is_valid_access(int off, int size, enum bpf_access_type type,
55455545
struct bpf_insn_access_aux *info)
55465546
{
5547-
if (off < 0 || off >= offsetofend(struct bpf_tcp_sock, delivered_ce))
5547+
if (off < 0 || off >= offsetofend(struct bpf_tcp_sock,
5548+
icsk_retransmits))
55485549
return false;
55495550

55505551
if (off % size != 0)
@@ -5575,6 +5576,20 @@ u32 bpf_tcp_sock_convert_ctx_access(enum bpf_access_type type,
55755576
offsetof(struct tcp_sock, FIELD)); \
55765577
} while (0)
55775578

5579+
#define BPF_INET_SOCK_GET_COMMON(FIELD) \
5580+
do { \
5581+
BUILD_BUG_ON(FIELD_SIZEOF(struct inet_connection_sock, \
5582+
FIELD) > \
5583+
FIELD_SIZEOF(struct bpf_tcp_sock, FIELD)); \
5584+
*insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF( \
5585+
struct inet_connection_sock, \
5586+
FIELD), \
5587+
si->dst_reg, si->src_reg, \
5588+
offsetof( \
5589+
struct inet_connection_sock, \
5590+
FIELD)); \
5591+
} while (0)
5592+
55785593
if (insn > insn_buf)
55795594
return insn - insn_buf;
55805595

@@ -5661,6 +5676,9 @@ u32 bpf_tcp_sock_convert_ctx_access(enum bpf_access_type type,
56615676
case offsetof(struct bpf_tcp_sock, delivered_ce):
56625677
BPF_TCP_SOCK_GET_COMMON(delivered_ce);
56635678
break;
5679+
case offsetof(struct bpf_tcp_sock, icsk_retransmits):
5680+
BPF_INET_SOCK_GET_COMMON(icsk_retransmits);
5681+
break;
56645682
}
56655683

56665684
return insn - insn_buf;

0 commit comments

Comments
 (0)