Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / tools / testing / selftests / bpf / sockmap_parse_prog.c
bloba1dec2b6d9c5b28618996fe6e8312df814d2b4cf
1 #include <linux/bpf.h>
2 #include "bpf_helpers.h"
3 #include "bpf_util.h"
4 #include "bpf_endian.h"
6 int _version SEC("version") = 1;
8 #define bpf_printk(fmt, ...) \
9 ({ \
10 char ____fmt[] = fmt; \
11 bpf_trace_printk(____fmt, sizeof(____fmt), \
12 ##__VA_ARGS__); \
15 SEC("sk_skb1")
16 int bpf_prog1(struct __sk_buff *skb)
18 void *data_end = (void *)(long) skb->data_end;
19 void *data = (void *)(long) skb->data;
20 __u32 lport = skb->local_port;
21 __u32 rport = skb->remote_port;
22 __u8 *d = data;
24 if (data + 10 > data_end)
25 return skb->len;
27 /* This write/read is a bit pointless but tests the verifier and
28 * strparser handler for read/write pkt data and access into sk
29 * fields.
31 d[7] = 1;
32 return skb->len;
35 char _license[] SEC("license") = "GPL";