summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/progs/empty_skb.c
blob: 4b0cd675325119ad163b29def109b5c10db46864 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// 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;
}