mirror of
https://github.com/tailscale/tailscale.git
synced 2026-05-05 20:26:47 +02:00
net/netns: add more logging to returned interface in getInterfaceIndex
Change-Id: If9940c3613a3022fcb5446f1c11c77e9f5f2683f
This commit is contained in:
parent
2f07c6a9f4
commit
8689e4b901
@ -67,7 +67,7 @@ func getInterfaceIndex(logf logger.Logf, netMon *netmon.Monitor, address string)
|
||||
// Helper so we can log errors.
|
||||
defaultIdx := func() (int, error) {
|
||||
if netMon == nil {
|
||||
idx, err := interfaces.DefaultRouteInterfaceIndex()
|
||||
iface, err := interfaces.DefaultRoute()
|
||||
if err != nil {
|
||||
// It's somewhat common for there to be no default gateway route
|
||||
// (e.g. on a phone with no connectivity), don't log those errors
|
||||
@ -77,7 +77,8 @@ func getInterfaceIndex(logf logger.Logf, netMon *netmon.Monitor, address string)
|
||||
}
|
||||
return -1, err
|
||||
}
|
||||
return idx, nil
|
||||
logf("getInterfaceIndex(%q): no netMon: returning %d: %+v", address, iface.InterfaceIndex, iface)
|
||||
return iface.InterfaceIndex, nil
|
||||
}
|
||||
state := netMon.InterfaceState()
|
||||
if state == nil {
|
||||
@ -85,6 +86,7 @@ func getInterfaceIndex(logf logger.Logf, netMon *netmon.Monitor, address string)
|
||||
}
|
||||
|
||||
if iface, ok := state.Interface[state.DefaultRouteInterface]; ok {
|
||||
logf("getInterfaceIndex(%q): netMon: returning %d: %+v", address, state.DefaultRouteInterface, iface)
|
||||
return iface.Index, nil
|
||||
}
|
||||
return -1, errInterfaceStateInvalid
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user