public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Alexandre Derumier <aderumier@odiso.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH V2 pve-common 1/1] network: tap_plug: fix mtu
Date: Mon, 21 Mar 2022 08:05:27 +0100	[thread overview]
Message-ID: <20220321070527.3842366-2-aderumier@odiso.com> (raw)
In-Reply-To: <20220321070527.3842366-1-aderumier@odiso.com>

- ovsint port mtu need to be set with ""ovs-vsctl set mtu-request"
- update mtu on already existing interfaces (fwbr,fwln,tap,veth)
  if existing tap|veth interface is replugged on a different mtu bridge

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
---
 src/PVE/Network.pm | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/src/PVE/Network.pm b/src/PVE/Network.pm
index c83b1bb..d3eb5e0 100644
--- a/src/PVE/Network.pm
+++ b/src/PVE/Network.pm
@@ -219,6 +219,11 @@ my $bridge_disable_interface_learning = sub {
 my $bridge_add_interface = sub {
     my ($bridge, $iface, $tag, $trunks) = @_;
 
+    my $bridgemtu = read_bridge_mtu($bridge);
+    eval {
+       PVE::Tools::run_command(['/sbin/ip', 'link', 'set', $iface, 'mtu', $bridgemtu]);
+    };
+
     # drop link local address (it can't be used when on a bridge anyway)
     disable_ipv6($iface);
     iface_set_master($iface, $bridge);
@@ -259,6 +264,9 @@ my $ovs_bridge_add_port = sub {
     push @$cmd, "trunks=". join(',', $trunks) if $trunks;
     push @$cmd, "vlan_mode=native-untagged" if $tag && $trunks;
 
+    my $bridgemtu = read_bridge_mtu($bridge);
+    push @$cmd, '--', 'set', 'Interface', $iface, "mtu_request=$bridgemtu";
+
     if ($internal) {
 	# second command
 	push @$cmd, '--', 'set', 'Interface', $iface, 'type=internal';
@@ -271,9 +279,12 @@ my $ovs_bridge_add_port = sub {
 };
 
 my $activate_interface = sub {
-    my ($iface) = @_;
+    my ($iface, $mtu) = @_;
 
-    eval { run_command(['/sbin/ip', 'link', 'set', $iface, 'up']) };
+    my $cmd = ['/sbin/ip', 'link', 'set', $iface, 'up'];
+    push (@$cmd, ('mtu', $mtu)) if $mtu;
+
+    eval { run_command($cmd) };
     die "can't activate interface '$iface' - $@\n" if $@;
 };
 
@@ -354,8 +365,9 @@ sub veth_create {
     # up vethpair
     disable_ipv6($veth);
     disable_ipv6($vethpeer);
-    &$activate_interface($veth);
-    &$activate_interface($vethpeer);
+    &$activate_interface($veth, $bridgemtu);
+    &$activate_interface($vethpeer, $bridgemtu);
+
 }
 
 sub veth_delete {
@@ -373,8 +385,10 @@ my $create_firewall_bridge_linux = sub {
     my ($vmid, $devid) = &$parse_tap_device_name($iface);
     my ($fwbr, $vethfw, $vethfwpeer) = &$compute_fwbr_names($vmid, $devid);
 
+    my $bridgemtu = read_bridge_mtu($bridge);
+
     &$cond_create_bridge($fwbr);
-    &$activate_interface($fwbr);
+    &$activate_interface($fwbr, $bridgemtu);
 
     copy_bridge_config($bridge, $fwbr);
     veth_create($vethfw, $vethfwpeer, $bridge);
@@ -395,15 +409,12 @@ my $create_firewall_bridge_ovs = sub {
     my $bridgemtu = read_bridge_mtu($bridge);
 
     &$cond_create_bridge($fwbr);
-    &$activate_interface($fwbr);
+    &$activate_interface($fwbr, $bridgemtu);
 
     &$bridge_add_interface($fwbr, $iface);
 
     &$ovs_bridge_add_port($bridge, $ovsintport, $tag, 1, $trunks);
-    &$activate_interface($ovsintport);
-
-    # set the same mtu for ovs int port
-    run_command(['/sbin/ip', 'link', 'set', $ovsintport, 'mtu', $bridgemtu]);
+    &$activate_interface($ovsintport, $bridgemtu);
 
     &$bridge_add_interface($fwbr, $ovsintport);
     &$bridge_disable_interface_learning($ovsintport) if $no_learning;
-- 
2.30.2




      reply	other threads:[~2022-03-21  7:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-21  7:05 [pve-devel] [PATCH V2 pve-common 0/1] network: tap_plug: fix mtu bugs Alexandre Derumier
2022-03-21  7:05 ` Alexandre Derumier [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=20220321070527.3842366-2-aderumier@odiso.com \
    --to=aderumier@odiso.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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal