aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordrkhsh <me@drkhsh.at>2026-02-12 22:46:02 +0100
committerdrkhsh <me@drkhsh.at>2026-02-12 22:46:02 +0100
commit4f61bbbd8e9278c75f29e7853ae8922717261d2d (patch)
tree415b2fa707b5e5187eb19afb7288f687d0d0d2c9
parent6fa36bad9f74154d4bf3be834ada93e04bf737e1 (diff)
downloadslstatus-4f61bbbd8e9278c75f29e7853ae8922717261d2d.tar.gz
wifi: always retry ioctl for ifindex
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
-rw-r--r--components/wifi.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/components/wifi.c b/components/wifi.c
index 23af201..8b33baa 100644
--- a/components/wifi.c
+++ b/components/wifi.c
@@ -110,10 +110,10 @@
}
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;
}