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
This commit is contained in:
parent
6fa36bad9f
commit
4f61bbbd8e
@ -110,11 +110,11 @@
|
|||||||
}
|
}
|
||||||
if (strcmp(ifr.ifr_name, interface) != 0) {
|
if (strcmp(ifr.ifr_name, interface) != 0) {
|
||||||
strcpy(ifr.ifr_name, interface);
|
strcpy(ifr.ifr_name, interface);
|
||||||
|
}
|
||||||
if (ioctl(ifsock, SIOCGIFINDEX, &ifr) != 0) {
|
if (ioctl(ifsock, SIOCGIFINDEX, &ifr) != 0) {
|
||||||
warn("ioctl 'SIOCGIFINDEX':");
|
warn("ioctl 'SIOCGIFINDEX':");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return ifr.ifr_ifindex;
|
return ifr.ifr_ifindex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user