diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-05-24 22:08:13 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-06-01 03:24:47 +0200 |
commit | a879e1a46eb42b3468ff85c62a3d20582b760be4 (patch) | |
tree | 9e12e9a0c7f5c68d1858096e637808fcb8eb7108 /src/network/networkd-manager.c | |
parent | bash-completion: support --stats/-s option of networkctl (diff) | |
download | systemd-a879e1a46eb42b3468ff85c62a3d20582b760be4.tar.xz systemd-a879e1a46eb42b3468ff85c62a3d20582b760be4.zip |
network: monitor link bit rates
Diffstat (limited to 'src/network/networkd-manager.c')
-rw-r--r-- | src/network/networkd-manager.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c index de177e6d1a..6984c5b967 100644 --- a/src/network/networkd-manager.c +++ b/src/network/networkd-manager.c @@ -22,6 +22,7 @@ #include "netlink-util.h" #include "network-internal.h" #include "networkd-manager.h" +#include "networkd-speed-meter.h" #include "ordered-set.h" #include "path-util.h" #include "set.h" @@ -1369,10 +1370,14 @@ int manager_new(Manager **ret) { _cleanup_(manager_freep) Manager *m = NULL; int r; - m = new0(Manager, 1); + m = new(Manager, 1); if (!m) return -ENOMEM; + *m = (Manager) { + .speed_meter_interval_usec = SPEED_METER_DEFAULT_TIME_INTERVAL, + }; + m->state_file = strdup("/run/systemd/netif/state"); if (!m->state_file) return -ENOMEM; @@ -1469,6 +1474,7 @@ void manager_free(Manager *m) { sd_netlink_unref(m->genl); sd_resolve_unref(m->resolve); + sd_event_source_unref(m->speed_meter_event_source); sd_event_unref(m->event); sd_device_monitor_unref(m->device_monitor); @@ -1484,9 +1490,14 @@ void manager_free(Manager *m) { int manager_start(Manager *m) { Link *link; Iterator i; + int r; assert(m); + r = manager_start_speed_meter(m); + if (r < 0) + return log_error_errno(r, "Failed to initialize speed meter: %m"); + /* The dirty handler will deal with future serialization, but the first one must be done explicitly. */ |