ncsid: reconfigure gateway when default route is missing
This will ensure that default gateway can be reconfigured if any failure
happens at the first time.
Tested:
On a machine that has default route configured, manually deleted the
route, without this change it will stay broken. This change will bring
the route back in 1mins or so.
Change-Id: I7f8f1fafcbcfb3f4b904af8999d1a5c17400e99e
Signed-off-by: Yuxiao Zhang <yuxiaozhang@google.com>
diff --git a/subprojects/ncsid/src/update_ra_gw.sh b/subprojects/ncsid/src/update_ra_gw.sh
index 9403b28..e228909 100644
--- a/subprojects/ncsid/src/update_ra_gw.sh
+++ b/subprojects/ncsid/src/update_ra_gw.sh
@@ -22,6 +22,14 @@
function set_rtr() {
[ -n "$rtr" -a -n "$lifetime" ] || return
+
+ # Reconfigure gateway in case of anything goes wrong
+ if ! ip -6 route show | grep -q '^default'; then
+ echo 'default route missing, reconfiguring...' >&2
+ old_rtr=
+ old_mac=
+ fi
+
[ "$rtr" != "$old_rtr" -a "$mac" != "$old_mac" ] || return
# Only valid default routers can be considered, 0 lifetime implies
# a non-default router