Skip to content

Commit 68b1a95

Browse files
author
Ricardo Pchevuzinske Katz
committed
kube-proxy should check global IPv6 enablement
IPv6 should also be checked if it is globally enabled. On nftables, today this is hardcoded, so if a Linux Kernel disables IPv6 during its boot or doesn't have IPv6 compiled, it will still try to use IPv6, which can lead to some unexpected errors. This change verifies if IPv6 is enabled by checking if the IPv6 network interfaces proc file is available
1 parent 23258f1 commit 68b1a95

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

cmd/kube-proxy/app/server_linux.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"context"
2626
"errors"
2727
"fmt"
28+
"os"
2829
goruntime "runtime"
2930
"time"
3031

@@ -110,6 +111,7 @@ func (s *ProxyServer) platformCheckSupported(ctx context.Context) (ipv4Supported
110111
logger := klog.FromContext(ctx)
111112

112113
if isIPTablesBased(s.Config.Mode) {
114+
// Check for the iptables and ip6tables binaries.
113115
ipts := utiliptables.NewDualStack()
114116
ipv4Supported = ipts[v1.IPv4Protocol] != nil
115117
ipv6Supported = ipts[v1.IPv6Protocol] != nil
@@ -122,11 +124,17 @@ func (s *ProxyServer) platformCheckSupported(ctx context.Context) (ipv4Supported
122124
logger.Info("No iptables support for family", "ipFamily", v1.IPv6Protocol)
123125
}
124126
} else {
125-
// Assume support for both families.
126-
// FIXME: figure out how to check for kernel IPv6 support using nft
127+
// The nft CLI always supports both families.
127128
ipv4Supported, ipv6Supported = true, true
128129
}
129130

131+
// Check if the OS has IPv6 enabled, by verifying if the IPv6 interfaces are available
132+
_, errIPv6 := os.Stat("/proc/net/if_inet6")
133+
if errIPv6 != nil {
134+
logger.Info("No kernel support for family", "ipFamily", v1.IPv6Protocol)
135+
ipv6Supported = false
136+
}
137+
130138
// The Linux proxies can always support dual-stack if they can support both IPv4
131139
// and IPv6.
132140
dualStackSupported = ipv4Supported && ipv6Supported

0 commit comments

Comments
 (0)