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.
This commit is contained in:
MHSanaei
2026-06-11 20:53:05 +02:00
parent 554d85c2f7
commit 2db48174b0
+7 -2
View File
@@ -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