diff options
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 |
