pkt-loop-filter: Set map size from userspace instead of in BPF definition

With this we can add a command line parameter to dynamically size the map
later.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
This commit is contained in:
Toke Høiland-Jørgensen
2022-06-14 17:41:41 +02:00
parent 60ed7a8e8b
commit 96a5c2ebbf
2 changed files with 7 additions and 1 deletions

View File

@@ -66,6 +66,12 @@ int main(int argc, char *argv[])
return err;
}
err = bpf_map__set_max_entries(skel->maps.iface_state, 1024);
if (err) {
fprintf(stderr, "Failed to set map size\n");
goto out;
}
/* Propagate active ifindexes to the BPF program global variables so the
* BPF program can use it to filter multicast traffic
*/

View File

@@ -40,7 +40,7 @@ struct {
__uint(type, BPF_MAP_TYPE_LRU_HASH);
__type(key, struct pkt_loop_key);
__type(value, struct pkt_loop_data);
__uint(max_entries, 16384);
__uint(max_entries, 1); /* set from userspace before load */
} iface_state SEC(".maps");
int active_ifindexes[MAX_IFINDEXES] = {};