diff --git a/gateway-mon b/gateway-mon index 9091d02..3b759d5 100755 --- a/gateway-mon +++ b/gateway-mon @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f98cac284d8591db1636e5957bbb5610b45f1b7919075a7a394241c9b9b3c1f1 -size 2881181 +oid sha256:0301590777a402912287b0f89601ed60d10856de3d6cc6b3cb687ecd83a7a9af +size 2891573 diff --git a/main.go b/main.go index a450ac2..589586c 100644 --- a/main.go +++ b/main.go @@ -259,14 +259,21 @@ func delIfDefault(r *netlink.Route) { // Checks if route is default func isDefault(r *netlink.Route) bool { var isDefault bool - if r.Src == nil && r.Dst == nil && r.Gw.IsPrivate() { + if r.Src == nil && r.Dst == nil && (r.Gw.IsPrivate() || r.Gw == nil) { isDefault = true + } else { + log.Debugf("%+v is not default route", r) } return isDefault } // Deletes a route func delRoute(r *netlink.Route) { + // Can't delete a route with no dest net, so explicitly set to all if nil + if isDefault(r) && r.Dst == nil { + _, defaultDest, _ := net.ParseCIDR("0.0.0.0/0") + r.Dst = defaultDest + } err := netlink.RouteDel(r) if err != nil { log.Errorf("Failed to delete route on %s: %+v", linkName, err)