From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 1476E1FF0B6 for ; Thu, 12 Nov 2026 13:43:29 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 9929B217C0; Thu, 12 Nov 2026 13:42:36 +0100 (CET) From: Hannes Laimer To: pve-devel@lists.proxmox.com Subject: [PATCH pve-network v7 12/21] sdn: zones: factor out the underlay lookup of VXLAN and EVPN zones Date: Thu, 12 Nov 2026 13:41:52 +0100 Message-ID: <20261112124201.2844423-13-h.laimer@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261112124201.2844423-1-h.laimer@proxmox.com> References: <20261112124201.2844423-1-h.laimer@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1794487343731 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.708 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) KAM_MAILER 2 Automated Mailer Tag Left in Email RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: JPMNFHBYRWQIM4I3DOU4P7K4CCUBWOVR X-Message-ID-Hash: JPMNFHBYRWQIM4I3DOU4P7K4CCUBWOVR X-MailFrom: h.laimer@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: A VXLAN or EVPN zone finds its local tunnel address and the interface that has it while it generates the interfaces config. Move that lookup into a function of its own for each of the two zone types, so it can be used without generating the config. No functional change intended. For a zone on a fabric, the EVPN lookup also built a peer list and a loopback name that nothing read. Both are dropped. Signed-off-by: Hannes Laimer --- src/PVE/Network/SDN/Zones/EvpnPlugin.pm | 74 ++++++++++++----------- src/PVE/Network/SDN/Zones/VxlanPlugin.pm | 76 +++++++++++++----------- 2 files changed, 80 insertions(+), 70 deletions(-) diff --git a/src/PVE/Network/SDN/Zones/EvpnPlugin.pm b/src/PVE/Network/SDN/Zones/EvpnPlugin.pm index 9a85a9d9bf72..5c951dae120a 100644 --- a/src/PVE/Network/SDN/Zones/EvpnPlugin.pm +++ b/src/PVE/Network/SDN/Zones/EvpnPlugin.pm @@ -132,40 +132,16 @@ sub options { }; } -# Plugin implementation -sub generate_sdn_config { - my ( - $class, - $plugin_config, - $zoneid, - $vnetid, - $vnet, - $controller, - $controller_cfg, - $subnet_cfg, - $interfaces_config, - $config, - ) = @_; +my sub find_underlay { + my ($plugin_config, $controller, $controller_cfg) = @_; - my $tag = $vnet->{tag}; - my $alias = $vnet->{alias}; - my $mac = $plugin_config->{'mac'}; - my $vxlanport = $plugin_config->{'vxlan-port'}; - - my $vrf_iface = "vrf_$zoneid"; - my $vrfvxlan = $plugin_config->{'vrf-vxlan'}; my $local_node = PVE::INotify::nodename(); - - die "missing vxlan tag" if !$tag; - die "missing controller" if !$controller; - - my @peers; - my $loopback = undef; my $ifaceip = undef; my $iface = undef; if ($controller->{peers}) { - @peers = PVE::Tools::split_list($controller->{'peers'}); + my @peers = PVE::Tools::split_list($controller->{'peers'}); + my $loopback = undef; my $bgprouter = PVE::Network::SDN::Controllers::EvpnPlugin::find_bgp_controller( $local_node, $controller_cfg, @@ -182,8 +158,6 @@ sub generate_sdn_config { ($ifaceip, $iface) = PVE::Network::SDN::Zones::Plugin::find_local_ip_interface_peers(\@peers, $loopback); - log_warn("EVPN zone $zoneid, VNet $vnetid: no local address found for peers") - if !defined($ifaceip); } elsif ($controller->{fabric}) { my $config = PVE::Network::SDN::Fabrics::config(1); @@ -204,17 +178,45 @@ sub generate_sdn_config { "Node $local_node requires a $addr_key address in the fabric $fabric->{id} to configure the EVPN zone" if !$current_node->{$addr_key}; - for my $node_id (sort keys %$nodes) { - push @peers, $nodes->{$node_id}->{$addr_key}; - } - - $loopback = "dummy_$fabric->{id}"; - $ifaceip = $current_node->{$addr_key}; } else { die "neither fabric nor peers configured for EVPN controller $controller->{id}"; } + return ($ifaceip, $iface); +} + +# Plugin implementation +sub generate_sdn_config { + my ( + $class, + $plugin_config, + $zoneid, + $vnetid, + $vnet, + $controller, + $controller_cfg, + $subnet_cfg, + $interfaces_config, + $config, + ) = @_; + + my $tag = $vnet->{tag}; + my $alias = $vnet->{alias}; + my $mac = $plugin_config->{'mac'}; + my $vxlanport = $plugin_config->{'vxlan-port'}; + + my $vrf_iface = "vrf_$zoneid"; + my $vrfvxlan = $plugin_config->{'vrf-vxlan'}; + my $local_node = PVE::INotify::nodename(); + + die "missing vxlan tag" if !$tag; + die "missing controller" if !$controller; + + my ($ifaceip, $iface) = find_underlay($plugin_config, $controller, $controller_cfg); + log_warn("EVPN zone $zoneid, VNet $vnetid: no local address found for peers") + if !defined($ifaceip); + my $is_evpn_gateway = $plugin_config->{'exitnodes'}->{$local_node}; my $exitnodes_local_routing = $plugin_config->{'exitnodes-local-routing'}; diff --git a/src/PVE/Network/SDN/Zones/VxlanPlugin.pm b/src/PVE/Network/SDN/Zones/VxlanPlugin.pm index d8301bac0f3a..d9f86c8ef478 100644 --- a/src/PVE/Network/SDN/Zones/VxlanPlugin.pm +++ b/src/PVE/Network/SDN/Zones/VxlanPlugin.pm @@ -62,6 +62,45 @@ sub vxlan_mtu { return $underlay - ($family == 6 ? 70 : 50); } +my sub find_underlay { + my ($plugin_config) = @_; + + my @peers; + my $ifaceip; + my $iface; + + if ($plugin_config->{peers}) { + @peers = PVE::Tools::split_list($plugin_config->{peers}); + ($ifaceip, $iface) = + PVE::Network::SDN::Zones::Plugin::find_local_ip_interface_peers(\@peers); + } elsif ($plugin_config->{fabric}) { + my $local_node = PVE::INotify::nodename(); + my $config = PVE::Network::SDN::Fabrics::config(1); + + my $fabric = eval { $config->get_fabric($plugin_config->{fabric}) }; + die "could not configure VXLAN zone $plugin_config->{id}: $@" if $@; + + my $nodes = $config->list_nodes_fabric($plugin_config->{fabric}); + + my $current_node = eval { $config->get_node($plugin_config->{fabric}, $local_node) }; + die "could not configure VXLAN zone $plugin_config->{id}: $@" if $@; + + die + "Node $local_node requires an IP in the fabric $fabric->{id} to configure the VXLAN zone $plugin_config->{id}" + if !$current_node->{ip}; + + for my $node (values %$nodes) { + push @peers, $node->{ip} if $node->{ip}; + } + + $ifaceip = $current_node->{ip}; + } else { + die "neither peers nor fabric configured for VXLAN zone $plugin_config->{id}"; + } + + return ($ifaceip, $iface, @peers); +} + sub options { return { nodes => { optional => 1 }, @@ -99,40 +138,9 @@ sub generate_sdn_config { die "missing vxlan tag" if !$tag; - my @peers; - my $ifaceip; - my $iface; - - if ($plugin_config->{peers}) { - @peers = PVE::Tools::split_list($plugin_config->{'peers'}) if $plugin_config->{'peers'}; - ($ifaceip, $iface) = - PVE::Network::SDN::Zones::Plugin::find_local_ip_interface_peers(\@peers); - log_warn("VXLAN zone $zoneid, VNet $vnetid: no local address found for peers") - if !defined($ifaceip); - } elsif ($plugin_config->{fabric}) { - my $local_node = PVE::INotify::nodename(); - my $config = PVE::Network::SDN::Fabrics::config(1); - - my $fabric = eval { $config->get_fabric($plugin_config->{fabric}) }; - die "could not configure VXLAN zone $plugin_config->{id}: $@" if $@; - - my $nodes = $config->list_nodes_fabric($plugin_config->{fabric}); - - my $current_node = eval { $config->get_node($plugin_config->{fabric}, $local_node) }; - die "could not configure VXLAN zone $plugin_config->{id}: $@" if $@; - - die - "Node $local_node requires an IP in the fabric $fabric->{id} to configure the VXLAN zone $plugin_config->{id}" - if !$current_node->{ip}; - - for my $node (values %$nodes) { - push @peers, $node->{ip} if $node->{ip}; - } - - $ifaceip = $current_node->{ip}; - } else { - die "neither peers nor fabric configured for VXLAN zone $plugin_config->{id}"; - } + my ($ifaceip, $iface, @peers) = find_underlay($plugin_config); + log_warn("VXLAN zone $zoneid, VNet $vnetid: no local address found for peers") + if !defined($ifaceip); my $mtu = vxlan_mtu($plugin_config, $iface, $interfaces_config, $ifaceip); -- 2.47.3