mirror of
https://github.com/xdp-project/bpf-examples.git
synced 2024-05-06 15:54:53 +00:00
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:
@@ -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
|
||||
*/
|
||||
|
@@ -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] = {};
|
||||
|
Reference in New Issue
Block a user