Construct interfaces in reverse order
@@ -57,8 +57,10 @@ func GetInterfaces(includeRegexes []string, excludeRegexes []string, version int
}
}
- // Loop through interfaces filtering on the regexes.
- for _, iface := range netIfaces {
+ // Loop through interfaces filtering on the regexes. Loop in reverse
+ // order to maintain behavior with older versions.
+ for idx := len(netIfaces)-1; idx >= 0; idx-- {
+ iface := netIfaces[idx]
include := (includeRegexp == nil) || includeRegexp.MatchString(iface.Name)
exclude := (excludeRegexp != nil) && excludeRegexp.MatchString(iface.Name)
if include && !exclude {
