From 35c18c104adc45754e1c2940854c91955b997c54 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Fri, 30 Oct 2020 21:06:45 +0100 Subject: [PATCH 1/2] Fix ifname on macvlan if needed --- macvlan/files/etc/init.d/macvlan | 1 + 1 file changed, 1 insertion(+) diff --git a/macvlan/files/etc/init.d/macvlan b/macvlan/files/etc/init.d/macvlan index 2a868905d..01a6ee47c 100755 --- a/macvlan/files/etc/init.d/macvlan +++ b/macvlan/files/etc/init.d/macvlan @@ -67,6 +67,7 @@ _setup_interface() { [ -z "$(uci -q get network.$1.masterintf)" ] && uci -q set network.$1.masterintf=$(uci -q get network.$1_dev.ifname) [ -n "$(uci -q get network.$1.masterintf)" ] && uci -q set network.$1_dev.ifname=$(uci -q get network.$1.masterintf) [ -z "$(uci -q get network.$1.macaddr)" ] && uci -q set network.$1_dev.macaddr=$(uci -q get network.$1.macaddr) + uci set network.$1.ifname=$1 uci -q commit network return 0 } From 6c54484102a41254ee3f930ee53bf1c87fcb2cd4 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Fri, 30 Oct 2020 21:07:03 +0100 Subject: [PATCH 2/2] Fix add latency --- .../root/etc/init.d/openmptcprouter | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/luci-app-openmptcprouter/root/etc/init.d/openmptcprouter b/luci-app-openmptcprouter/root/etc/init.d/openmptcprouter index 8309d6c2d..c49866fd5 100755 --- a/luci-app-openmptcprouter/root/etc/init.d/openmptcprouter +++ b/luci-app-openmptcprouter/root/etc/init.d/openmptcprouter @@ -23,25 +23,27 @@ omr_intf_set() { config_get ifname "$1" ifname config_get device "$1" device 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) [ -z "$ifname" ] && ifname=$(ifstatus "$1" | jsonfilter -q -e '@["l3_device"]') 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 fi 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 - 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 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}) 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')" @@ -50,7 +52,7 @@ omr_intf_set() { uci -q delete network.$1.device uci -q delete network.$1.modalias 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.product="$(cat /sys/bus/usb-serial/devices/${devicename}/device/uevent | grep PRODUCT | cut -d '=' -f2 | tr -d '\n')" fi