net/netmon: log when the gateway/self IP changes

This logs that the gateway/self IP address has changed if one of the new
values differs.

Updates #8992

Signed-off-by: Andrew Dunham <andrew@du.nham.ca>
Change-Id: I0919424b68ad97fbe1204dd36317ed6f5915411f
pull/9373/head
Andrew Dunham 1 year ago
parent 45eafe1b06
commit ad4c11aca1

@ -174,8 +174,14 @@ func (m *Monitor) GatewayAndSelfIP() (gw, myIP netip.Addr, ok bool) {
return m.gw, m.gwSelfIP, true return m.gw, m.gwSelfIP, true
} }
gw, myIP, ok = interfaces.LikelyHomeRouterIP() gw, myIP, ok = interfaces.LikelyHomeRouterIP()
changed := false
if ok { if ok {
m.gw, m.gwSelfIP, m.gwValid = gw, myIP, true changed = m.gw != gw || m.gwSelfIP != myIP
m.gw, m.gwSelfIP = gw, myIP
m.gwValid = true
}
if changed {
m.logf("gateway and self IP changed: gw=%v self=%v", m.gw, m.gwSelfIP)
} }
return gw, myIP, ok return gw, myIP, ok
} }

Loading…
Cancel
Save