The default frame_headroom seems to be zero as
define XSK_UMEM__DEFAULT_FRAME_HEADROOM is zero.
This patch does explicit xsk_umem_config setup.
Comment taken from kernel/samples/bpf/xdpsock_user.c.
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
This only works in skb-mode, other modes fail the bpf_xdp_adjust_meta
call and result in XDP_ABORTED. This only occurred on mlx5.
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
BPF program title (bpf_program__title) is getting deprecated
in libbpf use bpf_program__section_name() instead.
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
In-practice only 'xdp_stats_map' definition gets associated BTF,
as it uses the proper '__type' construct.
The AF_XDP map BPF_MAP_TYPE_XSKMAP doesn't know about BTF yet.
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
When not loading an XDP-prog the XSK library bits will load a
default XDP-prog.
In our use-case we always want to load our XDP-prog, which is
stored in af_xdp_kern.o.
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Something in fishy as it seems this BPF-object is not getting used.
Use old maps SEC defines until figuring out what is wrong,
but keep new dot-maps defines.
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
The BPF-helper is now defined in bpf_helper_defs.h header:
lib/libbpf-install/usr/include/bpf/bpf_helper_defs.h
Update and keep comment as a help for people doing kernel
devel on BPF and want to test BPF-helpers not yet upstream.
Accepted in kernel v5.12
- commit 34b2021cc616 ("bpf: Add BPF-helper for MTU checking")
- https://git.kernel.org/torvalds/c/34b2021cc616
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
This USER_TARGETS_OBJS_DEPS allows makefiles to define
dependencies for USER_TARGETS_OBJS targets.
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
This allows including Makefile to define USER_TARGETS_OBJS
that contain code that USER_TARGETS depend on and needs
to be compiled as objects and later linked with.
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
The variable substitution used to parse the clang version was a bashism, so
it broke on Debian/Ubuntu. So let's just use sed instead.
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Seems some distributions will change the clang version output to be
something like 'Ubuntu clang version
12.0.1-++20210918042554+fed41342a82f-1~exp1~20210918143322.141'. Fix the
version parsing in configure to not barf on such weird version strings.
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Add rewriting of ICMP headers to nat64. This is specified in RFC6145, and
the implementation here follows that. The support is only partial, in
particular, in that the payload of ICMP error messages is not rewritten,
even though the RFC specifies that they should be.
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
IPv6 doesn't support fragmentation, so make sure IPv4 packets are not
fragmented in-flight either.
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
We insert a v4-via-v6 route on the interface to direct packets to the v4
subnet to the right interface, where it will be rewritten by the BPF
program. We also create a fake neighbour entry so the kernel won't do
neighbour resolution when sending the pre-rewrite packet. The egress BPF
program will use bpf_redirect_neigh() to do proper neighbour resolution for
the actual destination after rewriting the packet.
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Turns out the atomics just needed to operate on a 64-bit variable, we
didn't actually need a newer compiler.
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Endianness fixes for IP header length, need to also rewrite Ethernet
protocol. Also use direct packet access instead of skb_store_bytes().
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
This adds an initial version of a NAT64 translator in BPF. It compiles and
loads, but doesn't actually appear to work yet.
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Remember that xdp-project have fork of libbpf we use
https://github.com/xdp-project/libbpf
Synced to this libbpf via running command:
git submodule update --remote
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
This was added in kernel commit:
8fd886911a6a ("bpf: Add BTF_KIND_FLOAT to uapi") (Author: Ilya Leoshkevich)
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Fixes pull request #24
I had forgot to git add headers/vmlinux/vmlinux_arch.h in PR#24
which caused compile failures for ktrace-CO-RE.
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>