ebpf: fix compatibility with libbpf 1.0+

The current implementation fails to load on a system with
libbpf 1.0 and reports that legacy map definitions in 'maps'
section are not supported by libbpf v1.0+. This commit updates
the Makefile to add BTF (-g flag) and appropriately updates
the maps in rss.bpf.c and update the skeleton file in repo.

Signed-off-by: Shreesh Adiga <16567adigashreesh@gmail.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
master
Shreesh Adiga 2022-12-18 20:09:27 +05:30 committed by Jason Wang
parent 136e9dbad8
commit 197a137290
3 changed files with 890 additions and 330 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,9 @@
OBJS = rss.bpf.o
LLC ?= llc
LLVM_STRIP ?= llvm-strip
CLANG ?= clang
INC_FLAGS = `$(CLANG) -print-file-name=include`
EXTRA_CFLAGS ?= -O2 -emit-llvm -fno-stack-protector
EXTRA_CFLAGS ?= -O2 -g -target bpf
all: $(OBJS)
@ -11,11 +11,13 @@ all: $(OBJS)
clean:
rm -f $(OBJS)
rm -f rss.bpf.skeleton.h
$(OBJS): %.o:%.c
$(CLANG) $(INC_FLAGS) \
-D__KERNEL__ -D__ASM_SYSREG_H \
-I../include $(LINUXINCLUDE) \
$(EXTRA_CFLAGS) -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@
$(EXTRA_CFLAGS) -c $< -o $@
$(LLVM_STRIP) -g $@
bpftool gen skeleton rss.bpf.o > rss.bpf.skeleton.h
cp rss.bpf.skeleton.h ../../ebpf/

View File

@ -76,29 +76,26 @@ struct packet_hash_info_t {
};
};
struct bpf_map_def SEC("maps")
tap_rss_map_configurations = {
.type = BPF_MAP_TYPE_ARRAY,
.key_size = sizeof(__u32),
.value_size = sizeof(struct rss_config_t),
.max_entries = 1,
};
struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
__uint(key_size, sizeof(__u32));
__uint(value_size, sizeof(struct rss_config_t));
__uint(max_entries, 1);
} tap_rss_map_configurations SEC(".maps");
struct bpf_map_def SEC("maps")
tap_rss_map_toeplitz_key = {
.type = BPF_MAP_TYPE_ARRAY,
.key_size = sizeof(__u32),
.value_size = sizeof(struct toeplitz_key_data_t),
.max_entries = 1,
};
struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
__uint(key_size, sizeof(__u32));
__uint(value_size, sizeof(struct toeplitz_key_data_t));
__uint(max_entries, 1);
} tap_rss_map_toeplitz_key SEC(".maps");
struct bpf_map_def SEC("maps")
tap_rss_map_indirection_table = {
.type = BPF_MAP_TYPE_ARRAY,
.key_size = sizeof(__u32),
.value_size = sizeof(__u16),
.max_entries = INDIRECTION_TABLE_SIZE,
};
struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
__uint(key_size, sizeof(__u32));
__uint(value_size, sizeof(__u16));
__uint(max_entries, INDIRECTION_TABLE_SIZE);
} tap_rss_map_indirection_table SEC(".maps");
static inline void net_rx_rss_add_chunk(__u8 *rss_input, size_t *bytes_written,
const void *ptr, size_t size) {