diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-01-08 12:02:01 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-01-08 17:14:56 +0100 |
commit | 6666c4faeefa6e82704308cb3b77efad704bb80c (patch) | |
tree | 6989f5a912787955fa1affc351dfa930c3405132 /src/shared/ethtool-util.c | |
parent | network: rename *fd to *ethtool_fd (diff) | |
download | systemd-6666c4faeefa6e82704308cb3b77efad704bb80c.tar.xz systemd-6666c4faeefa6e82704308cb3b77efad704bb80c.zip |
network: do not require ethtool_get_permanent_macaddr() to get an fd
Diffstat (limited to '')
-rw-r--r-- | src/shared/ethtool-util.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/shared/ethtool-util.c b/src/shared/ethtool-util.c index e00ed8e97d..9d62728ca4 100644 --- a/src/shared/ethtool-util.c +++ b/src/shared/ethtool-util.c @@ -9,6 +9,7 @@ #include "conf-parser.h" #include "ethtool-util.h" #include "extract-word.h" +#include "fd-util.h" #include "log.h" #include "memory-util.h" #include "socket-util.h" @@ -219,14 +220,17 @@ int ethtool_get_link_info(int *ethtool_fd, const char *ifname, } int ethtool_get_permanent_macaddr(int *ethtool_fd, const char *ifname, struct ether_addr *ret) { + _cleanup_close_ int fd = -1; _cleanup_free_ struct ethtool_perm_addr *epaddr = NULL; struct ifreq ifr; int r; - assert(ethtool_fd); assert(ifname); assert(ret); + if (!ethtool_fd) + ethtool_fd = &fd; + if (*ethtool_fd < 0) { r = ethtool_connect_or_warn(ethtool_fd, false); if (r < 0) |