File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -173,10 +173,15 @@ func selectIPFromHostInterface(nodeIP string) (string, error) {
173
173
if err != nil {
174
174
return "" , err
175
175
}
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.
180
185
slices .SortFunc (ifaces , func (a , b tcpnet.Interface ) int {
181
186
if a .Index > b .Index {
182
187
return 1
You can’t perform that action at this time.
0 commit comments