S40network: do not consider network ok unless default route ok

This commit is contained in:
Calin Crisan 2020-01-15 22:29:19 +02:00
parent 0ee6f94520
commit b1b7d6790e

View File

@ -185,19 +185,22 @@ start() {
ssid=$(cat /data/etc/wpa_supplicant.conf 2>&1 | grep ssid | grep -v scan_ssid | cut -d '"' -f 2) ssid=$(cat /data/etc/wpa_supplicant.conf 2>&1 | grep ssid | grep -v scan_ssid | cut -d '"' -f 2)
test -n "${OS_WLAN}" -a -n "${ssid}" && start_wlan && wlan_ok="ok" test -n "${OS_WLAN}" -a -n "${ssid}" && start_wlan && wlan_ok="ok"
test -n "${OS_PPP}" -a -r /data/etc/ppp/modem && ifconfig | grep ${OS_PPP} &>/dev/null && ppp_ok="ok" test -n "${OS_PPP}" -a -r /data/etc/ppp/modem && ifconfig | grep ${OS_PPP} &>/dev/null && ppp_ok="ok"
def_route_ok=$(ip route get 1.1.1.1 &>/dev/null && echo "ok")
if [[ -n "${OS_ETH}" ]]; then if [[ -n "${OS_ETH}" ]]; then
# if wifi or ppp link ok, start eth in background # if wifi or ppp link ok, start eth in background
if [[ "${wlan_ok}" == "ok" ]] || [[ "${ppp_ok}" == "ok" ]]; then if [[ "${wlan_ok}" == "ok" ]] || [[ "${ppp_ok}" == "ok" ]] && [[ "${def_route_ok}" == "ok" ]]; then
start_eth &>/dev/null & start_eth &>/dev/null &
else else
start_eth && eth_ok="ok" start_eth && eth_ok="ok"
fi fi
fi fi
# re-evalutate default route, as it might have changed with start_eth
def_route_ok=$(ip route get 1.1.1.1 &>/dev/null && echo "ok")
if [[ "${eth_ok}" != "ok" ]] && [[ "${wlan_ok}" != "ok" ]] && [[ "${ppp_ok}" != "ok" ]]; then if [[ "${eth_ok}" != "ok" ]] && [[ "${wlan_ok}" != "ok" ]] && [[ "${ppp_ok}" != "ok" ]] || [[ "${def_route_ok}" != "ok" ]]; then
if [[ "${LINK_WATCH}" == "true" ]]; then if [[ "${LINK_WATCH}" == "true" ]]; then
logger -t network "no network connection available, calling panic action" logger -t network "no network connection available, calling panic action"
panic_action network panic_action network