aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/testing/selftests/bpf/progs/test_tc_peer.c
blob: ef264bced0e65ecf59345b69cb2462ff451604dd (plain) (blame)
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
// SPDX-License-Identifier: GPL-2.0
#include <stdint.h>
#include <stdbool.h>

#include <linux/bpf.h>
#include <linux/stddef.h>
#include <linux/pkt_cls.h>

#include <bpf/bpf_helpers.h>

volatile const __u32 IFINDEX_SRC;
volatile const __u32 IFINDEX_DST;

SEC("classifier/chk_egress")
int tc_chk(struct __sk_buff *skb)
{
	return TC_ACT_SHOT;
}

SEC("classifier/dst_ingress")
int tc_dst(struct __sk_buff *skb)
{
	return bpf_redirect_peer(IFINDEX_SRC, 0);
}

SEC("classifier/src_ingress")
int tc_src(struct __sk_buff *skb)
{
	return bpf_redirect_peer(IFINDEX_DST, 0);
}

char __license[] SEC("license") = "GPL";