Skip to content

Commit 2582ecf

Browse files
author
Brenden Blanco
committed
Add testing for scanf/printf in python, deprecate table_update
Signed-off-by: Brenden Blanco <bblanco@plumgrid.com>
1 parent f8ee5bf commit 2582ecf

7 files changed

Lines changed: 153 additions & 151 deletions

File tree

src/cc/bpf_common.cc

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ size_t bpf_num_tables(void *program) {
104104
return mod->num_tables();
105105
}
106106

107+
size_t bpf_table_id(void *program, const char *table_name) {
108+
auto mod = static_cast<ebpf::BPFModule *>(program);
109+
if (!mod) return ~0ull;
110+
return mod->table_id(table_name);
111+
}
112+
107113
int bpf_table_fd(void *program, const char *table_name) {
108114
auto mod = static_cast<ebpf::BPFModule *>(program);
109115
if (!mod) return -1;
@@ -170,38 +176,26 @@ size_t bpf_table_leaf_size_id(void *program, size_t id) {
170176
return mod->table_leaf_size(id);
171177
}
172178

173-
int bpf_table_update(void *program, const char *table_name, const char *key, const char *leaf) {
174-
auto mod = static_cast<ebpf::BPFModule *>(program);
175-
if (!mod) return 0;
176-
return mod->table_update(table_name, key, leaf);
177-
}
178-
179-
int bpf_table_update_id(void *program, size_t id, const char *key, const char *leaf) {
180-
auto mod = static_cast<ebpf::BPFModule *>(program);
181-
if (!mod) return 0;
182-
return mod->table_update(id, key, leaf);
183-
}
184-
185179
int bpf_table_key_snprintf(void *program, size_t id, char *buf, size_t buflen, const void *key) {
186180
auto mod = static_cast<ebpf::BPFModule *>(program);
187-
if (!mod) return 0;
181+
if (!mod) return -1;
188182
return mod->table_key_printf(id, buf, buflen, key);
189183
}
190184
int bpf_table_leaf_snprintf(void *program, size_t id, char *buf, size_t buflen, const void *leaf) {
191185
auto mod = static_cast<ebpf::BPFModule *>(program);
192-
if (!mod) return 0;
193-
return mod->table_key_printf(id, buf, buflen, leaf);
186+
if (!mod) return -1;
187+
return mod->table_leaf_printf(id, buf, buflen, leaf);
194188
}
195189

196190
int bpf_table_key_sscanf(void *program, size_t id, const char *buf, void *key) {
197191
auto mod = static_cast<ebpf::BPFModule *>(program);
198-
if (!mod) return 0;
192+
if (!mod) return -1;
199193
return mod->table_key_scanf(id, buf, key);
200194
}
201195
int bpf_table_leaf_sscanf(void *program, size_t id, const char *buf, void *leaf) {
202196
auto mod = static_cast<ebpf::BPFModule *>(program);
203-
if (!mod) return 0;
204-
return mod->table_key_scanf(id, buf, leaf);
197+
if (!mod) return -1;
198+
return mod->table_leaf_scanf(id, buf, leaf);
205199
}
206200

207201
}

src/cc/bpf_common.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ void * bpf_function_start(void *program, const char *name);
3737
size_t bpf_function_size_id(void *program, size_t id);
3838
size_t bpf_function_size(void *program, const char *name);
3939
size_t bpf_num_tables(void *program);
40+
size_t bpf_table_id(void *program, const char *table_name);
4041
int bpf_table_fd(void *program, const char *table_name);
4142
int bpf_table_fd_id(void *program, size_t id);
4243
const char * bpf_table_name(void *program, size_t id);
@@ -52,8 +53,6 @@ int bpf_table_key_snprintf(void *program, size_t id, char *buf, size_t buflen, c
5253
int bpf_table_leaf_snprintf(void *program, size_t id, char *buf, size_t buflen, const void *leaf);
5354
int bpf_table_key_sscanf(void *program, size_t id, const char *buf, void *key);
5455
int bpf_table_leaf_sscanf(void *program, size_t id, const char *buf, void *leaf);
55-
int bpf_table_update(void *program, const char *table_name, const char *key, const char *leaf);
56-
int bpf_table_update_id(void *program, size_t id, const char *key, const char *leaf);
5756

5857
#ifdef __cplusplus
5958
}

0 commit comments

Comments
 (0)