Merge pull request #1639 from RaspAP/feat/installer-tcp-bbr

Adds TCP BBR configuration option to installer
This commit is contained in:
Bill Zimmerman 2024-08-18 08:42:32 +02:00 committed by GitHub
commit 85c38f2a9a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 67 additions and 0 deletions

View file

@ -55,6 +55,7 @@ function _install_raspap() {
_install_lighttpd_configs _install_lighttpd_configs
_default_configuration _default_configuration
_configure_networking _configure_networking
_prompt_configure_tcp_bbr
_prompt_install_features _prompt_install_features
_install_extra_features _install_extra_features
_patch_system_files _patch_system_files
@ -788,6 +789,67 @@ function _configure_networking() {
_install_status 0 _install_status 0
} }
# Prompt to configure TCP BBR option
function _prompt_configure_tcp_bbr() {
_install_log "Configure TCP BBR congestion control"
echo "Network performance can be improved by changing TCP congestion control to BBR (Bottleneck Bandwidth and RTT)"
echo -n "Enable TCP BBR congestion control algorithm (Recommended)? [Y/n]: "
if [ "$assume_yes" == 0 ]; then
read answer < /dev/tty
if [ "$answer" != "${answer#[Nn]}" ]; then
_install_status 0 "(Skipped)"
else
_configure_tcp_bbr
fi
elif [ "${bbr_option}" == 1 ]; then
_configure_tcp_bbr
else
echo "(Skipped)"
fi
}
function _configure_tcp_bbr() {
echo "Checking kernel support for the TCP BBR algorithm..."
_check_tcp_bbr_available
if [ $? -eq 0 ]; then
echo "TCP BBR option found. Enabling configuration"
# Load the BBR module
echo "Loading BBR kernel module"
sudo modprobe tcp_bbr || _install_status 1 "Unable to execute modprobe tcp_bbr"
# Add BBR configuration to sysctl.conf if not present
echo "Adding BBR configuration to /etc/sysctl.conf if not present"
if ! grep -q "net.core.default_qdisc=fq" /etc/sysctl.conf; then
echo "net.core.default_qdisc=fq" | sudo tee -a /etc/sysctl.conf || _install_status 1 "Unable to modify /etc/sysctl.conf"
fi
if ! grep -q "net.ipv4.tcp_congestion_control=bbr" /etc/sysctl.conf; then
echo "net.ipv4.tcp_congestion_control=bbr" | sudo tee -a /etc/sysctl.conf || _install_status 1 "Unable to modify /etc/sysctl.conf"
fi
# Apply the sysctl changes
echo "Applying changes"
sudo sysctl -p || _install_status 1 "Unable to execute sysctl"
# Verify if BBR is enabled
cc=$(sysctl net.ipv4.tcp_congestion_control | awk '{print $3}')
if [ "$cc" == "bbr" ]; then
echo "TCP BBR successfully enabled"
else
_install_status 1 "Failed to enable TCP BBR"
fi
else
_install_status 2 "TCP BBR option is not available (Skipped)"
fi
_install_status 0
}
function _check_tcp_bbr_available() {
config_file="/boot/config-$(uname -r)"
if grep -q 'CONFIG_TCP_CONG_BBR' "$config_file" && grep -q 'CONFIG_NET_SCH_FQ' "$config_file"; then
return 0
else
return 1
fi
}
# Add sudoers file to /etc/sudoers.d/ and set file permissions # Add sudoers file to /etc/sudoers.d/ and set file permissions
function _patch_system_files() { function _patch_system_files() {

View file

@ -44,6 +44,7 @@ OPTIONS:
-a, --adblock <flag> Used with -y, --yes, sets Adblock install option (0=no install) -a, --adblock <flag> Used with -y, --yes, sets Adblock install option (0=no install)
-w, --wireguard <flag> Used with -y, --yes, sets WireGuard install option (0=no install) -w, --wireguard <flag> Used with -y, --yes, sets WireGuard install option (0=no install)
-e, --provider <value> Used with -y, --yes, sets the VPN provider install option -e, --provider <value> Used with -y, --yes, sets the VPN provider install option
-g, --tcp-bbr <value> Used with -y, --yes, sets the TCP BBR congestion control algorithm option
-r, --repo, --repository <name> Overrides the default GitHub repo (RaspAP/raspap-webgui) -r, --repo, --repository <name> Overrides the default GitHub repo (RaspAP/raspap-webgui)
-b, --branch <name> Overrides the default git branch (latest release) -b, --branch <name> Overrides the default git branch (latest release)
-t, --token <accesstoken> Specify a GitHub token to access a private repository -t, --token <accesstoken> Specify a GitHub token to access a private repository
@ -129,6 +130,10 @@ function _parse_params() {
pv_option="$2" pv_option="$2"
shift shift
;; ;;
-g|--tcp-bbr)
bbr_option="$2"
shift
;;
-c|--cert|--certificate) -c|--cert|--certificate)
install_cert=1 install_cert=1
;; ;;