diff options
| author | Viacheslav Hletenko <v.gletenko@vyos.io> | 2026-10-22 18:35:39 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-10-22 18:35:39 +0300 |
| commit | 22deb5818614e45d9adc3e6f9f757bd429f5e60e (patch) | |
| tree | f59141dadddc64f52a1ec320d0d8fcffa486a43c /python | |
| parent | 1fd7c6ef07252938d40c1ac86e20716e22899b63 (diff) | |
| parent | 57a5f6b623df7d7882a585cb786753577604ec7b (diff) | |
| download | vyos-1x-22deb5818614e45d9adc3e6f9f757bd429f5e60e.tar.gz vyos-1x-22deb5818614e45d9adc3e6f9f757bd429f5e60e.zip | |
Merge pull request #5583 from alexk37/T9484-vpp-netlink-rmem-max
vpp: T9484: keep net.core.rmem_max at VPP's netlink buffer size
Diffstat (limited to 'python')
| -rw-r--r-- | python/vyos/utils/system.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/python/vyos/utils/system.py b/python/vyos/utils/system.py index 90ab74ea6..fc6507328 100644 --- a/python/vyos/utils/system.py +++ b/python/vyos/utils/system.py @@ -33,6 +33,32 @@ def sysctl_read(name: list[str]) -> str: tmp = run(['sysctl', '-nb', key], capture_output=True) return tmp.stdout.decode().strip() + +def sysctl_read_default(name: list[str]) -> str | None: + """Read the value the sysctl.d files set for a sysctl() option + + systemd-analyze lists the files in the order systemd-sysctl applies them, + so the last assignment wins. + + Args: + name (list[str]): sysctl key name components + + Returns: + str | None: sysctl key value, None if no file sets it + """ + key = _sysctl_key(name) + tmp = run(['systemd-analyze', 'cat-config', 'sysctl.d'], capture_output=True) + value = None + for line in tmp.stdout.decode().splitlines(): + line = line.strip() + if not line or line.startswith(('#', ';')): + continue + tmp_key, sep, tmp_value = line.partition('=') + # a leading '-' only tells systemd-sysctl to ignore errors + if sep and tmp_key.strip().lstrip('-') == key: + value = tmp_value.strip() + return value + def sysctl_write(name: list[str], value: str | int) -> bool: """Change value via sysctl() |
