summaryrefslogtreecommitdiffstats
path: root/src/shared
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2024-09-17 12:15:12 +0200
committerGitHub <noreply@github.com>2024-09-17 12:15:12 +0200
commita7afe5a3e7723080fa79b5bba9b015a2f7246570 (patch)
treec43d0c2d73db1340badba32689b2f370b6965be6 /src/shared
parentdocs: fix typo in filename: REATLIME -> REALTIME (diff)
parentnetwork: drop unnecessary BPF related objects from Manager when disabled (diff)
downloadsystemd-a7afe5a3e7723080fa79b5bba9b015a2f7246570.tar.xz
systemd-a7afe5a3e7723080fa79b5bba9b015a2f7246570.zip
Merge pull request #34443 from yuwata/network-sysctl-monitor-follow-ups
network/sysctl-monitor: several follow-ups and cleanups
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/bpf-link.c9
-rw-r--r--src/shared/bpf-link.h5
2 files changed, 12 insertions, 2 deletions
diff --git a/src/shared/bpf-link.c b/src/shared/bpf-link.c
index 77f6a4ee9a..c83ebd4804 100644
--- a/src/shared/bpf-link.c
+++ b/src/shared/bpf-link.c
@@ -31,7 +31,7 @@ int bpf_serialize_link(FILE *f, FDSet *fds, const char *key, struct bpf_link *li
return serialize_fd(f, fds, key, sym_bpf_link__fd(link));
}
-struct bpf_link *bpf_link_free(struct bpf_link *link) {
+struct bpf_link* bpf_link_free(struct bpf_link *link) {
/* If libbpf wasn't dlopen()ed, sym_bpf_link__destroy might be unresolved (NULL), so let's not try to
* call it if link is NULL. link might also be a non-null "error pointer", but such a value can only
* originate from a call to libbpf, but that means that libbpf is available, and we can let
@@ -41,3 +41,10 @@ struct bpf_link *bpf_link_free(struct bpf_link *link) {
return NULL;
}
+
+struct ring_buffer* bpf_ring_buffer_free(struct ring_buffer *rb) {
+ if (rb) /* See the comment in bpf_link_free(). */
+ sym_ring_buffer__free(rb);
+
+ return NULL;
+}
diff --git a/src/shared/bpf-link.h b/src/shared/bpf-link.h
index 38aa080862..c66bf38eae 100644
--- a/src/shared/bpf-link.h
+++ b/src/shared/bpf-link.h
@@ -12,5 +12,8 @@ bool bpf_can_link_program(struct bpf_program *prog);
int bpf_serialize_link(FILE *f, FDSet *fds, const char *key, struct bpf_link *link);
-struct bpf_link *bpf_link_free(struct bpf_link *p);
+struct bpf_link* bpf_link_free(struct bpf_link *p);
DEFINE_TRIVIAL_CLEANUP_FUNC(struct bpf_link *, bpf_link_free);
+
+struct ring_buffer* bpf_ring_buffer_free(struct ring_buffer *rb);
+DEFINE_TRIVIAL_CLEANUP_FUNC(struct ring_buffer *, bpf_ring_buffer_free);