if (bst->n_present == 1)
device_set_present(&bst->dev, true);
- if (bst->dev.active)
- bridge_enable_member(bm);
+ 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:
odev->current_config = true;
change = device_set_config(odev, type, config);
if (odev->external) {
- system_if_apply_settings(odev, &odev->settings);
+ system_if_apply_settings(odev, &odev->settings, odev->settings.flags);
change = DEV_CONFIG_APPLIED;
}
switch (change) {
if (iface->device_config)
device_set_config(dev, &simple_device_type, iface->config);
- system_if_apply_settings(dev, &dev->settings);
+ system_if_apply_settings(dev, &dev->settings, dev->settings.flags);
ret = interface_add_link(iface, dev);
} else {
ret = interface_remove_link(iface, dev);
}
void
-system_if_apply_settings(struct device *dev, struct device_settings *s)
+system_if_apply_settings(struct device *dev, struct device_settings *s, unsigned int apply_mask)
{
struct ifreq ifr;
+ if (!apply_mask)
+ return;
+
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, dev->ifname, sizeof(ifr.ifr_name));
- if (s->flags & DEV_OPT_MTU) {
+ if (s->flags & DEV_OPT_MTU & apply_mask) {
ifr.ifr_mtu = s->mtu;
if (ioctl(sock_ioctl, SIOCSIFMTU, &ifr) < 0)
s->flags &= ~DEV_OPT_MTU;
}
- if (s->flags & DEV_OPT_TXQUEUELEN) {
+ if (s->flags & DEV_OPT_TXQUEUELEN & apply_mask) {
ifr.ifr_qlen = s->txqueuelen;
if (ioctl(sock_ioctl, SIOCSIFTXQLEN, &ifr) < 0)
s->flags &= ~DEV_OPT_TXQUEUELEN;
}
- if ((s->flags & DEV_OPT_MACADDR) && !dev->external) {
+ if ((s->flags & DEV_OPT_MACADDR & apply_mask) && !dev->external) {
ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
memcpy(&ifr.ifr_hwaddr.sa_data, s->macaddr, sizeof(s->macaddr));
if (ioctl(sock_ioctl, SIOCSIFHWADDR, &ifr) < 0)
int system_if_up(struct device *dev)
{
system_if_get_settings(dev, &dev->orig_settings);
- system_if_apply_settings(dev, &dev->settings);
+ system_if_apply_settings(dev, &dev->settings, dev->settings.flags);
device_set_ifindex(dev, system_if_resolve(dev));
return system_if_flags(dev->ifname, IFF_UP, 0);
}
{
int ret = system_if_flags(dev->ifname, 0, IFF_UP);
dev->orig_settings.flags &= dev->settings.flags;
- system_if_apply_settings(dev, &dev->orig_settings);
+ system_if_apply_settings(dev, &dev->orig_settings, dev->orig_settings.flags);
return ret;
}
int system_if_dump_stats(struct device *dev, struct blob_buf *b);
struct device *system_if_get_parent(struct device *dev);
bool system_if_force_external(const char *ifname);
-void system_if_apply_settings(struct device *dev, struct device_settings *s);
-
+void system_if_apply_settings(struct device *dev, struct device_settings *s,
+ unsigned int apply_mask);
int system_add_address(struct device *dev, struct device_addr *addr);
int system_del_address(struct device *dev, struct device_addr *addr);