From ad4c11aca17a09c80be86697c4cc5c0965937e57 Mon Sep 17 00:00:00 2001 From: Andrew Dunham Date: Tue, 12 Sep 2023 17:04:09 -0400 Subject: [PATCH] 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 Change-Id: I0919424b68ad97fbe1204dd36317ed6f5915411f --- net/netmon/netmon.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/netmon/netmon.go b/net/netmon/netmon.go index 64dffd26d..b0872034a 100644 --- a/net/netmon/netmon.go +++ b/net/netmon/netmon.go @@ -174,8 +174,14 @@ func (m *Monitor) GatewayAndSelfIP() (gw, myIP netip.Addr, ok bool) { return m.gw, m.gwSelfIP, true } gw, myIP, ok = interfaces.LikelyHomeRouterIP() + changed := false 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 }