Inotify : add mtu option

also check if mtu value is lower than parent interface

fixme: vxlan interface should be 50bytes lower than outgoing interface
       we need to find which interface is used (unicast/multicast/frr)
This commit is contained in:
Alexandre Derumier 2018-07-05 02:56:34 +02:00 committed by Wolfgang Bumiller
parent c4e564708b
commit 9b053d70de
2 changed files with 32 additions and 0 deletions

View File

@ -753,6 +753,20 @@ my $extract_ovs_option = sub {
return $v; return $v;
}; };
my $check_mtu = sub {
my ($ifaces, $parent, $child) = @_;
die "check mtu : missing parent interface\n" if !$parent;
die "check mtu : missing child interface\n" if !$child;
my $pmtu = $ifaces->{$parent}->{mtu} ? $ifaces->{$parent}->{mtu} : 1500;
my $cmtu = $ifaces->{$child}->{mtu} ? $ifaces->{$child}->{mtu} : 1500;
die "interface '$parent' - mtu $pmtu is bigger than '$child' - mtu $cmtu\n"
if $pmtu gt $cmtu;
};
# config => { # config => {
# ifaces => { # ifaces => {
# $ifname => { # $ifname => {
@ -874,6 +888,7 @@ sub __read_etc_network_interfaces {
$id = $options_alternatives->{$id} if $options_alternatives->{$id}; $id = $options_alternatives->{$id} if $options_alternatives->{$id};
my $simple_options = { my $simple_options = {
'mtu' => 1,
'ovs_type' => 1, 'ovs_type' => 1,
'ovs_options' => 1, 'ovs_options' => 1,
'ovs_bridge' => 1, 'ovs_bridge' => 1,
@ -1301,6 +1316,8 @@ sub __write_etc_network_interfaces {
} else { } else {
die "interface '$p' is not defined as OVS port/bond\n"; die "interface '$p' is not defined as OVS port/bond\n";
} }
&$check_mtu($ifaces, $iface, $p);
} }
} }
} }
@ -1315,6 +1332,7 @@ sub __write_etc_network_interfaces {
if !$n; if !$n;
die "OVS bond '$iface' - wrong interface type on slave '$p' " . die "OVS bond '$iface' - wrong interface type on slave '$p' " .
"('$n->{type}' != 'eth')\n" if $n->{type} ne 'eth'; "('$n->{type}' != 'eth')\n" if $n->{type} ne 'eth';
&$check_mtu($ifaces, $iface, $p);
} }
} }
} }
@ -1330,6 +1348,7 @@ sub __write_etc_network_interfaces {
if !$n; if !$n;
die "bond '$iface' - wrong interface type on slave '$p' " . die "bond '$iface' - wrong interface type on slave '$p' " .
"('$n->{type}' != 'eth')\n" if $n->{type} ne 'eth'; "('$n->{type}' != 'eth')\n" if $n->{type} ne 'eth';
&$check_mtu($ifaces, $iface, $p);
} }
} }
} }
@ -1356,6 +1375,7 @@ sub __write_etc_network_interfaces {
if (defined($d->{'vxlan-svcnodeip'}) != defined($d->{'vxlan-physdev'})) { if (defined($d->{'vxlan-svcnodeip'}) != defined($d->{'vxlan-physdev'})) {
die "iface $iface : vxlan-svcnodeip and vxlan-physdev must be define together\n"; die "iface $iface : vxlan-svcnodeip and vxlan-physdev must be define together\n";
} }
#fixme : check if vxlan mtu is lower than 50bytes than physical interface where tunnel is going out
} }
# check vlan # check vlan
@ -1374,6 +1394,7 @@ sub __write_etc_network_interfaces {
die "vlan '$iface' - wrong interface type on parent '$p' " . die "vlan '$iface' - wrong interface type on parent '$p' " .
"('$n->{type}' != 'eth|bond|bridge' )\n"; "('$n->{type}' != 'eth|bond|bridge' )\n";
} }
&$check_mtu($ifaces, $iface, $p);
} }
} }
@ -1387,6 +1408,7 @@ sub __write_etc_network_interfaces {
my $n = $ifaces->{$p}; my $n = $ifaces->{$p};
die "bridge '$iface' - unable to find bridge port '$p'\n" die "bridge '$iface' - unable to find bridge port '$p'\n"
if !$n; if !$n;
&$check_mtu($ifaces, $iface, $p);
$bridgeports->{$p} = $iface; $bridgeports->{$p} = $iface;
} }
$bridges->{$iface} = $d; $bridges->{$iface} = $d;

View File

@ -40,6 +40,7 @@ $config->{ifaces}->{eth3} = {
$config->{ifaces}->{bond0} = { $config->{ifaces}->{bond0} = {
type => 'bond', type => 'bond',
mtu => 1400,
slaves => 'eth2 eth3', slaves => 'eth2 eth3',
bond_mode => '802.3ad', bond_mode => '802.3ad',
bond_xmit_hash_policy => 'layer3+4', bond_xmit_hash_policy => 'layer3+4',
@ -50,6 +51,7 @@ $config->{ifaces}->{bond0} = {
}; };
$config->{ifaces}->{vmbr1} = { $config->{ifaces}->{vmbr1} = {
mtu => 1400,
type => 'bridge', type => 'bridge',
method => 'manual', method => 'manual',
families => ['inet'], families => ['inet'],
@ -117,6 +119,7 @@ $config->{ifaces}->{vxlan3} = {
$config->{ifaces}->{'vmbr1.100'} = { $config->{ifaces}->{'vmbr1.100'} = {
type => 'vlan', type => 'vlan',
mtu => 1300,
method => 'manual', method => 'manual',
families => ['inet'], families => ['inet'],
autostart => 1 autostart => 1
@ -124,6 +127,7 @@ $config->{ifaces}->{'vmbr1.100'} = {
$config->{ifaces}->{'bond0.100'} = { $config->{ifaces}->{'bond0.100'} = {
type => 'vlan', type => 'vlan',
mtu => 1300,
method => 'manual', method => 'manual',
families => ['inet'], families => ['inet'],
autostart => 1 autostart => 1
@ -131,6 +135,7 @@ $config->{ifaces}->{'bond0.100'} = {
$config->{ifaces}->{'eth1.100'} = { $config->{ifaces}->{'eth1.100'} = {
type => 'vlan', type => 'vlan',
mtu => 1400,
method => 'manual', method => 'manual',
families => ['inet'], families => ['inet'],
autostart => 1 autostart => 1
@ -155,6 +160,7 @@ iface eth3 inet manual
auto eth1.100 auto eth1.100
iface eth1.100 inet manual iface eth1.100 inet manual
mtu 1400
auto bond0 auto bond0
iface bond0 inet manual iface bond0 inet manual
@ -162,9 +168,11 @@ iface bond0 inet manual
bond-miimon 100 bond-miimon 100
bond-mode 802.3ad bond-mode 802.3ad
bond-xmit-hash-policy layer3+4 bond-xmit-hash-policy layer3+4
mtu 1400
auto bond0.100 auto bond0.100
iface bond0.100 inet manual iface bond0.100 inet manual
mtu 1300
auto vmbr0 auto vmbr0
iface vmbr0 inet static iface vmbr0 inet static
@ -182,6 +190,7 @@ iface vmbr1 inet manual
bridge-fd 0 bridge-fd 0
bridge-vlan-aware yes bridge-vlan-aware yes
bridge-vids 2-4094 bridge-vids 2-4094
mtu 1400
auto vmbr2 auto vmbr2
iface vmbr2 inet manual iface vmbr2 inet manual
@ -199,6 +208,7 @@ iface vmbr3 inet manual
auto vmbr1.100 auto vmbr1.100
iface vmbr1.100 inet manual iface vmbr1.100 inet manual
mtu 1300
auto vxlan1 auto vxlan1
iface vxlan1 inet manual iface vxlan1 inet manual