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 and I found that they use IOCTL sockets and the command of ethtool ETHTOOL_NWAY_RST. According to kernel docs here, 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