mirror of
https://github.com/rancher/os.git
synced 2025-08-15 21:43:42 +00:00
Merge pull request #112 from wlan0/netconf
match network interfaces by MAC addresses
This commit is contained in:
commit
6ce39f7c66
@ -1,11 +1,13 @@
|
|||||||
package network
|
package network
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"strings"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
|
|
||||||
@ -48,6 +50,18 @@ func applyNetworkConfigs(cfg *config.Config) error {
|
|||||||
continue
|
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
|
// "" means match has not been found
|
||||||
if match.Match == "" && matches(linkName, netConf.Match) {
|
if match.Match == "" && matches(linkName, netConf.Match) {
|
||||||
match = netConf
|
match = netConf
|
||||||
|
Loading…
Reference in New Issue
Block a user