From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 615F066C47 for ; Tue, 28 Jul 2020 13:00:53 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 4192423ABB for ; Tue, 28 Jul 2020 13:00:23 +0200 (CEST) Received: from mailpro.odiso.net (mailpro.odiso.net [89.248.211.110]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 4908423A6C for ; Tue, 28 Jul 2020 13:00:19 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mailpro.odiso.net (Postfix) with ESMTP id 5093F11181BC; Tue, 28 Jul 2020 13:00:11 +0200 (CEST) Received: from mailpro.odiso.net ([127.0.0.1]) by localhost (mailpro.odiso.net [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id Y60aGQfftox0; Tue, 28 Jul 2020 13:00:11 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mailpro.odiso.net (Postfix) with ESMTP id 9EB50111811B; Tue, 28 Jul 2020 13:00:06 +0200 (CEST) X-Virus-Scanned: amavisd-new at mailpro.odiso.com Received: from mailpro.odiso.net ([127.0.0.1]) by localhost (mailpro.odiso.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id u0FLjOds0gul; Tue, 28 Jul 2020 13:00:06 +0200 (CEST) Received: from pve.fritz.box (unknown [213.211.148.86]) by mailpro.odiso.net (Postfix) with ESMTPSA id E6971111814A; Tue, 28 Jul 2020 13:00:04 +0200 (CEST) From: Alexandre Derumier To: pve-devel@pve.proxmox.com Date: Tue, 28 Jul 2020 12:59:50 +0200 Message-Id: <20200728105958.18313-5-aderumier@odiso.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200728105958.18313-1-aderumier@odiso.com> References: <20200728105958.18313-1-aderumier@odiso.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_NONE -0.0001 Sender listed at https://www.dnswl.org/, no trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [qinqplugin.pm, vxlanplugin.pm, vlanplugin.pm, simpleplugin.pm, evpnplugin.pm, zones.pm, plugin.pm] Subject: [pve-devel] [PATCH v4 pve-network 04/12] zones: simple|evpn: add gateway ip from subnets to vnet X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Jul 2020 11:00:53 -0000 Signed-off-by: Alexandre Derumier --- PVE/Network/SDN/Zones.pm | 4 +++- PVE/Network/SDN/Zones/EvpnPlugin.pm | 11 ++++++++--- PVE/Network/SDN/Zones/Plugin.pm | 2 +- PVE/Network/SDN/Zones/QinQPlugin.pm | 2 +- PVE/Network/SDN/Zones/SimplePlugin.pm | 11 ++++++++--- PVE/Network/SDN/Zones/VlanPlugin.pm | 2 +- PVE/Network/SDN/Zones/VxlanPlugin.pm | 8 +------- 7 files changed, 23 insertions(+), 17 deletions(-) diff --git a/PVE/Network/SDN/Zones.pm b/PVE/Network/SDN/Zones.pm index 143d6e5..25af088 100644 --- a/PVE/Network/SDN/Zones.pm +++ b/PVE/Network/SDN/Zones.pm @@ -11,6 +11,7 @@ use PVE::Cluster qw(cfs_read_file cfs_write_file cfs_lo= ck_file); use PVE::Network; =20 use PVE::Network::SDN::Vnets; +use PVE::Network::SDN::Subnets; use PVE::Network::SDN::Zones::VlanPlugin; use PVE::Network::SDN::Zones::QinQPlugin; use PVE::Network::SDN::Zones::VxlanPlugin; @@ -78,6 +79,7 @@ sub generate_etc_network_config { my $version =3D PVE::Cluster::cfs_read_file('sdn/.version'); my $vnet_cfg =3D PVE::Cluster::cfs_read_file('sdn/vnets.cfg'); my $zone_cfg =3D PVE::Cluster::cfs_read_file('sdn/zones.cfg'); + my $subnet_cfg =3D PVE::Network::SDN::Subnets::config(); my $controller_cfg =3D PVE::Cluster::cfs_read_file('sdn/controllers.= cfg'); return if !$vnet_cfg && !$zone_cfg; =20 @@ -112,7 +114,7 @@ sub generate_etc_network_config { =20 my $plugin =3D PVE::Network::SDN::Zones::Plugin->lookup($plugin_config-= >{type}); eval { - $plugin->generate_sdn_config($plugin_config, $zone, $id, $vnet, $co= ntroller, $interfaces_config, $config); + $plugin->generate_sdn_config($plugin_config, $zone, $id, $vnet, $co= ntroller, $subnet_cfg, $interfaces_config, $config); }; if (my $err =3D $@) { warn "zone $zone : vnet $id : $err\n"; diff --git a/PVE/Network/SDN/Zones/EvpnPlugin.pm b/PVE/Network/SDN/Zones/= EvpnPlugin.pm index a916579..83ceb3a 100644 --- a/PVE/Network/SDN/Zones/EvpnPlugin.pm +++ b/PVE/Network/SDN/Zones/EvpnPlugin.pm @@ -38,7 +38,7 @@ sub options { =20 # Plugin implementation sub generate_sdn_config { - my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $controller, $i= nterfaces_config, $config) =3D @_; + my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $controller, $s= ubnet_cfg, $interfaces_config, $config) =3D @_; =20 my $tag =3D $vnet->{tag}; my $alias =3D $vnet->{alias}; @@ -72,8 +72,13 @@ sub generate_sdn_config { =20 #vnet bridge @iface_config =3D (); - push @iface_config, "address $ipv4" if $ipv4; - push @iface_config, "address $ipv6" if $ipv6; + + my @subnets =3D PVE::Tools::split_list($vnet->{subnets}) if $vnet->{= subnets}; + foreach my $subnet (@subnets) { + next if !defined($subnet_cfg->{ids}->{$subnet}); + push @iface_config, "address $subnet_cfg->{ids}->{$subnet}->{gat= eway}" if $subnet_cfg->{ids}->{$subnet}->{gateway}; + } + push @iface_config, "hwaddress $mac" if $mac; push @iface_config, "bridge_ports $vxlan_iface"; push @iface_config, "bridge_stp off"; diff --git a/PVE/Network/SDN/Zones/Plugin.pm b/PVE/Network/SDN/Zones/Plug= in.pm index d96e069..451699f 100644 --- a/PVE/Network/SDN/Zones/Plugin.pm +++ b/PVE/Network/SDN/Zones/Plugin.pm @@ -94,7 +94,7 @@ sub parse_section_header { } =20 sub generate_sdn_config { - my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $controller, $i= nterfaces_config, $config) =3D @_; + my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $controller, $s= ubnet_cfg, $interfaces_config, $config) =3D @_; =20 die "please implement inside plugin"; } diff --git a/PVE/Network/SDN/Zones/QinQPlugin.pm b/PVE/Network/SDN/Zones/= QinQPlugin.pm index b39732a..5fffd15 100644 --- a/PVE/Network/SDN/Zones/QinQPlugin.pm +++ b/PVE/Network/SDN/Zones/QinQPlugin.pm @@ -45,7 +45,7 @@ sub options { =20 # Plugin implementation sub generate_sdn_config { - my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $controller, $i= nterfaces_config, $config) =3D @_; + my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $controller, $s= ubnet_cfg, $interfaces_config, $config) =3D @_; =20 my $stag =3D $plugin_config->{tag}; my $mtu =3D $plugin_config->{mtu}; diff --git a/PVE/Network/SDN/Zones/SimplePlugin.pm b/PVE/Network/SDN/Zone= s/SimplePlugin.pm index 6137062..312dcbf 100644 --- a/PVE/Network/SDN/Zones/SimplePlugin.pm +++ b/PVE/Network/SDN/Zones/SimplePlugin.pm @@ -20,7 +20,7 @@ sub options { =20 # Plugin implementation sub generate_sdn_config { - my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $controller, $i= nterfaces_config, $config) =3D @_; + my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $controller, $s= ubnet_cfg, $interfaces_config, $config) =3D @_; =20 return $config if$config->{$vnetid}; # nothing to do =20 @@ -32,8 +32,13 @@ sub generate_sdn_config { =20 # vnet bridge my @iface_config =3D (); - push @iface_config, "address $ipv4" if $ipv4; - push @iface_config, "address $ipv6" if $ipv6; + + my @subnets =3D PVE::Tools::split_list($vnet->{subnets}) if $vnet->{= subnets}; + foreach my $subnet (@subnets) { + next if !defined($subnet_cfg->{ids}->{$subnet}); + push @iface_config, "address $subnet_cfg->{ids}->{$subnet}->{gateway}" = if $subnet_cfg->{ids}->{$subnet}->{gateway}; + } + push @iface_config, "hwaddress $mac" if $mac; push @iface_config, "bridge_ports none"; push @iface_config, "bridge_stp off"; diff --git a/PVE/Network/SDN/Zones/VlanPlugin.pm b/PVE/Network/SDN/Zones/= VlanPlugin.pm index db719a0..8485ae1 100644 --- a/PVE/Network/SDN/Zones/VlanPlugin.pm +++ b/PVE/Network/SDN/Zones/VlanPlugin.pm @@ -39,7 +39,7 @@ sub options { =20 # Plugin implementation sub generate_sdn_config { - my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $controller, $i= nterfaces_config, $config) =3D @_; + my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $controller, $s= ubnet_cfg, $interfaces_config, $config) =3D @_; =20 my $bridge =3D $plugin_config->{bridge}; die "can't find bridge $bridge" if !-d "/sys/class/net/$bridge"; diff --git a/PVE/Network/SDN/Zones/VxlanPlugin.pm b/PVE/Network/SDN/Zones= /VxlanPlugin.pm index a256268..8386c43 100644 --- a/PVE/Network/SDN/Zones/VxlanPlugin.pm +++ b/PVE/Network/SDN/Zones/VxlanPlugin.pm @@ -43,13 +43,10 @@ sub options { =20 # Plugin implementation sub generate_sdn_config { - my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $controller, $i= nterfaces_config, $config) =3D @_; + my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $controller, $s= ubnet_cfg, $interfaces_config, $config) =3D @_; =20 my $tag =3D $vnet->{tag}; my $alias =3D $vnet->{alias}; - my $ipv4 =3D $vnet->{ipv4}; - my $ipv6 =3D $vnet->{ipv6}; - my $mac =3D $vnet->{mac}; my $multicastaddress =3D $plugin_config->{'multicast-address'}; my @peers; @peers =3D PVE::Tools::split_list($plugin_config->{'peers'}) if $plu= gin_config->{'peers'}; @@ -78,9 +75,6 @@ sub generate_sdn_config { =20 #vnet bridge @iface_config =3D (); - push @iface_config, "address $ipv4" if $ipv4; - push @iface_config, "address $ipv6" if $ipv6; - push @iface_config, "hwaddress $mac" if $mac; push @iface_config, "bridge_ports $vxlan_iface"; push @iface_config, "bridge_stp off"; push @iface_config, "bridge_fd 0"; --=20 2.20.1