Skip to content

Commit 0872901

Browse files
ericma15smira
authored andcommitted
feat: use ethtool ioctl to get link status when netlink api not available
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>
1 parent 395c642 commit 0872901

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

internal/app/machined/pkg/controllers/network/link_status.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,20 @@ func (ctrl *LinkStatusController) reconcile(
207207
if err == nil && permAddr != "" {
208208
permanentAddr, _ = net.ParseMAC(permAddr) //nolint:errcheck
209209
}
210+
211+
if ethState == nil {
212+
state, err := ethtoolIoctlClient.LinkState(link.Attributes.Name)
213+
if err != nil {
214+
logger.Warn("error querying ethtool ioctl link state", zap.String("link", link.Attributes.Name), zap.Error(err))
215+
} else {
216+
ethState = &ethtool.LinkState{
217+
Interface: ethtool.Interface{
218+
Index: int(link.Index),
219+
},
220+
Link: state > 0,
221+
}
222+
}
223+
}
210224
}
211225

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

0 commit comments

Comments
 (0)