diff options
| author | Christian Breunig <christian@breunig.cc> | 2026-04-12 09:01:26 +0200 |
|---|---|---|
| committer | Christian Breunig <christian@breunig.cc> | 2026-04-12 09:03:25 +0200 |
| commit | 4af2579d8a6f73f4fc61c0d30d09695f07bf6940 (patch) | |
| tree | 09245927be9db9a66dea96c94d9a2765acf75391 /src | |
| parent | b7d191cd3053a736fa14ebfefe7a95093b0fcacd (diff) | |
| download | vyos-1x-4af2579d8a6f73f4fc61c0d30d09695f07bf6940.tar.gz vyos-1x-4af2579d8a6f73f4fc61c0d30d09695f07bf6940.zip | |
vyos-netlinkd: T8486: fix high-cpu utilisation due to excessive CLI calls
strace: Process 16362 attached
[pid 16362] execve("/bin/cli-shell-api", ["/bin/cli-shell-api", "--show-active-only", "showConfig", "interfaces"], ...) = 0
[pid 16362] +++ exited with 0 +++
--- SIGCHLD ...
strace: Process 16363 attached
[pid 16363] execve("/bin/cli-shell-api", ["/bin/cli-shell-api", "--show-active-only", "showConfig", "interfaces"], ...) = 0
[pid 16363] +++ exited with 0 +++
--- SIGCHLD ...
This would appear to be due to vyos-netlinkd calling op_mode_config_dict() more
than is necessary: it can be called only when it may be applicable (this patch).
Co-Authored-by: John Estabrook <jestabro@vyos.io>
Diffstat (limited to 'src')
| -rwxr-xr-x | src/services/vyos-netlinkd | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/services/vyos-netlinkd b/src/services/vyos-netlinkd index 647241276..c759ebd3d 100755 --- a/src/services/vyos-netlinkd +++ b/src/services/vyos-netlinkd @@ -50,7 +50,7 @@ def sigterm_handler(signo, frame): sig = signal.Signals(signo) syslog.syslog(syslog.LOG_INFO, f'Received signal {sig.name} - shutting down...') -def _handle_dhcp_events(config_dict: dict, operstate: Optional[str], ifname: str) -> None: +def _handle_dhcp_events(operstate: Optional[str], ifname: str) -> None: systemdV4_service = f'dhclient@{ifname}.service' systemdV6_service = f'dhcp6c@{ifname}.service' @@ -70,6 +70,11 @@ def _handle_dhcp_events(config_dict: dict, operstate: Optional[str], ifname: str elif operstate == 'UP': v6_restart = False interface_path = Section.get_config_path(ifname, delimiter='.') + + config_dict = op_mode_config_dict( + ['interfaces'], key_mangling=('-', '_'), get_first_key=True + ) + if tmp := dict_search(f'{interface_path}.address', config_dict): # Always (re-)start the DHCP(v6) client service. If the DHCP(v6) client # is already running - which could happen if the interface is re- @@ -123,10 +128,6 @@ def main(): while commit_in_progress(): sleep(0.250) - config_dict = op_mode_config_dict(['interfaces'], - key_mangling=('-', '_'), - get_first_key=True) - # Parse NETLINK message match message['event']: # Message received during interface creation or modification @@ -146,7 +147,7 @@ def main(): if not match_iface(ifname): continue - _handle_dhcp_events(config_dict, operstate, ifname) + _handle_dhcp_events(operstate, ifname) # Deletion of a network link which has been previously added to the kernel case 'RTM_DELLINK': |
