Sample Header Ad - 728x90

Can I trigger an auto-negotiation of an interface using the ethtool userspace API with NETLINK sockets?

1 vote
1 answer
445 views
I would like to replicate the behavior of ethtool -r when auto-negotiation is active in my C++ code with NETLINK sockets. I search the CLI ethtool [source code](https://git.kernel.org/pub/scm/network/ethtool/ethtool.git/tree/ethtool.c#n3435) and I found that they use IOCTL sockets and the command of ethtool ETHTOOL_NWAY_RST. According to kernel docs [here](https://docs.kernel.org/networking/ethtool-netlink.html#request-translation) , this command has not been translated to NETLINK sockets. Before I give up, I just want know if there is another approach to get the same behavior. ### What I tried so far - I have static routes in the interface, so turning down and up the interface would not work because I lose those routes. This does not happen with ethtool -r. - For the same reason the ip link set down/up [dev] behavior also would not be ideal in my case. My code is currently working using the CLI of ethtool, but a more clean and better approach would be to use the userspace API directly. My code has already been made for NETLINK sockets and that's why I prefer this approach. I would appreciate any help. Thanks
Asked by Jairo Mejia (36 rep)
Nov 7, 2023, 02:39 PM
Last activity: Jun 5, 2024, 03:42 PM