-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bugtool: get bpffs mountpoint from /proc/mounts #13342
bugtool: get bpffs mountpoint from /proc/mounts #13342
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thank you!
This won't be “tested” by the CI, I suppose you validated the change locally to make sure we still dump the maps as intended?
I'm just thinking: Although unlikely, we could have several bpffs mounted at different points. Would it be worth to try and list the maps under each of them in that case? |
Yes, I tested it both manually in the dev VMs as well as by crashing some e2e tests and looking at its dump in |
I wasn't aware of this possibility but yes, I agree that we should try list maps under each of the mounted bpffs 👍 |
You can mount multiple ones, but I don't think this is something Cilium would ever do. Just thinking that if for any reason users have mounted another bpffs, we would risk missing the correct one when dumping the maps. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
We already have a separate package for listing mounts (pkg/mountinfo
), I think it would be better to use it here.
bugtool/cmd/configuration.go
Outdated
@@ -39,6 +41,27 @@ func setupDefaultConfig(path string, k8sPods []string, confDir, cmdDir string) ( | |||
return &c, save(&c, path) | |||
} | |||
|
|||
func bpffsMountpoint() []string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have a separate module for listing mounts from /proc/self/mountinfo
(which contains more details than /proc/mounts
):
https://github.com/cilium/cilium/blob/master/pkg/mountinfo/mountinfo.go#L125-L135
The example of using it, also for checking BPFFS mount, is here:
https://github.com/cilium/cilium/blob/master/pkg/bpf/bpffs_linux.go#L69-L81
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mrostecki, I'll take a look at that package now
In cilium-agent we even return an explicit error if there are multiple BPFFS mounts: https://github.com/cilium/cilium/blob/master/pkg/bpf/bpffs_linux.go#L278-L284 |
It looks like we have a case of multiple bpf fs even in the dev VM: vagrant@k8s1:/sys/fs/bpf$ cat /proc/mounts | grep bpf
bpffs /sys/fs/bpf bpf rw,relatime 0 0
bpffs /sys/fs/bpf/xdp bpf rw,relatime 0 0
bpffs /sys/fs/bpf/ip bpf rw,relatime 0 0
bpffs /sys/fs/bpf/sk bpf rw,relatime 0 0
bpffs /sys/fs/bpf/sa bpf rw,relatime 0 0 and I'm slightly confused as edit: vagrant@k8s1:~/go/src/github.com/cilium/cilium/bugtool$ sudo ./cilium-bugtool
mountpoints: [/sys/fs/bpf /sys/fs/bpf/xdp /sys/fs/bpf/ip /sys/fs/bpf/sk /sys/fs/bpf/sa]
[..] |
iproute2 considers Hmm I wonder why this does not seem to be picked up by the check in |
@jibi We want to avoid multiple BPFFS mounts which have |
@qmonnet The last link I pasted is the reason why cilium-agent doesn't fail because of `/sys/fs/bpf´ subdirectories. ;) |
Thank you both @qmonnet and @mrostecki, I just learnt a bunch of new things :) In this case I think i will:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, please just add a comment so we can remember the logics here.
Rather then hardcoding the /sys/fs/bpf value in bugtool, use the `mountinfo` package (which exposes the information in /proc/self/mounts) to determine the correct mountpoint for the BPF filesystem. Fixes: #13218 Signed-off-by: Gilberto Bertin <gilberto@isovalent.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks!
Rather then hardcoding the /sys/fs/bpf value in bugtool, parse
/proc/mounts to determine the correct mountpoint for the BPF filesystem.
Fixes: #13218
Signed-off-by: Gilberto Bertin gilberto@isovalent.com