mirror of
https://github.com/torvalds/linux.git
synced 2024-12-24 11:51:27 +00:00
7cf245a37e
Fix all files in samples/bpf to include libbpf header files with the bpf/
prefix, to be consistent with external users of the library. Also ensure
that all includes of exported libbpf header files (those that are exported
on 'make install' of the library) use bracketed includes instead of quoted.
To make sure no new files are introduced that doesn't include the bpf/
prefix in its include, remove tools/lib/bpf from the include path entirely,
and use tools/lib instead.
Fixes: 6910d7d386
("selftests/bpf: Ensure bpf_helper_defs.h are taken from selftests dir")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/157952560911.1683545.8795966751309534150.stgit@toke.dk
25 lines
593 B
C
25 lines
593 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
#include <linux/bpf.h>
|
|
#include <bpf/bpf_helpers.h>
|
|
#include "xdpsock.h"
|
|
|
|
/* This XDP program is only needed for the XDP_SHARED_UMEM mode.
|
|
* If you do not use this mode, libbpf can supply an XDP program for you.
|
|
*/
|
|
|
|
struct {
|
|
__uint(type, BPF_MAP_TYPE_XSKMAP);
|
|
__uint(max_entries, MAX_SOCKS);
|
|
__uint(key_size, sizeof(int));
|
|
__uint(value_size, sizeof(int));
|
|
} xsks_map SEC(".maps");
|
|
|
|
static unsigned int rr;
|
|
|
|
SEC("xdp_sock") int xdp_sock_prog(struct xdp_md *ctx)
|
|
{
|
|
rr = (rr + 1) & (MAX_SOCKS - 1);
|
|
|
|
return bpf_redirect_map(&xsks_map, rr, XDP_DROP);
|
|
}
|