1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

Add interface additional latency settings

This commit is contained in:
Ycarus (Yannick Chabanois) 2020-10-19 16:20:53 +02:00
parent 7a7bf1a7f4
commit 4d15174b5d
2 changed files with 20 additions and 0 deletions

View file

@ -23,8 +23,24 @@ omr_intf_set() {
config_get ifname "$1" ifname
config_get device "$1" device
config_get proto "$1" proto
config_get addlatency "$1" addlatency "0"
devicename=$(echo "$device" | cut -d'/' -f3)
[ -z "$ifname" ] && ifname=$(ifstatus "$1" | jsonfilter -q -e '@["l3_device"]')
if [ -n "$ifname" ]; then
if [ "$addlatency" = "0" ] && [ "$(tc qdisc show $ifname | grep delay)" != "" ]; then
tc qdisc del dev ${ifname} root netem
fi
if [ "$addlatency" != "0" ]; then
if [ "$(tc qdisc show $ifname | grep delay)" != "" ]; then
tc qdisc add dev ${ifname} root netem delay ${addlatency}ms
elif [ "$(tc qdisc show $ifname | awk '/delay/ { print $10 }' | sed 's/ms//')" != "$addlatency" ]; then
tc qdisc replace dev ${ifname} root netem delay ${addlatency}ms
fi
fi
fi
if [ -n "$ifname" ] && [ -f /sys/class/net/${ifname}/device/uevent ]; then
devicepath=$(readlink -f /sys/class/net/${ifname})
if [ -n "$devicepath" ] && [ "$(echo ${devicepath} | grep virtual)" = "" ]; then