mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Fix MTU detection
This commit is contained in:
parent
81f221ec07
commit
04c4161845
2 changed files with 27 additions and 4 deletions
|
@ -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
|
||||
|
|
21
openmptcprouter/files/bin/omr-mtu6
Executable file
21
openmptcprouter/files/bin/omr-mtu6
Executable file
|
@ -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))"
|
Loading…
Add table
Add a link
Reference in a new issue