2021-05-12 16:04:51 +05:30
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
|
|
|
#include <linux/bpf.h>
|
|
|
|
#include <bpf/bpf_helpers.h>
|
2023-08-23 02:07:03 +00:00
|
|
|
#include <linux/if_ether.h>
|
|
|
|
#include <linux/ip.h>
|
2021-05-12 16:04:51 +05:30
|
|
|
|
|
|
|
/* Dummy prog to test TC-BPF API */
|
|
|
|
|
2021-09-28 09:19:39 -07:00
|
|
|
SEC("tc")
|
2021-05-12 16:04:51 +05:30
|
|
|
int cls(struct __sk_buff *skb)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2023-08-23 02:07:03 +00:00
|
|
|
|
|
|
|
/* Prog to verify tc-bpf without cap_sys_admin and cap_perfmon */
|
|
|
|
SEC("tcx/ingress")
|
|
|
|
int pkt_ptr(struct __sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct iphdr *iph = (void *)(long)skb->data + sizeof(struct ethhdr);
|
|
|
|
|
|
|
|
if ((long)(iph + 1) > (long)skb->data_end)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|