1// SPDX-License-Identifier: GPL-2.0
2/* Copyright (c) 2023 Isovalent */
3#include <stdbool.h>
4
5#include <linux/bpf.h>
6#include <linux/if_ether.h>
7
8#include <bpf/bpf_endian.h>
9#include <bpf/bpf_helpers.h>
10
11char LICENSE[] SEC("license") = "GPL";
12
13bool seen_tc1;
14bool seen_tc2;
15bool seen_tc3;
16bool seen_tc4;
17bool seen_tc5;
18bool seen_tc6;
19bool seen_eth;
20
21SEC("tc/ingress")
22int tc1(struct __sk_buff *skb)
23{
24	struct ethhdr eth = {};
25
26	if (skb->protocol != __bpf_constant_htons(ETH_P_IP))
27		goto out;
28	if (bpf_skb_load_bytes(skb, 0, &eth, sizeof(eth)))
29		goto out;
30	seen_eth = eth.h_proto == bpf_htons(ETH_P_IP);
31out:
32	seen_tc1 = true;
33	return TCX_NEXT;
34}
35
36SEC("tc/egress")
37int tc2(struct __sk_buff *skb)
38{
39	seen_tc2 = true;
40	return TCX_NEXT;
41}
42
43SEC("tc/egress")
44int tc3(struct __sk_buff *skb)
45{
46	seen_tc3 = true;
47	return TCX_NEXT;
48}
49
50SEC("tc/egress")
51int tc4(struct __sk_buff *skb)
52{
53	seen_tc4 = true;
54	return TCX_NEXT;
55}
56
57SEC("tc/egress")
58int tc5(struct __sk_buff *skb)
59{
60	seen_tc5 = true;
61	return TCX_PASS;
62}
63
64SEC("tc/egress")
65int tc6(struct __sk_buff *skb)
66{
67	seen_tc6 = true;
68	return TCX_PASS;
69}
70