summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-06-19 09:09:58 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-06-19 23:15:19 +0900
commit7864b16b27cf7039c92492c4699fb8476618b7d0 (patch)
treec3ce144e947b99f544e75c8df50a899b225471fa
parentb9bc7d42e3e79fcfd44145d2984017ca66aebde1 (diff)
downloadsystemd-7864b16b27cf7039c92492c4699fb8476618b7d0.tar.gz
ethtool-util: make ethtool_connect() warn on failure
-rw-r--r--src/shared/ethtool-util.c29
-rw-r--r--src/shared/ethtool-util.h2
2 files changed, 15 insertions, 16 deletions
diff --git a/src/shared/ethtool-util.c b/src/shared/ethtool-util.c
index d95363955b..3fba238ac4 100644
--- a/src/shared/ethtool-util.c
+++ b/src/shared/ethtool-util.c
@@ -115,14 +115,15 @@ assert_cc((ELEMENTSOF(ethtool_link_mode_bit_table)-1) / 32 < N_ADVERTISE);
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;
@@ -140,9 +141,9 @@ int ethtool_get_driver(int *fd, const char *ifname, char **ret) {
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);
@@ -173,9 +174,9 @@ int ethtool_set_speed(int *fd, const char *ifname, unsigned speed, Duplex duplex
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);
@@ -231,9 +232,9 @@ int ethtool_set_wol(int *fd, const char *ifname, WakeOnLan wol) {
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);
@@ -368,9 +369,9 @@ int ethtool_set_features(int *fd, const char *ifname, int *features) {
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);
@@ -599,9 +600,9 @@ int ethtool_set_glinksettings(
}
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);
@@ -654,9 +655,9 @@ int ethtool_set_channels(int *fd, const char *ifname, netdev_channels *channels)
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);
diff --git a/src/shared/ethtool-util.h b/src/shared/ethtool-util.h
index 5e2698949f..cbbe041799 100644
--- a/src/shared/ethtool-util.h
+++ b/src/shared/ethtool-util.h
@@ -79,8 +79,6 @@ typedef struct netdev_channels {
bool combined_count_set;
} netdev_channels;
-int ethtool_connect(int *ret);
-
int ethtool_get_driver(int *fd, const char *ifname, char **ret);
int ethtool_set_speed(int *fd, const char *ifname, unsigned speed, Duplex duplex);
int ethtool_set_wol(int *fd, const char *ifname, WakeOnLan wol);