]> git.proxmox.com Git - pve-network.git/commitdiff
zones: evpn: move vnet mac option to evpn zone plugin
authorAlexandre Derumier <aderumier@odiso.com>
Wed, 21 Apr 2021 21:49:23 +0000 (23:49 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 22 Apr 2021 08:05:52 +0000 (10:05 +0200)
This is only used by evpn plugin, and we can have
same anycast mac for all vnets like cisco,juniper,arista...

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
PVE/Network/SDN/VnetPlugin.pm
PVE/Network/SDN/Zones/EvpnPlugin.pm
test/zones/evpn/ipv4/expected_sdn_interfaces
test/zones/evpn/ipv4/sdn_config

index 34841ae5edb776fb1c71a5c336508f3199fd7e14..96a13b47dd2ac71644fe846c2b994b8736ddf2e8 100644 (file)
@@ -70,11 +70,6 @@ sub properties {
             description => "alias name of the vnet",
            optional => 1,
         },
-        mac => {
-            type => 'string',
-            description => "Anycast router mac address",
-           optional => 1, format => 'mac-addr'
-        }
     };
 }
 
@@ -83,7 +78,6 @@ sub options {
         zone => { optional => 0},
         tag => { optional => 1},
         alias => { optional => 1 },
-        mac => { optional => 1 },
         vlanaware => { optional => 1 },
     };
 }
index ca000cf6049d65680b908a884807031b323f7228..d68d3ee65c102b80d8b198e3eaafdb6d62bdf5e5 100644 (file)
@@ -28,6 +28,11 @@ sub properties {
            type => 'string',
            description => "Frr router name",
        },
+        'mac' => {
+            type => 'string',
+            description => "Anycast logical router mac address",
+            optional => 1, format => 'mac-addr'
+        },
        'exitnodes' => get_standard_option('pve-node-list'),
     };
 }
@@ -40,6 +45,7 @@ sub options {
         controller => { optional => 0 },
        exitnodes => { optional => 1 },
        mtu => { optional => 1 },
+       mac => { optional => 1 },
        dns => { optional => 1 },
        reversedns => { optional => 1 },
        dnszone => { optional => 1 },
@@ -55,7 +61,7 @@ sub generate_sdn_config {
     my $alias = $vnet->{alias};
     my $ipv4 = $vnet->{ipv4};
     my $ipv6 = $vnet->{ipv6};
-    my $mac = $vnet->{mac};
+    my $mac = $plugin_config->{'mac'};
 
     my $vrf_iface = "vrf_$zoneid";
     my $vrfvxlan = $plugin_config->{'vrf-vxlan'};
@@ -184,6 +190,10 @@ sub on_update_hook {
                if (defined($zone_cfg->{ids}->{$id}->{'vrf-vxlan'}) && $zone_cfg->{ids}->{$id}->{'vrf-vxlan'} eq $vrfvxlan);
     }
 
+    if (!defined($zone_cfg->{ids}->{$zoneid}->{'mac'})) {
+       my $dc = PVE::Cluster::cfs_read_file('datacenter.cfg');
+       $zone_cfg->{ids}->{$zoneid}->{'mac'} = PVE::Tools::random_ether_addr($dc->{mac_prefix});
+    }
 }
 
 
@@ -206,11 +216,6 @@ sub vnet_update_hook {
        next if $other_zone->{type} ne 'vxlan' && $other_zone->{type} ne 'evpn';
        raise_param_exc({ tag => "vxlan tag $tag already exist in vnet $id in zone $other_zoneid "}) if $other_tag && $tag eq $other_tag;
     }
-
-    if (!defined($vnet->{mac})) {
-       my $dc = PVE::Cluster::cfs_read_file('datacenter.cfg');
-       $vnet->{mac} = PVE::Tools::random_ether_addr($dc->{mac_prefix});
-    }
 }
 
 
index 6d2d3b65d1a589795f4c1c8e2b72d1ab1c51830e..e2d5a75bbec3d10edbe608df40239f7b0f272501 100644 (file)
@@ -3,6 +3,7 @@
 auto myvnet
 iface myvnet
        address 10.0.0.1/24
+       hwaddress A2:1D:CB:1A:C0:8B
        bridge_ports vxlan_myvnet
        bridge_stp off
        bridge_fd 0
index 4c115a94ae2a1c7b5711bb3a40850633430345eb..dd73b5cdc140e2dc98f051cf95013241b0a89e89 100644 (file)
@@ -7,7 +7,7 @@
              },
 
   zones   => {
-               ids => { myzone => { ipam => "pve", type => "evpn", controller => "evpnctl", 'vrf-vxlan' => 1000 } },
+               ids => { myzone => { ipam => "pve", type => "evpn", controller => "evpnctl", 'vrf-vxlan' => 1000, 'mac' => 'A2:1D:CB:1A:C0:8B' } },
              },
   controllers  => {
                ids => { evpnctl => { type => "evpn", 'peers' => '192.168.0.1,192.168.0.2,192.168.0.3', asn => "65000" } },