From b94d05ecc612c01aa4fd749a3453b5b1ad077118 Mon Sep 17 00:00:00 2001 From: Alexandre Derumier Date: Thu, 9 Jan 2020 14:11:02 +0100 Subject: [PATCH] INotify: add bond-primary option Signed-off-by: Alexandre Derumier --- src/PVE/INotify.pm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm index 1a528fa..e3e43c1 100644 --- a/src/PVE/INotify.pm +++ b/src/PVE/INotify.pm @@ -956,6 +956,7 @@ sub __read_etc_network_interfaces { 'bridge-multicast-flood' => 1, 'bond_miimon' => 1, 'bond_xmit_hash_policy' => 1, + 'bond-primary' => 1, 'uplink-id' => 1, 'vlan-protocol' => 1, 'vxlan-id' => 1, @@ -1234,6 +1235,12 @@ sub __interface_to_string { $raw .= "\tbond-xmit-hash-policy $d->{'bond_xmit_hash_policy'}\n"; } $done->{'bond_xmit_hash_policy'} = 1; + + if ($d->{'bond_mode'} && $d->{'bond_mode'} eq 'active-backup' && $d->{'bond-primary'}) { + $raw .= "\tbond-primary $d->{'bond-primary'}\n"; + } + $done->{'bond-primary'} = 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'; @@ -1427,15 +1434,18 @@ sub __write_etc_network_interfaces { foreach my $iface (keys %$ifaces) { my $d = $ifaces->{$iface}; if ($d->{type} eq 'bond' && $d->{slaves}) { + 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' " . "('$n->{type}' != 'eth')\n" if $n->{type} ne 'eth'; &$check_mtu($ifaces, $iface, $p); + $bond_primary_is_slave = 1 if $d->{'bond-primary'} && $d->{'bond-primary'} eq $p; } + die "bond '$iface' - bond-primary interface is not a slave" if $d->{'bond-primary'} && !$bond_primary_is_slave; } } -- 2.39.2