]> git.proxmox.com Git - pve-container.git/commitdiff
config: hwaddr: enforce unicast MAC addresses
authorStoiko Ivanov <s.ivanov@proxmox.com>
Tue, 12 Mar 2019 15:07:42 +0000 (16:07 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 14 Mar 2019 09:04:11 +0000 (10:04 +0100)
having a container with a multicast mac (see [1]), prevents it from starting
(see [0,3]).

This patch uses the 'mac-addr' standard_option defined in PVE::JSONSchema to
ensure only unicast macaddresses are used for netconfig.

[0] https://lists.linuxcontainers.org/pipermail/lxc-users/2010-August/000783.html
[1] https://en.wikipedia.org/wiki/MAC_address
[2] https://pve.proxmox.com/pipermail/pve-devel/2019-March/035996.html

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/LXC/Config.pm

index 7762533cb16c1120e579351d4269aefb3b36e7bc..866d7874124432780e838f882fdc71418256f7a2 100644 (file)
@@ -600,13 +600,9 @@ our $netconf_desc = {
        pattern => '[-_.\w\d]+',
        optional => 1,
     },
-    hwaddr => {
-       type => 'string',
-       format_description => "XX:XX:XX:XX:XX:XX",
+    hwaddr => get_standard_option('mac-addr', {
         description => 'The interface MAC address. This is dynamically allocated by default, but you can set that statically if needed, for example to always have the same link-local IPv6 address. (lxc.network.hwaddr)',
-       pattern => qr/(?:[a-f0-9]{2}:){5}[a-f0-9]{2}/i,
-       optional => 1,
-    },
+       }),
     mtu => {
        type => 'integer',
        description => 'Maximum transfer unit of the interface. (lxc.network.mtu)',