[pve-devel] [PATCH pve-common] Inotify: fix mtu check
Alexandre Derumier
aderumier at odiso.com
Mon Sep 3 15:16:58 CEST 2018
- special check for bond, ifupdown set parent mtu from
slaves mtu if no defined.
- error if parent mtu is lower than child mtu (not bigger)
- child inherit from parent mtu if not defined
- fix vlan check (parent/child was inverted)
---
src/PVE/INotify.pm | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm
index 4cf8699..083fb70 100644
--- a/src/PVE/INotify.pm
+++ b/src/PVE/INotify.pm
@@ -754,16 +754,20 @@ my $extract_ovs_option = sub {
};
my $check_mtu = sub {
- my ($ifaces, $parent, $child) = @_;
+ my ($ifaces, $parent, $child, $ifupdown2) = @_;
die "check mtu - missing parent interface\n" if !$parent;
die "check mtu - missing child interface\n" if !$child;
+ if($ifaces->{$parent}->{type} eq 'bond') {
+ $ifaces->{$parent}->{mtu} = $ifaces->{$child}->{mtu} if (!$ifaces->{$parent}->{mtu} && $ifaces->{$child}->{mtu} && !$ifupdown2);
+ }
+
my $pmtu = $ifaces->{$parent}->{mtu} ? $ifaces->{$parent}->{mtu} : 1500;
- my $cmtu = $ifaces->{$child}->{mtu} ? $ifaces->{$child}->{mtu} : 1500;
+ my $cmtu = $ifaces->{$child}->{mtu} ? $ifaces->{$child}->{mtu} : $pmtu;
- die "interface '$parent' - mtu $pmtu is bigger than '$child' - mtu $cmtu\n"
- if $pmtu > $cmtu;
+ die "interface '$parent' - mtu $pmtu is lower than '$child' - mtu $cmtu\n"
+ if $pmtu < $cmtu;
};
# config => {
@@ -1347,7 +1351,7 @@ sub __write_etc_network_interfaces {
if !$n;
die "bond '$iface' - wrong interface type on slave '$p' " .
"('$n->{type}' != 'eth')\n" if $n->{type} ne 'eth';
- &$check_mtu($ifaces, $iface, $p);
+ &$check_mtu($ifaces, $iface, $p, $ifupdown2);
}
}
}
@@ -1393,7 +1397,7 @@ sub __write_etc_network_interfaces {
die "vlan '$iface' - wrong interface type on parent '$p' " .
"('$n->{type}' != 'eth|bond|bridge' )\n";
}
- &$check_mtu($ifaces, $iface, $p);
+ &$check_mtu($ifaces, $p, $iface);
}
}
--
2.11.0
More information about the pve-devel
mailing list