hostapd: Check the bridge if ioctl SIOCBRADDIF fails
If ioctl() returns EBUSY on the command SIOCBRADDIF, the interface might have already been added to the bridge by an external operation (e.g., netifd in OpenWrt), and linux_br_add_if() should not indicate an error. Check whether the interface is correctly brigded when ioctl() returns EBUSY and if so, report success. Signed-off-by: Michael-CY Lee <michael-cy.lee@mediatek.com>
This commit is contained in:
parent
1b9006a8cb
commit
0af4c1478e
1 changed files with 10 additions and 1 deletions
|
@ -161,11 +161,20 @@ int linux_br_add_if(int sock, const char *brname, const char *ifname)
|
|||
ifr.ifr_ifindex = ifindex;
|
||||
if (ioctl(sock, SIOCBRADDIF, &ifr) < 0) {
|
||||
int saved_errno = errno;
|
||||
char in_br[IFNAMSIZ];
|
||||
|
||||
wpa_printf(MSG_DEBUG, "Could not add interface %s into bridge "
|
||||
"%s: %s", ifname, brname, strerror(errno));
|
||||
errno = saved_errno;
|
||||
return -1;
|
||||
|
||||
/* If ioctl() returns EBUSY when adding an interface into the
|
||||
* bridge, the interface might have already been added by an
|
||||
* external operation, so check whether the interface is
|
||||
* currently on the right bridge and ignore the error if it is.
|
||||
*/
|
||||
if (errno != EBUSY || linux_br_get(in_br, ifname) != 0 ||
|
||||
os_strcmp(in_br, brname) != 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue