Skip to content

Commit

Permalink
daemon: Enable dev auto-detect for host-fw
Browse files Browse the repository at this point in the history
Enable the device auto-detection when BPF NodePort is disabled, but
host-fw is enabled.

Signed-off-by: Martynas Pumputis <m@lambda.lt>
  • Loading branch information
brb authored and tgraf committed Jun 16, 2020
1 parent 5c2c8b1 commit e4bd54c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions daemon/cmd/daemon_main.go
Expand Up @@ -1749,7 +1749,8 @@ func initKubeProxyReplacementOptions() (strict bool) {
// detectDevicesForNodePortAndHostFirewall tries to detect bpf_host devices
// (if needed).
func detectDevicesForNodePortAndHostFirewall(strict bool) {
detectNodePortDevs := option.Config.EnableNodePort && len(option.Config.Devices) == 0
detectNodePortDevs := len(option.Config.Devices) == 0 &&
(option.Config.EnableNodePort || option.Config.EnableHostFirewall)
detectDirectRoutingDev := option.Config.EnableNodePort &&
option.Config.DirectRoutingDevice == ""
if detectNodePortDevs || detectDirectRoutingDev {
Expand Down Expand Up @@ -1901,7 +1902,9 @@ func detectDevices(detectNodePortDevs, detectDirectRoutingDev bool) error {
}
}
}
devSet[option.Config.DirectRoutingDevice] = struct{}{}
if option.Config.DirectRoutingDevice != "" {
devSet[option.Config.DirectRoutingDevice] = struct{}{}
}

option.Config.Devices = make([]string, 0, len(devSet))
for dev := range devSet {
Expand Down
5 changes: 3 additions & 2 deletions pkg/option/config.go
Expand Up @@ -2914,6 +2914,7 @@ func EndpointStatusValuesMap() (values map[string]struct{}) {
// MightAutoDetectDevices returns true if the device auto-detection might take
// place.
func MightAutoDetectDevices() bool {
return Config.KubeProxyReplacement != KubeProxyReplacementDisabled &&
(len(Config.Devices) == 0 || Config.DirectRoutingDevice == "")
return (Config.EnableHostFirewall && len(Config.Devices) == 0) ||
(Config.KubeProxyReplacement != KubeProxyReplacementDisabled &&
(len(Config.Devices) == 0 || Config.DirectRoutingDevice == ""))
}

0 comments on commit e4bd54c

Please sign in to comment.