diff options
| -rw-r--r-- | netspeed/src/backend.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/netspeed/src/backend.c b/netspeed/src/backend.c index e1321497..cd369200 100644 --- a/netspeed/src/backend.c +++ b/netspeed/src/backend.c @@ -64,10 +64,20 @@ struct nl80211_state { #endif /* HAVE_NL */ +static gboolean +device_exists (const char *device) +{ + return (if_nametoindex (device) != 0); +} + gboolean is_dummy_device (const char* device) { glibtop_netload netload; + + if (!device_exists (device)) + return TRUE; + glibtop_get_netload (&netload, device); if (netload.if_flags & (1 << GLIBTOP_IF_FLAGS_LOOPBACK)) @@ -332,6 +342,11 @@ get_device_info (const char *device, devinfo->name = g_strdup (device); devinfo->type = DEV_UNKNOWN; + /* Device doesn't exist. + * Return so the auto-change logic can find an active device. */ + if (!device_exists (device)) + return; + glibtop_get_netload (&netload, device); devinfo->up = (netload.if_flags & (1L << GLIBTOP_IF_FLAGS_UP) ? TRUE : FALSE); |
