xref: /linux/tools/testing/selftests/bpf/progs/test_sockmap_msg_pop_data.c (revision b2128290c29902315e632ea59e0504d6bc9e9b42)
1 // SPDX-License-Identifier: GPL-2.0
2 #include "vmlinux.h"
3 #include <bpf/bpf_helpers.h>
4 
5 struct {
6 	__uint(type, BPF_MAP_TYPE_SOCKMAP);
7 	__uint(max_entries, 1);
8 	__type(key, int);
9 	__type(value, int);
10 } sock_map SEC(".maps");
11 
12 #define POP_START 0x48a3
13 #define POP_LEN   0xfffffffd
14 
15 long pop_data_ret = 1;
16 
17 SEC("sk_msg")
18 int prog_msg_pop_data(struct sk_msg_md *msg)
19 {
20 	if (msg->size <= POP_START)
21 		return SK_PASS;
22 
23 	pop_data_ret = bpf_msg_pop_data(msg, POP_START, POP_LEN, 0);
24 	return SK_PASS;
25 }
26 
27 char _license[] SEC("license") = "GPL";
28