Commit 64258256 authored by Zaafar Ahmed's avatar Zaafar Ahmed

optimised the percpu support patch.

removed kernel checks.
parent b0e40388
......@@ -571,11 +571,9 @@ bool BTypeVisitor::VisitVarDecl(VarDecl *Decl) {
} else if (A->getName() == "maps/array") {
map_type = BPF_MAP_TYPE_ARRAY;
} else if (A->getName() == "maps/pc_hash") {
if (KERNEL_VERSION(major,minor,0) >= KERNEL_VERSION(4,5,0))
map_type = BPF_MAP_TYPE_PERCPU_HASH;
map_type = BPF_MAP_TYPE_PERCPU_HASH;
} else if (A->getName() == "maps/pc_array") {
if (KERNEL_VERSION(major,minor,0) >= KERNEL_VERSION(4,5,0))
map_type = BPF_MAP_TYPE_PERCPU_ARRAY;
map_type = BPF_MAP_TYPE_PERCPU_ARRAY;
} else if (A->getName() == "maps/histogram") {
if (table.key_desc == "\"int\"")
map_type = BPF_MAP_TYPE_ARRAY;
......
......@@ -228,7 +228,7 @@ class BPF(object):
cls = type(str(desc[0]), (base,), dict(_fields_=fields))
return cls
def get_table(self, name, keytype=None, leaftype=None, func_reducer=None):
def get_table(self, name, keytype=None, leaftype=None, reducer=None):
map_id = lib.bpf_table_id(self.module, name.encode("ascii"))
map_fd = lib.bpf_table_fd(self.module, name.encode("ascii"))
if map_fd < 0:
......@@ -243,7 +243,7 @@ class BPF(object):
if not leaf_desc:
raise Exception("Failed to load BPF Table %s leaf desc" % name)
leaftype = BPF._decode_table_type(json.loads(leaf_desc.decode()))
return Table(self, map_id, map_fd, keytype, leaftype, func_reducer)
return Table(self, map_id, map_fd, keytype, leaftype, reducer=reducer)
def __getitem__(self, key):
if key not in self.tables:
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment