]> git.proxmox.com Git - pve-container.git/commitdiff
pass datacenter.cfg's mac_prefix to random_ether_addr
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 13 Jul 2016 14:25:43 +0000 (16:25 +0200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Thu, 14 Jul 2016 07:01:59 +0000 (09:01 +0200)
src/PVE/LXC/Config.pm
src/pve-update-lxc-config

index 6b0ed4f1a2f01636dbd07168db4585e88e487591..79882032acfbd148b3bc9cf66735dc0a1d0c8386 100644 (file)
@@ -1079,7 +1079,10 @@ sub parse_lxc_network {
     $res = PVE::JSONSchema::parse_property_string($netconf_desc, $data);
 
     $res->{type} = 'veth';
-    $res->{hwaddr} = PVE::Tools::random_ether_addr() if !$res->{hwaddr};
+    if (!$res->{hwaddr}) {
+       my $dc = PVE::Cluster::cfs_read_file('datacenter.cfg');
+       $res->{hwaddr} = PVE::Tools::random_ether_addr($dc->{mac_prefix});
+    }
 
     return $res;
 }
index 119e6255eaa60d80beda785364861e1a61b0ad9c..d7d89854d6037114bafce671122c273e0e5dc3ed 100755 (executable)
@@ -243,7 +243,10 @@ sub parse_lxc_config {
        
        foreach my $net (@{$network_list}) {
            next if $net->{type} eq 'empty'; # skip
-           $net->{hwaddr} =  PVE::Tools::random_ether_addr() if !$net->{hwaddr};
+           if (!$net->{hwaddr}) {
+               my $dc = PVE::Cluster::cfs_read_file('datacenter.cfg');
+               $net->{hwaddr} =  PVE::Tools::random_ether_addr($dc->{mac_prefix});
+           }
            die "unsupported network type '$net->{type}'\n" if $net->{type} ne 'veth';
            die "undefined veth network pair'\n" if !$net->{'veth.pair'};