ebb886078b
Though currently there is no problem including bpf_util.h in kernel space BPF C programs, in next patch in this stack, I will reuse libbpf_num_possible_cpus() in bpf_util.h thus include libbpf.h in it, which will cause BPF C programs compile error. Therefore I will first remove bpf_util.h from all test BPF programs. This can also make it clear that bpf_util.h is a user-space utility while bpf_helpers.h is a kernel space utility. Signed-off-by: Hechao Li <hechaol@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
27 lines
516 B
C
27 lines
516 B
C
#include <linux/bpf.h>
|
|
|
|
#include "bpf_helpers.h"
|
|
#include "bpf_endian.h"
|
|
|
|
int _version SEC("version") = 1;
|
|
|
|
SEC("sk_msg1")
|
|
int bpf_prog1(struct sk_msg_md *msg)
|
|
{
|
|
void *data_end = (void *)(long) msg->data_end;
|
|
void *data = (void *)(long) msg->data;
|
|
|
|
char *d;
|
|
|
|
if (data + 8 > data_end)
|
|
return SK_DROP;
|
|
|
|
bpf_printk("data length %i\n", (__u64)msg->data_end - (__u64)msg->data);
|
|
d = (char *)data;
|
|
bpf_printk("hello sendmsg hook %i %i\n", d[0], d[1]);
|
|
|
|
return SK_PASS;
|
|
}
|
|
|
|
char _license[] SEC("license") = "GPL";
|