diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-06-20 06:56:37 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-20 06:56:37 +0900 |
commit | b19eab1f74f5105fc5737b3790071175ea1a9292 (patch) | |
tree | aaf07ce7487b224143688e24b89bc9c88a821585 /src/network/networkd-link-bus.c | |
parent | f9dc94408d70dd2f44915f4c6d67dc498c1c6243 (diff) | |
parent | c967d2c7ce19a460a3d6b63ef6a0b752f5427a1a (diff) | |
download | systemd-b19eab1f74f5105fc5737b3790071175ea1a9292.tar.gz |
Merge pull request #12806 from yuwata/networkctl-ethtool-12657
networkctl: show speed, duplex, auto negotiation, and port
Diffstat (limited to 'src/network/networkd-link-bus.c')
-rw-r--r-- | src/network/networkd-link-bus.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/network/networkd-link-bus.c b/src/network/networkd-link-bus.c index 2f414cb116..076845421c 100644 --- a/src/network/networkd-link-bus.c +++ b/src/network/networkd-link-bus.c @@ -22,7 +22,8 @@ static int property_get_bit_rates( Link *link = userdata; Manager *manager; - double tx, rx, interval_sec; + double interval_sec; + uint64_t tx, rx; assert(bus); assert(reply); @@ -40,19 +41,19 @@ static int property_get_bit_rates( return sd_bus_error_set(error, BUS_ERROR_SPEED_METER_INACTIVE, "Failed to measure bit-rates."); assert(manager->speed_meter_usec_new > manager->speed_meter_usec_old); - interval_sec = (double) (manager->speed_meter_usec_new - manager->speed_meter_usec_old) / USEC_PER_SEC; + interval_sec = (manager->speed_meter_usec_new - manager->speed_meter_usec_old) / USEC_PER_SEC; if (link->stats_new.tx_bytes > link->stats_old.tx_bytes) - tx = (link->stats_new.tx_bytes - link->stats_old.tx_bytes) / interval_sec; + tx = (uint64_t) ((link->stats_new.tx_bytes - link->stats_old.tx_bytes) / interval_sec); else - tx = (UINT64_MAX - (link->stats_old.tx_bytes - link->stats_new.tx_bytes)) / interval_sec; + tx = (uint64_t) ((UINT64_MAX - (link->stats_old.tx_bytes - link->stats_new.tx_bytes)) / interval_sec); if (link->stats_new.rx_bytes > link->stats_old.rx_bytes) - rx = (link->stats_new.rx_bytes - link->stats_old.rx_bytes) / interval_sec; + rx = (uint64_t) ((link->stats_new.rx_bytes - link->stats_old.rx_bytes) / interval_sec); else - rx = (UINT64_MAX - (link->stats_old.rx_bytes - link->stats_new.rx_bytes)) / interval_sec; + rx = (uint64_t) ((UINT64_MAX - (link->stats_old.rx_bytes - link->stats_new.rx_bytes)) / interval_sec); - return sd_bus_message_append(reply, "(dd)", tx, rx); + return sd_bus_message_append(reply, "(tt)", tx, rx); } const sd_bus_vtable link_vtable[] = { @@ -60,7 +61,7 @@ const sd_bus_vtable link_vtable[] = { SD_BUS_PROPERTY("OperationalState", "s", property_get_operational_state, offsetof(Link, operstate), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE), SD_BUS_PROPERTY("AdministrativeState", "s", property_get_administrative_state, offsetof(Link, state), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE), - SD_BUS_PROPERTY("BitRates", "(dd)", property_get_bit_rates, 0, 0), + SD_BUS_PROPERTY("BitRates", "(tt)", property_get_bit_rates, 0, 0), SD_BUS_VTABLE_END }; |