[pve-devel] [PATCH pve-container] fix #4457: use bridge mtu if no mtu is defined

Alexandre Derumier aderumier at odiso.com
Tue Apr 11 14:44:48 CEST 2023


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 src/PVE/LXC.pm | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index c4d53e8..0ccbb33 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -731,14 +731,14 @@ sub update_lxc_config {
 	$raw .= "lxc.net.$ind.hwaddr = $d->{hwaddr}\n" if defined($d->{hwaddr});
 	$raw .= "lxc.net.$ind.name = $d->{name}\n" if defined($d->{name});
 
+	my $bridge_mtu = PVE::Network::read_bridge_mtu($d->{bridge});
+	my $mtu = $d->{mtu} || $bridge_mtu;
+
 	# Keep container from starting with invalid mtu configuration
-	if (my $mtu = $d->{mtu}) {
-	    my $bridge_mtu = PVE::Network::read_bridge_mtu($d->{bridge});
-	    die "$k: MTU size '$mtu' is bigger than bridge MTU '$bridge_mtu'\n"
-		if ($mtu > $bridge_mtu);
+	die "$k: MTU size '$mtu' is bigger than bridge MTU '$bridge_mtu'\n"
+	    if ($mtu > $bridge_mtu);
 
-	    $raw .= "lxc.net.$ind.mtu = $mtu\n";
-	}
+	$raw .= "lxc.net.$ind.mtu = $mtu\n";
 
 	# Starting with lxc 4.0, we do not patch lxc to execute our up-scripts.
 	if ($lxc_major >= 4) {
-- 
2.30.2





More information about the pve-devel mailing list