Skip to content

Commit

Permalink
modified self.max_entries to be available from all the MAP types
Browse files Browse the repository at this point in the history
This commit introduces the self.max_entries attribute both into Queue/Stack maps and to all those whwqo extend TableBase

Signed-off-by: Simone Magnani <[email protected]>
  • Loading branch information
smagnani96 authored and yonghong-song committed Apr 29, 2021
1 parent 226816d commit 8034be6
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/python/bcc/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ def __init__(self, bpf, map_id, map_fd, keytype, leaftype, name=None):
self.flags = lib.bpf_table_flags_id(self.bpf.module, self.map_id)
self._cbs = {}
self._name = name
self.max_entries = int(lib.bpf_table_max_entries_id(self.bpf.module,
self.map_id))

def get_fd(self):
return self.map_fd
Expand Down Expand Up @@ -670,9 +672,7 @@ def print_linear_hist(self, val_type="value", section_header="Bucket ptr",
class HashTable(TableBase):
def __init__(self, *args, **kwargs):
super(HashTable, self).__init__(*args, **kwargs)
self.max_entries = int(lib.bpf_table_max_entries_id(self.bpf.module,
self.map_id))


def __len__(self):
i = 0
for k in self: i += 1
Expand All @@ -685,9 +685,7 @@ def __init__(self, *args, **kwargs):
class ArrayBase(TableBase):
def __init__(self, *args, **kwargs):
super(ArrayBase, self).__init__(*args, **kwargs)
self.max_entries = int(lib.bpf_table_max_entries_id(self.bpf.module,
self.map_id))


def _normalize_key(self, key):
if isinstance(key, int):
if key < 0:
Expand Down

0 comments on commit 8034be6

Please sign in to comment.