#!/bin/sh ## qts_bbr [ get | set | check ] ## arg 1: ## get or empty ## standard output will echo "0" or "1". ## 0 : setting is disabled BBR ## 1 : setting is enabled BBR ## set ## args 2: ## 0 : disable BBR ## 1 : enabled BBR ## check ## standard output will echo "0" or "1". ## 0 : QTS firmware not support BBR ## 1 : QTS firmware support BBR QPKG_CONF="/etc/config/qpkg.conf" QPKG_ROOT=`getcfg "HybridBackup" Install_Path -f ${QPKG_CONF}` BBR_CONF="${QPKG_ROOT}/qtsbbr.conf" SECTION="HBS" KEY="BBR_Enable" function echoerr() { echo "$@" 1>&2 } function is_support_bbr() { cat /proc/sys/net/ipv4/tcp_allowed_congestion_control | grep bbr 1>/dev/null 2>/dev/null if [ $? -eq 0 ]; then return 0 # true else return 1 # false fi } function get_bbr_setting() { BBR_ENABLED=`getcfg "${SECTION}" "${KEY}" -f "${BBR_CONF}" -d "0"` echo "${BBR_ENABLED}" } function set_bbr_setting() { VALUE=$1 if [ "${VALUE}" == "1" ] && ! is_support_bbr; then echoerr "kernel not support BBR, skip enable" exit 1 fi if [ ! -f ${BBR_CONF} ]; then touch ${BBR_CONF} fi /sbin/setcfg "${SECTION}" "${KEY}" "${VALUE}" -f "${BBR_CONF}" } if [ "$1"x == "x" ] || [ "$1" == "get" ]; then get_bbr_setting elif [ "$1" == "set" ]; then if [ "$2"x != "0"x ] && [ "$2"x != "1"x ]; then echoerr "missing param 2" exit 1 fi set_bbr_setting $2 elif [ "$1" == "check" ]; then if is_support_bbr; then echo "1" # QTS kernel support bbr else echo "0" # QTS kernel not support bbr fi fi exit 0