From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 8F4811FF066 for ; Tue, 24 Nov 2026 10:28:56 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 7E59F2153A; Tue, 24 Nov 2026 10:28:55 +0100 (CET) Message-ID: Date: Tue, 24 Nov 2026 10:28:51 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH network] sdn: dhcp: do not start dnsmasq for zones without a vnet with subnets To: pve-devel@lists.proxmox.com References: <20261123-sdn_dhcp_do-v1-1-4b55711e9620@proxmox.com> Content-Language: en-US From: Stefan Hanreich In-Reply-To: <20261123-sdn_dhcp_do-v1-1-4b55711e9620@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.192 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) 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: AOCXEJVA34A5PTMEGZRZVVMJ6JCCNMVZ X-Message-ID-Hash: AOCXEJVA34A5PTMEGZRZVVMJ6JCCNMVZ X-MailFrom: s.hanreich@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: 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 Reviewed-by: Stefan Hanreich 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 > --- > 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/. 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 > > > > >