Commit 31e42721 authored by Andrii Nakryiko's avatar Andrii Nakryiko Committed by Alexei Starovoitov
Browse files

selftests/bpf: remove last tests with legacy BPF map definitions



Libbpf 1.0 stops support legacy-style BPF map definitions. Selftests has
been migrated away from using legacy BPF map definitions except for two
selftests, to make sure that legacy functionality still worked in
pre-1.0 libbpf. Now it's time to let those tests go as libbpf 1.0 is
imminent.

Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20220627211527.2245459-14-andrii@kernel.org


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 450b167f
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -2,15 +2,6 @@
#ifndef __BPF_LEGACY__
#define __BPF_LEGACY__

#define BPF_ANNOTATE_KV_PAIR(name, type_key, type_val)		\
	struct ____btf_map_##name {				\
		type_key key;					\
		type_val value;					\
	};							\
	struct ____btf_map_##name				\
	__attribute__ ((section(".maps." #name), used))		\
		____btf_map_##name = { }

/* llvm builtin functions that eBPF C program may use to
 * emit BPF_LD_ABS and BPF_LD_IND instructions
 */
+0 −1
Original line number Diff line number Diff line
@@ -4651,7 +4651,6 @@ struct btf_file_test {
};

static struct btf_file_test file_tests[] = {
	{ .file = "test_btf_haskv.o", },
	{ .file = "test_btf_newkv.o", },
	{ .file = "test_btf_nokv.o", .btf_kv_notfound = true, },
};
+0 −51
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (c) 2018 Facebook */
#include <linux/bpf.h>
#include <bpf/bpf_helpers.h>
#include "bpf_legacy.h"

struct ipv_counts {
	unsigned int v4;
	unsigned int v6;
};

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
struct bpf_map_def SEC("maps") btf_map = {
	.type = BPF_MAP_TYPE_ARRAY,
	.key_size = sizeof(int),
	.value_size = sizeof(struct ipv_counts),
	.max_entries = 4,
};
#pragma GCC diagnostic pop

BPF_ANNOTATE_KV_PAIR(btf_map, int, struct ipv_counts);

__attribute__((noinline))
int test_long_fname_2(void)
{
	struct ipv_counts *counts;
	int key = 0;

	counts = bpf_map_lookup_elem(&btf_map, &key);
	if (!counts)
		return 0;

	counts->v6++;

	return 0;
}

__attribute__((noinline))
int test_long_fname_1(void)
{
	return test_long_fname_2();
}

SEC("dummy_tracepoint")
int _dummy_tracepoint(void *arg)
{
	return test_long_fname_1();
}

char _license[] SEC("license") = "GPL";
+0 −18
Original line number Diff line number Diff line
@@ -9,19 +9,6 @@ struct ipv_counts {
	unsigned int v6;
};

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
/* just to validate we can handle maps in multiple sections */
struct bpf_map_def SEC("maps") btf_map_legacy = {
	.type = BPF_MAP_TYPE_ARRAY,
	.key_size = sizeof(int),
	.value_size = sizeof(long long),
	.max_entries = 4,
};
#pragma GCC diagnostic pop

BPF_ANNOTATE_KV_PAIR(btf_map_legacy, int, struct ipv_counts);

struct {
	__uint(type, BPF_MAP_TYPE_ARRAY);
	__uint(max_entries, 4);
@@ -41,11 +28,6 @@ int test_long_fname_2(void)

	counts->v6++;

	/* just verify we can reference both maps */
	counts = bpf_map_lookup_elem(&btf_map_legacy, &key);
	if (!counts)
		return 0;

	return 0;
}