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 v3 12/17] sdn: zones: allow the ebpf DHCP backend on every zone type
Date: Tue, 20 Oct 2026 10:00:00 +0200	[thread overview]
Message-ID: <20261020080005.470757-13-h.laimer@proxmox.com> (raw)
In-Reply-To: <20261020080005.470757-1-h.laimer@proxmox.com>

The ebpf backend answers each guest on the guest's own tap or veth
device, so the zone type makes no difference to it. dnsmasq stays
limited to simple zones, since every node runs its own instance on
the vnet bridge and only a simple zone's bridge is cut off from the
other nodes. Choosing it elsewhere fails on create and on update.

Every zone type now reports the MTU its guests should use. The ebpf
backend hands it out, and until now only simple zones could answer.
A VXLAN or EVPN zone without an MTU setting takes it from the
interface that reaches its peers.

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
 src/PVE/API2/Network/SDN/Zones.pm         |   8 +-
 src/PVE/Network/SDN/Zones/EvpnPlugin.pm   |  32 +++++++
 src/PVE/Network/SDN/Zones/FaucetPlugin.pm |   1 +
 src/PVE/Network/SDN/Zones/QinQPlugin.pm   |   7 ++
 src/PVE/Network/SDN/Zones/SimplePlugin.pm |   2 +-
 src/PVE/Network/SDN/Zones/VlanPlugin.pm   |   7 ++
 src/PVE/Network/SDN/Zones/VxlanPlugin.pm  |  25 +++++
 src/test/run_test_vnets_blackbox.pl       | 111 +++++++++++++++++++++-
 8 files changed, 188 insertions(+), 5 deletions(-)

diff --git a/src/PVE/API2/Network/SDN/Zones.pm b/src/PVE/API2/Network/SDN/Zones.pm
index 0e907260..181d2872 100644
--- a/src/PVE/API2/Network/SDN/Zones.pm
+++ b/src/PVE/API2/Network/SDN/Zones.pm
@@ -93,7 +93,7 @@ my $ZONE_PROPERTIES = {
         type => 'string',
         enum => PVE::Network::SDN::Dhcp->plugin_types(),
         optional => 1,
-        description => 'Name of DHCP server backend for this zone.',
+        description => 'DHCP backend serving the zone. dnsmasq works on simple zones only.',
     },
     'rt-import' => {
         type => 'string',
@@ -448,6 +448,9 @@ __PACKAGE__->register_method({
                 raise_param_exc({ ipam => "$ipam not existing" })
                     if $ipam && !$ipam_cfg->{ids}->{$ipam};
 
+                raise_param_exc({ dhcp => "the dnsmasq backend only supports simple zones" })
+                    if ($opts->{dhcp} // '') eq 'dnsmasq' && $plugin->type() ne 'simple';
+
                 $zone_cfg->{ids}->{$id} = $opts;
                 $plugin->on_update_hook($id, $zone_cfg, $controller_cfg);
 
@@ -544,6 +547,9 @@ __PACKAGE__->register_method({
                 raise_param_exc({ ipam => "$ipam not existing" })
                     if $ipam && !$ipam_cfg->{ids}->{$ipam};
 
+                raise_param_exc({ dhcp => "the dnsmasq backend only supports simple zones" })
+                    if ($scfg->{dhcp} // '') eq 'dnsmasq' && $plugin->type() ne 'simple';
+
                 $plugin->on_update_hook($id, $zone_cfg, $controller_cfg);
 
                 PVE::Network::SDN::Zones::write_config($zone_cfg);
diff --git a/src/PVE/Network/SDN/Zones/EvpnPlugin.pm b/src/PVE/Network/SDN/Zones/EvpnPlugin.pm
index 0e79707c..60fe788f 100644
--- a/src/PVE/Network/SDN/Zones/EvpnPlugin.pm
+++ b/src/PVE/Network/SDN/Zones/EvpnPlugin.pm
@@ -125,10 +125,42 @@ sub options {
         reversedns => { optional => 1 },
         dnszone => { optional => 1 },
         ipam => { optional => 1 },
+        dhcp => { optional => 1 },
     };
 }
 
 # Plugin implementation
+# the underlay interface is the one the controller's peers name, found the
+# way the bridge generation finds it
+sub get_mtu {
+    my ($class, $plugin_config) = @_;
+
+    return $plugin_config->{mtu} if $plugin_config->{mtu};
+
+    my $iface;
+    my $controller_cfg = PVE::Network::SDN::running_config()->{controllers};
+    my $controller = $controller_cfg->{ids}->{ $plugin_config->{controller} // '' };
+    if ($controller && $controller->{peers}) {
+        my @peers = PVE::Tools::split_list($controller->{peers});
+        my $local_node = PVE::INotify::nodename();
+        my $bgprouter = PVE::Network::SDN::Controllers::EvpnPlugin::find_bgp_controller(
+            $local_node, $controller_cfg,
+        );
+        my $isisrouter = PVE::Network::SDN::Controllers::EvpnPlugin::find_isis_controller(
+            $local_node, $controller_cfg,
+        );
+        my $loopback = $bgprouter->{loopback} // $isisrouter->{loopback};
+        (undef, $iface) = eval {
+            PVE::Network::SDN::Zones::Plugin::find_local_ip_interface_peers(\@peers, $loopback);
+        };
+    }
+    return PVE::Network::SDN::Zones::VxlanPlugin::vxlan_mtu(
+        $plugin_config,
+        $iface,
+        PVE::INotify::read_file('interfaces'),
+    );
+}
+
 sub generate_sdn_config {
     my (
         $class,
diff --git a/src/PVE/Network/SDN/Zones/FaucetPlugin.pm b/src/PVE/Network/SDN/Zones/FaucetPlugin.pm
index 5f069aea..4e3f5eff 100644
--- a/src/PVE/Network/SDN/Zones/FaucetPlugin.pm
+++ b/src/PVE/Network/SDN/Zones/FaucetPlugin.pm
@@ -30,6 +30,7 @@ sub options {
         reversedns => { optional => 1 },
         dnszone => { optional => 1 },
         ipam => { optional => 1 },
+        dhcp => { optional => 1 },
     };
 }
 
diff --git a/src/PVE/Network/SDN/Zones/QinQPlugin.pm b/src/PVE/Network/SDN/Zones/QinQPlugin.pm
index 642420e9..85d9ce98 100644
--- a/src/PVE/Network/SDN/Zones/QinQPlugin.pm
+++ b/src/PVE/Network/SDN/Zones/QinQPlugin.pm
@@ -36,6 +36,12 @@ sub properties {
     };
 }
 
+sub get_mtu {
+    my ($class, $plugin_config) = @_;
+
+    return $plugin_config->{mtu};
+}
+
 sub options {
     return {
         nodes => { optional => 1 },
@@ -48,6 +54,7 @@ sub options {
         reversedns => { optional => 1 },
         dnszone => { optional => 1 },
         ipam => { optional => 1 },
+        dhcp => { optional => 1 },
     };
 }
 
diff --git a/src/PVE/Network/SDN/Zones/SimplePlugin.pm b/src/PVE/Network/SDN/Zones/SimplePlugin.pm
index 347eee9a..655f7e41 100644
--- a/src/PVE/Network/SDN/Zones/SimplePlugin.pm
+++ b/src/PVE/Network/SDN/Zones/SimplePlugin.pm
@@ -31,7 +31,7 @@ sub properties {
             description => "dns domain zone  ex: mydomain.com",
         },
         dhcp => {
-            description => 'Type of the DHCP backend for this zone',
+            description => 'DHCP backend serving the zone. dnsmasq works on simple zones only.',
             type => 'string',
             enum => PVE::Network::SDN::Dhcp->plugin_types(),
         },
diff --git a/src/PVE/Network/SDN/Zones/VlanPlugin.pm b/src/PVE/Network/SDN/Zones/VlanPlugin.pm
index 271b3fab..a5d0fb0d 100644
--- a/src/PVE/Network/SDN/Zones/VlanPlugin.pm
+++ b/src/PVE/Network/SDN/Zones/VlanPlugin.pm
@@ -36,6 +36,12 @@ sub properties {
     };
 }
 
+sub get_mtu {
+    my ($class, $plugin_config) = @_;
+
+    return $plugin_config->{mtu};
+}
+
 sub options {
 
     return {
@@ -47,6 +53,7 @@ sub options {
         reversedns => { optional => 1 },
         dnszone => { optional => 1 },
         ipam => { optional => 1 },
+        dhcp => { optional => 1 },
     };
 }
 
diff --git a/src/PVE/Network/SDN/Zones/VxlanPlugin.pm b/src/PVE/Network/SDN/Zones/VxlanPlugin.pm
index a4082615..0dab5d95 100644
--- a/src/PVE/Network/SDN/Zones/VxlanPlugin.pm
+++ b/src/PVE/Network/SDN/Zones/VxlanPlugin.pm
@@ -47,6 +47,30 @@ sub properties {
     };
 }
 
+# the vnet bridge takes the underlay interface's MTU minus the vxlan
+# encapsulation where the peers name a local interface, the default
+# otherwise. An explicit zone MTU wins
+sub vxlan_mtu {
+    my ($plugin_config, $iface, $interfaces_config) = @_;
+
+    return $plugin_config->{mtu} if $plugin_config->{mtu};
+    return $interfaces_config->{ifaces}->{$iface}->{mtu} - 50
+        if $iface && $interfaces_config->{ifaces}->{$iface}->{mtu};
+    return 1450;
+}
+
+sub get_mtu {
+    my ($class, $plugin_config) = @_;
+
+    my $iface;
+    if ($plugin_config->{peers}) {
+        my @peers = PVE::Tools::split_list($plugin_config->{peers});
+        (undef, $iface) =
+            eval { PVE::Network::SDN::Zones::Plugin::find_local_ip_interface_peers(\@peers) };
+    }
+    return vxlan_mtu($plugin_config, $iface, PVE::INotify::read_file('interfaces'));
+}
+
 sub options {
     return {
         nodes => { optional => 1 },
@@ -58,6 +82,7 @@ sub options {
         dnszone => { optional => 1 },
         ipam => { optional => 1 },
         fabric => { optional => 1 },
+        dhcp => { optional => 1 },
     };
 }
 
diff --git a/src/test/run_test_vnets_blackbox.pl b/src/test/run_test_vnets_blackbox.pl
index 9a4dbb9c..816f8382 100755
--- a/src/test/run_test_vnets_blackbox.pl
+++ b/src/test/run_test_vnets_blackbox.pl
@@ -1488,6 +1488,55 @@ sub test_ipam_cache_case {
 
 run_test(\&test_ipam_cache_case);
 
+sub test_zone_dhcp_backends {
+    my $test_name = (split(/::/, (caller(0))[3]))[-1];
+    my $zoneid = "TESTZONE";
+
+    # dnsmasq answers on the vnet bridge, so it only fits zones confined to
+    # one node. The ebpf backend answers on the guest's tap and fits any
+    my $zone = {
+        type => "vlan",
+        bridge => "vmbr0",
+        ipam => "pve",
+        zone => $zoneid,
+    };
+    eval { PVE::API2::Network::SDN::Zones->create({ %$zone, dhcp => "dnsmasq" }); };
+    like(
+        $@,
+        qr/dnsmasq backend only supports simple zones/,
+        "$test_name: dnsmasq is refused on a vlan zone",
+    );
+
+    create_zone({ %$zone, dhcp => "ebpf" });
+    is(get_zone($zoneid)->{dhcp}, "ebpf", "$test_name: ebpf is accepted on a vlan zone");
+
+    eval { update_zone($zoneid, { dhcp => "dnsmasq" }); };
+    like(
+        $@,
+        qr/dnsmasq backend only supports simple zones/,
+        "$test_name: switching a vlan zone to dnsmasq is refused",
+    );
+
+    # every other zone type offers the backend as well
+    $test_state->{controller_config} = {
+        ids => { ctrl => { type => 'evpn', asn => 65000, peers => '10.0.0.1' } },
+    };
+    my $params = {
+        qinq => { bridge => 'vmbr0', tag => 100 },
+        vxlan => { peers => '10.0.0.1' },
+        evpn => { controller => 'ctrl', 'vrf-vxlan' => 1000 },
+        faucet => { 'dp-id' => 1, controller => 'ctrl' },
+    };
+    for my $type (sort keys %$params) {
+        my $id = uc($type) . "Z";
+        my $zone = { type => $type, ipam => "pve", zone => $id, %{ $params->{$type} } };
+        create_zone({ %$zone, dhcp => "ebpf" });
+        is(get_zone($id)->{dhcp}, "ebpf", "$test_name: ebpf is accepted on a $type zone");
+    }
+}
+
+run_test(\&test_zone_dhcp_backends);
+
 sub test_dnsmasq_dual_stack_and_sweep {
     my $test_name = (split(/::/, (caller(0))[3]))[-1];
     my $zoneid = "TESTZONE";
@@ -1584,7 +1633,7 @@ sub test_dnsmasq_dual_stack_and_sweep {
     is(
         PVE::Tools::file_get_contents($TMP_ETHERS_FILE),
         "$mac,10.0.0.100,[8888::ab]\n$other,10.0.0.102,[8888::AB]\n",
-        "$test_name: a line of another MAC spelled by the old code is kept",
+        "$test_name: a line of another MAC in its earlier spelling is kept",
     );
     is(
         scalar(grep { $_ eq 'reload' } $test_state->{dnsmasq_calls}->@*),
@@ -1818,6 +1867,8 @@ sub test_ebpf_backend {
     );
 }
 
+run_test(\&test_ebpf_backend);
+
 sub test_ebpf_backend_edge_cases {
     my $test_name = (split(/::/, (caller(0))[3]))[-1];
     my $zoneid = "TESTZONE";
@@ -1933,7 +1984,7 @@ sub test_ebpf_backend_edge_cases {
     );
 }
 
-run_test(\&test_ebpf_backend);
+run_test(\&test_ebpf_backend_edge_cases);
 
 sub test_zone_tap_plug {
     my $test_name = (split(/::/, (caller(0))[3]))[-1];
@@ -2063,7 +2114,6 @@ sub test_zone_tap_plug {
 }
 
 run_test(\&test_zone_tap_plug);
-run_test(\&test_ebpf_backend_edge_cases);
 
 sub test_ebpf_mac_case {
     my $test_name = (split(/::/, (caller(0))[3]))[-1];
@@ -2252,6 +2302,61 @@ sub test_ebpf_zone_mtu {
 
 run_test(\&test_ebpf_zone_mtu);
 
+sub test_ebpf_vxlan_mtu {
+    my $test_name = (split(/::/, (caller(0))[3]))[-1];
+    my $zoneid = "VXZONE";
+    my $vnetid = "vxvnet";
+    my $mac = "da:65:8f:18:9b:6f";
+
+    # a vxlan zone without an MTU of its own answers with the one its bridge
+    # takes from the underlay, the encapsulation overhead taken off
+    my $mocked_zone_plugin = Test::MockModule->new('PVE::Network::SDN::Zones::Plugin');
+    $mocked_zone_plugin->mock(
+        find_local_ip_interface_peers => sub { return ('10.10.10.1', 'eno1'); });
+    $mocked_pve_inotify->mock(
+        read_file => sub { return { ifaces => { eno1 => { mtu => 1400 } } }; });
+    create_zone({
+        type => "vxlan",
+        peers => "10.10.10.2",
+        dhcp => "ebpf",
+        ipam => "pve",
+        zone => $zoneid,
+    });
+    create_vnet({
+        type => "vnet",
+        zone => $zoneid,
+        vnet => $vnetid,
+        tag => 100,
+    });
+    create_subnet({
+        type => "subnet",
+        vnet => $vnetid,
+        subnet => "10.0.0.0/24",
+        gateway => "10.0.0.1",
+    });
+    $test_state->{vmlist} = { ids => { 999 => { type => 'qemu', node => 'localnode' } } };
+    $test_state->{guest_nets} = { 999 => { net0 => "virtio=$mac,bridge=$vnetid" } };
+    $test_state->{macdb} = { macs => { $mac => { ip4 => '10.0.0.100' } } };
+
+    take_ebpf_calls();
+    PVE::Network::SDN::Dhcp::regenerate_config();
+    is(
+        take_ebpf_calls()->[0]->{args}->[0]->[0]->{record}->{mtu},
+        1350,
+        "$test_name: the underlay's MTU minus the encapsulation is handed out",
+    );
+    update_zone($zoneid, { mtu => 1500 });
+    PVE::Network::SDN::Dhcp::regenerate_config();
+    is(
+        take_ebpf_calls()->[0]->{args}->[0]->[0]->{record}->{mtu},
+        1500,
+        "$test_name: an explicit zone MTU wins",
+    );
+    $mocked_pve_inotify->unmock('read_file');
+}
+
+run_test(\&test_ebpf_vxlan_mtu);
+
 sub test_ebpf_overlapping_subnets {
     my $test_name = (split(/::/, (caller(0))[3]))[-1];
     my $zoneid = "TESTZONE";
-- 
2.47.3





  parent reply	other threads:[~2026-10-20  8:03 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20  7:59 [PATCH container/docs/manager/network/proxmox{-ebpf,-perl-rs}/qemu-server v3 00/17] sdn: implement DHCP for all zones using eBPF Hannes Laimer
2026-10-20  7:59 ` [PATCH proxmox-ebpf v3 01/17] dhcp: add the per-tap DHCPv4 responder program Hannes Laimer
2026-10-20  7:59 ` [PATCH proxmox-ebpf v3 02/17] dhcp: add the subsystem that loads the responder and keeps its records Hannes Laimer
2026-10-20 13:09   ` Stefan Hanreich
2026-10-21  7:09     ` Hannes Laimer
2026-10-20  7:59 ` [PATCH proxmox-perl-rs v3 03/17] pve-rs: sdn: add bindings for the eBPF DHCP responder Hannes Laimer
2026-10-20 13:10   ` Stefan Hanreich
2026-10-21  7:32     ` Hannes Laimer
2026-10-20  7:59 ` [PATCH pve-network v3 04/17] sdn: dhcp: replace a stale dnsmasq reservation instead of dropping it Hannes Laimer
2026-10-20 13:15   ` Stefan Hanreich
2026-10-20  7:59 ` [PATCH pve-network v3 05/17] sdn: dhcp: update reservations when ip mappings change Hannes Laimer
2026-10-20 13:42   ` Stefan Hanreich
2026-10-21  7:21     ` Hannes Laimer
2026-10-20  7:59 ` [PATCH pve-network v3 06/17] sdn: ipam: key the MAC cache by lower-case MAC, stop caching misses Hannes Laimer
2026-10-20 13:10   ` Stefan Hanreich
2026-10-21  6:17     ` Hannes Laimer
2026-10-20  7:59 ` [PATCH pve-network v3 07/17] sdn: dhcp: make the lease time configurable per subnet Hannes Laimer
2026-10-20 13:17   ` Stefan Hanreich
2026-10-20  7:59 ` [PATCH pve-network v3 08/17] sdn: dhcp: require a backend only if a zone on this node uses it Hannes Laimer
2026-10-20 13:17   ` Stefan Hanreich
2026-10-20  7:59 ` [PATCH pve-network v3 09/17] sdn: dhcp: add an eBPF backend answering on each guest interface Hannes Laimer
2026-10-20 13:10   ` Stefan Hanreich
2026-10-21  6:16     ` Hannes Laimer
2026-10-20  7:59 ` [PATCH pve-network v3 10/17] sdn: zones: report interface plugs and unplugs to the DHCP backends Hannes Laimer
2026-10-20 13:17   ` Stefan Hanreich
2026-10-20  7:59 ` [PATCH pve-network v3 11/17] sdn: dhcp: push IP mapping edits to the guest's node Hannes Laimer
2026-10-20 13:09   ` Stefan Hanreich
2026-10-21  6:44     ` Hannes Laimer
2026-10-20  8:00 ` Hannes Laimer [this message]
2026-10-20  8:00 ` [PATCH qemu-server v3 13/17] network: sdn: keep the DHCP backends current on guest NICs Hannes Laimer
2026-10-20 13:38   ` Stefan Hanreich
2026-10-20  8:00 ` [PATCH pve-container v3 14/17] net: report NIC plugs and removals to the SDN DHCP backends Hannes Laimer
2026-10-20 13:36   ` Stefan Hanreich
2026-10-21  7:29     ` Hannes Laimer
2026-10-20  8:00 ` [PATCH pve-manager v3 15/17] ui: sdn: add zone DHCP backend selector and subnet DHCP options Hannes Laimer
2026-10-20 13:19   ` Stefan Hanreich
2026-10-20  8:00 ` [PATCH pve-manager v3 16/17] sdn: bring up the DHCP backends at boot before the guests start Hannes Laimer
2026-10-20 13:21   ` Stefan Hanreich
2026-10-21  7:17     ` Hannes Laimer
2026-10-20  8:00 ` [PATCH pve-docs v3 17/17] sdn: dhcp: add eBPF backend section Hannes Laimer
2026-10-20 13:11 ` [PATCH container/docs/manager/network/proxmox{-ebpf,-perl-rs}/qemu-server v3 00/17] sdn: implement DHCP for all zones using eBPF Stefan Hanreich
2026-10-21  7:35   ` Hannes Laimer
2026-10-21  8:46 ` superseded: " 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=20261020080005.470757-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