Merge pull request #71035 from Nordix/issue-68437

Fixes NodePort in ipv6 with proxy-mode=ipvs
pull/564/head
Kubernetes Prow Robot 2018-12-10 08:53:42 -08:00 committed by GitHub
commit 0914272a42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 7 deletions

View File

@ -30,11 +30,12 @@ import (
type netlinkHandle struct {
netlink.Handle
isIPv6 bool
}
// NewNetLinkHandle will crate a new NetLinkHandle
func NewNetLinkHandle() NetLinkHandle {
return &netlinkHandle{netlink.Handle{}}
func NewNetLinkHandle(isIPv6 bool) NetLinkHandle {
return &netlinkHandle{netlink.Handle{}, isIPv6}
}
// 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.isIPv6 {
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())
}
}

View File

@ -28,7 +28,7 @@ type emptyHandle struct {
}
// NewNetLinkHandle will create an EmptyHandle
func NewNetLinkHandle() NetLinkHandle {
func NewNetLinkHandle(ipv6 bool) NetLinkHandle {
return &emptyHandle{}
}

View File

@ -406,14 +406,14 @@ func NewProxier(ipt utiliptables.Interface,
healthzServer: healthzServer,
ipvs: ipvs,
ipvsScheduler: scheduler,
ipGetter: &realIPGetter{nl: NewNetLinkHandle()},
ipGetter: &realIPGetter{nl: NewNetLinkHandle(isIPv6)},
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(isIPv6),
ipset: ipset,
nodePortAddresses: nodePortAddresses,
networkInterfacer: utilproxy.RealNetwork{},
@ -600,7 +600,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)