Commit 0f0e5f5b authored by Ilya Leoshkevich's avatar Ilya Leoshkevich Committed by Alexei Starovoitov

bpf: iterators: Split iterators.lskel.h into little- and big- endian versions

iterators.lskel.h is little-endian, therefore bpf iterator is currently
broken on big-endian systems. Introduce a big-endian version and add
instructions regarding its generation. Unfortunately bpftool's
cross-endianness capabilities are limited to BTF right now, so the
procedure requires access to a big-endian machine or a configured
emulator.
Signed-off-by: default avatarIlya Leoshkevich <iii@linux.ibm.com>
Link: https://lore.kernel.org/r/20230128000650.1516334-25-iii@linux.ibm.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 42fae973
......@@ -3,7 +3,11 @@
#include <linux/init.h>
#include <linux/module.h>
#include "bpf_preload.h"
#include "iterators/iterators.lskel.h"
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#include "iterators/iterators.lskel-little-endian.h"
#else
#include "iterators/iterators.lskel-big-endian.h"
#endif
static struct bpf_link *maps_link, *progs_link;
static struct iterators_bpf *skel;
......
......@@ -35,20 +35,22 @@ endif
.PHONY: all clean
all: iterators.lskel.h
all: iterators.lskel-little-endian.h
big: iterators.lskel-big-endian.h
clean:
$(call msg,CLEAN)
$(Q)rm -rf $(OUTPUT) iterators
iterators.lskel.h: $(OUTPUT)/iterators.bpf.o | $(BPFTOOL)
iterators.lskel-%.h: $(OUTPUT)/%/iterators.bpf.o | $(BPFTOOL)
$(call msg,GEN-SKEL,$@)
$(Q)$(BPFTOOL) gen skeleton -L $< > $@
$(OUTPUT)/iterators.bpf.o: iterators.bpf.c $(BPFOBJ) | $(OUTPUT)
$(OUTPUT)/%/iterators.bpf.o: iterators.bpf.c $(BPFOBJ) | $(OUTPUT)
$(call msg,BPF,$@)
$(Q)$(CLANG) -g -O2 -target bpf $(INCLUDES) \
$(Q)mkdir -p $(@D)
$(Q)$(CLANG) -g -O2 -target bpf -m$* $(INCLUDES) \
-c $(filter %.c,$^) -o $@ && \
$(LLVM_STRIP) -g $@
......
WARNING:
If you change "iterators.bpf.c" do "make -j" in this directory to rebuild "iterators.skel.h".
If you change "iterators.bpf.c" do "make -j" in this directory to
rebuild "iterators.lskel-little-endian.h". Then, on a big-endian
machine, do "make -j big" in this directory to rebuild
"iterators.lskel-big-endian.h". Commit both resulting headers.
Make sure to have clang 10 installed.
See Documentation/bpf/bpf_devel_QA.rst
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment