X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=blobdiff_plain;f=src%2FPVE%2FINotify.pm;h=9bfd6fbe5429e299d7587724ccebcc460e225782;hp=e3e43c1ade054228631b19863a140db841e0a75c;hb=bbe7d3edf338d4cf441cdded31312b0669a390b4;hpb=b94d05ecc612c01aa4fd749a3453b5b1ad077118 diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm index e3e43c1..9bfd6fb 100644 --- a/src/PVE/INotify.pm +++ b/src/PVE/INotify.pm @@ -872,6 +872,7 @@ sub __read_etc_network_interfaces { my $options = $config->{options} = []; my $options_alternatives = { + 'ovs_mtu' => 'mtu', 'bond-slaves' => 'slaves', 'bond_slaves' => 'slaves', 'bond-xmit-hash-policy' => 'bond_xmit_hash_policy', @@ -959,6 +960,8 @@ sub __read_etc_network_interfaces { 'bond-primary' => 1, 'uplink-id' => 1, 'vlan-protocol' => 1, + 'vlan-raw-device' => 1, + 'vlan-id' => 1, 'vxlan-id' => 1, 'vxlan-svcnodeip' => 1, 'vxlan-physdev' => 1, @@ -1075,12 +1078,14 @@ sub __read_etc_network_interfaces { $ifaces->{$1}->{exists} = 0; $d->{exists} = 0; } - } elsif ($iface =~ m/^(\S+)\.\d+$/) { + } elsif ($iface =~ m/^(\S+)\.\d+$/ || $d->{'vlan-raw-device'}) { $d->{type} = 'vlan'; - if (defined ($ifaces->{$1})) { - $d->{exists} = $ifaces->{$1}->{exists}; + + my $raw_iface = $d->{'vlan-raw-device'} ? $d->{'vlan-raw-device'} : $1; + if (defined ($ifaces->{$raw_iface})) { + $d->{exists} = $ifaces->{$raw_iface}->{exists}; } else { - $ifaces->{$1}->{exists} = 0; + $ifaces->{$raw_iface}->{exists} = 0; $d->{exists} = 0; } } elsif ($iface =~ m/^$PVE::Network::PHYSICAL_NIC_RE$/) { @@ -1215,6 +1220,9 @@ sub __interface_to_string { $done->{bridge_vlan_aware} = 1; $done->{bridge_vids} = 1; + $raw .= "\tmtu $d->{mtu}\n" if $d->{mtu}; + $done->{mtu} = 1; + } elsif ($d->{type} eq 'bond') { $d->{slaves} =~ s/[;,\s]+/ /g; @@ -1241,6 +1249,9 @@ sub __interface_to_string { } $done->{'bond-primary'} = 1; + $raw .= "\tmtu $d->{mtu}\n" if $d->{mtu}; + $done->{mtu} = 1; + } elsif ($d->{type} eq 'vlan') { die "$iface: wrong vlan-protocol $d->{'vlan-protocol'}\n" if $d->{'vlan-protocol'} && $d->{'vlan-protocol'} ne '802.1ad' && $d->{'vlan-protocol'} ne '802.1q'; @@ -1258,14 +1269,21 @@ sub __interface_to_string { } $done->{'vxlan-remoteip'} = 1; } + + $raw .= "\tmtu $d->{mtu}\n" if $d->{mtu}; + $done->{mtu} = 1; + } elsif ($d->{type} eq 'OVSBridge') { $raw .= "\tovs_type $d->{type}\n"; $done->{ovs_type} = 1; $raw .= "\tovs_ports $d->{ovs_ports}\n" if $d->{ovs_ports}; - $done->{ovs_ports} = 1; + + $raw .= "\tovs_mtu $d->{mtu}\n" if $d->{mtu}; + $done->{mtu} = 1; + } elsif ($d->{type} eq 'OVSPort' || $d->{type} eq 'OVSIntPort' || $d->{type} eq 'OVSBond') { @@ -1307,6 +1325,9 @@ sub __interface_to_string { $raw .= "\tovs_bridge $bridge\n"; $done->{ovs_bridge} = 1; } + + $raw .= "\tovs_mtu $d->{mtu}\n" if $d->{mtu}; + $done->{mtu} = 1; } if ($first_block) { @@ -1437,7 +1458,7 @@ sub __write_etc_network_interfaces { my $bond_primary_is_slave = undef; foreach my $p (split (/\s+/, $d->{slaves})) { my $n = $ifaces->{$p}; - + die "bond '$iface' - unable to find slave '$p'\n" if !$n; die "bond '$iface' - wrong interface type on slave '$p' " . @@ -1477,10 +1498,31 @@ sub __write_etc_network_interfaces { # check vlan foreach my $iface (keys %$ifaces) { my $d = $ifaces->{$iface}; - if ($d->{type} eq 'vlan' && $iface =~ m/^(\S+)\.\d+$/) { - my $p = $1; + if ($d->{type} eq 'vlan') { + + my $p = undef; + my $vlanid = undef; + + if ($iface =~ m/^(\S+)\.(\d+)$/) { + $p = $1; + $vlanid = $2; + delete $d->{'vlan-raw-device'} if $d->{'vlan-raw-device'}; + } else { + die "missing vlan-raw-device option" if !$d->{'vlan-raw-device'}; + $p = $d->{'vlan-raw-device'}; + + if ($iface =~ m/^vlan(\d+)$/) { + $vlanid = $1; + delete $d->{'vlan-id'} if $d->{'vlan-id'}; + } else { + die "custom vlan interface name need ifupdown2" if !$ifupdown2; + die "missing vlan-id option" if !$d->{'vlan-id'}; + $vlanid = $d->{'vlan-id'}; + } + } my $n = $ifaces->{$p}; + die "vlan '$iface' - vlan-id $vlanid should be <= 4094\n" if $vlanid > 4094; die "vlan '$iface' - unable to find parent '$p'\n" if !$n; @@ -1518,11 +1560,10 @@ sub __write_etc_network_interfaces { foreach my $p (split (/\s+/, $d->{bridge_ports})) { $p =~ s/\.\d+$//; my $n = $ifaces->{$p}; - die "bridge '$iface' - unable to find bridge port '$p'\n" - if !$n; - die "iface $p - ip address can't be set on interface if bridged in $iface\n" - if ($n->{method} eq 'static' && $n->{address} ne '0.0.0.0') || - ($n->{method6} eq 'static' && $n->{address} ne "\:\:"); + die "bridge '$iface' - unable to find bridge port '$p'\n" if !$n; + die "iface $p - ip address can't be set on interface if bridged in $iface\n" + if ($n->{method} eq 'static' && $n->{address} ne '0.0.0.0') || + ($n->{method6} eq 'static' && $n->{address} ne '::'); &$check_mtu($ifaces, $iface, $p); $bridgeports->{$p} = $iface; @@ -1568,6 +1609,7 @@ NETWORKDOC bond => 300000, bridge => 400000, OVSBridge => 400000, + vlan => 500000, vxlan => 500000, };