my $have_sdn;
eval {
- require PVE::API2::Network::SDN;
+ require PVE::Network::SDN::Zones;
+ require PVE::Network::SDN::Controllers;
$have_sdn = 1;
};
optional => 1,
type => 'string', enum => $bond_mode_enum,
},
+ 'bond-primary' => {
+ description => "Specify the primary interface for active-backup bond.",
+ optional => 1,
+ type => 'string', format => 'pve-iface',
+ },
bond_xmit_hash_policy => {
description => "Selects the transmit hash policy to use for slave selection in balance-xor and 802.3ad modes.",
optional => 1,
type => 'string', format => 'CIDRv4',
optional => 1,
},
+ mtu => {
+ description => 'MTU.',
+ optional => 1,
+ type => 'integer',
+ minimum => 1280,
+ maximum => 65520,
+ },
gateway6 => {
description => 'Default ipv6 gateway address.',
type => 'string', format => 'ipv6',
my $new_config_file = "/etc/network/interfaces.new";
die "you need ifupdown2 to reload networking\n" if !-e '/usr/share/ifupdown2';
- die "ifupdown2 reload is not compatible if openvswitch currently" if -x '/usr/bin/ovs-vsctl';
+
+ if (-x '/usr/bin/ovs-vsctl') {
+ my $ovs_configured = sub {
+ my $ifaces = shift;
+ my @ovstypes = grep { $_->{type} =~ /^ovs\S+/i } values %$ifaces;
+ return scalar(@ovstypes) > 0;
+ };
+ my $tmp = PVE::INotify::read_file('interfaces', 1);
+ my $ifaces = $tmp->{data}->{ifaces};
+ my $changes = $tmp->{changes};
+
+ if ($ovs_configured->($ifaces)) {
+ die "There are OpenVSwitch configured interfaces, but ifupdown2 ".
+ " reload is not compatible with openvswitch currently\n";
+ } elsif ($changes && $changes =~ /^\s*(?:[+-])?\s*(ovs_type|allow-ovs)/mi) {
+ die "Changes include OpenVSwitch interfaces, but ifupdown2 ".
+ "reload is not compatible with openvswitch currently\n";
+ }
+ }
my $worker = sub {
rename($new_config_file, $current_config_file) if -e $new_config_file;
- my $frr_config;
if ($have_sdn) {
- my $network_config = PVE::Network::SDN::generate_etc_network_config();
- PVE::Network::SDN::write_etc_network_config($network_config);
-
- $frr_config = PVE::Network::SDN::generate_frr_config();
- PVE::Network::SDN::write_frr_config($frr_config) if $frr_config;
+ my $network_sdn_config = PVE::Network::SDN::Zones::generate_etc_network_config();
+ PVE::Network::SDN::Zones::write_etc_network_config($network_sdn_config);
}
-
my $err = sub {
my $line = shift;
if ($line =~ /(warning|error): (\S+):/) {
};
PVE::Tools::run_command(['ifreload', '-a'], errfunc => $err);
- if ($frr_config && -e "/usr/lib/frr/frr-reload.py") {
- PVE::Tools::run_command(['systemctl', 'reload', 'frr']);
+ if ($have_sdn) {
+ my $controller_config = PVE::Network::SDN::Controllers::generate_controller_config();
+ PVE::Network::SDN::Controllers::write_controller_config($controller_config) if ($controller_config);
+ PVE::Network::SDN::Controllers::reload_controller();
}
};
return $rpcenv->fork_worker('srvreload', 'networking', $authuser, $worker);