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 CEBF4639F8 for ; Mon, 5 Oct 2020 17:09:04 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 7AEA91C23A for ; Mon, 5 Oct 2020 17:08:41 +0200 (CEST) Received: from kvmformation1.odiso.net (globalOdiso.M6Lille.odiso.net [89.248.211.242]) by firstgate.proxmox.com (Proxmox) with ESMTP id 014411C102 for ; Mon, 5 Oct 2020 17:08:31 +0200 (CEST) Received: by kvmformation1.odiso.net (Postfix, from userid 0) id BB40EE89AC; Mon, 5 Oct 2020 17:08:24 +0200 (CEST) From: Alexandre Derumier To: pve-devel@lists.proxmox.com Date: Mon, 5 Oct 2020 17:08:13 +0200 Message-Id: <20201005150823.462387-17-aderumier@odiso.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201005150823.462387-1-aderumier@odiso.com> References: <20201005150823.462387-1-aderumier@odiso.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 1 AWL -0.492 Adjusted score from AWL reputation of From: address HEADER_FROM_DIFFERENT_DOMAINS 0.248 From and EnvelopeFrom 2nd level mail domains are different KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods KHOP_HELO_FCRDNS 0.398 Relay HELO differs from its IP's reverse DNS NO_DNS_FOR_FROM 0.379 Envelope sender has no MX or A DNS records SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Subject: [pve-devel] [PATCH v9 pve-network 16/26] 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: Mon, 05 Oct 2020 15:09:05 -0000 Signed-off-by: Alexandre Derumier --- 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/SubnetPlugin.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 = $subnet->{reversedns}; my $reversednszone = $subnet->{reversednszone}; - #to: for /32 pointotoping, allow gateway outside the subnet - raise_param_exc({ gateway => "$gateway is not in subnet $subnet"}) if $gateway && !$subnet_matcher->($gateway); + my ($ip, $mask) = split(/\//, $cidr); + + #for /32 pointopoint, we allow gateway outside the subnet + raise_param_exc({ gateway => "$gateway is not in subnet $subnet"}) if $gateway && !$subnet_matcher->($gateway) && $mask != 32; raise_param_exc({ dns => "missing dns provider"}) if $dnszone && !$dns; raise_param_exc({ dnszone => "missing dns zone"}) if $dns && !$dnszone; 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 = (); my @subnets = PVE::Tools::split_list($vnet->{subnets}) if $vnet->{subnets}; + my $address = {}; 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 = $subnet =~ s/\//-/r; + next if !defined($subnet_cfg->{ids}->{$subnetid}); + my $gateway = $subnet_cfg->{ids}->{$subnetid}->{gateway}; + if ($gateway) { + push @iface_config, "address $gateway" if !defined($address->{$gateway}); + $address->{$gateway} = 1; + } } push @iface_config, "hwaddress $mac" if $mac; diff --git a/PVE/Network/SDN/Zones/SimplePlugin.pm b/PVE/Network/SDN/Zones/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 = (); my @subnets = PVE::Tools::split_list($vnet->{subnets}) if $vnet->{subnets}; + my $address = {}; 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 = $subnet =~ s/\//-/r; + next if !defined($subnet_cfg->{ids}->{$subnetid}); + my $gateway = $subnet_cfg->{ids}->{$subnetid}->{gateway}; + if ($gateway) { + push @iface_config, "address $gateway" if !defined($address->{$gateway}); + $address->{$gateway} = 1; + } + #add route for /32 pointtopoint + my ($ip, $mask) = split(/\//, $subnet); + push @iface_config, "up ip route add $subnet dev $vnetid" if $mask == 32; } 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); +use PVE::Network::SDN; use PVE::Network::SDN::Zones; use PVE::Network::SDN::Controllers; use Data::Dumper; my $network_config = PVE::Network::SDN::Zones::generate_etc_network_config(); + PVE::Network::SDN::Zones::write_etc_network_config($network_config); print "/etc/network/interfaces.d/sdn\n"; print $network_config; print "\n"; - my $controller_config = PVE::Network::SDN::Controllers::generate_controller_config(); if ($controller_config) { print Dumper($controller_config); -- 2.20.1