wgengine/magicsock: add MTU to addrLatency and rename to addrQuality
Add a field to record the wire MTU of the path to this address to the addrLatency struct and rename it addrQuality. Updates #311 Signed-off-by: Val <valerie@tailscale.com>
This commit is contained in:
@@ -1648,10 +1648,13 @@ func TestEndpointSetsEqual(t *testing.T) {
|
||||
|
||||
func TestBetterAddr(t *testing.T) {
|
||||
const ms = time.Millisecond
|
||||
al := func(ipps string, d time.Duration) addrLatency {
|
||||
return addrLatency{netip.MustParseAddrPort(ipps), d}
|
||||
al := func(ipps string, d time.Duration) addrQuality {
|
||||
return addrQuality{AddrPort: netip.MustParseAddrPort(ipps), latency: d}
|
||||
}
|
||||
zero := addrLatency{}
|
||||
almtu := func(ipps string, d time.Duration, mtu tstun.WireMTU) addrQuality {
|
||||
return addrQuality{AddrPort: netip.MustParseAddrPort(ipps), latency: d, wireMTU: mtu}
|
||||
}
|
||||
zero := addrQuality{}
|
||||
|
||||
const (
|
||||
publicV4 = "1.2.3.4:555"
|
||||
@@ -1662,7 +1665,7 @@ func TestBetterAddr(t *testing.T) {
|
||||
)
|
||||
|
||||
tests := []struct {
|
||||
a, b addrLatency
|
||||
a, b addrQuality
|
||||
want bool // whether a is better than b
|
||||
}{
|
||||
{a: zero, b: zero, want: false},
|
||||
@@ -1724,7 +1727,12 @@ func TestBetterAddr(t *testing.T) {
|
||||
b: al(publicV6, 100*ms),
|
||||
want: true,
|
||||
},
|
||||
|
||||
// If addresses are equal, prefer larger MTU
|
||||
{
|
||||
a: almtu(publicV4, 30*ms, 1500),
|
||||
b: almtu(publicV4, 30*ms, 0),
|
||||
want: true,
|
||||
},
|
||||
// Private IPs are preferred over public IPs even if the public
|
||||
// IP is IPv6.
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user