summaryrefslogtreecommitdiffstats
path: root/src/shared/bpf-program.h
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2023-04-16 09:14:49 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-04-18 01:23:55 +0200
commit25d9c6cdaf82d3f627db92b69f3be3e2a68e06fa (patch)
tree3a699e9bf78703bd7471a6fcda4d277411e03d5d /src/shared/bpf-program.h
parentprocess-util: be more careful with pidfd_get_pid() special cases (diff)
downloadsystemd-25d9c6cdaf82d3f627db92b69f3be3e2a68e06fa.tar.xz
systemd-25d9c6cdaf82d3f627db92b69f3be3e2a68e06fa.zip
bpf-firewall: give a name to maps used
Running systemd with IP accounting enabled generates many bpf maps (two per unit for accounting, another two if IPAddressAllow/Deny are used). Systemd itself knows which maps belong to what unit and commands like `systemctl status <unit>` can be used to query what service has which map, but monitoring these values all the time costs 4 dbus requests (calling the .IP{E,I}gress{Bytes,Packets} method for each unit) and makes services like the prometheus systemd_exporter[1] somewhat slow when doing that for every units, while less precise information could quickly be obtained by looking directly at the maps. Unfortunately, bpf map names are rather limited: - only 15 characters in length (16, but last byte must be 0) - only allows isalnum(), _ and . characters If it wasn't for the length limit we could use the normal unit escape functions but I've opted to just make any forbidden character into underscores for maximum brievty -- the map prefix is also rather short: This isn't meant as a precise mapping, but as a hint for admins who want to look at these. (Note there is no problem if multiple maps have the same name) Link: https://github.com/povilasv/systemd_exporter [1]
Diffstat (limited to 'src/shared/bpf-program.h')
-rw-r--r--src/shared/bpf-program.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/shared/bpf-program.h b/src/shared/bpf-program.h
index b640fb9d9f..0e0b666df6 100644
--- a/src/shared/bpf-program.h
+++ b/src/shared/bpf-program.h
@@ -54,7 +54,8 @@ int bpf_program_deserialize_attachment_set(const char *v, FDSet *fds, Set **bpfs
extern const struct hash_ops bpf_program_hash_ops;
-int bpf_map_new(enum bpf_map_type type, size_t key_size, size_t value_size, size_t max_entries, uint32_t flags);
+int bpf_map_new(const char *name, enum bpf_map_type type, size_t key_size, size_t value_size,
+ size_t max_entries, uint32_t flags);
int bpf_map_update_element(int fd, const void *key, void *value);
int bpf_map_lookup_element(int fd, const void *key, void *value);