mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Fixes NodePort in ipv6 with proxy-mode=ipvs. #68437
Use ipv6 addresses for NodePort with proxy-mode=ipvs in a ipv6-only cluster.
This commit is contained in:
		@@ -30,11 +30,12 @@ import (
 | 
			
		||||
 | 
			
		||||
type netlinkHandle struct {
 | 
			
		||||
	netlink.Handle
 | 
			
		||||
	ipv6 bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NewNetLinkHandle will crate a new NetLinkHandle
 | 
			
		||||
func NewNetLinkHandle() NetLinkHandle {
 | 
			
		||||
	return &netlinkHandle{netlink.Handle{}}
 | 
			
		||||
func NewNetLinkHandle(ipv6 bool) NetLinkHandle {
 | 
			
		||||
	return &netlinkHandle{netlink.Handle{}, ipv6}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// EnsureAddressBind checks if address is bound to the interface and, if not, binds it. If the address is already bound, return true.
 | 
			
		||||
@@ -181,7 +182,11 @@ func (h *netlinkHandle) GetLocalAddresses(dev, filterDev string) (sets.String, e
 | 
			
		||||
		if route.LinkIndex == filterLinkIndex {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
		if route.Src != nil {
 | 
			
		||||
		if h.ipv6 {
 | 
			
		||||
			if route.Dst.IP.To4() == nil && ! route.Dst.IP.IsLinkLocalUnicast() {
 | 
			
		||||
				res.Insert(route.Dst.IP.String())
 | 
			
		||||
			}
 | 
			
		||||
		} else if route.Src != nil {
 | 
			
		||||
			res.Insert(route.Src.String())
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -382,14 +382,14 @@ func NewProxier(ipt utiliptables.Interface,
 | 
			
		||||
		healthzServer:         healthzServer,
 | 
			
		||||
		ipvs:                  ipvs,
 | 
			
		||||
		ipvsScheduler:         scheduler,
 | 
			
		||||
		ipGetter:              &realIPGetter{nl: NewNetLinkHandle()},
 | 
			
		||||
		ipGetter:              &realIPGetter{nl: NewNetLinkHandle(nodeIP.To4() == nil)},
 | 
			
		||||
		iptablesData:          bytes.NewBuffer(nil),
 | 
			
		||||
		filterChainsData:      bytes.NewBuffer(nil),
 | 
			
		||||
		natChains:             bytes.NewBuffer(nil),
 | 
			
		||||
		natRules:              bytes.NewBuffer(nil),
 | 
			
		||||
		filterChains:          bytes.NewBuffer(nil),
 | 
			
		||||
		filterRules:           bytes.NewBuffer(nil),
 | 
			
		||||
		netlinkHandle:         NewNetLinkHandle(),
 | 
			
		||||
		netlinkHandle:         NewNetLinkHandle(nodeIP.To4() == nil),
 | 
			
		||||
		ipset:                 ipset,
 | 
			
		||||
		nodePortAddresses:     nodePortAddresses,
 | 
			
		||||
		networkInterfacer:     utilproxy.RealNetwork{},
 | 
			
		||||
@@ -576,7 +576,7 @@ func CleanupLeftovers(ipvs utilipvs.Interface, ipt utiliptables.Interface, ipset
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	// Delete dummy interface created by ipvs Proxier.
 | 
			
		||||
	nl := NewNetLinkHandle()
 | 
			
		||||
	nl := NewNetLinkHandle(false)
 | 
			
		||||
	err := nl.DeleteDummyDevice(DefaultDummyDevice)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		klog.Errorf("Error deleting dummy device %s created by IPVS proxier: %v", DefaultDummyDevice, err)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user