Browse Source

net/routetable: include unknown flags in the routetable doctor output

As part of the work on #7248 I wanted to know all of the flags on the
RouteMessage struct that we get back from macOS. Though it doesn't turn
out to be useful (when using an exit node/Tailscale is the default route,
the flags for the physical interface routes are the same), it still seems
useful from a debugging/comprehensiveness perspective.

Adds additional Darwin flags that were output once I enabled this mode.

Signed-off-by: Mihai Parparita <[email protected]>
Mihai Parparita 3 years ago
parent
commit
21fda7f670
2 changed files with 15 additions and 0 deletions
  1. 10 0
      net/routetable/routetable_bsd.go
  2. 5 0
      net/routetable/routetable_darwin.go

+ 10 - 0
net/routetable/routetable_bsd.go

@@ -64,6 +64,16 @@ func (r RouteEntryBSD) Format(f fmt.State, verb rune) {
 		}
 		pr("Flags: %v", r.Flags)
 
+		unknownFlags := r.RawFlags
+		for fv := range flags {
+			if r.RawFlags&fv == fv {
+				unknownFlags &= ^fv
+			}
+		}
+		if unknownFlags != 0 {
+			pr("UnknownFlags: %x ", unknownFlags)
+		}
+
 		w.WriteString("}")
 	}).Format(f, verb)
 }

+ 5 - 0
net/routetable/routetable_darwin.go

@@ -23,9 +23,14 @@ var flags = map[int]string{
 	unix.RTF_GLOBAL:    "global",
 	unix.RTF_HOST:      "host",
 	unix.RTF_IFSCOPE:   "ifscope",
+	unix.RTF_LOCAL:     "local",
 	unix.RTF_MULTICAST: "multicast",
 	unix.RTF_REJECT:    "reject",
 	unix.RTF_ROUTER:    "router",
 	unix.RTF_STATIC:    "static",
 	unix.RTF_UP:        "up",
+	// More obscure flags, just to have full coverage.
+	unix.RTF_LLINFO:    "{RTF_LLINFO}",
+	unix.RTF_PRCLONING: "{RTF_PRCLONING}",
+	unix.RTF_CLONING:   "{RTF_CLONING}",
 }