Skip to content

Commit 3489f45

Browse files
committed
Add failing XDP vmlinux tests
1 parent 204ec26 commit 3489f45

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from ctypes import c_int64
2+
from pythonbpf import bpf, section, bpfglobal, compile
3+
from vmlinux import struct_xdp_md
4+
from vmlinux import XDP_PASS
5+
import logging
6+
7+
8+
@bpf
9+
@section("xdp")
10+
def print_xdp_data(ctx: struct_xdp_md) -> c_int64:
11+
data = 0
12+
data = ctx.data # 32-bit field: packet start pointer
13+
something = 2 + data
14+
print(f"ctx->data = {something}")
15+
return c_int64(XDP_PASS)
16+
17+
18+
@bpf
19+
@bpfglobal
20+
def LICENSE() -> str:
21+
return "GPL"
22+
23+
24+
compile(logging.INFO)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from ctypes import c_int64
2+
from pythonbpf import bpf, section, bpfglobal, compile
3+
from vmlinux import struct_xdp_md
4+
from vmlinux import XDP_PASS
5+
import logging
6+
7+
8+
@bpf
9+
@section("xdp")
10+
def print_xdp_data(ctx: struct_xdp_md) -> c_int64:
11+
data = c_int64(ctx.data) # 32-bit field: packet start pointer
12+
something = 2 + data
13+
print(f"ctx->data = {something}")
14+
return c_int64(XDP_PASS)
15+
16+
17+
@bpf
18+
@bpfglobal
19+
def LICENSE() -> str:
20+
return "GPL"
21+
22+
23+
compile(logging.INFO)

0 commit comments

Comments
 (0)