summaryrefslogtreecommitdiffstats
path: root/src/network/networkctl.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-10-23 12:24:42 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-10-23 12:29:04 +0200
commit516e9c802ff60816e58e5cbd8c05be036199d09c (patch)
tree73d176cdd47fdd80517a3c3c430bc45619d383aa /src/network/networkctl.c
parentnetworkctl: show carrier in green for loopback iface (diff)
downloadsystemd-516e9c802ff60816e58e5cbd8c05be036199d09c.tar.xz
systemd-516e9c802ff60816e58e5cbd8c05be036199d09c.zip
networkctl: split out helper function
Diffstat (limited to 'src/network/networkctl.c')
-rw-r--r--src/network/networkctl.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/network/networkctl.c b/src/network/networkctl.c
index 7c8f25ffae..df09f75c56 100644
--- a/src/network/networkctl.c
+++ b/src/network/networkctl.c
@@ -349,6 +349,15 @@ static int acquire_link_bitrates(sd_bus *bus, LinkInfo *link) {
return 0;
}
+static void acquire_ether_link_info(int *fd, LinkInfo *link) {
+ if (ethtool_get_link_info(fd, link->name,
+ &link->autonegotiation,
+ &link->speed,
+ &link->duplex,
+ &link->port) >= 0)
+ link->has_ethtool_link_info = true;
+}
+
static int acquire_link_info(sd_bus *bus, sd_netlink *rtnl, char **patterns, LinkInfo **ret) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL, *reply = NULL;
_cleanup_free_ LinkInfo *links = NULL;
@@ -382,11 +391,7 @@ static int acquire_link_info(sd_bus *bus, sd_netlink *rtnl, char **patterns, Lin
if (r == 0)
continue;
- r = ethtool_get_link_info(&fd, links[c].name,
- &links[c].autonegotiation, &links[c].speed,
- &links[c].duplex, &links[c].port);
- if (r >= 0)
- links[c].has_ethtool_link_info = true;
+ acquire_ether_link_info(&fd, &links[c]);
c++;
}