Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix 'default' alias not added to interface specified by network_interface #18096

Merged
merged 4 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/18096.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
fingerprint: fix 'default' alias not being added to interface specified by network_interface
```
8 changes: 2 additions & 6 deletions client/fingerprint/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}

Expand Down
7 changes: 5 additions & 2 deletions client/fingerprint/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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",
Expand All @@ -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", "", ""},
},
}

Expand Down
Loading