]> Git Repo - linux.git/blob - tools/testing/selftests/bpf/progs/test_tc_bpf.c
Linux 6.14-rc3
[linux.git] / tools / testing / selftests / bpf / progs / test_tc_bpf.c
1 // SPDX-License-Identifier: GPL-2.0
2
3 #include <linux/bpf.h>
4 #include <bpf/bpf_helpers.h>
5 #include <linux/if_ether.h>
6 #include <linux/ip.h>
7
8 /* Dummy prog to test TC-BPF API */
9
10 SEC("tc")
11 int cls(struct __sk_buff *skb)
12 {
13         return 0;
14 }
15
16 /* Prog to verify tc-bpf without cap_sys_admin and cap_perfmon */
17 SEC("tcx/ingress")
18 int pkt_ptr(struct __sk_buff *skb)
19 {
20         struct iphdr *iph = (void *)(long)skb->data + sizeof(struct ethhdr);
21
22         if ((long)(iph + 1) > (long)skb->data_end)
23                 return 1;
24         return 0;
25 }
This page took 0.03133 seconds and 4 git commands to generate.