mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-16 01:04:08 +08: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
31 lines
661 B
C
31 lines
661 B
C
#include <uapi/linux/bpf.h>
|
|
#include <uapi/linux/if_ether.h>
|
|
#include <uapi/linux/if_packet.h>
|
|
#include <uapi/linux/ip.h>
|
|
#include <bpf/bpf_helpers.h>
|
|
#include "bpf_legacy.h"
|
|
|
|
struct {
|
|
__uint(type, BPF_MAP_TYPE_ARRAY);
|
|
__type(key, u32);
|
|
__type(value, long);
|
|
__uint(max_entries, 256);
|
|
} my_map SEC(".maps");
|
|
|
|
SEC("socket1")
|
|
int bpf_prog1(struct __sk_buff *skb)
|
|
{
|
|
int index = load_byte(skb, ETH_HLEN + offsetof(struct iphdr, protocol));
|
|
long *value;
|
|
|
|
if (skb->pkt_type != PACKET_OUTGOING)
|
|
return 0;
|
|
|
|
value = bpf_map_lookup_elem(&my_map, &index);
|
|
if (value)
|
|
__sync_fetch_and_add(value, skb->len);
|
|
|
|
return 0;
|
|
}
|
|
char _license[] SEC("license") = "GPL";
|