Skip to content

Commit 441acf6

Browse files
author
Blaise Boscaccy
committed
selftests/bpf: Enable map verification for some lskel tests
Convert an existing signed lskel test to use the newly introduced map signature hash-chain support added to libbpf. Signed-off-by: Blaise Boscaccy <[email protected]>
1 parent f5eea47 commit 441acf6

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

tools/testing/selftests/bpf/Makefile

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,12 +500,14 @@ LSKELS := fexit_sleep.c trace_printk.c trace_vprintk.c map_ptr_kern.c \
500500
core_kern.c core_kern_overflow.c test_ringbuf.c \
501501
test_ringbuf_n.c test_ringbuf_map_key.c test_ringbuf_write.c
502502

503-
LSKELS_SIGNED := fentry_test.c fexit_test.c atomics.c
503+
LSKELS_SIGNED := fentry_test.c fexit_test.c
504+
505+
LSKELS_SIGNED_MAPS := atomics.c
504506

505507
# Generate both light skeleton and libbpf skeleton for these
506508
LSKELS_EXTRA := test_ksyms_module.c test_ksyms_weak.c kfunc_call_test.c \
507509
kfunc_call_test_subprog.c
508-
SKEL_BLACKLIST += $$(LSKELS) $$(LSKELS_SIGNED)
510+
SKEL_BLACKLIST += $$(LSKELS) $$(LSKELS_SIGNED) $$(LSKELS_SIGNED_MAPS)
509511

510512
test_static_linked.skel.h-deps := test_static_linked1.bpf.o test_static_linked2.bpf.o
511513
linked_funcs.skel.h-deps := linked_funcs1.bpf.o linked_funcs2.bpf.o
@@ -537,6 +539,7 @@ HEADERS_FOR_BPF_OBJS := $(wildcard $(BPFDIR)/*.bpf.h) \
537539
define DEFINE_TEST_RUNNER
538540

539541
LSKEL_SIGN := -S -k $(PRIVATE_KEY) -i $(VERIFICATION_CERT)
542+
LSKEL_SIGN_MAPS := -S -M -k $(PRIVATE_KEY) -i $(VERIFICATION_CERT)
540543
TRUNNER_OUTPUT := $(OUTPUT)$(if $2,/)$2
541544
TRUNNER_BINARY := $1$(if $2,-)$2
542545
TRUNNER_TEST_OBJS := $$(patsubst %.c,$$(TRUNNER_OUTPUT)/%.test.o, \
@@ -553,6 +556,7 @@ TRUNNER_BPF_SKELS := $$(patsubst %.c,$$(TRUNNER_OUTPUT)/%.skel.h, \
553556
TRUNNER_BPF_LSKELS := $$(patsubst %.c,$$(TRUNNER_OUTPUT)/%.lskel.h, $$(LSKELS) $$(LSKELS_EXTRA))
554557
TRUNNER_BPF_SKELS_LINKED := $$(addprefix $$(TRUNNER_OUTPUT)/,$(LINKED_SKELS))
555558
TRUNNER_BPF_LSKELS_SIGNED := $$(patsubst %.c,$$(TRUNNER_OUTPUT)/%.lskel.h, $$(LSKELS_SIGNED))
559+
TRUNNER_BPF_LSKELS_SIGNED_MAPS := $$(patsubst %.c,$$(TRUNNER_OUTPUT)/%.lskel.h, $$(LSKELS_SIGNED_MAPS))
556560
TEST_GEN_FILES += $$(TRUNNER_BPF_OBJS)
557561

558562
# Evaluate rules now with extra TRUNNER_XXX variables above already defined
@@ -616,6 +620,15 @@ $(TRUNNER_BPF_LSKELS_SIGNED): %.lskel.h: %.bpf.o $(BPFTOOL) | $(TRUNNER_OUTPUT)
616620
$(Q)$$(BPFTOOL) gen skeleton $(LSKEL_SIGN) $$(<:.o=.llinked3.o) name $$(notdir $$(<:.bpf.o=_lskel)) > $$@
617621
$(Q)rm -f $$(<:.o=.llinked1.o) $$(<:.o=.llinked2.o) $$(<:.o=.llinked3.o)
618622

623+
$(TRUNNER_BPF_LSKELS_SIGNED_MAPS): %.lskel.h: %.bpf.o $(BPFTOOL) | $(TRUNNER_OUTPUT)
624+
$$(call msg,GEN-SKEL,$(TRUNNER_BINARY) (signed),$$@)
625+
$(Q)$$(BPFTOOL) gen object $$(<:.o=.llinked1.o) $$<
626+
$(Q)$$(BPFTOOL) gen object $$(<:.o=.llinked2.o) $$(<:.o=.llinked1.o)
627+
$(Q)$$(BPFTOOL) gen object $$(<:.o=.llinked3.o) $$(<:.o=.llinked2.o)
628+
$(Q)diff $$(<:.o=.llinked2.o) $$(<:.o=.llinked3.o)
629+
$(Q)$$(BPFTOOL) gen skeleton $(LSKEL_SIGN_MAPS) $$(<:.o=.llinked3.o) name $$(notdir $$(<:.bpf.o=_lskel)) > $$@
630+
$(Q)rm -f $$(<:.o=.llinked1.o) $$(<:.o=.llinked2.o) $$(<:.o=.llinked3.o)
631+
619632
$(LINKED_BPF_OBJS): %: $(TRUNNER_OUTPUT)/%
620633

621634
# .SECONDEXPANSION here allows to correctly expand %-deps variables as prerequisites
@@ -666,6 +679,7 @@ $(TRUNNER_TEST_OBJS:.o=.d): $(TRUNNER_OUTPUT)/%.test.d: \
666679
$(TRUNNER_BPF_SKELS) \
667680
$(TRUNNER_BPF_LSKELS) \
668681
$(TRUNNER_BPF_LSKELS_SIGNED) \
682+
$(TRUNNER_BPF_LSKELS_SIGNED_MAPS) \
669683
$(TRUNNER_BPF_SKELS_LINKED) \
670684
$$(BPFOBJ) | $(TRUNNER_OUTPUT)
671685

0 commit comments

Comments
 (0)