mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-12-06 09:58:34 +00:00
Compare commits
2 Commits
feat/integ
...
tests/pack
| Author | SHA1 | Date | |
|---|---|---|---|
| fab456b83d | |||
| dc628ee5b5 |
27
tests/failing_tests/vmlinux/ctx_data_arith.py
Normal file
27
tests/failing_tests/vmlinux/ctx_data_arith.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# xdp_md.data is declared u32, so C's rules make ctx.data - k a 32-bit
|
||||||
|
# subtraction, and that is what the compiler emits (w0 += -1). The verifier
|
||||||
|
# tracks data as a packet pointer and rejects it: "R0 32-bit pointer
|
||||||
|
# arithmetic prohibited". C hits the same and casts through (void *)(long).
|
||||||
|
# The planned fix gives the packet-pointer fields 64-bit pointer rank so no
|
||||||
|
# cast is needed; see the TODO in expr_pass._descriptor. The same u32 rank on
|
||||||
|
# a scalar field is pinned as passing in passing_tests/vmlinux/ctx_field_rank.py.
|
||||||
|
from ctypes import c_int32, c_int64
|
||||||
|
from pythonbpf import bpf, section, bpfglobal, compile
|
||||||
|
from vmlinux import struct_xdp_md
|
||||||
|
|
||||||
|
|
||||||
|
@bpf
|
||||||
|
@section("xdp")
|
||||||
|
def prog(ctx: struct_xdp_md) -> c_int64:
|
||||||
|
k = c_int32(1)
|
||||||
|
d = ctx.data - k
|
||||||
|
return c_int64(d)
|
||||||
|
|
||||||
|
|
||||||
|
@bpf
|
||||||
|
@bpfglobal
|
||||||
|
def LICENSE() -> str:
|
||||||
|
return "GPL"
|
||||||
|
|
||||||
|
|
||||||
|
compile()
|
||||||
@ -60,3 +60,7 @@
|
|||||||
"failing_tests/loops/for_continue.py" = {reason = "for/while loops not implemented: continue is not supported", level = "ir"}
|
"failing_tests/loops/for_continue.py" = {reason = "for/while loops not implemented: continue is not supported", level = "ir"}
|
||||||
|
|
||||||
"failing_tests/loops/for_map_items.py" = {reason = "for/while loops not implemented: no sugar over bpf_for_each_map_elem()-style map iteration exists yet", level = "ir"}
|
"failing_tests/loops/for_map_items.py" = {reason = "for/while loops not implemented: no sugar over bpf_for_each_map_elem()-style map iteration exists yet", level = "ir"}
|
||||||
|
|
||||||
|
# 32-bit arithmetic on a packet-pointer context field. IR and llc succeed; the
|
||||||
|
# verifier rejects it with "R0 32-bit pointer arithmetic prohibited".
|
||||||
|
"failing_tests/vmlinux/ctx_data_arith.py" = {reason = "xdp_md.data is u32 in C but a packet pointer to the verifier; 32-bit arithmetic on it is prohibited until packet-pointer fields get 64-bit pointer rank", level = "verifier"}
|
||||||
|
|||||||
Reference in New Issue
Block a user