File Index
Files and directories
Sign in
FILE

test_sockmap_ktls.c

File preview with syntax highlighting.

linux-6.19.14/tools/testing/selftests/bpf/progs/test_sockmap_ktls.c C
 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
 6int cork_byte;
 7int push_start;
 8int push_end;
 9int apply_bytes;
10int pop_start;
11int pop_end;
12
13struct {
14	__uint(type, BPF_MAP_TYPE_SOCKMAP);
15	__uint(max_entries, 20);
16	__type(key, int);
17	__type(value, int);
18} sock_map SEC(".maps");
19
20SEC("sk_msg")
21int prog_sk_policy(struct sk_msg_md *msg)
22{
23	if (cork_byte > 0)
24		bpf_msg_cork_bytes(msg, cork_byte);
25	if (push_start > 0 && push_end > 0)
26		bpf_msg_push_data(msg, push_start, push_end, 0);
27	if (pop_start >= 0 && pop_end > 0)
28		bpf_msg_pop_data(msg, pop_start, pop_end, 0);
29
30	return SK_PASS;
31}
32
33SEC("sk_msg")
34int prog_sk_policy_redir(struct sk_msg_md *msg)
35{
36	int two = 2;
37
38	bpf_msg_apply_bytes(msg, apply_bytes);
39	return bpf_msg_redirect_map(msg, &sock_map, two, 0);
40}
~/ Read-only file preview.