1
0
mirror of https://github.com/rancher/os.git synced 2025-09-05 00:37:12 +00:00

Added wildcard matching on MAC addresses.

This commit is contained in:
Morten Møller Riis
2019-03-12 08:57:34 +01:00
committed by niusmallnan
parent 66c5f6130a
commit a6c1645d47
2 changed files with 75 additions and 0 deletions

View File

@@ -111,6 +111,11 @@ func findMatch(link netlink.Link, netCfg *NetworkConfig) (InterfaceConfig, bool)
}
if strings.HasPrefix(netConf.Match, "mac") {
if strings.Contains(netConf.Match, "*") {
// If selector contains wildcard * and MAC address matches wildcard then return
return netConf, glob.Glob(netConf.Match[4:], link.Attrs().HardwareAddr.String())
}
haAddr, err := net.ParseMAC(netConf.Match[4:])
if err != nil {
log.Errorf("Failed to parse mac %s: %v", netConf.Match[4:], err)