From 70172ed2d29e5b11b468e94fc018ad339f253315 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Fri, 23 Mar 2012 14:47:16 +0100 Subject: pingu_iface: del renewed gateways via broken ISPs If we get a new default gateway for an interface that is marked "down", remove the default gw again from main table and let pingu detect that it went up This solves the case when dhcp will renew a lease, recreates the default gw and ISP is broke a bit futher down the road. --- pingu_iface.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'pingu_iface.c') diff --git a/pingu_iface.c b/pingu_iface.c index 065eea3..ec35628 100644 --- a/pingu_iface.c +++ b/pingu_iface.c @@ -166,6 +166,19 @@ void pingu_iface_gw_action(struct pingu_iface *iface, case RTM_NEWROUTE: pingu_route_add(&iface->route_list, gw); log_debug("%s: added route", iface->name); + /* if we get a new default gateway for an interface + * that is marked "down", remove the default gw again + * from main table and let pingu detect that it went up + * + * This solves the case when dhcp will renew a lease, + * recreates the default gw and ISP is broke a bit + * futher down the road. + */ + if (is_default_gw(gw) && !pingu_iface_gw_is_online(iface)) { + pingu_iface_update_routes(iface, RTM_DELROUTE); + /* avoid doing the multipath twice*/ + return; + } break; case RTM_DELROUTE: pingu_route_del(&iface->route_list, gw); -- cgit v1.2.3