为什么ethtool_cmd_speed会返回UINT32_MAX?

0 人关注

我有以下代码片段来获取linux网络接口速度。

struct ethtool_cmd cmd;
uint32_t speed = 0;
cmd.cmd = ETHTOOL_GSET;
/* Some other codes */
speed = ethtool_cmd_speed(&cmd);
std::cout << std::to_string(speed));

我发现在某些情况下,当一个linux接口关闭时,速度值被返回为UINT32_MAX。我还看到,当接口不可用时,速度被返回为 "0"。