]> Skullheadx's Git Forge - slstatus.git/commitdiff
wifi: always retry ioctl for ifindex
authordrkhsh <me@drkhsh.at>
Thu, 12 Feb 2026 21:46:02 +0000 (22:46 +0100)
committerdrkhsh <me@drkhsh.at>
Thu, 12 Feb 2026 21:46:02 +0000 (22:46 +0100)
ifindex() caches the result of ioctl(SIOCGIFINDEX) and never
retries it, since the interface name strcmp succeeds after the
first call. if the interface does not exist when slstatus starts
(e.g. iwd with default config destroys/recreates interfaces
depending on service state), the ioctl fails and the stale
result is returned on all subsequent calls.

based on a patch by ryhpez, with input from Taha Medhous

components/wifi.c

index 23af2015b4046bdc019cbf71911b8add6638546c..8b33baa05997318d2fa91dec262281a4979aba37 100644 (file)
                }
                if (strcmp(ifr.ifr_name, interface) != 0) {
                        strcpy(ifr.ifr_name, interface);
-                       if (ioctl(ifsock, SIOCGIFINDEX, &ifr) != 0) {
-                               warn("ioctl 'SIOCGIFINDEX':");
-                               return -1;
-                       }
+               }
+               if (ioctl(ifsock, SIOCGIFINDEX, &ifr) != 0) {
+                       warn("ioctl 'SIOCGIFINDEX':");
+                       return -1;
                }
                return ifr.ifr_ifindex;
        }