Skip to content

Commit 627ee92

Browse files
fix: Hashmap type check
1 parent 1bbf004 commit 627ee92

4 files changed

Lines changed: 18 additions & 4 deletions

File tree

examples/c-form/ex2.bpf.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
#include <linux/bpf.h>
22
#include <bpf/bpf_helpers.h>
3+
#define u64 unsigned long long
4+
5+
struct {
6+
__uint(type, BPF_MAP_TYPE_HASH);
7+
__uint(max_entries, 1);
8+
__type(key, u64);
9+
__type(value, u64);
10+
} last SEC(".maps");
311

412
SEC("tracepoint/syscalls/sys_enter_execve")
513
int hello(struct pt_regs *ctx) {

examples/execve2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from pythonbpf.decorators import bpf, bpfglobal, section
2-
from ctypes import c_void_p, c_int64, c_int32
2+
from ctypes import c_void_p, c_int64, c_int32, c_uint64
33
from pythonbpf.helpers import bpf_ktime_get_ns
4+
from pythonbpf.maps import HashMap
45

56

67
@bpf

pythonbpf/functions_pass.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ def process_bpf_chunk(func_node, module, return_type):
5656

5757
func_name = func_node.name
5858

59-
# TODO: The function actual arg retgurn type is parsed,
60-
# but the actual output is not. It's still very wrong. Try uncommenting the
61-
# code in execve2.py once
6259
ret_type = return_type
6360

6461
# TODO: parse parameters

pythonbpf/maps.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class HashMap:
2+
def __init__(self, key_type, value_type, max_entries):
3+
self.key_type = key_type
4+
self.value_type = value_type
5+
self.max_entries = max_entries
6+
self.entries = {}
7+
8+
# add other supported map functions here

0 commit comments

Comments
 (0)