Change:
<!-- Please use this template while reporting a bug and provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner. Thanks! If the matter is security related, please disclose it privately via --What happened: In Overlay mode, When 2 service has the same backend node IP, the LB was not programmed correctly causing datapath issues. What you expected to happen: Service data path to work properly How to reproduce it (as minimally and precisely as possible): Anything else we need to know?: Environment: Kubernetes version (use ): Cloud provider or hardware configuration: OS (e.g: ): Kernel (e.g. ): Install tools: Network plugin and version (if this is a network-related bug): Others:
/sig network /sig windows These SIGs are my best guesses for this issue. Please comment if I am incorrect about one. I am a bot run by vllry. ‍
/triage unresolved Comment when the issue is assessed and confirmed. I am a bot run by vllry. ‍

Discussion:
return info } <ins> func (network hnsNetworkInfo) findRemoteSubnetProviderAddress(ip string) string { var providerAddress string for _, rs := range network.remoteSubnets { _, ipNet, err := net.ParseCIDR(rs.destinationPrefix) if err != nil { klog.Fatalf("%v", err) } if ipNet.Contains(net.ParseIP(ip)) { providerAddress = rs.providerAddress } if ip == rs.providerAddress { providerAddress = rs.providerAddress } } return providerAddress } </ins> type endpointsChange struct { previous proxyEndpointsMap current  proxyEndpointsMap

return } proxier.network = *updatedNetwork <del> var providerAddress string for _, rs := range proxier.network.remoteSubnets { _, ipNet, err := net.ParseCIDR(rs.destinationPrefix) if err != nil { klog.Fatalf("%v", err) } if ipNet.Contains(net.ParseIP(ep.ip)) { providerAddress = rs.providerAddress } if ep.ip == rs.providerAddress { providerAddress = rs.providerAddress containsNodeIP = true } } </del> <ins> providerAddress := proxier.network.findRemoteSubnetProviderAddress(ep.ip) </ins> if len(providerAddress) == 0 { klog.Infof("Could not find provider address for %s. Assuming it is a public IP", ep.ip) providerAddress = proxier.nodeIP.String() <del> containsPublicIP = true </del> } hnsEndpoint := &endpointsInfo{

} } <ins> if proxier.network.networkType == "Overlay" { providerAddress := proxier.network.findRemoteSubnetProviderAddress(ep.ip) isNodeIP := (ep.ip == providerAddress) isPublicIP := (len(providerAddress) == 0) klog.Infof("Endpoint %s on overlay network %s is classified as NodeIp: %v, Public Ip: %v", ep.ip, hnsNetworkName, isNodeIP, isPublicIP) containsNodeIP = containsNodeIP || isNodeIP containsPublicIP = containsPublicIP || isPublicIP } </ins> // Save the hnsId for reference LogJson(newHnsEndpoint, "Hns Endpoint resource", 1) hnsEndpoints = append(hnsEndpoints, *newHnsEndpoint)

p.OnEndpointSlicesSynced() } <ins> func TestFindRemoteSubnetProviderAddress(t *testing.T) { networkInfo, _ := newFakeHNS().getNetworkByName("TestNetwork") pa := networkInfo.findRemoteSubnetProviderAddress(providerAddress) if pa != providerAddress { t.Errorf("%v does not match %v", pa, providerAddress) } pa = networkInfo.findRemoteSubnetProviderAddress(epIpAddressRemote) if pa != providerAddress { t.Errorf("%v does not match %v", pa, providerAddress) } pa = networkInfo.findRemoteSubnetProviderAddress(serviceVip) if len(pa) != 0 { t.Errorf("Provider address is not empty as expected") } } </ins> func makeNSN(namespace, name string) types.NamespacedName { return types.NamespacedName{Namespace: namespace, Name: name} }