If ioctl returns EBUSY on the command SIOCBRADDIF, the interface might already be bridged by others (e.g. netifd in OpenWrt), and linux_br_add_if should not indicate an error. This patch checks whether the interface is correctly brigded when ioctl returns EBUSY. Signed-off-by: Michael-CY Lee <michael-cy.lee@xxxxxxxxxxxx> --- v2: fix coding style. --- src/drivers/linux_ioctl.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/drivers/linux_ioctl.c b/src/drivers/linux_ioctl.c index 7edb9df..06812ab 100644 --- a/src/drivers/linux_ioctl.c +++ b/src/drivers/linux_ioctl.c @@ -151,6 +151,7 @@ int linux_br_add_if(int sock, const char *brname, const char *ifname) { struct ifreq ifr; int ifindex; + char in_br[IFNAMSIZ]; ifindex = if_nametoindex(ifname); if (ifindex == 0) @@ -165,7 +166,14 @@ int linux_br_add_if(int sock, const char *brname, const char *ifname) 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 interface into bridge, + * the interface might already be added by others, so checks + * whether the interface is currently on the right bridge. + */ + if (errno != EBUSY || linux_br_get(in_br, ifname) != 0 || + os_strcmp(in_br, brname) != 0) + return -1; } return 0; -- 2.25.1 _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap