Files
xdp-project-bpf-examples/include/bpf/errno.h
Toke Høiland-Jørgensen 5f5ea00a6c include: Import data loading helpers from Cilium
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>
2021-06-01 16:11:33 +02:00

38 lines
610 B
C

/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (C) 2016-2020 Authors of Cilium */
#ifndef __BPF_ERRNO__
#define __BPF_ERRNO__
/* Few basic errno codes as we don't want to include errno.h. */
#ifndef EPERM
# define EPERM 1
#endif
#ifndef ENOENT
# define ENOENT 2
#endif
#ifndef ENXIO
# define ENXIO 6
#endif
#ifndef ENOMEM
# define ENOMEM 12
#endif
#ifndef EFAULT
# define EFAULT 14
#endif
#ifndef EINVAL
# define EINVAL 22
#endif
#ifndef ENOTSUP
# define ENOTSUP 95
#endif
#ifndef EADDRINUSE
# define EADDRINUSE 98
#endif
#ifndef ENOTSUPP
# define ENOTSUPP 524
#endif
#endif /* __BPF_ERRNO__ */