mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Fix gateway for connection tracking scripts
This commit is contained in:
parent
79df058855
commit
fbef2bfbce
3 changed files with 14 additions and 4 deletions
|
@ -58,6 +58,7 @@ interface_multipath_settings() {
|
|||
network_get_ipaddr $config ipaddr
|
||||
ipaddr=$(ip -4 addr show dev $iface | grep inet | awk '{print $2}' | cut -d/ -f1 | tr -d "\n")
|
||||
gateway=$(ip -4 r list dev $iface | grep -v default | awk '/proto static/ {print $1}' | tr -d "\n")
|
||||
[ -z "$gateway" ] && gateway=$(uci -q get "network.$config.gateway")
|
||||
[ -z "$gateway" ] && gateway=$(ubus call network.interface.$config status | jsonfilter -e '@.route[0].nexthop' | tr -d "\n")
|
||||
[ -z "$gateway" ] && gateway=$(ubus call network.interface.$config status | jsonfilter -e '@.inactive.route[0].nexthop' | tr -d "\n")
|
||||
netmask=$(ip -4 addr show dev $iface | grep inet | awk '{print $2}' | cut -d/ -f2 | tr -d "\n")
|
||||
|
|
|
@ -11,6 +11,12 @@ set_route() {
|
|||
#if [ "$multipath_config" != "off" ] && [ "$SETROUTE" != true ]; then
|
||||
#if [ "$multipath_config" != "off" ] && [ "$INTERFACE" != "$PREVINTERFACE" ] && [ "$SETROUTE" != true ]; then
|
||||
interface_gw=$(uci -q get "network.$INTERFACE.gateway")
|
||||
if [ -z $interface_gw ]; then
|
||||
$interface_gw=$(ubus call network.interface.$INTERFACE status | jsonfilter -e '@.route[0].nexthop' | tr -d "\d")
|
||||
fi
|
||||
if [ -z $interface_gw ]; then
|
||||
$interface_gw=$(ubus call network.interface.$INTERFACE status | jsonfilter -e '@.inactive.route[0].nexthop' | tr -d "\d")
|
||||
fi
|
||||
interface_if=$(uci -q get "network.$INTERFACE.ifname")
|
||||
if [ "$interface_gw" != "" ]; then
|
||||
_log "Replace default route by $interface_gw dev $interface_if"
|
||||
|
@ -30,14 +36,14 @@ case "$(multipath "$OMR_TRACKER_DEVICE")" in
|
|||
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")
|
||||
#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
|
||||
if [ "$default_gw" = "$OMR_TRACKER_DEVICE_GATEWAY" ] || [ "$default_gw" = "" ]; then
|
||||
config_load network
|
||||
config_foreach set_route interface $OMR_TRACKER_DEVICE
|
||||
fi
|
||||
|
@ -49,9 +55,9 @@ multipath_config=$(uci -q get "network.$OMR_TRACKER_INTERFACE.multipath" || echo
|
|||
[ "$multipath_status" = "$multipath_config" ] && exit 0
|
||||
_log "$OMR_TRACKER_DEVICE switched to $multipath_config"
|
||||
if [ "$multipath_config" = "master" ]; then
|
||||
if [ "$default_gw" != "$current_interface_gw" ] || [ "$default_gw" = "" ]; then
|
||||
if [ "$default_gw" != "$OMR_TRACKER_DEVICE_GATEWAY" ] || [ "$default_gw" = "" ]; then
|
||||
_log "Master up : Replace default route by $current_interface_gw dev $OMR_TRACKER_INTERFACE"
|
||||
ip route replace default scope global nexthop via $current_interface_gw dev $OMR_TRACKER_INTERFACE
|
||||
ip route replace default scope global nexthop via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_INTERFACE
|
||||
fi
|
||||
multipath_config="on"
|
||||
fi
|
||||
|
|
|
@ -128,6 +128,9 @@ while true; do
|
|||
if [ -z "$OMR_TRACKER_DEVICE_GATEWAY" ]; then
|
||||
OMR_TRACKER_DEVICE_GATEWAY=$(ip -4 r list dev "$OMR_TRACKER_DEVICE" | grep -v default | awk '/proto static/ {print $1}' | tr -d "\n")
|
||||
fi
|
||||
if [ -s "$OMR_TRACKER_DEVICE_GATEWAY" ]; then
|
||||
OMR_TRACKER_DEVICE_GATEWAY=$(uci -q get "network.$OMR_TRACKER_INTERFACE.gateway")
|
||||
fi
|
||||
if [ -z "$OMR_TRACKER_DEVICE_GATEWAY" ]; then
|
||||
OMR_TRACKER_DEVICE_GATEWAY=$(ubus call network.interface.$OMR_TRACKER_INTERFACE status | jsonfilter -e '@.route[0].nexthop' | tr -d "\n")
|
||||
fi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue