2023-07-19 16:08:57 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/* Copyright (c) 2023 Isovalent */
|
|
|
|
#include <stdbool.h>
|
2023-10-24 23:49:04 +02:00
|
|
|
|
2023-07-19 16:08:57 +02:00
|
|
|
#include <linux/bpf.h>
|
2023-10-24 23:49:04 +02:00
|
|
|
#include <linux/if_ether.h>
|
|
|
|
|
|
|
|
#include <bpf/bpf_endian.h>
|
2023-07-19 16:08:57 +02:00
|
|
|
#include <bpf/bpf_helpers.h>
|
|
|
|
|
|
|
|
char LICENSE[] SEC("license") = "GPL";
|
|
|
|
|
|
|
|
bool seen_tc1;
|
|
|
|
bool seen_tc2;
|
|
|
|
bool seen_tc3;
|
|
|
|
bool seen_tc4;
|
2023-08-14 18:14:10 +02:00
|
|
|
bool seen_tc5;
|
|
|
|
bool seen_tc6;
|
2023-10-24 23:49:04 +02:00
|
|
|
bool seen_eth;
|
2023-07-19 16:08:57 +02:00
|
|
|
|
|
|
|
SEC("tc/ingress")
|
|
|
|
int tc1(struct __sk_buff *skb)
|
|
|
|
{
|
2023-10-24 23:49:04 +02:00
|
|
|
struct ethhdr eth = {};
|
|
|
|
|
|
|
|
if (skb->protocol != __bpf_constant_htons(ETH_P_IP))
|
|
|
|
goto out;
|
|
|
|
if (bpf_skb_load_bytes(skb, 0, ð, sizeof(eth)))
|
|
|
|
goto out;
|
|
|
|
seen_eth = eth.h_proto == bpf_htons(ETH_P_IP);
|
|
|
|
out:
|
2023-07-19 16:08:57 +02:00
|
|
|
seen_tc1 = true;
|
|
|
|
return TCX_NEXT;
|
|
|
|
}
|
|
|
|
|
|
|
|
SEC("tc/egress")
|
|
|
|
int tc2(struct __sk_buff *skb)
|
|
|
|
{
|
|
|
|
seen_tc2 = true;
|
|
|
|
return TCX_NEXT;
|
|
|
|
}
|
|
|
|
|
|
|
|
SEC("tc/egress")
|
|
|
|
int tc3(struct __sk_buff *skb)
|
|
|
|
{
|
|
|
|
seen_tc3 = true;
|
|
|
|
return TCX_NEXT;
|
|
|
|
}
|
|
|
|
|
|
|
|
SEC("tc/egress")
|
|
|
|
int tc4(struct __sk_buff *skb)
|
|
|
|
{
|
|
|
|
seen_tc4 = true;
|
|
|
|
return TCX_NEXT;
|
|
|
|
}
|
2023-08-14 18:14:10 +02:00
|
|
|
|
|
|
|
SEC("tc/egress")
|
|
|
|
int tc5(struct __sk_buff *skb)
|
|
|
|
{
|
|
|
|
seen_tc5 = true;
|
|
|
|
return TCX_PASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
SEC("tc/egress")
|
|
|
|
int tc6(struct __sk_buff *skb)
|
|
|
|
{
|
|
|
|
seen_tc6 = true;
|
|
|
|
return TCX_PASS;
|
|
|
|
}
|