X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=bridge.c;h=3edfeaac4abf741dee2940e608cad0500c4c74c6;hp=0e06cc264b0439a4e1dd50f43bfe2229b351cacd;hb=27cecc14302de7ed2c5cbb63e6969dd7e77f893a;hpb=0bdaf23dc9fc786698787593381efefd527e5f89 diff --git a/bridge.c b/bridge.c index 0e06cc2..3edfeaa 100644 --- a/bridge.c +++ b/bridge.c @@ -140,6 +140,8 @@ bridge_disable_member(struct bridge_member *bm) system_bridge_delif(&bst->dev, bm->dev.dev); device_release(&bm->dev); + device_broadcast_event(&bst->dev, DEV_EVENT_TOPO_CHANGE); + return 0; } @@ -152,6 +154,12 @@ bridge_enable_member(struct bridge_member *bm) if (!bm->present) return 0; + /* Disable IPv6 for bridge members */ + if (!(bm->dev.dev->settings.flags & DEV_OPT_IPV6)) { + bm->dev.dev->settings.ipv6 = 0; + bm->dev.dev->settings.flags |= DEV_OPT_IPV6; + } + ret = device_claim(&bm->dev); if (ret < 0) goto error; @@ -162,6 +170,8 @@ bridge_enable_member(struct bridge_member *bm) goto error; } + device_broadcast_event(&bst->dev, DEV_EVENT_TOPO_CHANGE); + return 0; error: @@ -231,10 +241,17 @@ bridge_member_cb(struct device_user *dev, enum device_event ev) bm->present = true; bst->n_present++; - if (bst->dev.active) - bridge_enable_member(bm); - else if (bst->n_present == 1) + if (bst->n_present == 1) device_set_present(&bst->dev, true); + if (bst->dev.active && !bridge_enable_member(bm)) { + /* + * Adding a bridge member can overwrite the bridge mtu + * in the kernel, apply the bridge settings in case the + * bridge mtu is set + */ + system_if_apply_settings(&bst->dev, &bst->dev.settings, + DEV_OPT_MTU); + } break; case DEV_EVENT_REMOVE: @@ -318,6 +335,9 @@ bridge_create_member(struct bridge_state *bst, struct device *dev, bool hotplug) struct bridge_member *bm; bm = calloc(1, sizeof(*bm) + strlen(dev->ifname) + 1); + if (!bm) + return NULL; + bm->bst = bst; bm->dev.cb = bridge_member_cb; bm->dev.hotplug = hotplug;