[posix] handle infra interface index change (#12059)

This change updates the netlink message handling for the infra link on
the POSIX platform to be more robust and efficient for `RTM_NEWLINK`
and `RTM_DELLINK` messages.

The logic for handling infra index changes is:

1. On `RTM_DELLINK`, the code verifies `ifinfo->ifi_index` is for the
currently infra index `mInfraIfIndex`.

2. On `RTM_NEWLINK`, it identifies the infra by its name
`if_indextoname(ifinfo->ifi_index)` and updates `mInfraIfIndex`.
This commit is contained in:
Yang Song
2026-01-12 12:10:18 -08:00
committed by GitHub
parent 5d21b406a3
commit 61e2f2877d
4 changed files with 271 additions and 20 deletions
+23
View File
@@ -236,6 +236,29 @@ jobs:
path: tmp/coverage.info
retention-days: 1
infra-if-index-changed-linux:
name: infra-if-index-changed-linux
runs-on: ubuntu-22.04
steps:
- name: Harden Runner
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
run: |
sudo apt-get update
sudo apt-get --no-install-recommends install -y net-tools ninja-build
- name: Build
run: |
script/check-infra-if-index-changed build
- name: Run
run: |
script/check-infra-if-index-changed check
pty-macos:
name: pty-macos OT_DAEMON=${{ matrix.OT_DAEMON }}
runs-on: macos-14