mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-31 16:38:12 +00:00
3e689141e6
Fix all selftests to include libbpf header files with the bpf/ prefix, to
be consistent with external users of the library. Also ensure that all
includes of exported libbpf header files (those that are exported on 'make
install' of the library) use bracketed includes instead of quoted.
To not break the build, keep the old include path until everything has been
changed to the new one; a subsequent patch will remove that.
Fixes: 6910d7d386
("selftests/bpf: Ensure bpf_helper_defs.h are taken from selftests dir")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/157952560568.1683545.9649335788846513446.stgit@toke.dk
60 lines
1.2 KiB
C
60 lines
1.2 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
#include <linux/bpf.h>
|
|
#include <bpf/bpf_helpers.h>
|
|
|
|
char _license[] SEC("license") = "GPL";
|
|
__u32 _version SEC("version") = 1;
|
|
|
|
struct tcp_rtt_storage {
|
|
__u32 invoked;
|
|
__u32 dsack_dups;
|
|
__u32 delivered;
|
|
__u32 delivered_ce;
|
|
__u32 icsk_retransmits;
|
|
};
|
|
|
|
struct {
|
|
__uint(type, BPF_MAP_TYPE_SK_STORAGE);
|
|
__uint(map_flags, BPF_F_NO_PREALLOC);
|
|
__type(key, int);
|
|
__type(value, struct tcp_rtt_storage);
|
|
} socket_storage_map SEC(".maps");
|
|
|
|
SEC("sockops")
|
|
int _sockops(struct bpf_sock_ops *ctx)
|
|
{
|
|
struct tcp_rtt_storage *storage;
|
|
struct bpf_tcp_sock *tcp_sk;
|
|
int op = (int) ctx->op;
|
|
struct bpf_sock *sk;
|
|
|
|
sk = ctx->sk;
|
|
if (!sk)
|
|
return 1;
|
|
|
|
storage = bpf_sk_storage_get(&socket_storage_map, sk, 0,
|
|
BPF_SK_STORAGE_GET_F_CREATE);
|
|
if (!storage)
|
|
return 1;
|
|
|
|
if (op == BPF_SOCK_OPS_TCP_CONNECT_CB) {
|
|
bpf_sock_ops_cb_flags_set(ctx, BPF_SOCK_OPS_RTT_CB_FLAG);
|
|
return 1;
|
|
}
|
|
|
|
if (op != BPF_SOCK_OPS_RTT_CB)
|
|
return 1;
|
|
|
|
tcp_sk = bpf_tcp_sock(sk);
|
|
if (!tcp_sk)
|
|
return 1;
|
|
|
|
storage->invoked++;
|
|
|
|
storage->dsack_dups = tcp_sk->dsack_dups;
|
|
storage->delivered = tcp_sk->delivered;
|
|
storage->delivered_ce = tcp_sk->delivered_ce;
|
|
storage->icsk_retransmits = tcp_sk->icsk_retransmits;
|
|
|
|
return 1;
|
|
}
|