mirror of
https://github.com/tailscale/tailscale.git
synced 2025-03-29 12:32:24 +00:00
net/sockstats: prevent crash in setNetMon (#13985)
This commit is contained in:
parent
3477bfd234
commit
6985369479
@ -279,7 +279,13 @@ func setNetMon(netMon *netmon.Monitor) {
|
|||||||
if ifName == "" {
|
if ifName == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ifIndex := state.Interface[ifName].Index
|
// DefaultRouteInterface and Interface are gathered at different points in time.
|
||||||
|
// Check for existence first, to avoid a nil pointer dereference.
|
||||||
|
iface, ok := state.Interface[ifName]
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ifIndex := iface.Index
|
||||||
sockStats.mu.Lock()
|
sockStats.mu.Lock()
|
||||||
defer sockStats.mu.Unlock()
|
defer sockStats.mu.Unlock()
|
||||||
// Ignore changes to unknown interfaces -- it would require
|
// Ignore changes to unknown interfaces -- it would require
|
||||||
|
Loading…
x
Reference in New Issue
Block a user