linux-zen-desktop/tools/testing/selftests/bpf/progs/empty_skb.c

38 lines
692 B
C
Raw Normal View History

2023-08-30 17:31:07 +02:00
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
#include <linux/bpf.h>
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_endian.h>
char _license[] SEC("license") = "GPL";
int ifindex;
int ret;
SEC("lwt_xmit")
int redirect_ingress(struct __sk_buff *skb)
{
ret = bpf_clone_redirect(skb, ifindex, BPF_F_INGRESS);
return 0;
}
SEC("lwt_xmit")
int redirect_egress(struct __sk_buff *skb)
{
ret = bpf_clone_redirect(skb, ifindex, 0);
return 0;
}
SEC("tc")
int tc_redirect_ingress(struct __sk_buff *skb)
{
ret = bpf_clone_redirect(skb, ifindex, BPF_F_INGRESS);
return 0;
}
SEC("tc")
int tc_redirect_egress(struct __sk_buff *skb)
{
ret = bpf_clone_redirect(skb, ifindex, 0);
return 0;
}