1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2020 Facebook
4 #include <linux/stddef.h>
6 #include <linux/pkt_cls.h>
7 #include <bpf/bpf_endian.h>
8 #include <bpf/bpf_helpers.h>
11 __uint(type, BPF_MAP_TYPE_SOCKMAP);
14 __uint(max_entries, 2);
15 } sock_map SEC(".maps");
17 SEC("freplace/cls_redirect")
18 int freplace_cls_redirect_test(struct __sk_buff *skb)
24 sk = bpf_map_lookup_elem(&sock_map, &zero);
28 ret = bpf_map_update_elem(&sock_map, &zero, sk, 0);
31 return ret == 0 ? TC_ACT_OK : TC_ACT_SHOT;
34 char _license[] SEC("license") = "GPL";