[RFC,1/8] AQM: Use CAKE as default qdisc where appropriate instead of fq_codel

Message ID 20211202123748.2525617-1-michael.tremer@ipfire.org
State Accepted
Commit cfa5f916ea766d39dbcec49d5f68477cbf187142
Headers
Series [RFC,1/8] AQM: Use CAKE as default qdisc where appropriate instead of fq_codel |

Commit Message

Michael Tremer Dec. 2, 2021, 12:37 p.m. UTC
  This script configures CAKE as default qdisc where appropriate:

* It is not suitable to use any queue management on bridges/GRE/VTI/tun
  interfaces.
* On Internet-facing interfaces, CAKE is configured in "internet" mode
  whereas on any zones except RED, it is configured in "metro" mode

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
 config/udev/enable_codel | 65 ++++++++++++++++++++++++++++++++--------
 1 file changed, 52 insertions(+), 13 deletions(-)
  

Comments

Michael Tremer Dec. 2, 2021, 12:42 p.m. UTC | #1
Hello,

It would be great if people could help me test this.

This should improve network latency massively for users with a slow connection and it should reduce CPU load for people who have a lot of throughput to handle.

I lack a sufficiently slow connection to actually see noticeable benefits over fq_codel and would like to invite everyone who can to give this all a test and let me know if things have changed for them.

Best,
-Michael

> On 2 Dec 2021, at 12:37, Michael Tremer <michael.tremer@ipfire.org> wrote:
> 
> This script configures CAKE as default qdisc where appropriate:
> 
> * It is not suitable to use any queue management on bridges/GRE/VTI/tun
>  interfaces.
> * On Internet-facing interfaces, CAKE is configured in "internet" mode
>  whereas on any zones except RED, it is configured in "metro" mode
> 
> Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
> ---
> config/udev/enable_codel | 65 ++++++++++++++++++++++++++++++++--------
> 1 file changed, 52 insertions(+), 13 deletions(-)
> 
> diff --git a/config/udev/enable_codel b/config/udev/enable_codel
> index 6cafd9b26..3ef9b0f59 100644
> --- a/config/udev/enable_codel
> +++ b/config/udev/enable_codel
> @@ -21,9 +21,9 @@
> #                                                                          #
> ############################################################################
> 
> -LOG_FACILITY="codel"
> +LOG_FACILITY="aqm"
> 
> -function log() {
> +log() {
> 	logger -t "${LOG_FACILITY}" $@
> }
> 
> @@ -32,19 +32,58 @@ if [ -z "${INTERFACE}" ]; then
> 	exit 1
> fi
> 
> -# Do nothing for the loopback device.
> -[ "${INTERFACE}" = "lo" ] && exit 0
> -
> case "${ACTION}" in
> 	add|register)
> -		# Change root qdisc to use fq_codel.
> -		/sbin/tc qdisc add root dev ${INTERFACE} fq_codel
> -		ret=$?
> -
> -		if [ ${ret} -eq 0 ]; then
> -			log "Codel AQM has been enabled on '${INTERFACE}'."
> -		else
> -			log "Codel AQM could not be enabled on '${INTERFACE}'. Error code: ${ret}"
> +		TYPE="$(</sys/class/net/${INTERFACE}/type)"
> +
> +		# Detect bridges
> +		if [ -d "/sys/class/net/${INTERFACE}/bridge" ]; then
> +			TYPE="bridge"
> +		fi
> +
> +		args=()
> +
> +		# Configure some useful defaults depending on the interface
> +		case "${INTERFACE},${TYPE}" in
> +			# Ignore loopback
> +			lo,*)
> +				exit 0
> +				;;
> +
> +			# Ignore tun
> +			tun*)
> +				exit 0
> +				;;
> +
> +			# Ignore GRE/VTI
> +			*,778|*,768)
> +				exit 0
> +				;;
> +
> +			# Ignore bridges
> +			*,bridge)
> +				exit 0
> +				;;
> +
> +			# Handle RED PPPoE (default to VDSL2)
> +			ppp*,512)
> +				args+=( "cake" "internet" "pppoe-ptm" "ack-filter" )
> +				;;
> +
> +			# Treat any other interfaces as "Ethernet"
> +			red*,*)
> +				args+=( "cake" "internet" "ethernet" )
> +				;;
> +
> +			# All other interfaces are locally connected
> +			*)
> +				args+=( "cake" "ethernet" "metro" )
> +				;;
> +		esac
> +
> +		# Change root qdisc to use cake
> +		if ! tc qdisc replace root dev "${INTERFACE}" "${args[@]}"; then
> +			log "Could not configure qdisc on ${INTERFACE} with parameters ${args[@]}"
> 			exit ${ret}
> 		fi
> 		;;
> -- 
> 2.30.2
>
  

Patch

diff --git a/config/udev/enable_codel b/config/udev/enable_codel
index 6cafd9b26..3ef9b0f59 100644
--- a/config/udev/enable_codel
+++ b/config/udev/enable_codel
@@ -21,9 +21,9 @@ 
 #                                                                          #
 ############################################################################
 
-LOG_FACILITY="codel"
+LOG_FACILITY="aqm"
 
-function log() {
+log() {
 	logger -t "${LOG_FACILITY}" $@
 }
 
@@ -32,19 +32,58 @@  if [ -z "${INTERFACE}" ]; then
 	exit 1
 fi
 
-# Do nothing for the loopback device.
-[ "${INTERFACE}" = "lo" ] && exit 0
-
 case "${ACTION}" in
 	add|register)
-		# Change root qdisc to use fq_codel.
-		/sbin/tc qdisc add root dev ${INTERFACE} fq_codel
-		ret=$?
-
-		if [ ${ret} -eq 0 ]; then
-			log "Codel AQM has been enabled on '${INTERFACE}'."
-		else
-			log "Codel AQM could not be enabled on '${INTERFACE}'. Error code: ${ret}"
+		TYPE="$(</sys/class/net/${INTERFACE}/type)"
+
+		# Detect bridges
+		if [ -d "/sys/class/net/${INTERFACE}/bridge" ]; then
+			TYPE="bridge"
+		fi
+
+		args=()
+
+		# Configure some useful defaults depending on the interface
+		case "${INTERFACE},${TYPE}" in
+			# Ignore loopback
+			lo,*)
+				exit 0
+				;;
+
+			# Ignore tun
+			tun*)
+				exit 0
+				;;
+
+			# Ignore GRE/VTI
+			*,778|*,768)
+				exit 0
+				;;
+
+			# Ignore bridges
+			*,bridge)
+				exit 0
+				;;
+
+			# Handle RED PPPoE (default to VDSL2)
+			ppp*,512)
+				args+=( "cake" "internet" "pppoe-ptm" "ack-filter" )
+				;;
+
+			# Treat any other interfaces as "Ethernet"
+			red*,*)
+				args+=( "cake" "internet" "ethernet" )
+				;;
+
+			# All other interfaces are locally connected
+			*)
+				args+=( "cake" "ethernet" "metro" )
+				;;
+		esac
+
+		# Change root qdisc to use cake
+		if ! tc qdisc replace root dev "${INTERFACE}" "${args[@]}"; then
+			log "Could not configure qdisc on ${INTERFACE} with parameters ${args[@]}"
 			exit ${ret}
 		fi
 		;;