diff options
| author | Christian Breunig <christian@breunig.cc> | 2026-06-03 22:26:23 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-06-03 22:26:23 +0200 |
| commit | 88dfc8cd43521ae489900fb9746c56545140df54 (patch) | |
| tree | dc4b580eee974d347ba7a7dcca7fa47e17c46906 /src | |
| parent | 6d0d9e424936671f03df19ee59c94f7aa5c69d3e (diff) | |
| parent | 3649dd09743e47700d36ecd25bffcd77dbb3cc3f (diff) | |
| download | vyos-1x-88dfc8cd43521ae489900fb9746c56545140df54.tar.gz vyos-1x-88dfc8cd43521ae489900fb9746c56545140df54.zip | |
Merge pull request #5242 from rnavarro/fix/T8950-netlinkd-dhcp-state-tracking
vyos-netlinkd: T8950: track per-interface operstate to suppress UP-to-UP DHCP restarts
Diffstat (limited to 'src')
| -rwxr-xr-x | src/services/vyos-netlinkd | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/services/vyos-netlinkd b/src/services/vyos-netlinkd index 2b158e05d..0e7da7a59 100755 --- a/src/services/vyos-netlinkd +++ b/src/services/vyos-netlinkd @@ -40,6 +40,10 @@ running = True # compile regex once during startup for fast match IFACE_RE = re.compile(r"^(?:eth|br|bond|wlan)") +# Per-interface previous operstate, used to suppress DHCP restarts on +# UP-to-UP re-notifications (e.g. post-migration gratuitous-ARP events). +_iface_prev_operstate: dict[str, str] = {} + def match_iface(ifname: str) -> bool: """ Helper function returning true if interface name is a match for further processing (e.g. restart of DHCP(v6) client) @@ -60,6 +64,14 @@ def _handle_dhcp_events(operstate: Optional[str], ifname: str) -> None: if operstate not in ['UP', 'DOWN']: return None + prev = _iface_prev_operstate.get(ifname) + _iface_prev_operstate[ifname] = operstate + + if operstate == 'UP' and prev == 'UP': + syslog.syslog(syslog.LOG_DEBUG, + f'Suppressing DHCP restart for {ifname}: already UP') + return None + if operstate == 'DOWN': # Interface moved state to down if is_systemd_service_active(systemdV4_service): @@ -168,7 +180,10 @@ def main(): # Deletion of a network link which has been previously added to the kernel case 'RTM_DELLINK': - pass + attrs = dict(message.get('attrs', [])) + ifname = attrs.get('IFLA_IFNAME', None) + if ifname: + _iface_prev_operstate.pop(ifname, None) case _: pass |
