Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/pybpf3.py → examples/binops_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

# Instructions to how to run this program
# 1. Install PythonBPF: pip install pythonbpf
# 2. Run the program: python demo/pybpf3.py
# 3. Run the program with sudo: sudo examples/check.sh run demo/pybpf3.o
# 2. Run the program: python examples/binops_demo.py
# 3. Run the program with sudo: sudo tools/check.sh run examples/binops_demo.py
# 4. Start up any program and watch the output

@bpf
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/pybpf4.py → examples/clone_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# and then plots the distribution as a histogram using matplotlib.
# It provides a quick view of process creation activity over 10 seconds.
# Everything is done with Python only code and with the new pylibbpf library.
# Run `sudo /path/to/python/binary/ pybpf4.py`
# Run `sudo /path/to/python/binary/ clone_plot.py`

@bpf
@map
Expand Down
35 changes: 0 additions & 35 deletions examples/execve2.py

This file was deleted.

45 changes: 0 additions & 45 deletions examples/execve3.py

This file was deleted.

15 changes: 10 additions & 5 deletions examples/pybpf0.py → examples/hello_world.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from pythonbpf import bpf, section, bpfglobal, compile

from pythonbpf import bpf, section, bpfglobal, compile, BPF
from ctypes import c_void_p, c_int64

# Instructions to how to run this program
# 1. Install PythonBPF: pip install pythonbpf
# 2. Run the program: python demo/pybpf0.py
# 3. Run the program with sudo: sudo examples/check.sh run demo/pybpf0.o
# 2. Run the program: sudo python examples/hello_world.py
# 4. Start up any program and watch the output


Expand All @@ -20,4 +18,11 @@ def hello_world(ctx: c_void_p) -> c_int64:
def LICENSE() -> str:
return "GPL"

compile()
b = BPF()
b.load_and_attach()
if b.is_loaded() and b.is_attached():
print("Successfully loaded and attached")
else:
print("Could not load successfully")

# Now cat /sys/kernel/debug/tracing/trace_pipe to see results of the execve syscall.
File renamed without changes.
4 changes: 2 additions & 2 deletions examples/pybpf2.py → examples/sys_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

# Instructions to how to run this program
# 1. Install PythonBPF: pip install pythonbpf
# 2. Run the program: python demo/pybpf2.py
# 3. Run the program with sudo: sudo examples/check.sh run demo/pybpf2.o
# 2. Run the program: python examples/sys_sync.py
# 3. Run the program with sudo: sudo tools/check.sh run examples/sys_sync.o
# 4. Start a Python repl and `import os` and then keep entering `os.sync()` to see reponses.

@bpf
Expand Down
6 changes: 3 additions & 3 deletions examples/pybpf1.py → examples/xdp_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

# Instructions to how to run this program
# 1. Install PythonBPF: pip install pythonbpf
# 2. Run the program: python demo/pybpf1.py
# 3. Run the program with sudo: sudo examples/check.sh run demo/pybpf1.o
# 4. Attach object file to any network device with something like ./check.sh xdp ../demo/pybpf1.o tailscale0
# 2. Run the program: python examples/xdp_pass.py
# 3. Run the program with sudo: sudo tools/check.sh run examples/xdp_pass.o
# 4. Attach object file to any network device with something like ./check.sh xdp examples/xdp_pass.o tailscale0
# 5. send traffic through the device and observe effects

@bpf
Expand Down
2 changes: 2 additions & 0 deletions pythonbpf/bpf_helper_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ def bpf_printk_emitter(call, map_ptr, module, builder, func, local_sym_tab=None,

builder.call(fn_ptr, [fmt_ptr, ir.Constant(
ir.IntType(32), len(fmt_str))], tail=True)
return None


def bpf_map_update_elem_emitter(call, map_ptr, module, builder, func, local_sym_tab=None, struct_sym_tab=None, local_var_metadata=None):
Expand Down Expand Up @@ -496,3 +497,4 @@ def handle_helper_call(call, module, builder, func, local_sym_tab=None, map_sym_
else:
raise NotImplementedError(
"Attribute not supported for map method calls.")
return None
54 changes: 0 additions & 54 deletions pythonbpf/trace.py

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 0 additions & 20 deletions tools/compile.py

This file was deleted.