On Thu, 21 Jan 2021 at 08:39, Andrii Nakryiko <andrii.nakryiko@xxxxxxxxx> wrote: > > On Tue, Jan 19, 2021 at 7:55 AM Björn Töpel <bjorn.topel@xxxxxxxxx> wrote: > > > > From: Björn Töpel <bjorn.topel@xxxxxxxxx> > > > > Add support for externally loaded XDP programs to > > xdpxceiver/test_xsk.sh, so that bpf_redirect_xsk() and > > bpf_redirect_map() can be exercised. > > > > Signed-off-by: Björn Töpel <bjorn.topel@xxxxxxxxx> > > --- > > .../selftests/bpf/progs/xdpxceiver_ext1.c | 15 ++++ > > .../selftests/bpf/progs/xdpxceiver_ext2.c | 9 +++ > > tools/testing/selftests/bpf/test_xsk.sh | 48 ++++++++++++ > > tools/testing/selftests/bpf/xdpxceiver.c | 77 ++++++++++++++++++- > > tools/testing/selftests/bpf/xdpxceiver.h | 2 + > > 5 files changed, 147 insertions(+), 4 deletions(-) > > create mode 100644 tools/testing/selftests/bpf/progs/xdpxceiver_ext1.c > > create mode 100644 tools/testing/selftests/bpf/progs/xdpxceiver_ext2.c > > > > diff --git a/tools/testing/selftests/bpf/progs/xdpxceiver_ext1.c b/tools/testing/selftests/bpf/progs/xdpxceiver_ext1.c > > new file mode 100644 > > index 000000000000..18894040cca6 > > --- /dev/null > > +++ b/tools/testing/selftests/bpf/progs/xdpxceiver_ext1.c > > @@ -0,0 +1,15 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +#include <linux/bpf.h> > > +#include <bpf/bpf_helpers.h> > > + > > +struct { > > + __uint(type, BPF_MAP_TYPE_XSKMAP); > > + __uint(max_entries, 32); > > + __uint(key_size, sizeof(int)); > > + __uint(value_size, sizeof(int)); > > +} xsks_map SEC(".maps"); > > + > > +SEC("xdp_sock") int xdp_sock_prog(struct xdp_md *ctx) > > hmm.. that's unconventional... please keep SEC() on separate line > > > +{ > > + return bpf_redirect_map(&xsks_map, ctx->rx_queue_index, XDP_DROP); > > +} > > diff --git a/tools/testing/selftests/bpf/progs/xdpxceiver_ext2.c b/tools/testing/selftests/bpf/progs/xdpxceiver_ext2.c > > new file mode 100644 > > index 000000000000..bd239b958c01 > > --- /dev/null > > +++ b/tools/testing/selftests/bpf/progs/xdpxceiver_ext2.c > > @@ -0,0 +1,9 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +#include <linux/bpf.h> > > +#include <bpf/bpf_helpers.h> > > + > > +SEC("xdp_sock") int xdp_sock_prog(struct xdp_md *ctx) > > same here > Thanks Andrii! I'll make sure to have the SECs on separate lines going forward! Björn