1
0
mirror of https://github.com/rancher/os.git synced 2025-08-16 05:54:51 +00:00

match network interfaces by MAC addresses

This commit is contained in:
wlan0 2015-03-25 14:57:48 -07:00
parent d912957cb1
commit a6415394af

View File

@ -1,11 +1,13 @@
package network
import (
"bytes"
"errors"
"fmt"
"net"
"os"
"os/exec"
"strings"
log "github.com/Sirupsen/logrus"
@ -48,6 +50,18 @@ func applyNetworkConfigs(cfg *config.Config) error {
continue
}
if len(netConf.Match) > 4 && strings.ToLower(netConf.Match[:3]) == "mac" {
haAddr, err := net.ParseMAC(netConf.Match[4:])
if err != nil {
return err
}
if bytes.Compare(haAddr, link.Attrs().HardwareAddr) == 0 {
// MAC address match is used over all other matches
match = netConf
break
}
}
// "" means match has not been found
if match.Match == "" && matches(linkName, netConf.Match) {
match = netConf