From ecb277469439db526a86d9b08e2a96a304312fe6 Mon Sep 17 00:00:00 2001 From: Pragyansh Chaturvedi Date: Fri, 7 Aug 2026 16:55:39 +0530 Subject: [PATCH] Tests: Declare the ringbuf map with its real type and a legal size The map was declared as RingBuf, which is not an exported name -- the class is RingBuffer. maps_pass has no processor registered under RingBuf, so it fell through to the 'unknown map type, defaulting to HashMap' path and was emitted as BPF_MAP_TYPE_HASH with no key or value size. The kernel rejected it: libbpf: map 'mymap': found type = 1. libbpf: map 'mymap': failed to create: -EINVAL Nothing caught this earlier because the test framework compiles the file's AST and never imports it, so the bogus 'from pythonbpf.maps import RingBuf' never raised ImportError. Using the real name also subjects the map to process_ringbuf_map's validation, which max_entries=1024 does not survive: a ringbuf needs a power of two at least as large as the page size. Raised to 4096. libbpf now reports type = 27 with max_entries = 4096. Co-Authored-By: Claude Opus 5 (1M context) --- tests/passing_tests/ringbuf.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/passing_tests/ringbuf.py b/tests/passing_tests/ringbuf.py index 0566d85..05652cf 100644 --- a/tests/passing_tests/ringbuf.py +++ b/tests/passing_tests/ringbuf.py @@ -1,13 +1,13 @@ from pythonbpf import bpf, BPF, map, bpfglobal, section, compile, compile_to_ir -from pythonbpf.maps import RingBuf, HashMap +from pythonbpf.maps import RingBuffer, HashMap from ctypes import c_int32, c_void_p # Define a map @bpf @map -def mymap() -> RingBuf: - return RingBuf(max_entries=(1024)) +def mymap() -> RingBuffer: + return RingBuffer(max_entries=4096) @bpf