1 // SPDX-License-Identifier: GPL-2.0
3 #include <bpf/bpf_helpers.h>
5 char _license
[] SEC("license") = "GPL";
6 __u32 _version
SEC("version") = 1;
8 struct tcp_rtt_storage
{
13 __u32 icsk_retransmits
;
17 __uint(type
, BPF_MAP_TYPE_SK_STORAGE
);
18 __uint(map_flags
, BPF_F_NO_PREALLOC
);
20 __type(value
, struct tcp_rtt_storage
);
21 } socket_storage_map
SEC(".maps");
24 int _sockops(struct bpf_sock_ops
*ctx
)
26 struct tcp_rtt_storage
*storage
;
27 struct bpf_tcp_sock
*tcp_sk
;
28 int op
= (int) ctx
->op
;
35 storage
= bpf_sk_storage_get(&socket_storage_map
, sk
, 0,
36 BPF_SK_STORAGE_GET_F_CREATE
);
40 if (op
== BPF_SOCK_OPS_TCP_CONNECT_CB
) {
41 bpf_sock_ops_cb_flags_set(ctx
, BPF_SOCK_OPS_RTT_CB_FLAG
);
45 if (op
!= BPF_SOCK_OPS_RTT_CB
)
48 tcp_sk
= bpf_tcp_sock(sk
);
54 storage
->dsack_dups
= tcp_sk
->dsack_dups
;
55 storage
->delivered
= tcp_sk
->delivered
;
56 storage
->delivered_ce
= tcp_sk
->delivered_ce
;
57 storage
->icsk_retransmits
= tcp_sk
->icsk_retransmits
;