Last active
January 8, 2022 17:45
-
-
Save SaveTheRbtz/19928e50f42985d0ad752d5261ebed83 to your computer and use it in GitHub Desktop.
mq+fq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -ue | |
# Sets up mq+$shed combo for given interface. | |
if [ $# -ne 2 ] || [ -z "$1" ] || [ -z "$2" ]; then | |
echo "usage: $0 interface scheduler" >&2 | |
echo " e.g: $0 eth0 fq" >&2 | |
echo " e.g: $0 eth0 pfifo_fast" >&2 | |
exit 64 # EX_USAGE | |
fi | |
intf="$1" | |
shed="$2" | |
if [ -n "$(/sbin/tc qd show dev "$intf" | grep -F qdisc\ "$shed" | head -1)" ]; then | |
echo "default qdisc is already set to $shed" >&2 | |
exit 0 | |
fi | |
/sbin/tc qd del dev "$intf" root 2>/dev/null || : | |
/sbin/tc qd add dev "$intf" root handle 1: mq | |
default_qdisc="$(cat /proc/sys/net/core/default_qdisc)" | |
if [ "$shed" == "$default_qdisc" ]; then | |
echo "default qdisc selected; skipping creation" >&2 | |
exit 0 | |
fi | |
cpu_num="$(/usr/bin/nproc)" | |
for i in $(seq 1 "$cpu_num"); do | |
slot="$(printf %x "$i")" | |
/sbin/tc qd add dev "$intf" parent 1:"$slot" "$shed" | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@SaveTheRbtz Thank you, this snippet helped me!