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
3daf8e7
Documentation
LICENSES
arch
block
certs
crypto
drivers
fs
include
init
ipc
kernel
lib
mm
net
samples
scripts
security
sound
tools
accounting
arch
bpf
build
cgroup
crypto
debugging
firewire
firmware
gpio
hv
iio
include
io_uring
kvm
laptop
leds
lib
memory-model
nfsd
objtool
pci
pcmcia
perf
power
scripts
spi
testing
fault-injection
ktest
nvdimm
radix-tree
scatterlist
selftests
android
bpf
gnu
include
prog_tests
.gitignore
bpf_obj_id.c
bpf_verif_scale.c
flow_dissector.c
get_stack_raw_tp.c
global_data.c
l4lb_all.c
map_lock.c
obj_name.c
pkt_access.c
pkt_md_access.c
prog_run_xattr.c
queue_stack_map.c
reference_tracking.c
signal_pending.c
skb_ctx.c
spinlock.c
stacktrace_build_id.c
stacktrace_build_id_nmi.c
stacktrace_map.c
stacktrace_map_raw_tp.c
task_fd_query_rawtp.c
task_fd_query_tp.c
tcp_estats.c
tp_attach_query.c
xdp.c
xdp_adjust_tail.c
xdp_noinline.c
progs
verifier
.gitignore
Makefile
bpf_endian.h
bpf_helpers.h
bpf_rand.h
bpf_rlimit.h
bpf_util.h
cgroup_helpers.c
cgroup_helpers.h
config
flow_dissector_load.c
flow_dissector_load.h
get_cgroup_id_user.c
netcnt_common.h
tcp_client.py
tcp_server.py
test_align.c
test_btf.c
test_cgroup_storage.c
test_dev_cgroup.c
test_flow_dissector.c
test_flow_dissector.sh
test_iptunnel_common.h
test_kmod.sh
test_libbpf.sh
test_libbpf_open.c
test_lirc_mode2.sh
test_lirc_mode2_user.c
test_lpm_map.c
test_lru_map.c
test_lwt_ip_encap.sh
test_lwt_seg6local.sh
test_maps.c
test_netcnt.c
test_offload.py
test_progs.c
test_progs.h
test_queue_stack_map.h
test_section_names.c
test_select_reuseport.c
test_select_reuseport_common.h
test_skb_cgroup_id.sh
test_skb_cgroup_id_user.c
test_sock.c
test_sock_addr.c
test_sock_addr.sh
test_sock_fields.c
test_socket_cookie.c
test_sockmap.c
test_sockmap_kern.h
test_tag.c
test_tc_edt.sh
test_tc_tunnel.sh
test_tcp_check_syncookie.sh
test_tcp_check_syncookie_user.c
test_tcpbpf.h
test_tcpbpf_user.c
test_tcpnotify.h
test_tcpnotify_user.c
test_tunnel.sh
test_verifier.c
test_verifier_log.c
test_xdp_meta.sh
test_xdp_redirect.sh
test_xdp_vlan.sh
trace_helpers.c
trace_helpers.h
urandom_read.c
with_addr.sh
with_tunnels.sh
breakpoints
capabilities
cgroup
cpu-hotplug
cpufreq
drivers
efivarfs
exec
filesystems
firmware
ftrace
futex
gpio
ia64
ima
intel_pstate
ipc
ir
kcmp
kmod
kvm
lib
livepatch
locking
media_tests
membarrier
memfd
memory-hotplug
mount
mqueue
net
netfilter
networking
nsfs
ntb
pidfd
powerpc
prctl
proc
pstore
ptp
ptrace
rcutorture
rseq
rtc
safesetid
seccomp
sigaltstack
size
sparc64
splice
static_keys
sync
sysctl
tc-testing
timers
tmpfs
tpm2
uevent
user
vDSO
vm
watchdog
x86
zram
.gitignore
Makefile
gen_kselftest_tar.sh
kselftest.h
kselftest_harness.h
kselftest_install.sh
lib.mk
vsock
thermal
time
usb
virtio
vm
wmi
Makefile
usr
virt
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
Breadcrumbs
linux
/
tools
/
testing
/
selftests
/
bpf
/
prog_tests
/
skb_ctx.c
Blame
Blame
Latest commit
History
History
89 lines (74 loc) · 2.25 KB
Breadcrumbs
linux
/
tools
/
testing
/
selftests
/
bpf
/
prog_tests
/
skb_ctx.c
Top
File metadata and controls
Code
Blame
89 lines (74 loc) · 2.25 KB
Raw
// SPDX-License-Identifier: GPL-2.0 #include <test_progs.h> void test_skb_ctx(void) { struct __sk_buff skb = { .cb[0] = 1, .cb[1] = 2, .cb[2] = 3, .cb[3] = 4, .cb[4] = 5, .priority = 6, }; struct bpf_prog_test_run_attr tattr = { .data_in = &pkt_v4, .data_size_in = sizeof(pkt_v4), .ctx_in = &skb, .ctx_size_in = sizeof(skb), .ctx_out = &skb, .ctx_size_out = sizeof(skb), }; struct bpf_object *obj; int err; int i; err = bpf_prog_load("./test_skb_ctx.o", BPF_PROG_TYPE_SCHED_CLS, &obj, &tattr.prog_fd); if (CHECK_ATTR(err, "load", "err %d errno %d\n", err, errno)) return; /* ctx_in != NULL, ctx_size_in == 0 */ tattr.ctx_size_in = 0; err = bpf_prog_test_run_xattr(&tattr); CHECK_ATTR(err == 0, "ctx_size_in", "err %d errno %d\n", err, errno); tattr.ctx_size_in = sizeof(skb); /* ctx_out != NULL, ctx_size_out == 0 */ tattr.ctx_size_out = 0; err = bpf_prog_test_run_xattr(&tattr); CHECK_ATTR(err == 0, "ctx_size_out", "err %d errno %d\n", err, errno); tattr.ctx_size_out = sizeof(skb); /* non-zero [len, tc_index] fields should be rejected*/ skb.len = 1; err = bpf_prog_test_run_xattr(&tattr); CHECK_ATTR(err == 0, "len", "err %d errno %d\n", err, errno); skb.len = 0; skb.tc_index = 1; err = bpf_prog_test_run_xattr(&tattr); CHECK_ATTR(err == 0, "tc_index", "err %d errno %d\n", err, errno); skb.tc_index = 0; /* non-zero [hash, sk] fields should be rejected */ skb.hash = 1; err = bpf_prog_test_run_xattr(&tattr); CHECK_ATTR(err == 0, "hash", "err %d errno %d\n", err, errno); skb.hash = 0; skb.sk = (struct bpf_sock *)1; err = bpf_prog_test_run_xattr(&tattr); CHECK_ATTR(err == 0, "sk", "err %d errno %d\n", err, errno); skb.sk = 0; err = bpf_prog_test_run_xattr(&tattr); CHECK_ATTR(err != 0 || tattr.retval, "run", "err %d errno %d retval %d\n", err, errno, tattr.retval); CHECK_ATTR(tattr.ctx_size_out != sizeof(skb), "ctx_size_out", "incorrect output size, want %lu have %u\n", sizeof(skb), tattr.ctx_size_out); for (i = 0; i < 5; i++) CHECK_ATTR(skb.cb[i] != i + 2, "ctx_out_cb", "skb->cb[i] == %d, expected %d\n", skb.cb[i], i + 2); CHECK_ATTR(skb.priority != 7, "ctx_out_priority", "skb->priority == %d, expected %d\n", skb.priority, 7); }
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
You can’t perform that action at this time.