[SRU][Lunar][PATCH 3/3] selftests/net: mv bpf/nat6to4.c to net folder
Andrei Gherzan
andrei.gherzan at canonical.com
Thu Feb 9 11:30:56 UTC 2023
On 23/02/09 07:46AM, Andrea Righi wrote:
> On Wed, Feb 08, 2023 at 06:14:05PM +0000, Andrei Gherzan wrote:
> > From: Hangbin Liu <liuhangbin at gmail.com>
> >
> > BugLink: https://bugs.launchpad.net/bugs/2000708
> >
> > There are some issues with the bpf/nat6to4.c building.
> >
> > 1. It use TEST_CUSTOM_PROGS, which will add the nat6to4.o to
> > kselftest-list file and run by common run_tests.
> > 2. When building the test via `make -C tools/testing/selftests/
> > TARGETS="net"`, the nat6to4.o will be build in selftests/net/bpf/
> > folder. But in test udpgro_frglist.sh it refers to ../bpf/nat6to4.o.
> > The correct path should be ./bpf/nat6to4.o.
> > 3. If building the test via `make -C tools/testing/selftests/ TARGETS="net"
> > install`. The nat6to4.o will be installed to kselftest_install/net/
> > folder. Then the udpgro_frglist.sh should refer to ./nat6to4.o.
> >
> > To fix the confusing test path, let's just move the nat6to4.c to net folder
> > and build it as TEST_GEN_FILES.
> >
> > Fixes: edae34a3ed92 ("selftests net: add UDP GRO fraglist + bpf self-tests")
> > Tested-by: Björn Töpel <bjorn at kernel.org>
> > Signed-off-by: Hangbin Liu <liuhangbin at gmail.com>
> > Link: https://lore.kernel.org/r/20230118020927.3971864-1-liuhangbin@gmail.com
> > Signed-off-by: Paolo Abeni <pabeni at redhat.com>
> > (backported from 3c107f36db061603bee7564fbd6388b1f1879fd3 net-next)
> > [agherzan: This change merges the bpf Makefile into the main net
> > Makefile where more tests were added in the meanwhile. The backport
> > consisted only in matching the current state of these tests in the
> > TEST_GEN_FILES and OUTPUT sections.]
> > Signed-off-by: Andrei Gherzan <andrei.gherzan at canonical.com>
> > ---
> > tools/testing/selftests/net/Makefile | 51 ++++++++++++++++++-
> > .../testing/selftests/net/{bpf => }/nat6to4.c | 0
> > tools/testing/selftests/net/udpgro_frglist.sh | 8 +--
> > 3 files changed, 53 insertions(+), 6 deletions(-)
> > rename tools/testing/selftests/net/{bpf => }/nat6to4.c (100%)
> >
> > diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
> > index 69c58362c0ed..eecda1b74ad0 100644
> > --- a/tools/testing/selftests/net/Makefile
> > +++ b/tools/testing/selftests/net/Makefile
> > @@ -71,14 +71,61 @@ TEST_GEN_FILES += bind_bhash
> > TEST_GEN_PROGS += sk_bind_sendto_listen
> > TEST_GEN_PROGS += sk_connect_zero_addr
> > TEST_PROGS += test_ingress_egress_chaining.sh
> > +TEST_GEN_FILES += nat6to4.o
> >
> > TEST_FILES := settings
> >
> > include ../lib.mk
> >
> > -include bpf/Makefile
> > -
> > $(OUTPUT)/reuseport_bpf_numa: LDLIBS += -lnuma
> > $(OUTPUT)/tcp_mmap: LDLIBS += -lpthread
> > $(OUTPUT)/tcp_inq: LDLIBS += -lpthread
> > $(OUTPUT)/bind_bhash: LDLIBS += -lpthread
> > +
> > +# Rules to generate bpf obj nat6to4.o
> > +CLANG ?= clang
> > +SCRATCH_DIR := $(OUTPUT)/tools
> > +BUILD_DIR := $(SCRATCH_DIR)/build
> > +BPFDIR := $(abspath ../../../lib/bpf)
> > +APIDIR := $(abspath ../../../include/uapi)
> > +
> > +CCINCLUDE += -I../bpf
> > +CCINCLUDE += -I../../../../usr/include/
> > +CCINCLUDE += -I$(SCRATCH_DIR)/include
> > +
> > +BPFOBJ := $(BUILD_DIR)/libbpf/libbpf.a
> > +
> > +MAKE_DIRS := $(BUILD_DIR)/libbpf
> > +$(MAKE_DIRS):
> > + mkdir -p $@
> > +
> > +# Get Clang's default includes on this system, as opposed to those seen by
> > +# '-target bpf'. This fixes "missing" files on some architectures/distros,
> > +# such as asm/byteorder.h, asm/socket.h, asm/sockios.h, sys/cdefs.h etc.
> > +#
> > +# Use '-idirafter': Don't interfere with include mechanics except where the
> > +# build would have failed anyways.
> > +define get_sys_includes
> > +$(shell $(1) $(2) -v -E - </dev/null 2>&1 \
> > + | sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \
> > +$(shell $(1) $(2) -dM -E - </dev/null | grep '__riscv_xlen ' | awk '{printf("-D__riscv_xlen=%d -D__BITS_PER_LONG=%d", $$3, $$3)}')
> > +endef
> > +
> > +ifneq ($(CROSS_COMPILE),)
> > +CLANG_TARGET_ARCH = --target=$(notdir $(CROSS_COMPILE:%-=%))
> > +endif
> > +
> > +CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH))
> > +
> > +$(OUTPUT)/nat6to4.o: nat6to4.c $(BPFOBJ) | $(MAKE_DIRS)
> > + $(CLANG) -O2 -target bpf -c $< $(CCINCLUDE) $(CLANG_SYS_INCLUDES) -o $@
> > +
> > +$(BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile) \
> > + $(APIDIR)/linux/bpf.h \
> > + | $(BUILD_DIR)/libbpf
> > + $(MAKE) $(submake_extras) -C $(BPFDIR) OUTPUT=$(BUILD_DIR)/libbpf/ \
> > + EXTRA_CFLAGS='-g -O0' \
> > + DESTDIR=$(SCRATCH_DIR) prefix= all install_headers
> > +
> > +EXTRA_CLEAN := $(SCRATCH_DIR)
> > +>>>>>>> aad5b543f83d (selftests/net: mv bpf/nat6to4.c to net folder)
>
> ^ It looks like there's an extra line that should be removed, maybe left
> there after fixing the conflicts.
>
> The other 2 patches look good (NOTE: linux-unstable needs only patch 3/3,
> the other 2 are already applied via periodic rebase).
Thanks. I've sent a v2 for this.
--
Andrei Gherzan
More information about the kernel-team
mailing list