From 2db48174b0a3eb7a95f4029051a6b7b9fce6cbdb Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Thu, 11 Jun 2026 20:53:05 +0200 Subject: [PATCH] fix: apply only the x-ui sysctl config when toggling BBR (#5160) sysctl --system re-applies every sysctl file on the host, surfacing unrelated "Invalid argument" errors from the distro's own defaults (e.g. Ubuntu 22.04's 50-default.conf on kernels 5.14+). Apply only /etc/sysctl.d/99-bbr-x-ui.conf on enable, and drop the redundant re-apply on disable since sysctl -w already restores the live values. --- x-ui.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/x-ui.sh b/x-ui.sh index 6b18d7666..b527b5a5f 100644 --- a/x-ui.sh +++ b/x-ui.sh @@ -688,10 +688,12 @@ disable_bbr() { if [ -f "/etc/sysctl.d/99-bbr-x-ui.conf" ]; then old_settings=$(head -1 /etc/sysctl.d/99-bbr-x-ui.conf | tr -d '#') + # sysctl -w already restores the live values, so no `sysctl --system` + # afterwards — it would re-apply every sysctl file on the host and + # surface unrelated errors from the distro's own defaults (see issue #5160) sysctl -w net.core.default_qdisc="${old_settings%:*}" sysctl -w net.ipv4.tcp_congestion_control="${old_settings#*:}" rm /etc/sysctl.d/99-bbr-x-ui.conf - sysctl --system else # Replace BBR with CUBIC configurations if [ -f "/etc/sysctl.conf" ]; then @@ -726,7 +728,10 @@ enable_bbr() { sed -i 's/^net.core.default_qdisc/# &/' /etc/sysctl.conf sed -i 's/^net.ipv4.tcp_congestion_control/# &/' /etc/sysctl.conf fi - sysctl --system + # Apply only our config file; `sysctl --system` would re-apply every + # sysctl file on the host and surface unrelated errors from the distro's + # own defaults (see issue #5160) + sysctl -p /etc/sysctl.d/99-bbr-x-ui.conf else sed -i '/net.core.default_qdisc/d' /etc/sysctl.conf sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf