Skip to content

Commit

Permalink
Merge pull request iovisor#390 from iovisor/tables_cleanup
Browse files Browse the repository at this point in the history
Cleanup tables classes in bcc python module
  • Loading branch information
4ast committed Feb 17, 2016
2 parents 5e3ccf0 + f7767b5 commit fe03606
Show file tree
Hide file tree
Showing 11 changed files with 544 additions and 364 deletions.
12 changes: 12 additions & 0 deletions src/cc/bpf_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,18 @@ int bpf_table_type_id(void *program, size_t id) {
return mod->table_type(id);
}

size_t bpf_table_max_entries(void *program, const char *table_name) {
auto mod = static_cast<ebpf::BPFModule *>(program);
if (!mod) return 0;
return mod->table_max_entries(table_name);
}

size_t bpf_table_max_entries_id(void *program, size_t id) {
auto mod = static_cast<ebpf::BPFModule *>(program);
if (!mod) return 0;
return mod->table_max_entries(id);
}

const char * bpf_table_name(void *program, size_t id) {
auto mod = static_cast<ebpf::BPFModule *>(program);
if (!mod) return nullptr;
Expand Down
2 changes: 2 additions & 0 deletions src/cc/bpf_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ int bpf_table_fd(void *program, const char *table_name);
int bpf_table_fd_id(void *program, size_t id);
int bpf_table_type(void *program, const char *table_name);
int bpf_table_type_id(void *program, size_t id);
size_t bpf_table_max_entries(void *program, const char *table_name);
size_t bpf_table_max_entries_id(void *program, size_t id);
const char * bpf_table_name(void *program, size_t id);
const char * bpf_table_key_desc(void *program, const char *table_name);
const char * bpf_table_key_desc_id(void *program, size_t id);
Expand Down
9 changes: 9 additions & 0 deletions src/cc/bpf_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,15 @@ int BPFModule::table_type(size_t id) const {
return (*tables_)[id].type;
}

size_t BPFModule::table_max_entries(const string &name) const {
return table_max_entries(table_id(name));
}

size_t BPFModule::table_max_entries(size_t id) const {
if (id >= tables_->size()) return 0;
return (*tables_)[id].max_entries;
}

const char * BPFModule::table_name(size_t id) const {
if (id >= tables_->size()) return nullptr;
return (*tables_)[id].name.c_str();
Expand Down
2 changes: 2 additions & 0 deletions src/cc/bpf_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class BPFModule {
const char * table_name(size_t id) const;
int table_type(const std::string &name) const;
int table_type(size_t id) const;
size_t table_max_entries(const std::string &name) const;
size_t table_max_entries(size_t id) const;
const char * table_key_desc(size_t id) const;
const char * table_key_desc(const std::string &name) const;
size_t table_key_size(size_t id) const;
Expand Down
2 changes: 2 additions & 0 deletions src/python/MANIFEST
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# file GENERATED by distutils, do NOT edit
setup.py
bcc/__init__.py
bcc/table.py
bcc/libbcc.py
Loading

0 comments on commit fe03606

Please sign in to comment.