Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
43b987d
Breadcrumbs
linux
/
tools
/
testing
/
selftests
/
bpf
/
test_queue_stack_map.h
Blame
Blame
Latest commit
History
History
59 lines (47 loc) · 1.2 KB
Breadcrumbs
linux
/
tools
/
testing
/
selftests
/
bpf
/
test_queue_stack_map.h
Top
File metadata and controls
Code
Blame
59 lines (47 loc) · 1.2 KB
Raw
/* SPDX-License-Identifier: GPL-2.0 */ // Copyright (c) 2018 Politecnico di Torino #include <stddef.h> #include <string.h> #include <linux/bpf.h> #include <linux/if_ether.h> #include <linux/ip.h> #include <linux/pkt_cls.h> #include "bpf_helpers.h" int _version SEC("version") = 1; struct bpf_map_def __attribute__ ((section("maps"), used)) map_in = { .type = MAP_TYPE, .key_size = 0, .value_size = sizeof(__u32), .max_entries = 32, .map_flags = 0, }; struct bpf_map_def __attribute__ ((section("maps"), used)) map_out = { .type = MAP_TYPE, .key_size = 0, .value_size = sizeof(__u32), .max_entries = 32, .map_flags = 0, }; SEC("test") int _test(struct __sk_buff *skb) { void *data_end = (void *)(long)skb->data_end; void *data = (void *)(long)skb->data; struct ethhdr *eth = (struct ethhdr *)(data); __u32 value; int err; if (eth + 1 > data_end) return TC_ACT_SHOT; struct iphdr *iph = (struct iphdr *)(eth + 1); if (iph + 1 > data_end) return TC_ACT_SHOT; err = bpf_map_pop_elem(&map_in, &value); if (err) return TC_ACT_SHOT; iph->daddr = value; err = bpf_map_push_elem(&map_out, &iph->saddr, 0); if (err) return TC_ACT_SHOT; return TC_ACT_OK; } char _license[] SEC("license") = "GPL";
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
You can’t perform that action at this time.