wgengine/router: report to control when setPrivateNetwork fails

Fixes #1503

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/1507/head
Brad Fitzpatrick 4 years ago committed by Brad Fitzpatrick
parent ba8c6d0775
commit 232cfda280

@ -553,6 +553,9 @@ func (c *Direct) sendMapRequest(ctx context.Context, maxPolls int, cb func(*netm
if health.RouterHealth() != nil {
extraDebugFlags = append(extraDebugFlags, "warn-router-unhealthy")
}
if health.NetworkCategoryHealth() != nil {
extraDebugFlags = append(extraDebugFlags, "warn-network-category-unhealthy")
}
if len(extraDebugFlags) > 0 {
old := request.DebugFlags
request.DebugFlags = append(old[:len(old):len(old)], extraDebugFlags...)

@ -56,6 +56,12 @@ func SetRouterHealth(err error) { set("router", err) }
// RouterHealth returns the wgengine/router.Router error state.
func RouterHealth() error { return get("router") }
// SetNetworkCategoryHealth sets the state of setting the network adaptor's category.
// This only applies on Windows.
func SetNetworkCategoryHealth(err error) { set("network-category", err) }
func NetworkCategoryHealth() error { return get("network-category") }
func get(key string) error {
mu.Lock()
defer mu.Unlock()

@ -21,6 +21,7 @@ import (
"golang.org/x/sys/windows"
"golang.zx2c4.com/wireguard/windows/tunnel/winipcfg"
"inet.af/netaddr"
"tailscale.com/health"
"tailscale.com/net/interfaces"
"tailscale.com/net/tsaddr"
"tailscale.com/wgengine/winnet"
@ -272,6 +273,7 @@ func configureInterface(cfg *Config, tun *tun.NativeTun) (retErr error) {
const tries = 20
for i := 0; i < tries; i++ {
found, err := setPrivateNetwork(luid)
health.SetNetworkCategoryHealth(err)
if err != nil {
log.Printf("setPrivateNetwork(try=%d): %v", i, err)
} else {

Loading…
Cancel
Save