Skip to content

Commit

Permalink
Cache function handles in BPF class
Browse files Browse the repository at this point in the history
* This means repeated calls to get_func() are now allowed

Signed-off-by: Brenden Blanco <[email protected]>
  • Loading branch information
Brenden Blanco committed Jul 21, 2015
1 parent 5e41494 commit 53d45da
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/python/bpf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ def __init__(self, src_file="", hdr_file="", text=None, debug=0):
raise Exception("Failed to compile BPF module %s" % src_file)

def load_func(self, func_name, prog_type):
if func_name in self.funcs:
return self.funcs[func_name]

if lib.bpf_function_start(self.module, func_name.encode("ascii")) == None:
raise Exception("Unknown program %s" % func_name)

Expand Down

0 comments on commit 53d45da

Please sign in to comment.