]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
AQM: Use CAKE as default qdisc where appropriate instead of fq_codel
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 2 Dec 2021 12:37:41 +0000 (12:37 +0000)
committerArne Fitzenreiter <arne_f@ipfire.org>
Sun, 16 Jan 2022 15:17:50 +0000 (15:17 +0000)
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>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
config/udev/enable_codel

index 6cafd9b268a6f43c67eee119e5b00378f1b50660..3ef9b0f5929ffd7b93dc13c18a8d84f44a0cdf14 100644 (file)
@@ -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
                ;;