Conversation
| struct bpf_probes *p; | ||
| struct ring_buffer_opts ringbuf_opts; | ||
| int cgroup_fd, i, off, ringbuf_fd; | ||
| char *cgroup_unmount; |
| } | ||
|
|
||
| /* | ||
| * No cgroup2 mount found, try mountint it ourselves at |
Contributor
There was a problem hiding this comment.
Suggested change
| * No cgroup2 mount found, try mountint it ourselves at | |
| * No cgroup2 mount found, try to mount it ourselves at |
| char template[] = "/tmp/quark_cgroup2_mount.XXXXXX"; | ||
|
|
||
| if ((path = mkdtemp(template)) == NULL) { | ||
| qwarn("mktemp %s", template); |
Contributor
There was a problem hiding this comment.
Suggested change
| qwarn("mktemp %s", template); | |
| qwarn("mkdtemp %s", template); |
| goto fail; | ||
| } | ||
|
|
||
| *unmount_path = strdup(path); |
Contributor
There was a problem hiding this comment.
we check for strdup failures on line 585. should make them consistent. if it fails (and all other code miraculously works) we will fail to umount the custom cgroup2 mount.
Collaborator
Author
There was a problem hiding this comment.
I thought about it, it would basically just leave it dangling, while in practice that strdup will never fail, so I just ignored. I can add some print at least
f0135e8 to
148ea2e
Compare
nicholasberlin
approved these changes
Sep 24, 2025
| free(path); | ||
| if (fd != -1) | ||
| close(fd); | ||
| cgroup2_umount_tmp(umount_path); |
This looks up the path for cgroup2, in case it's not in /sys/fs/cgroup, but more importantly, it makes sure /sys/fs/cgroup is a cgroup2, and if not, it attempts to mount a temporary cgroup2 for loading the DNS probes. On some systems, cgroup2 is not mounted by default, even though the kernel supports it. For DNS and/or every future cgroup probe to function, we need to fetch the cgroup mounting point pass it to bpf_probes__load(). After that the fd is not really needed, we can close and also unmount the temporary cgroup2 mount we might have created. Idea from Nick.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
his looks up the path for cgroup2, in case it's not in /sys/fs/cgroup, but more
importantly, it makes sure /sys/fs/cgroup is a cgroup2, and if not, it attempts
to mount a temporary cgroup2 for loading the DNS probes.
On some systems, cgroup2 is not mounted by default, even though the kernel
supports it.
For DNS and/or every future cgroup probe to function, we need to fetch the
cgroup mounting point pass it to bpf_probes__load(). After that the fd is not
really needed, we can close and also unmount the temporary cgroup2 mount we
might have created.
Idea from Nick.