diff options
| author | Alex Kudentsov <43482574+alexk37@users.noreply.github.com> | 2026-10-19 19:03:41 +0700 |
|---|---|---|
| committer | Alex Kudentsov <43482574+alexk37@users.noreply.github.com> | 2026-10-21 20:17:16 +0700 |
| commit | 57a5f6b623df7d7882a585cb786753577604ec7b (patch) | |
| tree | d22f50dc352aafef16fc165a0bdda84874f11892 /python | |
| parent | 7216e748b8a37929f9d766f21cc47f099c92c27e (diff) | |
| download | vyos-1x-57a5f6b623df7d7882a585cb786753577604ec7b.tar.gz vyos-1x-57a5f6b623df7d7882a585cb786753577604ec7b.zip | |
vpp: T9484: keep net.core.rmem_max at VPP's netlink buffer size
VPP requests a 256 MiB netlink receive buffer (nl-rx-buffer-size), but
the kernel caps it at net.core.rmem_max, which VyOS sets to 2 MiB, so
VPP gets 4 MiB. A large routing table over VPP interfaces can overflow
it, and linux-cp then falls back to a full resync.
Setting the sysctl from the CLI does not help at boot: system sysctl
runs after vpp, so VPP has already opened its socket.
- vpp.py raises net.core.rmem_max to the requested size before VPP is
(re)started; a higher value is kept.
- VPP re-opens its netlink socket on every resync and sizes it again, so
system sysctl no longer applies a lower value while VPP is configured;
it uses the required size and prints a warning.
- When VPP is removed, vpp.py sets net.core.rmem_max back to the value
from system sysctl, or to the default from sysctl.d, read with the new
vyos.utils.system.sysctl_read_default().
- startup.conf.j2 takes nl-rx-buffer-size from the same value
(default_resource_map) instead of its own constant.
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() |
