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

Fix add latency

This commit is contained in:
Ycarus (Yannick Chabanois) 2020-10-30 21:07:03 +01:00
parent 35c18c104a
commit 6c54484102

View file

@ -23,25 +23,27 @@ omr_intf_set() {
config_get ifname "$1" ifname config_get ifname "$1" ifname
config_get device "$1" device config_get device "$1" device
config_get proto "$1" proto config_get proto "$1" proto
config_get addlatency "$1" addlatency "0" config_get type "$1" type
config_get addlatency "$1" addlatency
[ -z "$addlatency" ] && addlatency=0
devicename=$(echo "$device" | cut -d'/' -f3) devicename=$(echo "$device" | cut -d'/' -f3)
[ -z "$ifname" ] && ifname=$(ifstatus "$1" | jsonfilter -q -e '@["l3_device"]') [ -z "$ifname" ] && ifname=$(ifstatus "$1" | jsonfilter -q -e '@["l3_device"]')
if [ -n "$ifname" ]; then if [ -n "$ifname" ]; then
if [ "$addlatency" = "0" ] && [ "$(tc qdisc show $ifname | grep delay)" != "" ]; then if [ "$addlatency" = "0" ] && [ "$(tc qdisc show dev $ifname | grep delay)" != "" ]; then
tc qdisc del dev ${ifname} root netem tc qdisc del dev ${ifname} root netem
fi fi
if [ "$addlatency" != "0" ]; then if [ "$addlatency" != "0" ]; then
if [ "$(tc qdisc show $ifname | grep delay)" != "" ]; then if [ "$(tc qdisc show dev $ifname | grep delay)" != "" ]; then
tc qdisc add dev ${ifname} root netem delay ${addlatency}ms tc qdisc add dev ${ifname} root netem delay ${addlatency}ms
elif [ "$(tc qdisc show $ifname | awk '/delay/ { print $10 }' | sed 's/ms//')" != "$addlatency" ]; then elif [ "$(tc qdisc show dev $ifname | awk '/delay/ { print $10 }' | sed 's/ms//')" != "$addlatency" ]; then
tc qdisc replace dev ${ifname} root netem delay ${addlatency}ms tc qdisc replace dev ${ifname} root netem delay ${addlatency}ms
fi fi
fi fi
fi fi
if [ -n "$ifname" ] && [ -f /sys/class/net/${ifname}/device/uevent ]; then if [ "$type" != "macvlan" ] && [ -n "$ifname" ] && [ -f /sys/class/net/${ifname}/device/uevent ]; then
devicepath=$(readlink -f /sys/class/net/${ifname}) devicepath=$(readlink -f /sys/class/net/${ifname})
if [ -n "$devicepath" ] && [ "$(echo ${devicepath} | grep virtual)" = "" ]; then if [ -n "$devicepath" ] && [ "$(echo ${devicepath} | grep virtual)" = "" ]; then
uci -q set network.$1.modalias="$(cat /sys/class/net/${ifname}/device/uevent | grep MODALIAS | cut -d '=' -f2 | tr -d '\n')" uci -q set network.$1.modalias="$(cat /sys/class/net/${ifname}/device/uevent | grep MODALIAS | cut -d '=' -f2 | tr -d '\n')"
@ -50,7 +52,7 @@ omr_intf_set() {
uci -q delete network.$1.device uci -q delete network.$1.device
uci -q delete network.$1.modalias uci -q delete network.$1.modalias
fi fi
elif [ -n "$device" ] && [ -f /sys/bus/usb-serial/devices/${devicename}/device/uevent ]; then elif [ "$type" != "macvlan" ] && [ -n "$device" ] && [ -f /sys/bus/usb-serial/devices/${devicename}/device/uevent ]; then
uci -q set network.$1.modalias="$(cat /sys/bus/usb-serial/devices/${devicename}/device/uevent | grep MODALIAS | cut -d '=' -f2 | tr -d '\n')" uci -q set network.$1.modalias="$(cat /sys/bus/usb-serial/devices/${devicename}/device/uevent | grep MODALIAS | cut -d '=' -f2 | tr -d '\n')"
uci -q set network.$1.product="$(cat /sys/bus/usb-serial/devices/${devicename}/device/uevent | grep PRODUCT | cut -d '=' -f2 | tr -d '\n')" uci -q set network.$1.product="$(cat /sys/bus/usb-serial/devices/${devicename}/device/uevent | grep PRODUCT | cut -d '=' -f2 | tr -d '\n')"
fi fi