Skip to content
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

Merged
merged 1 commit into from
Mar 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions nodeup/pkg/model/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,11 @@ func (b *NetworkBuilder) Build(c *fi.ModelBuilderContext) error {
return fmt.Errorf("error checking for /sys/fs/bpf: %v", err)
}

// systemd v238 includes the bpffs mount by default; and gives an error "has a bad unit file setting" if we try to mount it again (see mount_point_is_api)
var alreadyMounted bool
// bpffs magic number. See https://github.com/torvalds/linux/blob/v4.8/include/uapi/linux/magic.h#L80
magic := uint32(0xCAFE4A11)
// equivalent to unix.BPF_FS_MAGIC in golang.org/x/sys/unix
BPF_FS_MAGIC := uint32(0xcafe4a11)

alreadyMounted = int32(magic) == int32(fsdata.Type)
// systemd v238 includes the bpffs mount by default; and gives an error "has a bad unit file setting" if we try to mount it again (see mount_point_is_api)
alreadyMounted := uint32(fsdata.Type) == BPF_FS_MAGIC

if !alreadyMounted {
unit := s(`
Expand Down