mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Add mptcp support
This commit is contained in:
parent
ec6e530e52
commit
40fdd921b9
7 changed files with 375 additions and 0 deletions
45
mptcp/files/usr/share/omr/post-tracking.d/post-tracking
Executable file
45
mptcp/files/usr/share/omr/post-tracking.d/post-tracking
Executable file
|
@ -0,0 +1,45 @@
|
|||
# vim: set ft=sh noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 :
|
||||
|
||||
SETROUTE=false
|
||||
set_route() {
|
||||
local multipath_config interface_gw interface_if
|
||||
INTERFACE=$1
|
||||
multipath_config=$(uci -q get "network.$INTERFACE.multipath" || echo "off")
|
||||
#multipath_current_config=$(multipath $INTERFACE | grep deactivated)
|
||||
#if [ "$multipath_config" != "off" ] && [ "$SETROUTE" != true ] && [ "$multipath_current_config" = "" ]; then
|
||||
if [ "$multipath_config" != "off" ] && [ "$SETROUTE" != true ]; then
|
||||
interface_gw=$(uci -q get "network.$INTERFACE.gateway")
|
||||
interface_if=$(uci -q get "network.$INTERFACE.ifname")
|
||||
ip route replace default scope global nexthop via $interface_gw dev $interface_if && SETROUTE=true
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Get the current multipath status
|
||||
multipath_status="off"
|
||||
case "$(multipath "$OMR_TRACKER_DEVICE")" in
|
||||
*default*) multipath_status="on" ;;
|
||||
*backup*) multipath_status="backup" ;;
|
||||
*handover*) multipath_status="handover" ;;
|
||||
esac
|
||||
|
||||
default_gw=$(ip route show default | grep -v metric | awk '/default/ {print $3}')
|
||||
current_interface_gw=$(uci -q get "network.$OMR_TRACKER_INTERFACE.gateway")
|
||||
|
||||
# An interface in error will never be used in MPTCP
|
||||
if [ "$OMR_TRACKER_STATUS" = "ERROR" ]; then
|
||||
[ "$multipath_status" = "off" ] && exit 0
|
||||
_log "$OMR_TRACKER_DEVICE switched off"
|
||||
multipath "$OMR_TRACKER_DEVICE" off
|
||||
if [ "$default_gw" = "$current_interface_gw" ] || [ "$default_gw" = "" ]; then
|
||||
config_load network
|
||||
config_foreach set_route interface
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
multipath_config=$(uci -q get "network.$OMR_TRACKER_INTERFACE.multipath" || echo "off")
|
||||
[ "$multipath_config" = "master" ] && multipath_config="on"
|
||||
[ "$multipath_status" = "$multipath_config" ] && exit 0
|
||||
_log "$OMR_TRACKER_DEVICE switched to $multipath_config"
|
||||
multipath "$OMR_TRACKER_DEVICE" "$multipath_config"
|
Loading…
Add table
Add a link
Reference in a new issue