1 // SPDX-License-Identifier: GPL-2.0 2 #include <linux/bpf.h> 3 #include <bpf/bpf_helpers.h> 4 #include <bpf/bpf_endian.h> 5 6 int cork_byte; 7 int push_start; 8 int push_end; 9 10 struct { 11 __uint(type, BPF_MAP_TYPE_SOCKMAP); 12 __uint(max_entries, 20); 13 __type(key, int); 14 __type(value, int); 15 } sock_map SEC(".maps"); 16 17 SEC("sk_msg") 18 int prog_sk_policy(struct sk_msg_md *msg) 19 { 20 if (cork_byte > 0) 21 bpf_msg_cork_bytes(msg, cork_byte); 22 if (push_start > 0 && push_end > 0) 23 bpf_msg_push_data(msg, push_start, push_end, 0); 24 25 return SK_PASS; 26 } 27