mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
move helper annotations to helpers module
This commit is contained in:
@ -60,12 +60,13 @@ pip install pythonbpf pylibbpf
|
||||
```python
|
||||
import time
|
||||
from pythonbpf import bpf, map, section, bpfglobal, BPF
|
||||
from pythonbpf.helpers import pid
|
||||
from pythonbpf.helper import pid
|
||||
from pythonbpf.maps import HashMap
|
||||
from pylibbpf import *
|
||||
from ctypes import c_void_p, c_int64, c_uint64, c_int32
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
|
||||
# This program attaches an eBPF tracepoint to sys_enter_clone,
|
||||
# counts per-PID clone syscalls, stores them in a hash map,
|
||||
# and then plots the distribution as a histogram using matplotlib.
|
||||
@ -76,6 +77,7 @@ import matplotlib.pyplot as plt
|
||||
def hist() -> HashMap:
|
||||
return HashMap(key=c_int32, value=c_uint64, max_entries=4096)
|
||||
|
||||
|
||||
@bpf
|
||||
@section("tracepoint/syscalls/sys_enter_clone")
|
||||
def hello(ctx: c_void_p) -> c_int64:
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
from pythonbpf import bpf, map, section, bpfglobal, compile
|
||||
from pythonbpf.helpers import ktime
|
||||
from pythonbpf.helper import ktime
|
||||
from pythonbpf.maps import HashMap
|
||||
|
||||
from ctypes import c_void_p, c_int64, c_uint64
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
from pythonbpf import bpf, map, section, bpfglobal, compile
|
||||
from pythonbpf.helpers import ktime
|
||||
from pythonbpf.helper import ktime
|
||||
from pythonbpf.maps import HashMap
|
||||
|
||||
from ctypes import c_void_p, c_int32, c_uint64
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
"import time\n",
|
||||
"\n",
|
||||
"from pythonbpf import bpf, map, section, bpfglobal, BPF\n",
|
||||
"from pythonbpf.helpers import pid\n",
|
||||
"from pythonbpf.helper import pid\n",
|
||||
"from pythonbpf.maps import HashMap\n",
|
||||
"from pylibbpf import *\n",
|
||||
"from ctypes import c_void_p, c_int64, c_uint64, c_int32\n",
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import time
|
||||
|
||||
from pythonbpf import bpf, map, section, bpfglobal, BPF
|
||||
from pythonbpf.helpers import pid
|
||||
from pythonbpf.helper import pid
|
||||
from pythonbpf.maps import HashMap
|
||||
from pylibbpf import BpfMap
|
||||
from ctypes import c_void_p, c_int64, c_uint64, c_int32
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
from pythonbpf import bpf, map, struct, section, bpfglobal, compile
|
||||
from pythonbpf.helpers import ktime, pid
|
||||
from pythonbpf.helper import ktime, pid
|
||||
from pythonbpf.maps import PerfEventArray
|
||||
|
||||
from ctypes import c_void_p, c_int32, c_uint64
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
from pythonbpf import bpf, map, section, bpfglobal, compile
|
||||
from pythonbpf.helpers import ktime
|
||||
from pythonbpf.helper import ktime
|
||||
from pythonbpf.maps import HashMap
|
||||
|
||||
from ctypes import c_void_p, c_int64, c_uint64
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
from pythonbpf import bpf, map, section, bpfglobal, compile
|
||||
from pythonbpf.helpers import XDP_PASS
|
||||
from pythonbpf.helper import XDP_PASS
|
||||
from pythonbpf.maps import HashMap
|
||||
|
||||
from ctypes import c_void_p, c_int64
|
||||
|
||||
@ -1,4 +1,13 @@
|
||||
from .helper_utils import HelperHandlerRegistry
|
||||
from .bpf_helper_handler import handle_helper_call
|
||||
from .helpers import ktime, pid, deref, XDP_DROP, XDP_PASS
|
||||
|
||||
__all__ = ["HelperHandlerRegistry", "handle_helper_call"]
|
||||
__all__ = [
|
||||
"HelperHandlerRegistry",
|
||||
"handle_helper_call",
|
||||
"ktime",
|
||||
"pid",
|
||||
"deref",
|
||||
"XDP_DROP",
|
||||
"XDP_PASS",
|
||||
]
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
from pythonbpf import bpf, map, section, bpfglobal, compile
|
||||
from pythonbpf.helpers import XDP_PASS
|
||||
from pythonbpf.helper import XDP_PASS
|
||||
from pythonbpf.maps import HashMap
|
||||
|
||||
from ctypes import c_void_p, c_int64
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
from pythonbpf import bpf, map, struct, section, bpfglobal, compile, compile_to_ir, BPF
|
||||
from pythonbpf.helpers import ktime, pid
|
||||
from pythonbpf.helper import ktime, pid
|
||||
from pythonbpf.maps import PerfEventArray
|
||||
|
||||
from ctypes import c_void_p, c_int32, c_uint64
|
||||
|
||||
Reference in New Issue
Block a user