mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
feat:non struct field values can be cast
This commit is contained in:
@ -3025,19 +3025,20 @@
|
||||
],
|
||||
"source": [
|
||||
"from vmlinux import struct_request, struct_pt_regs\n",
|
||||
"from pythonbpf import bpf, section, bpfglobal, compile_to_ir, compile, map, BPF\n",
|
||||
"from pythonbpf import bpf, section, bpfglobal, map, BPF\n",
|
||||
"from pythonbpf.helper import ktime\n",
|
||||
"from pythonbpf.maps import HashMap\n",
|
||||
"import logging\n",
|
||||
"from ctypes import c_int64, c_uint64, c_int32\n",
|
||||
"\n",
|
||||
"REQ_WRITE = 1\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"@bpf\n",
|
||||
"@map\n",
|
||||
"def start() -> HashMap:\n",
|
||||
" return HashMap(key=c_uint64, value=c_uint64, max_entries=10240)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"@bpf\n",
|
||||
"@section(\"kprobe/blk_mq_end_request\")\n",
|
||||
"def trace_completion(ctx: struct_pt_regs) -> c_int64:\n",
|
||||
@ -3063,6 +3064,7 @@
|
||||
"\n",
|
||||
" return c_int64(0)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"@bpf\n",
|
||||
"@section(\"kprobe/blk_mq_start_request\")\n",
|
||||
"def trace_start(ctx1: struct_pt_regs) -> c_int32:\n",
|
||||
@ -3071,11 +3073,13 @@
|
||||
" start.update(req, ts)\n",
|
||||
" return c_int32(0)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"@bpf\n",
|
||||
"@bpfglobal\n",
|
||||
"def LICENSE() -> str:\n",
|
||||
" return \"GPL\"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"b = BPF()"
|
||||
]
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user