use PVE::Network;
use PVE::Tools;
use PVE::ProcFSTools;
+use PVE::JSONSchema;
use Clone qw(clone);
use Linux::Inotify2;
use base 'Exporter';
'bridge-multicast-flood' => 1,
'bond_miimon' => 1,
'bond_xmit_hash_policy' => 1,
+ 'uplink-id' => 1,
'vlan-protocol' => 1,
'vxlan-id' => 1,
'vxlan-svcnodeip' => 1,
}
}
+ # map address and netmask to cidr
+ if ($d->{address}) {
+ if ($d->{netmask} && $d->{netmask} =~ m/^\d+$/) { # e.g. netmask 20
+ $d->{cidr} = $d->{address} . "/" . $d->{netmask};
+ } elsif ($d->{netmask} &&
+ (my $cidr = PVE::JSONSchema::get_netmask_bits($d->{netmask}))) { # e.g. netmask 255.255.255.0
+ $d->{cidr} = $d->{address} . "/" . $cidr;
+ } elsif ($d->{address} =~ m!^(.*)/(\d+)$!) {
+ $d->{cidr} = $d->{address};
+ $d->{address} = $1;
+ $d->{netmask} = $2;
+ } else {
+ $d->{cidr} = $d->{address};
+ }
+ }
+
+ # map address6 and netmask6 to cidr6
+ if ($d->{address6}) {
+ $d->{cidr6} = $d->{address6};
+ if ($d->{netmask6}) {
+ $d->{cidr6} .= "/" . $d->{netmask6};
+ } elsif ($d->{address6} =~ m!^(.*)/(\d+)$!) {
+ $d->{address6} = $1;
+ $d->{netmask6} = $2;
+ }
+ }
+
$d->{method} = 'manual' if !$d->{method};
$d->{method6} = 'manual' if !$d->{method6};
comments => 1, autostart => 1, options => 1,
address => 1, netmask => 1, gateway => 1, broadcast => 1,
method6 => 1, families => 1, options6 => 1,
- address6 => 1, netmask6 => 1, gateway6 => 1, broadcast6 => 1 };
+ address6 => 1, netmask6 => 1, gateway6 => 1, broadcast6 => 1, 'uplink-id' => 1 };
if (!$first_block) {
# not printing out options
foreach my $iface (keys %$ifaces) {
my $d = $ifaces->{$iface};
+ delete $d->{cidr};
+ delete $d->{cidr6};
+
my $ports = '';
foreach my $k (qw(bridge_ports ovs_ports slaves ovs_bonds)) {
$ports .= " $d->{$k}" if $d->{$k};
}
}
+ # check uplink
+ my $uplinks = {};
+ foreach my $iface (keys %$ifaces) {
+ my $d = $ifaces->{$iface};
+ if (my $uplinkid = $d->{'uplink-id'}) {
+ die "iface '$iface' - uplink-id $uplinkid is only allowed on physical and linux bond interfaces\n"
+ if $d->{type} ne 'eth' && $d->{type} ne 'bond';
+
+ die "iface '$iface' - uplink-id $uplinkid is already assigned on '$uplinks->{$uplinkid}'\n"
+ if $uplinks->{$uplinkid};
+
+ $uplinks->{$uplinkid} = $iface;
+ }
+ }
+
# check bridgeport option
my $bridgeports = {};
my $bridges = {};
# Please do NOT modify this file directly, unless you know what
# you're doing.
#
-# If you want to manage part of the network configuration manually,
+# If you want to manage parts of the network configuration manually,
# please utilize the 'source' or 'source-directory' directives to do
# so.
-# PVE will preserve these directives, but will NOT its network
+# PVE will preserve these directives, but will NOT read its network
# configuration from sourced files, so do not attempt to move any of
# the PVE managed interfaces into external files!