* [pve-devel] [PATCH pve-network v2 1/1] fix #5949: avoid dnsmasq segfault when subnet has no gateway
@ 2026-01-15 14:27 Stefan Hanreich
0 siblings, 0 replies; only message in thread
From: Stefan Hanreich @ 2026-01-15 14:27 UTC (permalink / raw)
To: pve-devel
When trying to start a guest with a network device in a VNet in a
simple zone that has DHCP enabled - but no gateway configured - a
SIGSEGV is triggered in dnsmasq. This seems to be an error in the
dnsmasq dbus handler that tries to allocate a lease, which fails
because there is no dhcp-range configured, and then leads to a
segfault.
Avoid the situation completely by always configuring a dhcp-range in
IPv4 subnets, even if there is no gateway configured. Skip configuring
the DHCP option that returns the router instead, which is the only
place in the configure_subnet function that uses the gateway.
Dnsmasq is configured to listen on an interface, so any DHCP messages
that are received on this interface are dropped, because dnsmasq
recognizes that there is no IP configured on this interface:
Nov 26 16:35:49 ipam-test dnsmasq-dhcp[140272]: DHCP packet received on vnet1 which has no address
Nov 26 16:35:57 ipam-test dnsmasq-dhcp[140272]: DHCP packet received on vnet1 which has no address
The respective upstream fix is contained in commit eb601683 [1].
[1] https://thekelleys.org.uk/gitweb/?p=dnsmasq.git;a=commit;h=eb601683820723df89858cfa695aa131012f1a63
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
Notes:
Changes from v1:
* added TODO comment
* adjusted commit message
* only run check for IPv4 subnets, since the error only occurs with
IPv4 subnets
src/PVE/Network/SDN/Dhcp/Dnsmasq.pm | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm b/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm
index db22e12..fe46cbb 100644
--- a/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm
+++ b/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm
@@ -138,14 +138,18 @@ sub add_ip_mapping {
sub configure_subnet {
my ($class, $config, $dhcpid, $vnetid, $subnet_config) = @_;
- die "No gateway defined for subnet $subnet_config->{id}"
- if !$subnet_config->{gateway};
-
my $tag = $subnet_config->{id};
my ($zone, $network, $mask) = split(/-/, $tag);
+ my $is_ipv4 = Net::IP::ip_is_ipv4($network);
+
+ # only die for IPv6 for now, since dnsmasq segfaults for IPv4 subnets
+ # without any gateway if no dhcp-range statement is configured (see #5949)
+ # TODO: enable check for IPv4 again as soon as fix is available.
+ die "No gateway configured for subnet $subnet_config->{id}"
+ if !$subnet_config->{gateway} && !$is_ipv4;
- if (Net::IP::ip_is_ipv4($network)) {
+ if ($is_ipv4) {
$mask = (2**$mask - 1) << (32 - $mask);
$mask = join('.', unpack("C4", pack("N", $mask)));
}
@@ -155,7 +159,7 @@ sub configure_subnet {
my $option_string;
if (ip_is_ipv6($subnet_config->{network})) {
$option_string = 'option6';
- } else {
+ } elsif ($subnet_config->{gateway}) {
$option_string = 'option';
push @{$config}, "dhcp-option=tag:$tag,$option_string:router,$subnet_config->{gateway}";
}
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-01-15 14:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-15 14:27 [pve-devel] [PATCH pve-network v2 1/1] fix #5949: avoid dnsmasq segfault when subnet has no gateway Stefan Hanreich
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.