1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2023 Isovalent */
6 #include <linux/if_ether.h>
7 #include <linux/stddef.h>
8 #include <linux/if_packet.h>
9 #include <bpf/bpf_endian.h>
10 #include <bpf/bpf_helpers.h>
12 char LICENSE[] SEC("license") = "GPL";
32 int tc1(struct __sk_buff *skb)
34 struct ethhdr eth = {};
36 if (skb->protocol != __bpf_constant_htons(ETH_P_IP))
38 if (bpf_skb_load_bytes(skb, 0, ð, sizeof(eth)))
40 seen_eth = eth.h_proto == bpf_htons(ETH_P_IP);
41 seen_host = skb->pkt_type == PACKET_HOST;
42 if (seen_host && set_type) {
44 if (bpf_skb_store_bytes(skb, 0, ð, sizeof(eth), 0))
46 bpf_skb_change_type(skb, PACKET_MULTICAST);
55 int tc2(struct __sk_buff *skb)
62 int tc3(struct __sk_buff *skb)
69 int tc4(struct __sk_buff *skb)
76 int tc5(struct __sk_buff *skb)
83 int tc6(struct __sk_buff *skb)
90 int tc7(struct __sk_buff *skb)
92 struct ethhdr eth = {};
94 if (skb->protocol != __bpf_constant_htons(ETH_P_IP))
96 if (bpf_skb_load_bytes(skb, 0, ð, sizeof(eth)))
98 if (eth.h_dest[0] == 4 && set_type) {
99 seen_mcast = skb->pkt_type == PACKET_MULTICAST;
100 bpf_skb_change_type(skb, PACKET_HOST);
108 int tc8(struct __sk_buff *skb)
112 prio = skb->priority;