Skip to content

Commit

Permalink
ncm-network: nmstate: handle the bond slaves explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
stdweird authored and jrha committed Sep 5, 2024
1 parent d69d3b2 commit f6f523c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
23 changes: 23 additions & 0 deletions ncm-network/src/main/perl/network.pm
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,19 @@ sub process_network
}
$iface->{my_inner_ipaddr} .= "/$iface->{my_inner_prefix}";
}

# insert master->slaves data
if ($iface->{master}) {
my $bond = $iface->{master};
my $bondiface = $nwtree->{interfaces}->{$bond};
if ($bondiface) {
$bondiface->{slaves} = [] if !exists($bondiface->{slaves});
push(@{$bondiface->{slaves}}, $ifname);
} else {
$self->warn("Interface $ifname has master $bond configured, but corresponding iface entry found");
}
}

}

return $nwtree;
Expand Down Expand Up @@ -1447,6 +1460,16 @@ sub make_ifup
$exifiles->{"$cfg_filename"} == $REMOVE) {
$self->verbose("Not starting $iface scheduled for removal");
} else {
if (!$self->BOND_MASTER_STARTS_SLAVES && $ifaces->{$iface}->{slaves}) {
my @slaves = @{$ifaces->{$iface}->{slaves}};
# master won't bring up slaves, so add them here
$self->verbose("Found MASTER interface $iface in ifdown map, ",
"adding slaves @slaves to ifup.");
foreach my $slname (@slaves) {
$ifup{$slname} = 1;
}
}

if ($self->BOND_MASTER_STARTS_SLAVES && $ifaces->{$iface}->{master}) {
# bonding devices: don't bring the slaves up, only the master
$self->verbose("Found SLAVE interface $iface in ifdown map, ",
Expand Down
2 changes: 2 additions & 0 deletions ncm-network/src/test/perl/nmstate_advance.t
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ ok(command_history_ok([
'/usr/bin/nmstatectl apply /etc/nmstate/eth0.yml',
'/usr/bin/nmstatectl apply /etc/nmstate/eth0.123.yml',
'/usr/bin/nmstatectl apply /etc/nmstate/eth1.yml',
'/usr/bin/nmstatectl apply /etc/nmstate/eth2.yml',
'/usr/bin/nmstatectl apply /etc/nmstate/eth3.yml',
'/usr/bin/nmstatectl apply /etc/nmstate/eth4.yml',
'/usr/bin/nmstatectl apply /etc/nmstate/ib0.yml',
'/usr/bin/nmstatectl apply /etc/nmstate/ib1.12345.yml',
Expand Down

0 comments on commit f6f523c

Please sign in to comment.