diff options
author | Mikael Kanstrup <mikael.kanstrup@sony.com> | 2019-03-07 10:47:41 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2019-03-08 07:30:04 +0000 |
commit | b08003309b9387f4c839b6c4516da602349af177 (patch) | |
tree | aa33e9a9f459d41baff0e117952391981ae3a095 /caputils | |
parent | 28c5b73545d33a9eb5fef591bb908b0c0548236e (diff) |
Remove the periodic interface update in wireless toolbar
The wireless toolbar retrieves the full list of network interfaces
every 1.5 seconds to keep its list of interfaces updated. This
not only adds unnecessary load on the system it also generates
plenty of netlink traffic. When capturing packets on nlmon
interfaces they are flooded with packets generated by Wireshark
itself making it hard to understand the traffic that's really present
on the system.
Remove the periodic interface update and instead listen to network
interface change events and update only when something has changed.
The wireless toolbar need to know all when wireless interfaces are
added/removed, not only whether an interface is 'up' or not so
iface_monitor changes were also necessary.
Bug: 15576
Change-Id: I8fb19fd919dfef1b6b35bf48790b105ecd2b60a8
Reviewed-on: https://code.wireshark.org/review/32350
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'caputils')
-rw-r--r-- | caputils/iface_monitor.c | 18 | ||||
-rw-r--r-- | caputils/iface_monitor.h | 2 |
2 files changed, 15 insertions, 5 deletions
diff --git a/caputils/iface_monitor.c b/caputils/iface_monitor.c index 5694abca1e..28ab3c1925 100644 --- a/caputils/iface_monitor.c +++ b/caputils/iface_monitor.c @@ -82,6 +82,7 @@ iface_mon_handler2(struct nl_object *obj, void *arg) return; } + int msg_type = nl_object_get_msgtype(obj); link_obj = (struct rtnl_link *) obj; flags = rtnl_link_get_flags (link_obj); ifname = rtnl_link_get_name(link_obj); @@ -99,8 +100,17 @@ iface_mon_handler2(struct nl_object *obj, void *arg) */ up = (flags & IFF_UP) ? 1 : 0; - cb(ifname, up); - + switch (msg_type) { + case RTM_NEWLINK: + cb(ifname, 1, up); + break; + case RTM_DELLINK: + cb(ifname, 0, 0); + break; + default: + /* Ignore other events */ + break; + } rtnl_link_put(filter); return; @@ -303,7 +313,7 @@ iface_mon_event(void) * to see whether we should show it as something on * which we can capture. */ - callback(ifr_name, 1); + callback(ifr_name, 1, 1); break; case KEV_DL_IF_DETACHED: @@ -315,7 +325,7 @@ iface_mon_event(void) * bpfdetach() makes an interface no longer BPFable, * and that's what we *really* care about. */ - callback(ifr_name, 0); + callback(ifr_name, 0, 0); break; default: diff --git a/caputils/iface_monitor.h b/caputils/iface_monitor.h index fa5350e38c..785ab34a63 100644 --- a/caputils/iface_monitor.h +++ b/caputils/iface_monitor.h @@ -32,7 +32,7 @@ extern "C" { * We also may want other events, such as address changes, so what * we might want is "add", "remove", and "modify" as the events. */ -typedef void (*iface_mon_cb)(const char *iface, int up); +typedef void (*iface_mon_cb)(const char *iface, int added, int up); /* * Start watching for interface changes. |