Skip to content

Commit

Permalink
feat: use ethtool ioctl to get link status when netlink api not avail…
Browse files Browse the repository at this point in the history
…able

when kernel not support ethtool-netlink,we will use ethtool-ioctl to get link status

Signed-off-by: EricMa <307748790@qq.com>
Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
  • Loading branch information
ericma15 authored and smira committed Jul 23, 2024
1 parent 395c642 commit 0872901
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions internal/app/machined/pkg/controllers/network/link_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,20 @@ func (ctrl *LinkStatusController) reconcile(
if err == nil && permAddr != "" {
permanentAddr, _ = net.ParseMAC(permAddr) //nolint:errcheck
}

if ethState == nil {
state, err := ethtoolIoctlClient.LinkState(link.Attributes.Name)
if err != nil {
logger.Warn("error querying ethtool ioctl link state", zap.String("link", link.Attributes.Name), zap.Error(err))
} else {
ethState = &ethtool.LinkState{
Interface: ethtool.Interface{
Index: int(link.Index),
},
Link: state > 0,
}
}
}
}

if err = r.Modify(ctx, network.NewLinkStatus(network.NamespaceName, link.Attributes.Name), func(r resource.Resource) error {
Expand Down

0 comments on commit 0872901

Please sign in to comment.