Skip to content

Commit

Permalink
dpcreconciler/linuxitems/adapter.go: set MAC and interface rename whi…
Browse files Browse the repository at this point in the history
…le interface is DOWN

On attempt to set MAC address or rename interface which is UP
host returns `Device or resource busy`. Patch fixes the error
by changing the order: first set MAC and rename interface,
then bring interface UP.

Patch fixes inability to use host interface, the problem was
reproduced on RPI4 board. Presumably any device should be
affected.

Signed-off-by: Roman Penyaev <[email protected]>
Fixes: 7a6981b ("Add support for switch network instance with multiple ports")
  • Loading branch information
rouming committed Sep 2, 2024
1 parent 83c73a5 commit 5d0f018
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions pkg/pillar/dpcreconciler/linuxitems/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,14 @@ func (c *AdapterConfigurator) Create(ctx context.Context, item depgraph.Item) er
// Managed by the wwan microservice, nothing to do here.
return nil
}
// Make sure that the interface is UP.
if err := netlink.LinkSetUp(link); err != nil {
err = fmt.Errorf("netlink.LinkSetUp(%s) failed: %v",
adapter.IfName, err)
c.Log.Error(err)
return err
}
if !c.isAdapterBridgedByNIM(adapter) {
// Make sure that the interface is UP.
if err := netlink.LinkSetUp(link); err != nil {
err = fmt.Errorf("netlink.LinkSetUp(%s) failed: %v",
adapter.IfName, err)
c.Log.Error(err)
return err
}
// Do not proceed with bridging the adapter, just set the MTU.
return c.setAdapterMTU(adapter, link)
}
Expand Down Expand Up @@ -195,12 +195,21 @@ func (c *AdapterConfigurator) Create(ctx context.Context, item depgraph.Item) er
c.Log.Error(err)
return err
}
// Make sure that corresponding bridge and interface are UP right
// after MAC address assignment and interface rename. Order matters,
// otherwise host returns `Device or resource busy`.
if err := netlink.LinkSetUp(bridge); err != nil {
err = fmt.Errorf("netlink.LinkSetUp(%s) failed: %v",
adapter.IfName, err)
c.Log.Error(err)
return err
}
if err := netlink.LinkSetUp(kernLink); err != nil {
err = fmt.Errorf("netlink.LinkSetUp(%s) failed: %v",
adapter.IfName, err)
c.Log.Error(err)
return err
}
return nil
}

Expand Down

0 comments on commit 5d0f018

Please sign in to comment.