-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Use BPF_FS_MAGIC from go sys lib instead of hardcode #8650
Conversation
fc8e319
to
d03c4a3
Compare
Ref. #8599 /cc @rifelpet @olemarkus |
@odinuge: GitHub didn't allow me to request PR reviews from the following users: olemarkus. Note that only kubernetes members and repo collaborators can review this PR, and authors cannot review their own PRs. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
I wanted to suggest using BPF_FS_MAGIC instead of the hardcoded value, but bumped into this on mac, same as you see in the failed CI run. The idea itself is good, converting to
|
Hmm. So CI runs on darwin as well.. The code is compiled with Since the code (nodeup) is linux only the best would be to add |
5cf099c
to
aaaf2df
Compare
2ec231a
to
c5c3619
Compare
I totally agree that the conversion part should be fixed. I would propose to only do the the conversion part and leave the hardcoded value for now. |
0xCAFE4A11 is bigger than the max of int32, so doing int32(uint32(0xCAFE4A11)) (will not compile directly unless done over two lines) will result in 0x-3501b5ef. For linux/amd64 "fsdata.Type" is an int64, while on darwin/amd64 it is an uint32. This code is however not supposed to be compiled for darwin, since it is linux spesific. Due to some strange errors[0] in the types in "unix.Statfs_t" for 32 bits systems on linux, we have to explicitly convert to uint to support those (eg. armv7). If we only need support for 64 bit systems, we can remove the uint conversion. [0]: For 32bits systems "fsdata.Type" should be uint32 instead of the current int32, as it is in the linux kernel. This is due to the types in glibc that the go types are generated from. For 64 bit systems the type is correctly set to int64.
I guess that is ok. Updated the PR now 😄 The Making this "linux-only-code" mac and windows "firendly" may cause some gains, but I also think it can lead to some strange bugs when developers on darwin/windows compile the code for their platform, when it wouldn't properly run there anyways. To avoid regression i do think this deserve some testing, and without fixing the compilation issues, that wouln't be possible (since bpf is linux only). |
Thanks :). |
looks good, thanks! |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: odinuge, rifelpet The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This also avoids overflow during conversion. 0xCAFE4A11 is bigger than
the max of int32, so doing int32(uint32(0xCAFE4A11)) (will not compile
directly unless done over two lines) will result in -0x3501b5ef.
Due to some strange errors[0] in the types in "unix.Statfs_t" for 32 bits
systems, we have to explicitly convert to uint to support those (eg.
armv7). If we only need support for 64 bit systems, we can remove the
uint conversion as well.
[0]: For 32bits systems "fsdata.Type" should be uint32 instead of the
current int32, as it is in the linux kernel. This is due to the types in
glibc that the go types are generated from. For 64 bit systems the type
is correctly set to int64.