luci-mod-status: luci-bwc: skip "." and ".." when finding netdevs
authorJo-Philipp Wich <jo@mein.io>
Wed, 1 Apr 2020 16:19:30 +0000 (18:19 +0200)
committerJo-Philipp Wich <jo@mein.io>
Wed, 1 Apr 2020 16:45:46 +0000 (18:45 +0200)
Skip the "." and ".." directory entries of "/sys/class/net/" instead of
passing them on to libiwinfo's probe function. This avoids a situation
where the kernel requests a modprobe of "netdev-." and "netdev-.." over
and over again, resulting in high load on lower end systems.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 16f0997bdbf85df0c7bae7f0773a118714d15cdf)

modules/luci-mod-status/src/luci-bwc.c

index 9a57fa23a8f75b24ea746db71a0e1ec88cbd69ac..6f7016ec9dd7c8a7d54b659c564bdaf4081448f4 100644 (file)
@@ -492,12 +492,12 @@ static int run_daemon(void)
                {
                        while ((e = readdir(dir)) != NULL)
                        {
+                               if (!strcmp(e->d_name, "lo") || !strcmp(e->d_name, ".") || !strcmp(e->d_name, ".."))
+                                       continue;
+
                                if (iw && iw_update(iw, e->d_name, &rate, &rssi, &noise))
                                        update_radiostat(e->d_name, rate, rssi, noise);
 
-                               if (!strcmp(e->d_name, "lo"))
-                                       continue;
-
                                for (i = 0; i < sizeof(sysfs_stats)/sizeof(sysfs_stats[0]); i++)
                                {
                                        *sysfs_stats[i].value = 0;