public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Hannes Laimer <h.laimer@proxmox.com>
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	[thread overview]
Message-ID: <20261112124201.2844423-13-h.laimer@proxmox.com> (raw)
In-Reply-To: <20261112124201.2844423-1-h.laimer@proxmox.com>

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 <h.laimer@proxmox.com>
---
 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





  parent reply	other threads:[~2026-11-12 12:43 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 12:41 [PATCH container/docs/manager/network/proxmox{,-perl-rs,-ve-rs}/qemu-server v7 00/21] sdn: implement DHCP for all zones using eBPF Hannes Laimer
2026-11-12 12:41 ` [PATCH proxmox v7 01/21] network-types: mac address: add an accessor for the bytes Hannes Laimer
2026-11-12 12:41 ` [PATCH proxmox-perl-rs v7 02/21] pve-rs: sdn: add bindings for the eBPF DHCP responder Hannes Laimer
2026-11-12 12:41 ` [PATCH proxmox-perl-rs v7 03/21] pve-rs: fire the pve-ebpf-update trigger on upgrade Hannes Laimer
2026-11-12 12:41 ` [PATCH pve-network v7 04/21] sdn: zones: take the VXLAN and EVPN MTU from the underlay interface Hannes Laimer
2026-11-12 12:41 ` [PATCH pve-network v7 05/21] sdn: zones: account for IPv6 in the VXLAN and EVPN MTU Hannes Laimer
2026-11-12 12:41 ` [PATCH pve-network v7 06/21] sdn: dhcp: make the lease time configurable per subnet Hannes Laimer
2026-11-12 12:41 ` [PATCH pve-network v7 07/21] sdn: dhcp: require a backend only if a zone on this node uses it Hannes Laimer
2026-11-12 12:41 ` [PATCH pve-network v7 08/21] bpf: add the build, the package and a native harness for BPF programs Hannes Laimer
2026-11-12 12:41 ` [PATCH pve-network v7 09/21] sdn: dhcp: add the per-tap DHCPv4 responder program Hannes Laimer
2026-11-12 12:41 ` [PATCH pve-network v7 10/21] sdn: dhcp: add an eBPF backend answering on each guest interface Hannes Laimer
2026-11-12 12:41 ` [PATCH pve-network v7 11/21] sdn: zones: report interface plugs and unplugs to the DHCP backends Hannes Laimer
2026-11-12 12:41 ` Hannes Laimer [this message]
2026-11-12 12:41 ` [PATCH pve-network v7 13/21] sdn: zones: allow the ebpf DHCP backend on every zone type Hannes Laimer
2026-11-12 12:41 ` [PATCH qemu-server v7 14/21] network: sdn: keep the DHCP backends current on guest NICs Hannes Laimer
2026-11-12 12:41 ` [PATCH pve-container v7 15/21] net: report NIC plugs and removals to the SDN DHCP backends Hannes Laimer
2026-11-12 12:41 ` [PATCH pve-manager v7 16/21] ui: sdn: add zone DHCP backend selector and subnet DHCP options Hannes Laimer
2026-11-12 12:41 ` [PATCH pve-manager v7 17/21] sdn: bring up the DHCP backends at boot before the guests start Hannes Laimer
2026-11-12 12:41 ` [PATCH proxmox-ve-rs v7 18/21] ve-config: sdn: add the ebpf dhcp backend Hannes Laimer
2026-11-12 12:41 ` [PATCH proxmox-ve-rs v7 19/21] sdn-dhcp: add the crate that runs the eBPF DHCP responder Hannes Laimer
2026-11-12 12:42 ` [PATCH pve-docs v7 20/21] sdn: zones: document the MTU taken from the underlay interface Hannes Laimer
2026-11-12 12:42 ` [PATCH pve-docs v7 21/21] sdn: dhcp: add eBPF backend section Hannes Laimer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261112124201.2844423-13-h.laimer@proxmox.com \
    --to=h.laimer@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal