Skip to main content

Pybpfmaps

Simple standalone python library to interact with bpf/ebpf maps via libbpf bindings.

This project aims to ease communication with eBPF programs using eBPF maps.

Installation

pip install bpfmaps

No need for any other dependencies, because the libbpf binary is built from source inside the github action and included in the python package. You can verify its authenticity by comparing the hashes of the pypi package with the ones printed in the github action that released it.

Usage

import bpfmaps

my_map = bpfmaps.BPF_Map.get_map_by_name('some_global')
my_map[0] = 10

Contributing

Dependencies

To locally work on this project you need to get the libbpf binary and put it into src/bpfmaps/libbpf/

This can be done by extracting it from the pypi package or building from source:

git clone --recurse-submodules git@github.com:PeterStolz/pybpfmaps.git
cd pybpfmaps/dependencies/libbpf/src
OBJDIR=../../../src/bpfmaps/libbpf/ make
cd ../../../

To install the build dependencies you may run:

sudo apt-get update
sudo apt-get install clang llvm libelf-dev libpcap-dev gcc-multilib build-essential linux-libc-dev

Testing

This project uses pytest for testing and the tests for x.py are stored in the file test_x.py. As working with eBPF maps requires root you can execute the tests with:

sudo python3.10 -m pytest ./src

The tests may leave some bpf maps lying around, but they will perish after a reboot.

Metadata

Release files for bpfmaps 0.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bpfmaps 0.0.8
File Size Uploaded
bpfmaps-0.0.8.tar.gz 706.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bpfmaps 0.0.8
File Interpreter ABI Platform
bpfmaps-0.0.8-py3-none-any.whl Python 3 none any Details

Total release size: 1.4 MB

Release files / bpfmaps-0.0.8.tar.gz

Download URL bpfmaps-0.0.8.tar.gz
Size 706.5 kB
Tags Source
SHA-256 checksum
How to use checksums
aa61f0973a96cef3696aed8cc6fea7207cdfcc70017931e7424bc758faf46593
BLAKE2b-256 checksum
How to use checksums
7e39cbcaaa4885eba33159b4e7b2e1ad1ba4cda4aa00684556795c51ca08e253
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / bpfmaps-0.0.8-py3-none-any.whl

Download URL bpfmaps-0.0.8-py3-none-any.whl
Size 709.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9708cab27030cdfb25e0250cdc4417ddfe7570613ca521d1b0d59dc224f70032
BLAKE2b-256 checksum
How to use checksums
5b45872f8c511e43e9f13d61d347e3ef7a3748c3bcb1615bdc26900a50d7765d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release history Release notifications | RSS feed

This release

0.0.8 This release

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page