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

Merge pull request #258 from Ysurac/develop

sync
This commit is contained in:
suyuan 2022-07-28 02:01:03 +08:00 committed by GitHub
commit dc3f45f91b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 11 deletions

View file

@ -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"

View file

@ -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

View file

@ -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

View 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))"