diff --git a/net/interfaces/interfaces.go b/net/interfaces/interfaces.go index 17b1db0c2..d6be0824a 100644 --- a/net/interfaces/interfaces.go +++ b/net/interfaces/interfaces.go @@ -163,6 +163,10 @@ type State struct { // considered "expensive", which currently means LTE/etc // instead of Wifi. This field is not populated by GetState. IsExpensive bool + + // DefaultRouteInterface is the interface name for the machine's default route. + // It is not yet populated on all OSes. + DefaultRouteInterface string } func (s *State) Equal(s2 *State) bool { @@ -198,6 +202,7 @@ func GetState() (*State, error) { }); err != nil { return nil, err } + s.DefaultRouteInterface, _ = DefaultRouteInterface() return s, nil } diff --git a/net/interfaces/interfaces_defaultrouteif_todo.go b/net/interfaces/interfaces_defaultrouteif_todo.go new file mode 100644 index 000000000..142d0a861 --- /dev/null +++ b/net/interfaces/interfaces_defaultrouteif_todo.go @@ -0,0 +1,15 @@ +// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !linux + +package interfaces + +import "errors" + +var errTODO = errors.New("TODO") + +func DefaultRouteInterface() (string, error) { + return "TODO", errTODO +} diff --git a/wgengine/userspace.go b/wgengine/userspace.go index 319e01b88..b775b7cb1 100644 --- a/wgengine/userspace.go +++ b/wgengine/userspace.go @@ -212,6 +212,7 @@ func newUserspaceEngineAdvanced(conf EngineConfig) (_ Engine, reterr error) { } e.localAddrs.Store(map[packet.IP]bool{}) e.linkState, _ = getLinkState() + logf("link state: %+v", e.linkState) // Respond to all pings only in fake mode. if conf.Fake { @@ -1105,7 +1106,11 @@ func (e *userspaceEngine) LinkChange(isExpensive bool) { cur.IsExpensive = isExpensive needRebind := e.setLinkState(cur) - e.logf("LinkChange(isExpensive=%v); needsRebind=%v", isExpensive, needRebind) + if needRebind { + e.logf("LinkChange: major, rebinding. New state: %+v", cur) + } else { + e.logf("LinkChange: minor") + } why := "link-change-minor" if needRebind {