Apply netem packet rules to only UDP traffic (#6754)

This commit is contained in:
Pankaj Garg 2019-11-05 18:34:04 -08:00 committed by GitHub
parent 1c5d2a85cf
commit 0c2bf022fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -16,5 +16,14 @@ fi
set -x
iface="$(ifconfig | grep mtu | grep -iv loopback | grep -i running | awk 'BEGIN { FS = ":" } ; {print $1}')"
if [[ "$1" = delete ]]; then
$sudo iptables -F -t mangle
else
$sudo iptables -A POSTROUTING -t mangle -p udp -j MARK --set-mark 1
fi
$sudo tc qdisc "$1" dev "$iface" root handle 1: prio
# shellcheck disable=SC2086 # Do not want to quote $2. It has space separated arguments for netem
$sudo tc qdisc "$1" dev "$iface" root netem $2
$sudo tc qdisc "$1" dev "$iface" parent 1:3 handle 30: netem $2
$sudo tc filter "$1" dev "$iface" parent 1:0 protocol ip prio 3 handle 1 fw flowid 1:3