Skip to content

Commit

Permalink
fix: bring up bonded interfaces correctly on packet
Browse files Browse the repository at this point in the history
This probably fixes bonding in general if 2nd link in the bond is down.

For packet, set additional options for the bonded interface. In
networkd, add interfaces filtered out by link status as ignored to make
them available as bond subinterfaces.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
  • Loading branch information
smira authored and talos-bot committed Dec 29, 2020
1 parent a8dd2ff commit 5325a66
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,6 @@ func (p *Packet) Configuration(ctx context.Context) ([]byte, error) {
}

bondName = iface.Bond

// nb: currently only one interface is supported, as adding one more interface breaks networking
break
}

// create multiple bond devices and add them to device list.
Expand All @@ -168,6 +165,10 @@ func (p *Packet) Configuration(ctx context.Context) ([]byte, error) {
DeviceCIDR: fmt.Sprintf("%s/%d", addr.Address, addr.CIDR),
DeviceBond: &v1alpha1.Bond{
BondMode: bondMode.String(),
BondDownDelay: 200,
BondMIIMon: 100,
BondUpDelay: 200,
BondHashPolicy: "layer3+4",
BondInterfaces: devicesInBond,
},
}
Expand Down
11 changes: 10 additions & 1 deletion internal/app/networkd/pkg/networkd/networkd.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ func New(config config.Provider) (*Networkd, error) {
}
}

// add local interfaces which were filtered out with Ignore
for _, device := range localInterfaces {
if _, ok := netconf[device.Name]; !ok {
netconf[device.Name] = []nic.Option{nic.WithName(device.Name), nic.WithIgnore()}
}
}

interfaces := make(map[string]*nic.NetworkInterface)

// Create nic.NetworkInterface representation of the interface
Expand Down Expand Up @@ -400,7 +407,9 @@ func (n *Networkd) configureLinks(bonded bool) error {
count++

go func(netif *nic.NetworkInterface) {
log.Printf("setting up %s", netif.Name)
if !netif.IsIgnored() {
log.Printf("setting up %s", netif.Name)
}

errCh <- func() error {
// Ensure link exists
Expand Down

0 comments on commit 5325a66

Please sign in to comment.