mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-02-12 10:31:51 +00:00
Add multipath settings in openmptcprouter section
This commit is contained in:
parent
d1446250e9
commit
cb8147a7e5
5 changed files with 45 additions and 12 deletions
|
@ -105,13 +105,17 @@ function wizard_add()
|
|||
ucic:set("network","wan" .. i,"ip4table","wan")
|
||||
if multipath_master then
|
||||
ucic:set("network","wan" .. i,"multipath","on")
|
||||
ucic:set("openmptcprouter","wan" .. i,"multipath","on")
|
||||
else
|
||||
ucic:set("network","wan" .. i,"multipath","master")
|
||||
ucic:set("openmptcprouter","wan" .. i,"multipath","master")
|
||||
end
|
||||
ucic:set("network","wan" .. i,"defaultroute","0")
|
||||
ucic:reorder("network","wan" .. i, i + 2)
|
||||
ucic:save("network")
|
||||
ucic:commit("network")
|
||||
ucic:save("openmptcprouter")
|
||||
ucic:commit("openmptcprouter")
|
||||
|
||||
ucic:set("qos","wan" .. i,"interface")
|
||||
ucic:set("qos","wan" .. i,"classgroup","Default")
|
||||
|
|
|
@ -81,8 +81,10 @@ function add_interface(add_interface_ifname)
|
|||
ucic:set("network","wan" .. i,"ip4table","wan")
|
||||
if multipath_master then
|
||||
ucic:set("network","wan" .. i,"multipath","on")
|
||||
ucic:set("openmptcprouter","wan" .. i,"multipath","on")
|
||||
else
|
||||
ucic:set("network","wan" .. i,"multipath","master")
|
||||
ucic:set("openmptcprouter","wan" .. i,"multipath","master")
|
||||
end
|
||||
ucic:set("network","wan" .. i,"defaultroute","0")
|
||||
ucic:reorder("network","wan" .. i, i + 2)
|
||||
|
@ -222,6 +224,8 @@ function set_interface(intf,proto,ipaddr,netmask,gateway,sqmenabled,downloadspee
|
|||
ucic:commit("qos")
|
||||
ucic:save("network")
|
||||
ucic:commit("network")
|
||||
ucic:save("openmptcprouter")
|
||||
ucic:commit("openmptcprouter")
|
||||
end
|
||||
|
||||
function default_vpn(default_vpn)
|
||||
|
|
|
@ -20,8 +20,11 @@ interface_multipath_settings() {
|
|||
local mode port
|
||||
local config="$1"
|
||||
id=$(($id+1))
|
||||
config_get mode "$config" multipath "off"
|
||||
[ "$mode" = "off" ] && return 1
|
||||
config_get mode "$config" multipath ""
|
||||
[ "$mode" = "" ] && {
|
||||
mode="$(uci -q get openmptcprouter.$config.multipath)"
|
||||
}
|
||||
[ "$mode" = "off" ] || [ "$mode" = "" ] && return 1
|
||||
config_get ifname "$config" ifname
|
||||
[ -z "$ifname" ] && ifname=$(ifstatus "$config" | jsonfilter -q -e '@["l3_device"]')
|
||||
[ -z "$ifname" ] && return 1
|
||||
|
|
|
@ -52,7 +52,12 @@ interface_multipath_settings() {
|
|||
id=$count
|
||||
config_set "$config" metric $count
|
||||
uci -q set network.${config}.metric=$count
|
||||
uci -q set openmptcprouter.${config}.metric=$count
|
||||
config_get mode "$config" multipath
|
||||
[ "$mode" = "" ] && {
|
||||
mode="$(uci -q get openmptcprouter.${config}.multipath)"
|
||||
[ -n "$mode" ] && uci -q set network.${config}.multipath="$mode"
|
||||
}
|
||||
[ "$mode" = "" ] && {
|
||||
[ "$config" = "lan" ] && mode="off"
|
||||
[ "$config" = "omrvpn" ] && mode="off"
|
||||
|
@ -60,6 +65,7 @@ interface_multipath_settings() {
|
|||
[ "$mode" = "" ] && mode="on"
|
||||
logger -t "MPTCP" "Multipath not defined for $config set to $mode"
|
||||
uci -q set network.${config}.multipath="$mode"
|
||||
uci -q set openmptcprouter.${config}.multipath="$mode"
|
||||
}
|
||||
[ "$mode" != "off" ] && {
|
||||
[ -n "$mptcpintf" ] && mptcpintf="$mptcpintf $iface"
|
||||
|
@ -74,6 +80,7 @@ interface_multipath_settings() {
|
|||
logger -t "MPTCP" "Multipath master already set, disable master for $config"
|
||||
config_set "$config" multipath "on"
|
||||
uci -q set network.${config}.multipath="on"
|
||||
uci -q set openmptcprouter.${config}.multipath="on"
|
||||
else
|
||||
master="$config"
|
||||
fi
|
||||
|
@ -176,7 +183,8 @@ interface_multipath_settings() {
|
|||
#ip route flush $id
|
||||
fi
|
||||
|
||||
config_get mode "$config" multipath "off"
|
||||
#config_get mode "$config" multipath ""
|
||||
#[ "$mode" = "" ] && mode="$(uci -q get openmptcprouter.${config}.multipath)"
|
||||
[ "$mode" = "master" ] && {
|
||||
#echo "ip route replace default via $gateway dev $iface"
|
||||
ip route replace default via $gateway dev $iface
|
||||
|
@ -258,7 +266,7 @@ interface_multipath_settings() {
|
|||
ip -6 route flush 6$id
|
||||
fi
|
||||
|
||||
config_get mode "$config" multipath "off"
|
||||
#config_get mode "$config" multipath "off"
|
||||
[ "$mode" = "master" ] && {
|
||||
ip -6 route replace default via $gateway6 dev $iface
|
||||
}
|
||||
|
@ -273,8 +281,9 @@ interface_multipath_settings() {
|
|||
|
||||
load_interfaces() {
|
||||
config_get ifname "$1" ifname
|
||||
config_get multipath "$1" multipath "off"
|
||||
[ "$multipath" != "off" ] && interfaces=" ${ifname} ${interfaces}"
|
||||
config_get multipath "$1" multipath ""
|
||||
[ -z "$multipath" ] && multipath="$(uci -q get openmptcprouter.$1.multipath)"
|
||||
[ "$multipath" != "off" ] && [ "$multipath" != "" ] && interfaces=" ${ifname} ${interfaces}"
|
||||
}
|
||||
|
||||
set_multipath() {
|
||||
|
@ -331,6 +340,7 @@ add_route6() {
|
|||
}
|
||||
|
||||
remove() {
|
||||
logger -t "MPTCP" "Remove network.$1"
|
||||
uci -q delete network.$1
|
||||
}
|
||||
|
||||
|
@ -362,9 +372,11 @@ start_service() {
|
|||
[ "$intfmaster" != "" ] && {
|
||||
logger -t "MPTCP" "No master multipath defined, setting it to $intfmaster"
|
||||
uci -q set network.${intfmaster}.multipath="master"
|
||||
uci -q set openmptcprouter.${intfmaster}.multipath="master"
|
||||
}
|
||||
fi
|
||||
uci -q commit network
|
||||
uci -q commit openmptcprouter
|
||||
[ -n "$(ubus call system board | jsonfilter -e '@.board_name' | grep raspberry)" ] && [ -z "$(ubus call system board | jsonfilter -e '@.board_name' | grep '4-model-b')" ] && {
|
||||
ethtool --offload eth0 rx off tx off
|
||||
}
|
||||
|
|
|
@ -5,7 +5,8 @@ set_route() {
|
|||
local multipath_config interface_gw interface_if
|
||||
INTERFACE=$1
|
||||
PREVINTERFACE=$2
|
||||
multipath_config=$(uci -q get network.$INTERFACE.multipath || echo "off")
|
||||
multipath_config=$(uci -q get network.$INTERFACE.multipath)
|
||||
[ -z "$multipath_config" ] && multipath_config=$(uci -q get openmptcprouter.$INTERFACE.multipath || echo "off")
|
||||
interface_if=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||
[ -z "$interface_if" ] && interface_if=$(ifstatus "${INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.ifname)
|
||||
|
@ -53,7 +54,8 @@ set_server_default_route() {
|
|||
local server=$1
|
||||
local serverip
|
||||
config_get serverip $server ip
|
||||
multipath_config_route=$(uci -q get network.$OMR_TRACKER_INTERFACE.multipath || echo "off")
|
||||
multipath_config_route=$(uci -q get network.$OMR_TRACKER_INTERFACE.multipath)
|
||||
[ -z "$multipath_config_route" ] && multipath_config_route=$(uci -q get network.$OMR_TRACKER_INTERFACE.multipath || echo "off")
|
||||
if [ "$serverip" != "" ] && [ "$OMR_TRACKER_DEVICE_GATEWAY" != "" ] && [ "$(ip route show dev $OMR_TRACKER_DEVICE metric 1 | grep $serverip | grep $OMR_TRACKER_DEVICE_GATEWAY)" = "" ] && [ "$multipath_config_route" != "off" ]; then
|
||||
_log "Set server $server ($serverip) default route via $OMR_TRACKER_DEVICE_GATEWAY"
|
||||
if [ "$(uci -q get openmptcprouter.settings.uci_route)" = "1" ]; then
|
||||
|
@ -74,7 +76,8 @@ set_server_default_route() {
|
|||
|
||||
set_routes_intf() {
|
||||
local INTERFACE=$1
|
||||
multipath_config=$(uci -q get network.$INTERFACE.multipath || echo "off")
|
||||
multipath_config=$(uci -q get network.$INTERFACE.multipath)
|
||||
[ -z "$multipath_config" ] && multipath_config_route=$(uci -q get network.$INTERFACE.multipath || echo "off")
|
||||
interface_if=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||
[ -z "$interface_if" ] && interface_if=$(ifstatus "${INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.ifname)
|
||||
|
@ -104,7 +107,8 @@ set_server_all_routes() {
|
|||
[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||
[ -z "$interface_if" ] && interface_if=$(ifstatus "${OMR_TRACKER_INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||
multipath_current_config=$(multipath $interface_if | grep "deactivated")
|
||||
multipath_config_route=$(uci -q get network.$OMR_TRACKER_INTERFACE.multipath || echo "off")
|
||||
multipath_config_route=$(uci -q get network.$OMR_TRACKER_INTERFACE.multipath)
|
||||
[ -z "$multipath_config_route" ] && multipath_config_route=$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipath || echo "off")
|
||||
if [ "$serverip" != "" ] && [ "$OMR_TRACKER_DEVICE_GATEWAY" != "" ] && [ "$(ip route show $serverip | grep nexthop | grep $OMR_TRACKER_DEVICE_GATEWAY | grep $OMR_TRACKER_INTERFACE)" = "" ] && [ "$multipath_config_route" != "off" ]; then
|
||||
routesintf=""
|
||||
config_load network
|
||||
|
@ -124,7 +128,8 @@ set_server_route() {
|
|||
config_get serverip $server ip
|
||||
local metric=$2
|
||||
[ -z "$metric" ] && metric=$(uci -q get network.$OMR_TRACKER_INTERFACE.metric)
|
||||
multipath_config_route=$(uci -q get network.$OMR_TRACKER_INTERFACE.multipath || echo "off")
|
||||
multipath_config_route=$(uci -q get network.$OMR_TRACKER_INTERFACE.multipath)
|
||||
[ "$multipath_config_route" ] && multipath_config_route=$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipath || echo "off")
|
||||
interface_if=$(uci -q get network.$OMR_TRACKER_INTERFACE.ifname)
|
||||
[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||
[ -z "$interface_if" ] && interface_if=$(ifstatus "${OMR_TRACKER_INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||
|
@ -360,7 +365,8 @@ if [ "$OMR_TRACKER_PREV_STATUS" != "" ] && [ "$OMR_TRACKER_PREV_STATUS" != "$OMR
|
|||
dns_flush
|
||||
fi
|
||||
|
||||
multipath_config=$(uci -q get "network.$OMR_TRACKER_INTERFACE.multipath" || echo "off")
|
||||
multipath_config=$(uci -q get "network.$OMR_TRACKER_INTERFACE.multipath")
|
||||
[ "$multipath_config" ] && multipath_config=$(uci -q get "openmptcprouter.$OMR_TRACKER_INTERFACE.multipath" || echo "off")
|
||||
if [ "$multipath_config" = "master" ]; then
|
||||
if [ "$default_gw" != "$OMR_TRACKER_DEVICE_GATEWAY" ] || [ "$default_gw" = "" ]; then
|
||||
omrvpn_intf=$(uci -q get "network.omrvpn.ifname" || echo "tun")
|
||||
|
@ -530,6 +536,7 @@ fi
|
|||
#[ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.latency_max)" -lt "$OMR_TRACKER_LATENCY" ] && uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.latency_max="$OMR_TRACKER_LATENCY"
|
||||
if [ "$multipath_config" = "on" ] && [ "$(uci -q get network.$OMR_TRACKER_INTERFACE.multipath)" != "master" ] && ([ "$(uci -q get openmptcprouter.settings.master)" = "dynamic" ] || (([ "$(uci -q get openmptcprouter.settings.master)" = "change" ] || [ "$(uci -q get openmptcprouter.settings.master)" = "" ]) && [ "$(uci -q get openmptcprouter.settings.master_lcintf | grep $OMR_TRACKER_INTERFACE)" = "" ])); then
|
||||
masterintf="$(uci -q show network | grep multipath=\'master\' | cut -d'.' -f2)"
|
||||
[ -z "$masterintf" ] && masterintf="$(uci -q show openmptcprouter | grep multipath=\'master\' | cut -d'.' -f2)"
|
||||
masterlatency="$(uci -q get openmptcprouter.$masterintf.latency | tr -d '\n')"
|
||||
if [ -z "$masterlatency" ] || [ "$(uci -q get openmptcprouter.$masterintf.state)" = "down" ]; then
|
||||
masterlatency=1000
|
||||
|
@ -537,12 +544,15 @@ fi
|
|||
if [ -n "$masterintf" ] && ([ "$masterlatency" != "" ] || [ "$(uci -q get openmptcprouter.$masterintf.state)" = "down" ]); then
|
||||
if (([ "$(uci -q get openmptcprouter.settings.master)" = "change" ] || [ "$(uci -q get openmptcprouter.settings.master)" = "" ]) && [ "$OMR_TRACKER_LATENCY" -lt "$((masterlatency/2))" ]) || ([ "$(uci -q get openmptcprouter.settings.master)" = "dynamic" ] && [ "$OMR_TRACKER_LATENCY" -lt "$((masterlatency/2))" ] && [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.latency_previous)" -lt "$((masterlatency/2))" ]); then
|
||||
uci -q set network.$masterintf.multipath='on'
|
||||
uci -q set openmptcprouter.$masterintf.multipath='on'
|
||||
uci -q set network.$OMR_TRACKER_INTERFACE.multipath='master'
|
||||
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.multipath='master'
|
||||
if [ "$(uci -q get openmptcprouter.settings.master_lcintf | grep $OMR_TRACKER_INTERFACE)" = "" ]; then
|
||||
uci -q add_list openmptcprouter.settings.master_lcintf="$OMR_TRACKER_INTERFACE"
|
||||
fi
|
||||
if [ "$(uci -q get openmptcprouter.settings.master)" != "dynamic" ]; then
|
||||
uci -q commit network
|
||||
uci -q commit openmptcprouter
|
||||
fi
|
||||
_log "Change master interface from $masterintf ($masterlatency ms) to $OMR_TRACKER_INTERFACE ($OMR_TRACKER_LATENCY ms)"
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue