From 2acf3a2b4189bf51d8631ffaf4b7671c10c790c9 Mon Sep 17 00:00:00 2001 From: Ycarus Date: Thu, 3 Jan 2019 11:49:05 +0100 Subject: [PATCH] Fix gateway detection in some case --- mptcp/files/etc/init.d/mptcp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mptcp/files/etc/init.d/mptcp b/mptcp/files/etc/init.d/mptcp index 2cef143e3..fdf4db7d8 100755 --- a/mptcp/files/etc/init.d/mptcp +++ b/mptcp/files/etc/init.d/mptcp @@ -101,12 +101,18 @@ interface_multipath_settings() { [ -z "$gateway" ] && 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 -q -e '@.route[0].nexthop' | tr -d "\n") + if [ -z "$gateway" ] || [ "$( valid_subnet4 $gateway )" != "ok" ]; then + gateway=$(ubus call network.interface.$config status | jsonfilter -q -e '@.route[1].nexthop' | tr -d "\n") + fi if [ -z "$gateway" ] || [ "$( valid_subnet4 $gateway )" != "ok" ]; then gateway=$(ubus call network.interface.$config status | jsonfilter -q -e '@.inactive.route[0].nexthop' | tr -d "\n") fi if [ -z "$gateway" ] || [ "$( valid_subnet4 $gateway )" != "ok" ]; then gateway=$(ubus call network.interface.${config}_4 status 2>/dev/null | jsonfilter -q -e '@.inactive.route[0].nexthop' | tr -d "\n") fi + if [ -z "$gateway" ] || [ "$( valid_subnet4 $gateway )" != "ok" ]; then + gateway=$(ubus call network.interface.${config}_4 status 2>/dev/null | jsonfilter -q -e '@.route[0].nexthop' | tr -d "\n") + fi network_get_subnet netmask $config [ -z "$netmask" ] && netmask=$(ip -4 addr show dev $iface | grep peer | awk '{print $4}' | cut -d/ -f2 | tr -d "\n") [ -z "$netmask" ] && netmask=$(ip -4 addr show dev $iface | grep inet | awk '{print $2}' | cut -d/ -f2 | tr -d "\n")