Skip to content

Commit

Permalink
Setup: Add BBR congestion control configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
stickz committed Apr 23, 2023
1 parent 444212b commit d7b3435
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,18 @@ function _checkbbr() {
[[ $BBR_CONGESTION_CONTROL = "yes" ]] && enablebbr=true
fi
# If bbr is already running on the operating system, skip checks and exit function
local old_cc=$(sysctl net.ipv4.tcp_congestion_control)
if [[ $old_cc = *"bbr"* ]]; then
local old_cc=$(sysctl net.ipv4.tcp_congestion_control | grep -c bbr)
if [[ $old_cc -ge 1 ]]; then
echo_info "BBR Congestion Control is already enabled, skipping BBR"
return 0
fi
# if sysctl.conf has already defined a cc or qdisc, skip checks and exit function
local sysctl_cc=$(grep -c net.ipv4.tcp_congestion_control /etc/sysctl.conf)
local sysctl_qdisc=$(grep -c net.core.default_qdisc /etc/sysctl.conf)
if [[ $sysctl_cc -ge 1 ]] || [[ $sysctl_qdisc -ge 1 ]]; then
echo_info "sysctl.conf has conflicting options, skipping BBR"
return 0
fi
# If bbr is not supported by the linux kernel, skip checks and exit function
modprobe tcp_bbr >> $log 2>&1
local availible_cc=$(sysctl net.ipv4.tcp_available_congestion_control | grep -c bbr)
Expand All @@ -258,12 +265,9 @@ function _checkbbr() {
fi
# If enablebbr is set then enable fq plus bbq and apply the changes
if [[ $enablebbr = "true" ]]; then
echo "net.core.default_qdisc=fq" | tee -a /etc/sysctl.d/10-custom-kernel-bbr.conf >> $log 2>&1
echo "net.ipv4.tcp_congestion_control=bbr" | tee -a /etc/sysctl.d/10-custom-kernel-bbr.conf >> $log 2>&1
sysctl -p || {
echo_error "Failed to apply BBR congestion control, rolling back"
rm_if_exists /etc/sysctl.d/10-custom-kernel-bbr.conf
}
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
sysctl -p >> $log 2>&1
fi
}

Expand Down

0 comments on commit d7b3435

Please sign in to comment.