Repository: kubernetes
Issue: kube-proxy: net.InterfaceAddrs may return error due to a race condition, causing the Nodeport Service to be inaccessible
Labels: kind/bug,sig/network,triage/accepted

### What happened?

In our production environment, which verson is 1.24.4
1. kube-proxy's error log: 
2024-12-09T07:35:24.325300135+08:00 E1209 07:35:24.325193       1 proxier.go:1131] "Failed to get node IP address matching nodeport cidr" err="error listing all interfaceAddrs from host, error: route ip+net: no such network interface"
2. Then the nodeport service's backend pod on this node cannot be accessible by the Nodeport Service.
3. On the save time, in this node's /var/log/message, the log is:
Dec  9 07:35:24 VM-96-121-tencentos containerd: 2024-12-09T07:35:24+08:00 [info] cmdDel: {containerId c915c615cb43c0f7711d125e39e722581384bc45b3453e3c3c79ebe5ed994e71, netNs /var/run/netns/cni-278204fe-6400-6354-982f-ae2299bfae17, ifName eth0, args K8S_POD_INFRA_CONTAINER_ID=c915c615cb43c0f7711d125e39e722581384bc45b3453e3c3c79ebe5ed994e71;K8S_POD_UID=0a3c7874-54ae-4ec6-b4a5-b5c3b9d63a12;IgnoreUnknown=1;K8S_POD_NAMESPACE=bkmonitor-operator;K8S_POD_NAME=bcs-blackbox-job-073518-f8n4c, path /opt/cni/bin, stdinData {"capabilities":{"bandwidth":true,"portMappings":true},"cniVersion":"0.3.1","defaultDelegates":"tke-bridge","kubeconfig":"/etc/kubernetes/tke-cni-kubeconfig","logLevel":"info","name":"multus-cni","type":"multus"}}, <nil>, <nil>


### What did you expect to happen?

The Nodeport Service should be accessible.

### How can we reproduce it (as minimally and precisely as possible)?

In the latest version, it also have the same problem.

1, syncProxyRules->GetNodeIPs->net.InterfaceAddrs()->interfaceAddrTable(which is in interface_linux.go for Linux)->syscall.NetlinkRIB(syscall.RTM_GETADDR, syscall.AF_UNSPEC) is called.
2. Then an interface is delete by CNI.
3. Then interfaceAddrTable(which is in interface_linux.go) call interfaceTable(which is in interface_linux.go)->syscall.NetlinkRIB(syscall.RTM_GETLINK, syscall.AF_UNSPEC)
   The key point is that, RTM_GETADDR's return have the delete interface, but the RTM_GETLINK's return donot have the deleted interface.
4.  Then in interfaceAddrTable->addrTable will return err.
<img width="805" alt="Clipboard_Screenshot_1733841188" src="https://github.com/user-attachments/assets/d84160a2-2b10-4a0a-9078-faad3a010076">
5. Then the syncProxyRules will not write correct forward configuration because the GetNodeIPs's return donot have any ip.



### Anything else we need to know?

_No response_

### Kubernetes version

<details>

```console
$ kubectl version
# paste output here
```
This production environment cluster version is v1.24.4

But any version have the same problem.

</details>


### Cloud provider

<details>
TKE
</details>


### OS version

<details>

```console
# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here
```
Centos8
</details>


### Install tools

<details>

</details>


### Container runtime (CRI) and version (if applicable)

<details>
containerd
</details>


### Related plugins (CNI, CSI, ...) and versions (if applicable)

<details>

</details>