]>
git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - tools/testing/selftests/bpf/test_queue_stack_map.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 // Copyright (c) 2018 Politecnico di Torino
6 #include <linux/if_ether.h>
8 #include <linux/pkt_cls.h>
9 #include "bpf_helpers.h"
11 int _version
SEC("version") = 1;
13 struct bpf_map_def
__attribute__ ((section("maps"), used
)) map_in
= {
16 .value_size
= sizeof(__u32
),
21 struct bpf_map_def
__attribute__ ((section("maps"), used
)) map_out
= {
24 .value_size
= sizeof(__u32
),
30 int _test(struct __sk_buff
*skb
)
32 void *data_end
= (void *)(long)skb
->data_end
;
33 void *data
= (void *)(long)skb
->data
;
34 struct ethhdr
*eth
= (struct ethhdr
*)(data
);
38 if (eth
+ 1 > data_end
)
41 struct iphdr
*iph
= (struct iphdr
*)(eth
+ 1);
43 if (iph
+ 1 > data_end
)
46 err
= bpf_map_pop_elem(&map_in
, &value
);
52 err
= bpf_map_push_elem(&map_out
, &iph
->saddr
, 0);
59 char _license
[] SEC("license") = "GPL";