summaryrefslogtreecommitdiff
path: root/system-linux.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2020-11-23 12:42:36 +0100
committerFelix Fietkau <nbd@nbd.name>2020-11-23 12:48:53 +0100
commit3abe1fc87151fae570fc1232053c73d1a5505664 (patch)
tree386eaa0a331e01a289b0cba79b01a052ceeb9406 /system-linux.c
parent213748a9bcd9683778250e3673b70acdcc8d96a2 (diff)
downloadnetifd-3abe1fc87151fae570fc1232053c73d1a5505664.tar.gz
system-linux: add retry for adding member devices to a bridge
When netifd tries to add bridge members brought up by hostapd asynchronously (e.g. after an autochannel run), the first try often fails with EBUSY or EAGAIN, since it's racing against hostapd's own setup. Add retry logic, which includes checking if the device was added to the bridge in the meantime to deal with this issue Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'system-linux.c')
-rw-r--r--system-linux.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/system-linux.c b/system-linux.c
index 7ca4c8b..1d5d232 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -813,11 +813,20 @@ int system_bridge_addif(struct device *bridge, struct device *dev)
{
char buf[64];
char *oldbr;
- int ret = 0;
+ int tries = 0;
+ int ret;
+retry:
+ ret = 0;
oldbr = system_get_bridge(dev->ifname, dev_buf, sizeof(dev_buf));
- if (!oldbr || strcmp(oldbr, bridge->ifname) != 0)
+ if (!oldbr || strcmp(oldbr, bridge->ifname) != 0) {
ret = system_bridge_if(bridge->ifname, dev, SIOCBRADDIF, NULL);
+ tries++;
+ D(SYSTEM, "Failed to add device '%s' to bridge '%s' (tries=%d): %s\n",
+ dev->ifname, bridge->ifname, tries, strerror(errno));
+ if (tries <= 3)
+ goto retry;
+ }
if (dev->wireless)
system_bridge_set_wireless(bridge, dev);