wgengine/magicsock: improve Rebind logging

We were accidentally logging oldPort -> oldPort.

Log oldPort as well as c.port; if we failed to get the preferred port
in a previous rebind, oldPort might differ from c.port.

Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
Josh Bleecher Snyder 2021-04-19 15:47:30 -07:00
parent 15ceacc4c5
commit 98714e784b

View File

@ -2658,10 +2658,10 @@ func (c *Conn) Rebind() {
c.pconn4.mu.Unlock()
return
}
newPort := c.pconn4.localAddrLocked().Port
newPort := packetConn.LocalAddr().(*net.UDPAddr).Port
c.logf("magicsock: link change rebound port: from %v to %v (failed to get %v)", oldPort, newPort, c.port)
} else {
c.logf("magicsock: link change rebound port: %d", c.port)
c.logf("magicsock: link change rebound port from %d to %d", oldPort, c.port)
}
c.pconn4.pconn = packetConn.(*net.UDPConn)
c.pconn4.mu.Unlock()