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 D4DB61FF0B7 for ; Tue, 08 Sep 2026 09:47:52 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id F418621492; Tue, 08 Sep 2026 09:47:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788795573; x=1789400373; darn=lists.proxmox.com; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=wPASf8SKs+KTS0e1PCCdCna+pNghplLVt3py1F1blXA=; b=U4mn+dup6pg5/vM6FlDdBul/vHBJgnIY8/eMq8yxDx2S1KrY8gzyJed2Bil3emDhi6 5YuZUPcS0Grg2M1OOiMTuuNBXMq5mBw76l51JrBhnkuk7UEK3KL2MyKkbUdvjFA+oXT1 crIagQjDiN8tGRcv4kCo8i/Bpa7cq5wI4ICLBaxpm95H/OIdtuzjQk8SZgW3GOtmG2M3 J+Pb/PNe/U9iABsYGT/SfuLSMc/x10PY+Xr8OA0wsEZcYTJLtSUh7qRdmcWHeXUhPf+o Qv9e3ocdgfCDWvYwsf8qR8XwVuyI1Rjy3I7uEJBKQy6w3z3KZDaUcl188BcA8t/z7+qj y7Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788795573; x=1789400373; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=wPASf8SKs+KTS0e1PCCdCna+pNghplLVt3py1F1blXA=; b=K79ifbiTDVARwln3G9XaFpf2ti2LGoqhMBwsiyx3nKWl3gVxp9sWNq3LqPGDE4su8T STUw9UXYud0wN/F9kspZP+tEOLSRy+kCbhfw3i9LQ65/DG39a835gRMw93E2ykgGsAqQ Gi92+yxedTZtF2ytg6EbmqT5s7dBk1azzRgb0EN8JfmpwqQPl4WLWSKVlJEGPYXg8qSL AzR4F7XNdcOnPl0jKZSwt12CdM+4ErMrCB+4NfuaYbh/9xQJu/u8tlXF8wjBwIoB4sNO YpF7bYONJTk5mhvmufNNgAtGCK+SgNiPKLatkFheAZlgDxQVnQbYNC4bjuHJG9zv6Azh M/RA== X-Gm-Message-State: AFuF++mepbn8CwIp2UsF+vzp1/E/DyU1ddbEqnvGEVMlM74rFu5xso4T CnNhxKn3w8ySHMaXUTzRG5nPMlUy6fp5f3GPT5seydbentiVycqN6abIZfTmoLyYM3s= X-Gm-Gg: AYBFou36pytrJZeHwrqrzjzqprbz7DzxPxxxsqsp2qZTyBekHmk3odv3qzhS+FpO5OG 4enf13VdIzsHd0wszap5ZrdtBMvqqpZKICIOCb103mJJ44MPJXmNqNT0xX2wzHwbKXN6gCPprFi Rfqds+1e0lNMI8v0HVcN5QxCY6zXBSGzKA3pRxAIacLx4b/gYtJe58FWol//YM1bsADvglNzIDS KEaCHtqO+ej6ifZhHsNuzgeENAHAq06Zu2JHtYrK3YiFrHeTEaMLvP2ow0HqUv6T2bbEbjkeXTR B84vgaR8tVxlSEncFI2ko4x8y6OLHdq6wnbkdXWt3daO2YMd0kXlR9JDLG40pmObM4UDKnHWug9 0HVaX1OoOmQn/l/0ndbVK3vZQ3NP5anPuEGvcAG5g6sT8zdTv96CxtvbzBM3aZD8hJxI3mDaWWD ZqkmiTAkYKAlufQJyZAqC0qNk2 X-Received: by 2002:a05:622a:1393:b0:530:15f1:b16c with SMTP id d75a77b69052e-530545049f0mr277777321cf.0.1788795572493; Mon, 07 Sep 2026 08:39:32 -0700 (PDT) From: Ilan Karasik X-Google-Original-From: Ilan Karasik To: pve-devel@lists.proxmox.com Subject: [PATCH v3] fix #7571: emit mtu in ifupdown-based LXC guests Date: Mon, 7 Sep 2026 11:39:21 -0400 Message-ID: <20260907153921.852786-1-ilankarasik@gmail.com> X-Mailer: git-send-email 2.51.2 In-Reply-To: <1788789833.n8xgk28l2s.astroid@yuna.none> References: <1788789833.n8xgk28l2s.astroid@yuna.none> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain DMARC_PASS -0.1 DMARC pass policy FREEMAIL_FROM 0.001 Sender email is commonly abused enduser mail provider RCVD_IN_DNSWL_NONE -0.0001 Sender listed at https://www.dnswl.org/, no trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record X-MailFrom: ilankarasik@gmail.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation Message-ID-Hash: VXX6DANJEZRPQSPURUUNJ627FVJHFGVE X-Message-ID-Hash: VXX6DANJEZRPQSPURUUNJ627FVJHFGVE X-Mailman-Approved-At: Tue, 08 Sep 2026 09:47:33 +0200 CC: iamkarasik X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: iamkarasik This fixes a bug where custom mtu settings applied to an LXC container are silently ignored during network setup for Debian-based guests using ifupdown. Because the Proxmox network setup was failing to write the mtu value to the guest's `/etc/network/interfaces` file, the container would always default to an mtu of 1500. This patch resolves the issue by writing the `mtu ` directive into the guest's network configuration file at /etc/network/interfaces. This configuration applies to static, dhcp, and manual configurations. Signed-off-by: Ilan Karasik --- src/PVE/LXC/Setup/Debian.pm | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/PVE/LXC/Setup/Debian.pm b/src/PVE/LXC/Setup/Debian.pm index 837397b..fd4a7d4 100644 --- a/src/PVE/LXC/Setup/Debian.pm +++ b/src/PVE/LXC/Setup/Debian.pm @@ -284,6 +284,7 @@ sub setup_network { $net->{needsroute6} = 1; } } + $net->{mtu} = $d->{mtu} if defined($d->{mtu}); $networks->{ $d->{name} } = $net if keys %$net; } } @@ -298,6 +299,7 @@ sub setup_network { my $done_auto = {}; my $done_v4_hash = {}; my $done_v6_hash = {}; + my $done_mtu_hash = {}; my ($os, $version) = ($conf->{ostype}, $self->{version}); my $print_section = sub { @@ -317,7 +319,12 @@ sub setup_network { if (!defined($net->{address})) { # no address => no iface line } elsif ($net->{address} =~ /^(dhcp|manual)$/) { - $interfaces .= "iface $ifname inet $1\n\n"; + $interfaces .= "iface $ifname inet $1\n"; + if (defined($net->{mtu}) && !$done_mtu_hash->{$ifname}) { + $interfaces .= "\tmtu $net->{mtu}\n"; + $done_mtu_hash->{$ifname} = 1; + } + $interfaces .= "\n"; } else { $interfaces .= "iface $ifname inet static\n"; if ( @@ -329,6 +336,10 @@ sub setup_network { $interfaces .= "\taddress $net->{address}\n" if defined($net->{address}); $interfaces .= "\tnetmask $net->{netmask}\n" if defined($net->{netmask}); } + if (defined($net->{mtu}) && !$done_mtu_hash->{$ifname}) { + $interfaces .= "\tmtu $net->{mtu}\n"; + $done_mtu_hash->{$ifname} = 1; + } remove_gateway_scripts($section->{attr}); if (defined(my $gw = $net->{gateway})) { if ($net->{needsroute}) { @@ -348,7 +359,12 @@ sub setup_network { if (!defined($net->{address6})) { # no address => no iface line } elsif ($net->{address6} =~ /^(auto|dhcp|manual)$/) { - $interfaces .= "iface $ifname inet6 $1\n\n"; + $interfaces .= "iface $ifname inet6 $1\n"; + if (defined($net->{mtu}) && !$done_mtu_hash->{$ifname}) { + $interfaces .= "\tmtu $net->{mtu}\n"; + $done_mtu_hash->{$ifname} = 1; + } + $interfaces .= "\n"; } else { $interfaces .= "iface $ifname inet6 static\n"; if ( @@ -360,6 +376,10 @@ sub setup_network { $interfaces .= "\taddress $net->{address6}\n" if defined($net->{address6}); $interfaces .= "\tnetmask $net->{netmask6}\n" if defined($net->{netmask6}); } + if (defined($net->{mtu}) && !$done_mtu_hash->{$ifname}) { + $interfaces .= "\tmtu $net->{mtu}\n"; + $done_mtu_hash->{$ifname} = 1; + } remove_gateway_scripts($section->{attr}); if (defined(my $gw = $net->{gateway6})) { if ($net->{needsroute6}) { @@ -450,6 +470,7 @@ sub setup_network { || $aname eq 'netmask' || $aname eq 'gateway' || $aname eq 'broadcast' + || $aname eq 'mtu' ) { # skip } else { -- 2.51.2