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 A3E7763604 for ; Tue, 25 Aug 2020 07:21:46 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 551D722FFB for ; Tue, 25 Aug 2020 07:21:13 +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 5FF7922D19 for ; Tue, 25 Aug 2020 07:20:59 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mailpro.odiso.net (Postfix) with ESMTP id 42CF415B9E32; Tue, 25 Aug 2020 07:20:59 +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 RJkIr8SHFLDZ; Tue, 25 Aug 2020 07:20:59 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mailpro.odiso.net (Postfix) with ESMTP id 2527C15B9EAF; Tue, 25 Aug 2020 07:20:59 +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 ZFunuLnDi7xX; Tue, 25 Aug 2020 07:20:59 +0200 (CEST) Received: from pve.fritz.box (unknown [213.211.148.86]) by mailpro.odiso.net (Postfix) with ESMTPSA id E762D15B9E9D; Tue, 25 Aug 2020 07:20:58 +0200 (CEST) From: Alexandre Derumier To: pve-devel@lists.proxmox.com Date: Tue, 25 Aug 2020 07:02:20 +0200 Message-Id: <20200825050222.12447-17-aderumier@odiso.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200825050222.12447-1-aderumier@odiso.com> References: <20200825050222.12447-1-aderumier@odiso.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.000 Adjusted score from AWL reputation of From: address 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. [generateconfig.pl, subnetplugin.pm, evpnplugin.pm, simpleplugin.pm] Subject: [pve-devel] [PATCH v6 pve-network 16/18] Fix vnet gateway for routed setup + /32 pointopoint subnet 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, 25 Aug 2020 05:21:46 -0000 --- PVE/Network/SDN/SubnetPlugin.pm | 6 ++++-- PVE/Network/SDN/Zones/EvpnPlugin.pm | 10 ++++++++-- PVE/Network/SDN/Zones/SimplePlugin.pm | 13 +++++++++++-- test/generateconfig.pl | 3 ++- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/PVE/Network/SDN/SubnetPlugin.pm b/PVE/Network/SDN/SubnetPlug= in.pm index 3769e04..bc66b82 100644 --- a/PVE/Network/SDN/SubnetPlugin.pm +++ b/PVE/Network/SDN/SubnetPlugin.pm @@ -120,8 +120,10 @@ sub on_update_hook { my $reversedns =3D $subnet->{reversedns}; my $reversednszone =3D $subnet->{reversednszone}; =20 - #to: for /32 pointotoping, allow gateway outside the subnet - raise_param_exc({ gateway =3D> "$gateway is not in subnet $subnet"})= if $gateway && !$subnet_matcher->($gateway); + my ($ip, $mask) =3D split(/\//, $cidr); + + #for /32 pointopoint, we allow gateway outside the subnet + raise_param_exc({ gateway =3D> "$gateway is not in subnet $subnet"})= if $gateway && !$subnet_matcher->($gateway) && $mask !=3D 32; =20 raise_param_exc({ dns =3D> "missing dns provider"}) if $dnszone && != $dns; raise_param_exc({ dnszone =3D> "missing dns zone"}) if $dns && !$dns= zone; diff --git a/PVE/Network/SDN/Zones/EvpnPlugin.pm b/PVE/Network/SDN/Zones/= EvpnPlugin.pm index 0ebe13e..17c9262 100644 --- a/PVE/Network/SDN/Zones/EvpnPlugin.pm +++ b/PVE/Network/SDN/Zones/EvpnPlugin.pm @@ -77,9 +77,15 @@ sub generate_sdn_config { @iface_config =3D (); =20 my @subnets =3D PVE::Tools::split_list($vnet->{subnets}) if $vnet->{= subnets}; + my $address =3D {}; 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}; + my $subnetid =3D $subnet =3D~ s/\//-/r; + next if !defined($subnet_cfg->{ids}->{$subnetid}); + my $gateway =3D $subnet_cfg->{ids}->{$subnetid}->{gateway}; + if ($gateway) { + push @iface_config, "address $gateway" if !defined($address->{$gate= way}); + $address->{$gateway} =3D 1; + } } =20 push @iface_config, "hwaddress $mac" if $mac; diff --git a/PVE/Network/SDN/Zones/SimplePlugin.pm b/PVE/Network/SDN/Zone= s/SimplePlugin.pm index 7006b13..a1733d5 100644 --- a/PVE/Network/SDN/Zones/SimplePlugin.pm +++ b/PVE/Network/SDN/Zones/SimplePlugin.pm @@ -36,9 +36,18 @@ sub generate_sdn_config { my @iface_config =3D (); =20 my @subnets =3D PVE::Tools::split_list($vnet->{subnets}) if $vnet->{= subnets}; + my $address =3D {}; 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}; + my $subnetid =3D $subnet =3D~ s/\//-/r; + next if !defined($subnet_cfg->{ids}->{$subnetid}); + my $gateway =3D $subnet_cfg->{ids}->{$subnetid}->{gateway}; + if ($gateway) { + push @iface_config, "address $gateway" if !defined($address->{$gate= way}); + $address->{$gateway} =3D 1; + } + #add route for /32 pointtopoint + my ($ip, $mask) =3D split(/\//, $subnet); + push @iface_config, "up ip route add $subnet dev $vnetid" if $mask =3D=3D= 32; } =20 push @iface_config, "hwaddress $mac" if $mac; diff --git a/test/generateconfig.pl b/test/generateconfig.pl index 36880ba..92108ec 100644 --- a/test/generateconfig.pl +++ b/test/generateconfig.pl @@ -3,17 +3,18 @@ use warnings; use File::Copy; use PVE::Cluster qw(cfs_read_file); =20 +use PVE::Network::SDN; use PVE::Network::SDN::Zones; use PVE::Network::SDN::Controllers; use Data::Dumper; =20 my $network_config =3D PVE::Network::SDN::Zones::generate_etc_network_co= nfig(); + PVE::Network::SDN::Zones::write_etc_network_config($network_config); print "/etc/network/interfaces.d/sdn\n"; print $network_config; print "\n"; =20 - my $controller_config =3D PVE::Network::SDN::Controllers::generate_contr= oller_config(); if ($controller_config) { print Dumper($controller_config); --=20 2.20.1