DEFINE_STRING_TABLE_LOOKUP(ethtool_link_mode_bit, enum ethtool_link_mode_bit_indices);
-int ethtool_connect(int *ret) {
+static int ethtool_connect_or_warn(int *ret, bool warn) {
int fd;
assert_return(ret, -EINVAL);
fd = socket_ioctl_fd();
if (fd < 0)
- return fd;
+ return log_full_errno(warn ? LOG_WARNING: LOG_DEBUG, fd,
+ "ethtool: could not create control socket: %m");
*ret = fd;
int r;
if (*fd < 0) {
- r = ethtool_connect(fd);
+ r = ethtool_connect_or_warn(fd, true);
if (r < 0)
- return log_warning_errno(r, "ethtool: could not connect to ethtool: %m");
+ return r;
}
strscpy(ifr.ifr_name, IFNAMSIZ, ifname);
return 0;
if (*fd < 0) {
- r = ethtool_connect(fd);
+ r = ethtool_connect_or_warn(fd, true);
if (r < 0)
- return log_warning_errno(r, "ethtool: could not connect to ethtool: %m");
+ return r;
}
strscpy(ifr.ifr_name, IFNAMSIZ, ifname);
return 0;
if (*fd < 0) {
- r = ethtool_connect(fd);
+ r = ethtool_connect_or_warn(fd, true);
if (r < 0)
- return log_warning_errno(r, "ethtool: could not connect to ethtool: %m");
+ return r;
}
strscpy(ifr.ifr_name, IFNAMSIZ, ifname);
struct ifreq ifr = {};
if (*fd < 0) {
- r = ethtool_connect(fd);
+ r = ethtool_connect_or_warn(fd, true);
if (r < 0)
- return log_warning_errno(r, "ethtool: could not connect to ethtool: %m");
+ return r;
}
strscpy(ifr.ifr_name, IFNAMSIZ, ifname);
}
if (*fd < 0) {
- r = ethtool_connect(fd);
+ r = ethtool_connect_or_warn(fd, true);
if (r < 0)
- return log_warning_errno(r, "ethtool: could not connect to ethtool: %m");
+ return r;
}
strscpy(ifr.ifr_name, IFNAMSIZ, ifname);
int r;
if (*fd < 0) {
- r = ethtool_connect(fd);
+ r = ethtool_connect_or_warn(fd, true);
if (r < 0)
- return log_warning_errno(r, "ethtool: could not connect to ethtool: %m");
+ return r;
}
strscpy(ifr.ifr_name, IFNAMSIZ, ifname);