fingerprint: fix 'default' alias not added to interface specified by `network_interface` (#18096) (#18116)
Co-authored-by: Kevin Schoonover <github@kschoon.me>
This commit is contained in:
parent
9fe88ebefe
commit
b75f552246
|
@ -0,0 +1,3 @@
|
|||
```release-note:bug
|
||||
fingerprint: fix 'default' alias not being added to interface specified by network_interface
|
||||
```
|
|
@ -247,18 +247,14 @@ func deriveAddressAliases(iface net.Interface, addr net.IP, config *config.Confi
|
|||
}
|
||||
}
|
||||
|
||||
if len(aliases) > 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if config.NetworkInterface != "" {
|
||||
if config.NetworkInterface == iface.Name {
|
||||
return []string{"default"}
|
||||
aliases = append(aliases, "default")
|
||||
}
|
||||
} else if ri, err := sockaddr.NewRouteInfo(); err == nil {
|
||||
defaultIface, err := ri.GetDefaultInterfaceName()
|
||||
if err == nil && iface.Name == defaultIface {
|
||||
return []string{"default"}
|
||||
aliases = append(aliases, "default")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -500,6 +500,9 @@ func TestNetworkFingerPrint_MultipleAliases(t *testing.T) {
|
|||
for alias := range cfg.HostNetworks {
|
||||
expected = append(expected, alias)
|
||||
}
|
||||
// eth3 matches the NetworkInterface and will then generate the 'default'
|
||||
// alias
|
||||
expected = append(expected, "default")
|
||||
sort.Strings(expected)
|
||||
sort.Strings(aliases)
|
||||
require.Equal(t, expected, aliases, "host networks should match aliases")
|
||||
|
@ -537,7 +540,7 @@ func TestNetworkFingerPrint_HostNetworkReservedPorts(t *testing.T) {
|
|||
CIDR: "100.64.0.11/10",
|
||||
},
|
||||
},
|
||||
expected: []string{"", "", ""},
|
||||
expected: []string{"", "", "", ""},
|
||||
},
|
||||
{
|
||||
name: "reserved ports in some aliases",
|
||||
|
@ -560,7 +563,7 @@ func TestNetworkFingerPrint_HostNetworkReservedPorts(t *testing.T) {
|
|||
CIDR: "100.64.0.11/10",
|
||||
},
|
||||
},
|
||||
expected: []string{"22", "80,3000-4000", ""},
|
||||
expected: []string{"22", "80,3000-4000", "", ""},
|
||||
},
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue