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 feature probes to detect kernel support for sockops #10941

Merged

Conversation

soumynathan
Copy link
Contributor

This patch probes the kernel for bpf sockops support and validates
the user configuration for SockopsEnable.

Fixes: #10931
Signed-off-by: Swaminathan Vasudevan svasudevan@suse.com

@soumynathan soumynathan requested a review from a team April 11, 2020 05:24
@soumynathan soumynathan requested a review from a team as a code owner April 11, 2020 05:24
@maintainer-s-little-helper

This comment has been minimized.

@maintainer-s-little-helper maintainer-s-little-helper bot added this to In progress in 1.8.0 Apr 11, 2020
@pchaigno pchaigno self-assigned this Apr 11, 2020
@pchaigno pchaigno added area/sockops release-note/misc This PR makes changes that have no direct user impact. labels Apr 11, 2020
Copy link
Member

@pchaigno pchaigno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @soumynathan for taking care of this!

daemon/cmd/daemon.go Outdated Show resolved Hide resolved
daemon/cmd/daemon.go Outdated Show resolved Hide resolved
daemon/cmd/daemon_main.go Outdated Show resolved Hide resolved
daemon/cmd/daemon_main.go Outdated Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Apr 11, 2020

Coverage Status

Coverage decreased (-0.03%) to 44.776% when pulling 57c625b on soumynathan:detect-kernel-support-for-sockops into e7d4f5c on cilium:master.

@soumynathan soumynathan force-pushed the detect-kernel-support-for-sockops branch from d29d73d to d5f3543 Compare April 14, 2020 05:49
daemon/cmd/daemon.go Outdated Show resolved Hide resolved
@soumynathan soumynathan force-pushed the detect-kernel-support-for-sockops branch from d5f3543 to 175f622 Compare April 15, 2020 07:17
daemon/cmd/daemon.go Show resolved Hide resolved
@soumynathan soumynathan force-pushed the detect-kernel-support-for-sockops branch from 175f622 to 18085c1 Compare April 15, 2020 07:25
@tklauser
Copy link
Member

test-me-please

daemon/cmd/daemon_main.go Outdated Show resolved Hide resolved
daemon/cmd/daemon_main.go Show resolved Hide resolved
test/k8sT/DatapathConfiguration.go Outdated Show resolved Hide resolved
@soumynathan soumynathan force-pushed the detect-kernel-support-for-sockops branch from 18085c1 to cea62ad Compare April 16, 2020 02:47
daemon/cmd/daemon.go Outdated Show resolved Hide resolved
@soumynathan soumynathan force-pushed the detect-kernel-support-for-sockops branch 2 times, most recently from 4d16f3b to 165d149 Compare April 16, 2020 16:35
daemon/cmd/daemon.go Outdated Show resolved Hide resolved
@soumynathan soumynathan force-pushed the detect-kernel-support-for-sockops branch from 165d149 to 1c0d98c Compare April 20, 2020 17:51
@soumynathan soumynathan force-pushed the detect-kernel-support-for-sockops branch from 1c0d98c to 315ab0a Compare April 24, 2020 07:37
@aanm
Copy link
Member

aanm commented Apr 24, 2020

@soumynathan it seems a real failure:

    ./test/k8sT/... \
    ./tools/...
go: warning: "./hubble-proxy/..." matched no packages
# github.com/cilium/cilium/daemon/cmd
daemon/cmd/daemon_main.go:1463:5: too many arguments to return
	have (nil)
	want ()
# github.com/cilium/cilium/daemon/cmd
vet: daemon/cmd/daemon_main.go:1463:12: no result values expected
make[1]: *** [govet] Error 2
make[1]: Leaving directory `/home/travis/gopath/src/github.com/cilium/cilium'
make: *** [unit-tests] Error 2
The command "./.travis/build.sh" exited with 2.

if option.Config.SockopsEnable {
if h := probes.NewProbeManager().GetHelpers("sk_msg"); h != nil {
if _, ok := h["bpf_msg_redirect_hash"]; ok {
return nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return nil here might be the cause for the build error. Simply return should work?

Note: Instead of having all the code of that function if the if option.Config.SockopsEnable block, you could also return early if the option is not set and avoid indenting all the rest:

if !option.Config.SockopsEnable {
        return
}
if h := probes.NewProbeManager()...

It usually makes the code a bit easier to read, I find.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qmonnet The probe still needs to be fixed anyway ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok will fix it. @pchaigno is the probe fix that you mentioned above related to this patch or we need to handle it in a different PR>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to this patch. Please see #10941 (comment) and #10941 (comment).

This patch probes the kernel for bpf sockops support and validates
the user configuration for SockopsEnable.

Fixes: cilium#10931
Signed-off-by: Swaminathan Vasudevan <svasudevan@suse.com>
@soumynathan soumynathan force-pushed the detect-kernel-support-for-sockops branch from 315ab0a to 57c625b Compare April 28, 2020 02:49
@pchaigno
Copy link
Member

test-me-please

Copy link
Member

@pchaigno pchaigno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @soumynathan! LGTM!

@pchaigno pchaigno requested a review from qmonnet April 28, 2020 06:01
Copy link
Member

@qmonnet qmonnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks

Comment on lines +1460 to +1461
k := probes.NewProbeManager().GetHelpers("sock_ops")
h := probes.NewProbeManager().GetHelpers("sk_msg")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
k := probes.NewProbeManager().GetHelpers("sock_ops")
h := probes.NewProbeManager().GetHelpers("sk_msg")
pm := probes.NewProbeManager()
k := pm.GetHelpers("sock_ops")
h := pm.GetHelpers("sk_msg")

Not an issue because probe results are cached, but suggestion for next time: don't create more probe managers than necessary :)

@qmonnet qmonnet merged commit 43570d5 into cilium:master Apr 28, 2020
1.8.0 automation moved this from In progress to Merged Apr 28, 2020
@pchaigno pchaigno removed their assignment Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/misc This PR makes changes that have no direct user impact.
Projects
No open projects
1.8.0
  
Merged
Development

Successfully merging this pull request may close these issues.

Use feature probes to detect kernel support for sockops
6 participants