From 8cde301b92c8bfbcc80b3827a8e9e6a0eb30389a Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 27 Jul 2022 13:29:30 +0200 Subject: [PATCH 1/3] Fix static route and errors in log --- mptcp/files/etc/init.d/mptcp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/mptcp/files/etc/init.d/mptcp b/mptcp/files/etc/init.d/mptcp index 4f26ff74e..99cd7d0db 100755 --- a/mptcp/files/etc/init.d/mptcp +++ b/mptcp/files/etc/init.d/mptcp @@ -170,6 +170,7 @@ interface_multipath_settings() { [ -n "$(ifconfig | grep $iface)" ] || return 0 [ "$(echo $iface | grep _dev)" != "" ] && return 0 [ "$(echo $iface | grep '^if')" != "" ] && return 0 + [ "$iface" = "lo" ] && return 0 if [ "$mode" = "master" ]; then multipath "$iface" "on" @@ -262,8 +263,8 @@ interface_multipath_settings() { EOF else #echo "Add routes for $ipaddr table $id" - [ -n "$ipaddr" ] && ip rule add from $ipaddr table $id pref 0 - ip rule add oif $iface table $id pref 0 + [ -n "$ipaddr" ] && [ -z "$(ip rule show from $ipaddr table $id)" ] && ip rule add from $ipaddr table $id pref 0 + [ -z "$(ip rule show oif $iface table $id)" ] && ip rule add oif $iface table $id pref 0 ip route replace $network/$netmask dev $iface scope link metric $id 2>&1 >/dev/null ip route replace $network/$netmask dev $iface scope link table $id 2>&1 >/dev/null ip route replace default via $gateway dev $iface table $id 2>&1 >/dev/null @@ -389,11 +390,15 @@ set_multipath() { exist=1 fi done - [ "$exist" = "0" ] && multipath $iface off + [ "$exist" = "0" ] && { + multipath $iface off + } done } add_route() { + config_get disabled "$1" disabled + [ "$disabled" = "1" ] && return 0 config_get target "$1" target routeset="$target" config_get netmask "$1" netmask @@ -417,10 +422,14 @@ add_route() { [ -n "$(echo $iface | grep '@')" ] && iface=$(ifstatus "$interface" | jsonfilter -q -e '@["device"]') [ -n "$iface" ] && routeset="$routeset dev $iface" logger -t "MPTCP" "Add route $routeset" - [ -n "$routeset" ] && ip route replace $routeset 2>&1 >/dev/null + [ -n "$routeset" ] && { + ip route replace ${routeset} 2>&1 >/dev/null + } } add_route6() { + config_get disabled "$1" disabled + [ "$disabled" = "1" ] && return 0 config_get target "$1" target routeset="$target" config_get gateway "$1" gateway @@ -438,7 +447,9 @@ add_route6() { [ -n "$(echo $iface | grep '@')" ] && iface=$(ifstatus "$interface" | jsonfilter -q -e '@["device"]') [ -n "$iface" ] && routeset="$routeset dev $iface" logger -t "MPTCP" "Add IPv6 route $routeset" - [ -n "$routeset" ] && ip -6 route replace $routeset 2>&1 >/dev/null + [ -n "$routeset" ] && { + ip -6 route replace ${routeset} 2>&1 >/dev/null + } } remove() { @@ -484,7 +495,7 @@ start_service() { config_foreach interface_multipath_settings interface $intf set_multipath config_foreach add_route route - config_foreach add_route route6 + config_foreach add_route6 route6 # If no master is defined, one interface is defined as master if [ "$master" = "" ] && [ "$intf" = "" ]; then intfmaster="$mptcpmintf" From 81f221ec07c569b4cf3db2c7ed8ebcd6ccd680f0 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 27 Jul 2022 13:29:54 +0200 Subject: [PATCH 2/3] Fix when device have no IP and multipath command launched --- mptcp/files/usr/bin/multipath | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mptcp/files/usr/bin/multipath b/mptcp/files/usr/bin/multipath index 6125f1759..294c3aaab 100755 --- a/mptcp/files/usr/bin/multipath +++ b/mptcp/files/usr/bin/multipath @@ -134,7 +134,7 @@ else ID=$(ip mptcp endpoint show | grep "dev $DEVICE" | awk '{print $3}') IFF=$(ip mptcp endpoint show | grep "dev $DEVICE" | awk '{print $4}') IP=$(ip a show $DEVICE | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p') - [ -z "$ID" ] && ID=$(ip mptcp endpoint show | grep "$IP" | awk '{print $3}') + [ -z "$ID" ] && [ -n "$IP" ] && ID=$(ip mptcp endpoint show | grep "$IP" | awk '{print $3}') RMID=$(ip mptcp endpoint show | grep '::ffff' | awk '{ print $3 }') [ -n "$RMID" ] && ip mptcp endpoint delete id $RMID 2>&1 >/dev/null case $TYPE in From 04c4161845ea9d580ff11fb94fb94bd9d9ed3194 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 27 Jul 2022 13:30:24 +0200 Subject: [PATCH 3/3] Fix MTU detection --- .../share/omr/post-tracking.d/post-tracking | 10 +++++---- openmptcprouter/files/bin/omr-mtu6 | 21 +++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) create mode 100755 openmptcprouter/files/bin/omr-mtu6 diff --git a/mptcp/files/usr/share/omr/post-tracking.d/post-tracking b/mptcp/files/usr/share/omr/post-tracking.d/post-tracking index 615c0fad2..9fcfb89ca 100755 --- a/mptcp/files/usr/share/omr/post-tracking.d/post-tracking +++ b/mptcp/files/usr/share/omr/post-tracking.d/post-tracking @@ -1376,7 +1376,8 @@ if [ -n "$OMR_TRACKER_INTERFACE" ] && ([ "$(uci -q get openmptcprouter.$OMR_TRAC omrtracebox="$(omr-tracebox-mptcp $serverip $OMR_TRACKER_DEVICE)" [ -n "$omrtracebox" ] && [ -z "$(echo $omrtracebox | grep error)" ] && uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.mptcp_status="$omrtracebox" } - if [ "$OMR_TRACKER_INTERFACE" != "omrvpn" ] && [ "$(uci -q get glorytun.vpn.enable)" != "1" ] && [ "$(uci -q get glorytun-udp.vpn.enable)" != "1" ] && [ -n "$OMR_TRACKER_DEVICE" ]; then + #if [ "$OMR_TRACKER_INTERFACE" != "omrvpn" ] && [ "$(uci -q get glorytun.vpn.enable)" != "1" ] && [ "$(uci -q get glorytun-udp.vpn.enable)" != "1" ] && [ -n "$OMR_TRACKER_DEVICE" ]; then + if [ "$OMR_TRACKER_INTERFACE" != "omrvpn" ] && [ -n "$OMR_TRACKER_DEVICE" ]; then if [ -n "$(uci -q get network.$(find_network_device ${OMR_TRACKER_INTERFACE}).mtu)" ]; then network_device=$(find_network_device ${OMR_TRACKER_INTERFACE}) mtu="" @@ -1449,7 +1450,8 @@ if [ -n "$OMR_TRACKER_INTERFACE" ] && ([ "$(uci -q get openmptcprouter.$OMR_TRAC omrtracebox="$(omr-tracebox-mptcp $serverip $OMR_TRACKER_DEVICE)" [ -n "$omrtracebox" ] && [ -z "$(echo $omrtracebox | grep error)" ] && uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.mptcp_status="$omrtracebox" } - if [ "$OMR_TRACKER_INTERFACE" != "omrvpn" ] && [ "$(uci -q get glorytun.vpn.enable)" != "1" ] && [ "$(uci -q get glorytun-udp.vpn.enable)" != "1" ] && [ -n "$OMR_TRACKER_DEVICE" ]; then + #if [ "$OMR_TRACKER_INTERFACE" != "omrvpn" ] && [ "$(uci -q get glorytun.vpn.enable)" != "1" ] && [ "$(uci -q get glorytun-udp.vpn.enable)" != "1" ] && [ -n "$OMR_TRACKER_DEVICE" ]; then + if [ "$OMR_TRACKER_INTERFACE" != "omrvpn" ] && [ -n "$OMR_TRACKER_DEVICE" ]; then network_device=$(find_network_device ${OMR_TRACKER_INTERFACE}) if [ -n "$network_device" ] && [ -n "$(uci -q get network.${network_device}.mtu)" ]; then mtu=$(uci -q get network.$(find_network_device ${OMR_TRACKER_INTERFACE}).mtu) @@ -1459,13 +1461,13 @@ if [ -n "$OMR_TRACKER_INTERFACE" ] && ([ "$(uci -q get openmptcprouter.$OMR_TRAC } elif [ -n "$OMR_TRACKER_DEVICE_IP" ]; then [ -n "$serverip" ] && [ "$serverip" != "127.0.0.1" ] && { - local mtu=$(omr-mtu $OMR_TRACKER_DEVICE_IP $serverip) + local mtu=$(omr-mtu6 $OMR_TRACKER_DEVICE_IP6 $serverip) [ -n "$mtu" ] && { uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.mtu=$mtu ip link set dev $OMR_TRACKER_DEVICE mtu $mtu > /dev/null 2>&1 } } || { - local mtu=$(omr-mtu $OMR_TRACKER_DEVICE_IP 1.1.1.1) + local mtu=$(omr-mtu6 $OMR_TRACKER_DEVICE_IP 2606:4700:4700::1111) [ -n "$mtu" ] && { uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.mtu=$mtu ip link set dev $OMR_TRACKER_DEVICE mtu $mtu > /dev/null 2>&1 diff --git a/openmptcprouter/files/bin/omr-mtu6 b/openmptcprouter/files/bin/omr-mtu6 new file mode 100755 index 000000000..df63bdd54 --- /dev/null +++ b/openmptcprouter/files/bin/omr-mtu6 @@ -0,0 +1,21 @@ +#!/bin/sh + +PKT_SIZE=1472 +INTERFACE="$1" +HOSTNAME="$2" + +#count=$(ping -q -w 1 -M do -c 1 -s $PKT_SIZE -I $INTERFACE $HOSTNAME | grep -cE 'Message too long|100% packet loss') +#count=$(ping -B -w 1 -M do -c 1 -s $PKT_SIZE -I $INTERFACE $HOSTNAME 2>&1 | grep -c 'Message too long') +count=$(ping -6 -B -w 2 -M do -c 3 -s $PKT_SIZE -I $INTERFACE $HOSTNAME 2>&1 | grep -cE 'Message too long|100% packet loss') + +while [ $count -ge 1 ]; do + PKT_SIZE=$((PKT_SIZE - 1)) + if [ "$PKT_SIZE" -lt "1252" ]; then + exit 0 + fi + #count=$(ping -q -w 1 -M do -c 1 -s $PKT_SIZE -I $INTERFACE $HOSTNAME | grep -cE 'Message too long|100% packet loss') + #count=$(ping -B -w 1 -M do -c 1 -s $PKT_SIZE -I $INTERFACE $HOSTNAME 2>&1 | grep -c 'Message too long') + count=$(ping -6 -B -w 2 -M do -c 3 -s $PKT_SIZE -I $INTERFACE $HOSTNAME 2>&1 | grep -cE 'Message too long|100% packet loss') +done + +printf "$((PKT_SIZE + 28))" \ No newline at end of file