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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 2 additions & 6 deletions daemon/cmd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,11 @@ func (d *Daemon) init() error {
}

if option.Config.SockopsEnable {
disableSockops := func(err error) {
option.Config.SockopsEnable = false
log.WithError(err).Warn("Disabled '--sockops-enable' due to missing BPF kernel support")
}
eppolicymap.CreateEPPolicyMap()
if err := sockops.SockmapEnable(); err != nil {
disableSockops(err)
log.WithError(err).Error("Failed to enable Sockmap")
} else if err := sockops.SkmsgEnable(); err != nil {
disableSockops(err)
log.WithError(err).Error("Failed to enable Sockmsg")
pchaigno marked this conversation as resolved.
Show resolved Hide resolved
} else {
sockmap.SockmapCreate()
}
Expand Down
16 changes: 16 additions & 0 deletions daemon/cmd/daemon_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,7 @@ func initEnv(cmd *cobra.Command) {
}

initKubeProxyReplacementOptions()
initSockmapOption()

// If device has been specified, use it to derive better default
// allocation prefixes
Expand Down Expand Up @@ -1451,6 +1452,21 @@ func (d *Daemon) instantiateAPI() *restapi.CiliumAPI {
return restAPI
}

func initSockmapOption() {
if !option.Config.SockopsEnable {
return
}
if probes.NewProbeManager().GetMapTypes().HaveSockhashMapType {
k := probes.NewProbeManager().GetHelpers("sock_ops")
h := probes.NewProbeManager().GetHelpers("sk_msg")
Comment on lines +1460 to +1461
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 :)

if h != nil && k != nil {
return
}
}
log.Warn("BPF Sock ops not supported by kernel. Disabling '--sockops-enable' feature.")
option.Config.SockopsEnable = false
}
soumynathan marked this conversation as resolved.
Show resolved Hide resolved

func initKubeProxyReplacementOptions() {
if option.Config.KubeProxyReplacement != option.KubeProxyReplacementStrict &&
option.Config.KubeProxyReplacement != option.KubeProxyReplacementPartial &&
Expand Down
8 changes: 1 addition & 7 deletions test/k8sT/DatapathConfiguration.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"fmt"
"regexp"
"strconv"
"strings"

. "github.com/cilium/cilium/test/ginkgo-ext"
"github.com/cilium/cilium/test/helpers"
Expand Down Expand Up @@ -67,12 +66,7 @@ var _ = Describe("K8sDatapathConfig", func() {
})

JustAfterEach(func() {
blacklist := helpers.GetBadLogMessages()
if strings.Contains(CurrentGinkgoTestDescription().TestText, "sockops") {
delete(blacklist, helpers.ClangErrorsMsg)
delete(blacklist, helpers.ClangErrorMsg)
}
kubectl.ValidateListOfErrorsInLogs(CurrentGinkgoTestDescription().Duration, blacklist)
kubectl.ValidateNoErrorsInLogs(CurrentGinkgoTestDescription().Duration)
})

deployNetperf := func() {
Expand Down