Skip to content

Commit 91b7426

Browse files
committed
OCPBUGS-51366: Update comment
1 parent e6c71b0 commit 91b7426

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

pkg/util/net.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,15 @@ func selectIPFromHostInterface(nodeIP string) (string, error) {
173173
if err != nil {
174174
return "", err
175175
}
176-
// Sort all interfaces by index. If an index goes up to 256 it gets listed
177-
// before index 1 in the function above. These devices are not from the OS,
178-
// but other pods/containers, rendering wrong IP addresses to take for the
179-
// node IP. Ensure we take the lower indices first.
176+
// Sort all interfaces by index. Interfaces are listed in the same ordering as
177+
// in /proc/net/dev. The ordering is not based in interface index, and it is
178+
// not guaranteed to list system interfaces first. Veth interfaces from containers
179+
// could get listed first and retrieve the wrong node IP.
180+
// The index is assigned sequentially depending on the order of kmods loading
181+
// and interface creation. Since the interfaces we are looking for belong to
182+
// NetworkManager and the ones that could get a wrong node IP depend on a systemd
183+
// unit that requires system networking to be ready, we can assume the lower
184+
// indices are safe to use.
180185
slices.SortFunc(ifaces, func(a, b tcpnet.Interface) int {
181186
if a.Index > b.Index {
182187
return 1

0 commit comments

Comments
 (0)