mirror of
				https://github.com/k3s-io/kubernetes.git
				synced 2025-11-03 23:40:03 +00:00 
			
		
		
		
	Make NodePortAddresses explicitly IP-family-specific
Both proxies handle IPv4 and IPv6 nodeport addresses separately, but GetNodeAddresses went out of its way to make that difficult. Fix that. This commit does not change any externally-visible semantics, but it makes the existing weird semantics more obvious. Specifically, if you say "--nodeport-addresses 10.0.0.0/8,192.168.0.0/16", then the dual-stack proxy code would have split that into a list of IPv4 CIDRs (["10.0.0.0/8", "192.168.0.0/16"]) to pass to the IPv4 proxier, and a list of IPv6 CIDRs ([]) to pass to the IPv6 proxier, and then the IPv6 proxier would say "well since the list of nodeport addresses is empty, I'll listen on all IPv6 addresses", which probably isn't what you meant, but that's what it did.
This commit is contained in:
		@@ -169,7 +169,7 @@ func NewFakeProxier(ipt utiliptables.Interface, ipvs utilipvs.Interface, ipset u
 | 
			
		||||
		filterRules:           utilproxy.LineBuffer{},
 | 
			
		||||
		netlinkHandle:         netlinkHandle,
 | 
			
		||||
		ipsetList:             ipsetList,
 | 
			
		||||
		nodePortAddresses:     utilproxy.NewNodePortAddresses(nil),
 | 
			
		||||
		nodePortAddresses:     utilproxy.NewNodePortAddresses(ipFamily, nil),
 | 
			
		||||
		networkInterfacer:     proxyutiltest.NewFakeNetwork(),
 | 
			
		||||
		gracefuldeleteManager: NewGracefulTerminationManager(ipvs),
 | 
			
		||||
		ipFamily:              ipFamily,
 | 
			
		||||
@@ -960,7 +960,7 @@ func TestNodePortIPv4(t *testing.T) {
 | 
			
		||||
			ipvs := ipvstest.NewFake()
 | 
			
		||||
			ipset := ipsettest.NewFake(testIPSetVersion)
 | 
			
		||||
			fp := NewFakeProxier(ipt, ipvs, ipset, test.nodeIPs, nil, v1.IPv4Protocol)
 | 
			
		||||
			fp.nodePortAddresses = utilproxy.NewNodePortAddresses(test.nodePortAddresses)
 | 
			
		||||
			fp.nodePortAddresses = utilproxy.NewNodePortAddresses(v1.IPv4Protocol, test.nodePortAddresses)
 | 
			
		||||
 | 
			
		||||
			makeServiceMap(fp, test.services...)
 | 
			
		||||
			populateEndpointSlices(fp, test.endpoints...)
 | 
			
		||||
@@ -1305,7 +1305,7 @@ func TestNodePortIPv6(t *testing.T) {
 | 
			
		||||
			ipvs := ipvstest.NewFake()
 | 
			
		||||
			ipset := ipsettest.NewFake(testIPSetVersion)
 | 
			
		||||
			fp := NewFakeProxier(ipt, ipvs, ipset, test.nodeIPs, nil, v1.IPv6Protocol)
 | 
			
		||||
			fp.nodePortAddresses = utilproxy.NewNodePortAddresses(test.nodePortAddresses)
 | 
			
		||||
			fp.nodePortAddresses = utilproxy.NewNodePortAddresses(v1.IPv6Protocol, test.nodePortAddresses)
 | 
			
		||||
 | 
			
		||||
			makeServiceMap(fp, test.services...)
 | 
			
		||||
			populateEndpointSlices(fp, test.endpoints...)
 | 
			
		||||
@@ -2068,7 +2068,7 @@ func TestOnlyLocalNodePorts(t *testing.T) {
 | 
			
		||||
	addrs1 := []net.Addr{&net.IPNet{IP: netutils.ParseIPSloppy("2001:db8::"), Mask: net.CIDRMask(64, 128)}}
 | 
			
		||||
	fp.networkInterfacer.(*proxyutiltest.FakeNetwork).AddInterfaceAddr(&itf, addrs)
 | 
			
		||||
	fp.networkInterfacer.(*proxyutiltest.FakeNetwork).AddInterfaceAddr(&itf1, addrs1)
 | 
			
		||||
	fp.nodePortAddresses = utilproxy.NewNodePortAddresses([]string{"100.101.102.0/24"})
 | 
			
		||||
	fp.nodePortAddresses = utilproxy.NewNodePortAddresses(v1.IPv4Protocol, []string{"100.101.102.0/24"})
 | 
			
		||||
 | 
			
		||||
	fp.syncProxyRules()
 | 
			
		||||
 | 
			
		||||
@@ -2156,7 +2156,7 @@ func TestHealthCheckNodePort(t *testing.T) {
 | 
			
		||||
	addrs1 := []net.Addr{&net.IPNet{IP: netutils.ParseIPSloppy("2001:db8::"), Mask: net.CIDRMask(64, 128)}}
 | 
			
		||||
	fp.networkInterfacer.(*proxyutiltest.FakeNetwork).AddInterfaceAddr(&itf, addrs)
 | 
			
		||||
	fp.networkInterfacer.(*proxyutiltest.FakeNetwork).AddInterfaceAddr(&itf1, addrs1)
 | 
			
		||||
	fp.nodePortAddresses = utilproxy.NewNodePortAddresses([]string{"100.101.102.0/24"})
 | 
			
		||||
	fp.nodePortAddresses = utilproxy.NewNodePortAddresses(v1.IPv4Protocol, []string{"100.101.102.0/24"})
 | 
			
		||||
 | 
			
		||||
	fp.syncProxyRules()
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user