summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/progs/test_sock_fields_kern.c
diff options
context:
space:
mode:
authorAndrii Nakryiko <andriin@fb.com>2019-07-05 08:50:11 -0700
committerDaniel Borkmann <daniel@iogearbox.net>2019-07-05 22:52:25 +0200
commitbc7430cc8bfb51577e466a8ca02ad87375a70bde (patch)
treec56b050f3bb07c491da3f0fa082e651dbfe6d993 /tools/testing/selftests/bpf/progs/test_sock_fields_kern.c
parent00acd00814527a1856c92beda17475205bddaba6 (diff)
downloadlinux-stable-bc7430cc8bfb51577e466a8ca02ad87375a70bde.tar.gz
linux-stable-bc7430cc8bfb51577e466a8ca02ad87375a70bde.tar.bz2
linux-stable-bc7430cc8bfb51577e466a8ca02ad87375a70bde.zip
selftests/bpf: convert selftests using BTF-defined maps to new syntax
Convert all the existing selftests that are already using BTF-defined maps to use new syntax (with no static data initialization). Signed-off-by: Andrii Nakryiko <andriin@fb.com> Acked-by: Song Liu <songliubraving@fb.com> Acked-by: Yonghong Song <yhs@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools/testing/selftests/bpf/progs/test_sock_fields_kern.c')
-rw-r--r--tools/testing/selftests/bpf/progs/test_sock_fields_kern.c78
1 files changed, 30 insertions, 48 deletions
diff --git a/tools/testing/selftests/bpf/progs/test_sock_fields_kern.c b/tools/testing/selftests/bpf/progs/test_sock_fields_kern.c
index c3d383d650cb..a47b003623ef 100644
--- a/tools/testing/selftests/bpf/progs/test_sock_fields_kern.c
+++ b/tools/testing/selftests/bpf/progs/test_sock_fields_kern.c
@@ -28,44 +28,32 @@ enum bpf_linum_array_idx {
};
struct {
- __u32 type;
- __u32 max_entries;
- __u32 *key;
- struct sockaddr_in6 *value;
-} addr_map SEC(".maps") = {
- .type = BPF_MAP_TYPE_ARRAY,
- .max_entries = __NR_BPF_ADDR_ARRAY_IDX,
-};
+ __uint(type, BPF_MAP_TYPE_ARRAY);
+ __uint(max_entries, __NR_BPF_ADDR_ARRAY_IDX);
+ __type(key, __u32);
+ __type(value, struct sockaddr_in6);
+} addr_map SEC(".maps");
struct {
- __u32 type;
- __u32 max_entries;
- __u32 *key;
- struct bpf_sock *value;
-} sock_result_map SEC(".maps") = {
- .type = BPF_MAP_TYPE_ARRAY,
- .max_entries = __NR_BPF_RESULT_ARRAY_IDX,
-};
+ __uint(type, BPF_MAP_TYPE_ARRAY);
+ __uint(max_entries, __NR_BPF_RESULT_ARRAY_IDX);
+ __type(key, __u32);
+ __type(value, struct bpf_sock);
+} sock_result_map SEC(".maps");
struct {
- __u32 type;
- __u32 max_entries;
- __u32 *key;
- struct bpf_tcp_sock *value;
-} tcp_sock_result_map SEC(".maps") = {
- .type = BPF_MAP_TYPE_ARRAY,
- .max_entries = __NR_BPF_RESULT_ARRAY_IDX,
-};
+ __uint(type, BPF_MAP_TYPE_ARRAY);
+ __uint(max_entries, __NR_BPF_RESULT_ARRAY_IDX);
+ __type(key, __u32);
+ __type(value, struct bpf_tcp_sock);
+} tcp_sock_result_map SEC(".maps");
struct {
- __u32 type;
- __u32 max_entries;
- __u32 *key;
- __u32 *value;
-} linum_map SEC(".maps") = {
- .type = BPF_MAP_TYPE_ARRAY,
- .max_entries = __NR_BPF_LINUM_ARRAY_IDX,
-};
+ __uint(type, BPF_MAP_TYPE_ARRAY);
+ __uint(max_entries, __NR_BPF_LINUM_ARRAY_IDX);
+ __type(key, __u32);
+ __type(value, __u32);
+} linum_map SEC(".maps");
struct bpf_spinlock_cnt {
struct bpf_spin_lock lock;
@@ -73,24 +61,18 @@ struct bpf_spinlock_cnt {
};
struct {
- __u32 type;
- __u32 map_flags;
- int *key;
- struct bpf_spinlock_cnt *value;
-} sk_pkt_out_cnt SEC(".maps") = {
- .type = BPF_MAP_TYPE_SK_STORAGE,
- .map_flags = BPF_F_NO_PREALLOC,
-};
+ __uint(type, BPF_MAP_TYPE_SK_STORAGE);
+ __uint(map_flags, BPF_F_NO_PREALLOC);
+ __type(key, int);
+ __type(value, struct bpf_spinlock_cnt);
+} sk_pkt_out_cnt SEC(".maps");
struct {
- __u32 type;
- __u32 map_flags;
- int *key;
- struct bpf_spinlock_cnt *value;
-} sk_pkt_out_cnt10 SEC(".maps") = {
- .type = BPF_MAP_TYPE_SK_STORAGE,
- .map_flags = BPF_F_NO_PREALLOC,
-};
+ __uint(type, BPF_MAP_TYPE_SK_STORAGE);
+ __uint(map_flags, BPF_F_NO_PREALLOC);
+ __type(key, int);
+ __type(value, struct bpf_spinlock_cnt);
+} sk_pkt_out_cnt10 SEC(".maps");
static bool is_loopback6(__u32 *a6)
{