[lxc-devel] [lxd/master] Allow both cases in MACs

stgraber on Github lxc-bot at linuxcontainers.org
Tue Sep 24 12:49:04 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190924/65414b2b/attachment.bin>
-------------- next part --------------
From 3b439718259c1aab2f08e02fc0438d66e5cb0d7c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 24 Sep 2019 08:36:13 -0400
Subject: [PATCH 1/3] lxd/device/network: Fix typo in comment
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/device/device_utils_network.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lxd/device/device_utils_network.go b/lxd/device/device_utils_network.go
index 073d1720e8..82806d3658 100644
--- a/lxd/device/device_utils_network.go
+++ b/lxd/device/device_utils_network.go
@@ -353,7 +353,7 @@ func networkSetupHostVethDevice(device config.Device, oldDevice config.Device, v
 			oldDevice["host_name"] = v["host_name"]
 		}
 
-		// If not configured, copy the volatile host_name into old device to support live updates.
+		// If not configured, copy the volatile hwaddr into old device to support live updates.
 		if oldDevice["hwaddr"] == "" {
 			oldDevice["hwaddr"] = v["hwaddr"]
 		}

From 7f9fa1c6564bab2f92c69366f8003dc1103f5fea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 24 Sep 2019 08:45:32 -0400
Subject: [PATCH 2/3] lxd/dnsmasq: Support uppercase MACs in UpdateStaticEntry
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/dnsmasq/dnsmasq.go | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lxd/dnsmasq/dnsmasq.go b/lxd/dnsmasq/dnsmasq.go
index b72dd92966..1c1f07d12f 100644
--- a/lxd/dnsmasq/dnsmasq.go
+++ b/lxd/dnsmasq/dnsmasq.go
@@ -31,6 +31,7 @@ var ConfigMutex sync.Mutex
 
 // UpdateStaticEntry writes a single dhcp-host line for a network/instance combination.
 func UpdateStaticEntry(network string, projectName string, instanceName string, netConfig map[string]string, hwaddr string, ipv4Address string, ipv6Address string) error {
+	hwaddr = strings.ToLower(hwaddr)
 	line := hwaddr
 
 	// Generate the dhcp-host line

From 30cbfc51f138543a60f68e11631e6647ec3dd1ae Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 24 Sep 2019 08:47:18 -0400
Subject: [PATCH 3/3] lxd/device: Allow uppercase in MACs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #6232

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/device/device_utils_infiniband.go | 4 ++--
 lxd/device/device_utils_network.go    | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lxd/device/device_utils_infiniband.go b/lxd/device/device_utils_infiniband.go
index 718553a7bc..d7e56dc2ad 100644
--- a/lxd/device/device_utils_infiniband.go
+++ b/lxd/device/device_utils_infiniband.go
@@ -117,12 +117,12 @@ func infinibandAddDevices(s *state.State, devicesPath string, deviceName string,
 // infinibandValidMAC validates an infiniband MAC address. Supports both short and long variants,
 // e.g. "4a:c8:f9:1b:aa:57:ef:19" and "a0:00:0f:c0:fe:80:00:00:00:00:00:00:4a:c8:f9:1b:aa:57:ef:19".
 func infinibandValidMAC(value string) error {
-	regexHwaddrLong, err := regexp.Compile("^([0-9a-f]{2}:){19}[0-9a-f]{2}$")
+	regexHwaddrLong, err := regexp.Compile("^([0-9a-fA-F]{2}:){19}[0-9a-fA-F]{2}$")
 	if err != nil {
 		return err
 	}
 
-	regexHwaddrShort, err := regexp.Compile("^([0-9a-f]{2}:){7}[0-9a-f]{2}$")
+	regexHwaddrShort, err := regexp.Compile("^([0-9a-fA-F]{2}:){7}[0-9a-fA-F]{2}$")
 	if err != nil {
 		return err
 	}
diff --git a/lxd/device/device_utils_network.go b/lxd/device/device_utils_network.go
index 82806d3658..fa55c9f6e9 100644
--- a/lxd/device/device_utils_network.go
+++ b/lxd/device/device_utils_network.go
@@ -521,7 +521,7 @@ func networkSetVethLimits(m config.Device) error {
 
 // networkValidMAC validates an ethernet MAC address. e.g. "32:47:ae:06:22:f9".
 func networkValidMAC(value string) error {
-	regexHwaddr, err := regexp.Compile("^([0-9a-f]{2}:){5}[0-9a-f]{2}$")
+	regexHwaddr, err := regexp.Compile("^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$")
 	if err != nil {
 		return err
 	}


More information about the lxc-devel mailing list