all lists on 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 13/21] sdn: zones: allow the ebpf DHCP backend on every zone type
Date: Thu, 12 Nov 2026 13:41:53 +0100	[thread overview]
Message-ID: <20261112124201.2844423-14-h.laimer@proxmox.com> (raw)
In-Reply-To: <20261112124201.2844423-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, or gets the default if it is on a
fabric.

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
 src/PVE/API2/Network/SDN/Zones.pm         |  13 ++-
 src/PVE/Network/SDN/Zones/EvpnPlugin.pm   |  16 +++
 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  |   9 ++
 src/test/run_test_vnets_blackbox.pl       | 123 +++++++++++++++++++++-
 8 files changed, 174 insertions(+), 4 deletions(-)

diff --git a/src/PVE/API2/Network/SDN/Zones.pm b/src/PVE/API2/Network/SDN/Zones.pm
index 4f61e1e858aa..218d13018353 100644
--- a/src/PVE/API2/Network/SDN/Zones.pm
+++ b/src/PVE/API2/Network/SDN/Zones.pm
@@ -60,7 +60,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',
@@ -358,6 +358,13 @@ sub create_etc_interfaces_sdn_dir {
     mkdir("/etc/pve/sdn");
 }
 
+my sub assert_dhcp_backend {
+    my ($plugin, $dhcp) = @_;
+
+    raise_param_exc({ dhcp => "the dnsmasq backend only supports simple zones" })
+        if ($dhcp // '') eq 'dnsmasq' && $plugin->type() ne 'simple';
+}
+
 __PACKAGE__->register_method({
     name => 'create',
     protected => 1,
@@ -406,6 +413,8 @@ __PACKAGE__->register_method({
                 raise_param_exc({ dnszone => "missing dns server" })
                     if $dnszone && !$dnsserver;
 
+                assert_dhcp_backend($plugin, $opts->{dhcp});
+
                 $zone_cfg->{ids}->{$id} = $opts;
                 $plugin->on_update_hook($id, $zone_cfg, $controller_cfg);
 
@@ -493,6 +502,8 @@ __PACKAGE__->register_method({
                 my $dnszone = $opts->{dnszone};
                 raise_param_exc({ dnszone => "missing dns server" }) if $dnszone && !$dnsserver;
 
+                assert_dhcp_backend($plugin, $scfg->{dhcp});
+
                 $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 5c951dae120a..5e062f976686 100644
--- a/src/PVE/Network/SDN/Zones/EvpnPlugin.pm
+++ b/src/PVE/Network/SDN/Zones/EvpnPlugin.pm
@@ -129,6 +129,7 @@ sub options {
         reversedns => { optional => 1 },
         dnszone => { optional => 1 },
         ipam => { optional => 1 },
+        dhcp => { optional => 1 },
     };
 }
 
@@ -187,6 +188,21 @@ my sub find_underlay {
 }
 
 # Plugin implementation
+sub get_mtu {
+    my ($class, $plugin_config) = @_;
+
+    return $plugin_config->{mtu} if $plugin_config->{mtu};
+
+    my $controller_cfg = PVE::Network::SDN::running_config()->{controllers};
+    my $controller = $controller_cfg->{ids}->{ $plugin_config->{controller} // '' };
+    # a zone whose underlay cannot be found gets the default MTU
+    my ($ifaceip, $iface) =
+        $controller ? eval { find_underlay($plugin_config, $controller, $controller_cfg) } : ();
+    return PVE::Network::SDN::Zones::VxlanPlugin::vxlan_mtu(
+        $plugin_config, $iface, PVE::INotify::read_file('interfaces'), $ifaceip,
+    );
+}
+
 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 5f069aea85de..4e3f5eff8a8b 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 894bba16a20e..6031e0ad5002 100644
--- a/src/PVE/Network/SDN/Zones/QinQPlugin.pm
+++ b/src/PVE/Network/SDN/Zones/QinQPlugin.pm
@@ -39,6 +39,12 @@ sub properties {
     };
 }
 
+sub get_mtu {
+    my ($class, $plugin_config) = @_;
+
+    return $plugin_config->{mtu};
+}
+
 sub options {
     return {
         nodes => { optional => 1 },
@@ -51,6 +57,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 347eee9a46ba..655f7e41cf37 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 de19755d04f5..46b00d747b80 100644
--- a/src/PVE/Network/SDN/Zones/VlanPlugin.pm
+++ b/src/PVE/Network/SDN/Zones/VlanPlugin.pm
@@ -38,6 +38,12 @@ sub properties {
     };
 }
 
+sub get_mtu {
+    my ($class, $plugin_config) = @_;
+
+    return $plugin_config->{mtu};
+}
+
 sub options {
 
     return {
@@ -49,6 +55,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 d9f86c8ef478..ba38739abc6f 100644
--- a/src/PVE/Network/SDN/Zones/VxlanPlugin.pm
+++ b/src/PVE/Network/SDN/Zones/VxlanPlugin.pm
@@ -101,6 +101,14 @@ my sub find_underlay {
     return ($ifaceip, $iface, @peers);
 }
 
+sub get_mtu {
+    my ($class, $plugin_config) = @_;
+
+    # a zone whose underlay cannot be found gets the default MTU
+    my ($ifaceip, $iface) = eval { find_underlay($plugin_config) };
+    return vxlan_mtu($plugin_config, $iface, PVE::INotify::read_file('interfaces'), $ifaceip);
+}
+
 sub options {
     return {
         nodes => { optional => 1 },
@@ -112,6 +120,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 a3a6547313ce..4598c6d1ce16 100755
--- a/src/test/run_test_vnets_blackbox.pl
+++ b/src/test/run_test_vnets_blackbox.pl
@@ -1622,6 +1622,55 @@ sub test_mapping_edit_target {
 
 run_test(\&test_mapping_edit_target);
 
+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_ipam_per_vnet {
     my $test_name = (split(/::/, (caller(0))[3]))[-1];
     my $zoneid = "TESTZONE";
@@ -2257,6 +2306,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";
@@ -2371,7 +2422,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];
@@ -2563,7 +2614,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];
@@ -2870,6 +2920,75 @@ 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} = {
+        vnets => { $vnetid => { $mac => { ip4 => '10.0.0.100' } } },
+        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",
+    );
+
+    # over IPv6 the encapsulation takes 70 bytes
+    $mocked_zone_plugin->mock(find_local_ip_interface_peers => sub { return ('fd00::1', 'eno1'); });
+    PVE::Network::SDN::Dhcp::regenerate_config();
+    is(
+        take_ebpf_calls()->[0]->{args}->[0]->[0]->{record}->{mtu},
+        1330,
+        "$test_name: over an IPv6 underlay 70 bytes are taken off",
+    );
+    $mocked_zone_plugin->mock(
+        find_local_ip_interface_peers => sub { return ('10.10.10.1', 'eno1'); });
+    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-11-12 12:44 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 ` [PATCH pve-network v7 12/21] sdn: zones: factor out the underlay lookup of VXLAN and EVPN zones Hannes Laimer
2026-11-12 12:41 ` Hannes Laimer [this message]
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-14-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal