diff options
| author | Victor Kareh <[email protected]> | 2026-03-11 17:03:37 -0400 |
|---|---|---|
| committer | Victor Kareh <[email protected]> | 2026-05-27 15:55:54 -0400 |
| commit | bdf674770c36b708cc1397b93f9fe44c6aef2c53 (patch) | |
| tree | 00ecf49eb2ce431a3ac3ae8c7b2087a34bee4976 | |
| parent | d14b2ed05574c4fc8a7f52c671367c00da440d1f (diff) | |
| download | mate-applets-master.tar.bz2 mate-applets-master.tar.xz | |
When a network interface is disabled at the kernel level, the applet
tries to read from a device that no longer exist, generating continuous
warning messages in syslog.
Check if the device exists before calling glibtop_get_netload in both
is_dummy_device and get_device_info. When the device doesn't exist,
get_device_info returns a non-running device info, allowing the existing
auto-change logic to find an active device.
Fixes #688
| -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); |
