Skip to content

Commit e73db62

Browse files
authored
Merge pull request kubernetes#131265 from rikatz/check-ipv6-enablement-kproxy
kube-proxy should check global IPv6 enablement
2 parents e3b9541 + 68b1a95 commit e73db62

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)