]> git.proxmox.com Git - pve-network.git/blobdiff - PVE/Network/SDN/SubnetPlugin.pm
controllers: evpn : use frr restart if reload fail
[pve-network.git] / PVE / Network / SDN / SubnetPlugin.pm
index cb0f4ef7b44e51f396780105f77b276c91cd3e9c..15b370fb91ce80e9cab368aad42c75dbf314eea7 100644 (file)
@@ -3,14 +3,16 @@ package PVE::Network::SDN::SubnetPlugin;
 use strict;
 use warnings;
 
+use Net::IP;
+use Net::Subnet qw(subnet_matcher);
+
 use PVE::Cluster qw(cfs_read_file cfs_write_file cfs_lock_file);
-use base qw(PVE::SectionConfig);
-use PVE::JSONSchema qw(get_standard_option);
 use PVE::Exception qw(raise raise_param_exc);
-use Net::Subnet qw(subnet_matcher);
-use PVE::Network::SDN::Vnets;
+use PVE::JSONSchema qw(get_standard_option);
 use PVE::Network::SDN::Ipams;
-use Net::IP;
+use PVE::Network::SDN::Vnets;
+
+use base qw(PVE::SectionConfig);
 
 PVE::Cluster::cfs_register_file('sdn/subnets.cfg',
                                  sub { __PACKAGE__->parse_config(@_); },
@@ -111,11 +113,13 @@ sub on_update_hook {
     my $reversedns = $zone->{reversedns};
 
     my $old_gateway = $old_subnet->{gateway} if $old_subnet;
+    my $mac = undef;
 
     if($vnetid) {
        my $vnet = PVE::Network::SDN::Vnets::get_vnet($vnetid);
        raise_param_exc({ vnet => "$vnetid don't exist"}) if !$vnet;
        raise_param_exc({ vnet => "you can't add a subnet on a vlanaware vnet"}) if $vnet->{vlanaware};
+       $mac = $vnet->{mac};
     }
 
     my $pointopoint = 1 if Net::IP::ip_is_ipv4($gateway) && $mask == 32;
@@ -125,10 +129,7 @@ sub on_update_hook {
 
 
     if ($ipam) {
-       my $ipam_cfg = PVE::Network::SDN::Ipams::config();
-       my $plugin_config = $ipam_cfg->{ids}->{$ipam};
-       my $plugin = PVE::Network::SDN::Ipams::Plugin->lookup($plugin_config->{type});
-       $plugin->add_subnet($plugin_config, $subnetid, $subnet);
+       PVE::Network::SDN::Subnets::add_subnet($zone, $subnetid, $subnet);
 
        #don't register gateway for pointopoint
        return if $pointopoint;
@@ -142,8 +143,8 @@ sub on_update_hook {
        }
         if(!$old_gateway || $gateway && $gateway ne $old_gateway) {
            my $hostname = "$vnetid-gw";
-           my $description = "$vnetid gw";
-           PVE::Network::SDN::Subnets::add_ip($zone, $subnetid, $subnet, $gateway, $hostname, $description, 1);
+           my $description = "gateway";
+           PVE::Network::SDN::Subnets::add_ip($zone, $subnetid, $subnet, $gateway, $hostname, $mac, $description, 1);
        }
 
        #delete old gateway after update