From: Stefan Hanreich <s.hanreich@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: Re: [PATCH network] sdn: dhcp: do not start dnsmasq for zones without a vnet with subnets
Date: Tue, 24 Nov 2026 10:28:51 +0100 [thread overview]
Message-ID: <c7829f4c-e9ec-49a8-a004-9e420fbadb3c@proxmox.com> (raw)
In-Reply-To: <20261123-sdn_dhcp_do-v1-1-4b55711e9620@proxmox.com>
tested on a node with two simple zones that contain no vnets
applying without the patch failed and left a dnsmasq instance
on all ifaces, whereas with the patch it worked.
Another issue on guest startup was flagged, that we could
improve as well. We reload dnsmasq for guests after adding an
IP mapping which can make guest startup fail if the dnsmasq
instance is not running. Can reproduce by having a simple
zone with an IPv6 subnet but no gateway. Can be fixed
independently of this patch imo.
Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
Reviewed-by: Stefan Hanreich <s.hanreich@proxmox.com>
On 11/23/26 5:48 PM, Gabriel Goller wrote:
> A zone with DHCP enabled but no vnet with a subnet still got a dnsmasq
> instance. The interface= line for a vnet is only written once the vnet
> has a subnet, so the instance config only has except-interface=lo. With
> bind-dynamic, dnsmasq then binds port 53 on every address of the host,
> including the vnets of other zones. Zones are configured in sorted
> order, so every DHCP zone after the empty one then fails to start:
>
> dnsmasq: failed to create listening socket for fe80::d840:37ff:fea1:fa73%test2: Address already in use
> dnsmasq: FAILED to start up
>
> This was preexisting but zones with a dedicated VRF are affected too.
> dnsmasq runs via "ip vrf exec", but it binds link-local addresses with
> sin6_scope_id set to the interface. The kernel then replaces the VRF
> binding of the socket with that interface, so the instance still binds
> to host and other zone interfaces, and also answers DNS there.
>
> Only enable and start dnsmasq for a zone if at least one of its vnets
> has a subnet, and thus an interface= line. before_regenerate already
> stops and disables all instances, so a skipped zone stays down.
>
> Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
> ---
> Note that with this patch, a DHCP zone without a vnet that has a subnet
> no longer gets a dnsmasq instance, even if the user added custom config
> files (e.g. 90-custom.conf) in etc/dnsmasq.d/<zone>. I don't expect
> anyone to rely on this, since that instance would also bind to every
> address on the host and break the other zones
> ---
> src/PVE/Network/SDN/Dhcp.pm | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/src/PVE/Network/SDN/Dhcp.pm b/src/PVE/Network/SDN/Dhcp.pm
> index 10d7ee917da5..47161208c802 100644
> --- a/src/PVE/Network/SDN/Dhcp.pm
> +++ b/src/PVE/Network/SDN/Dhcp.pm
> @@ -97,6 +97,8 @@ sub regenerate_config {
> eval { $dhcp_plugin->before_configure($zoneid, $zone) };
> die "Could not run before_configure for DHCP server $zoneid $@\n" if $@;
>
> + my $has_dhcp_vnet = 0;
> +
> for my $vnetid (sort keys %{ $vnet_cfg->{ids} }) {
> my $vnet = $vnet_cfg->{ids}->{$vnetid};
> next if $vnet->{zone} ne $zoneid;
> @@ -126,8 +128,13 @@ sub regenerate_config {
>
> eval { $dhcp_plugin->configure_vnet($config, $zoneid, $vnetid, $vnet) };
> warn "Could not configure vnet $vnetid: $@\n" if $@;
> + $has_dhcp_vnet = 1 if !$@ && @$config;
> }
>
> + # Without a vnet to serve, the DHCP server isn't restricted to any interface and binds to
> + # every address on the host, including those on vnets of other zones.
> + next if !$has_dhcp_vnet;
> +
> eval { $dhcp_plugin->after_configure($zoneid, !$any_zone_needs_dhcp) };
> warn "Could not run after_configure for DHCP server $zoneid $@\n" if $@;
>
>
> ---
> base-commit: e933d383aebdff9f31f6d00986331fc6e6dd898b
> change-id: 20261123-sdn_dhcp_do-02a78a052589
>
> Best regards,
> --
> Gabriel Goller <g.goller@proxmox.com>
>
>
>
>
>
prev parent reply other threads:[~2026-11-24 9:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 16:48 [PATCH network] sdn: dhcp: do not start dnsmasq for zones without a vnet with subnets Gabriel Goller
2026-11-24 9:22 ` Thomas Lamprecht
2026-11-24 9:33 ` Stefan Hanreich
2026-11-24 9:28 ` Stefan Hanreich [this message]
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=c7829f4c-e9ec-49a8-a004-9e420fbadb3c@proxmox.com \
--to=s.hanreich@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