Add a check that the protocol version field matches the expected value when
parsing IPv4 and IPv6 headers. This makes it possible to parse an IP header
that we don't know the version of (such as on interfaces that don't use an
Ethernet header).
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Seems we need to copy a few more bytes at once for the DHCP relay daemon,
so let's extend __bpf_memcpy to handle copies of up to 288 bytes.
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
It's way too difficult to read packet data in XDP because LLVM will mostly
generate code that doesn't pass the verifier. Thankfully, Cilium has a nice
workaround for this in the form of hand-written BPF assembly to perform the
reads in a way that the verifier will understand. Let's import these
helpers so they can be used by the examples in this repository, along with
some of the other BPF helpers that it relies on.
This commit imports these files wholesale from Cilium:
- include/bpf/builtins.h
- include/bpf/compiler.h
- include/bpf/errno.h
And also adds include/xdp/context_helpers.h which only contains the
xdp_load_bytes() and xdp_store_bytes() helpers from Cilium's
include/bpf/ctx/xdp.h (as the other functions in that file are specific to
how the Cilium code is structured).
We also extend the maximum size supported by the efficient memcpy()
implementation in builtins.h to 280 bytes, and the mask size applied to
packet data copies up to 0x3ff.
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
As reported in the xdp-tutorial (where this code is from), there were a
couple of sizeof checks in parsing_helpers.h that was using the pointer
size instead of the size of the struct being pointed to.
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
It is a bit strange we have this header file in this repo, but
it likely be very useful later.
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>