device: restore cleared flags on device down
[project/netifd.git] / device.c
index eef6ca6d662fe1053e302a03b05bc9e83c9ad12a..322e009352eb80fd534c80871e84065bab7e979c 100644 (file)
--- a/device.c
+++ b/device.c
@@ -172,6 +172,11 @@ static int set_device_state(struct device *dev, bool state)
        } else {
                system_if_down(dev);
                system_if_apply_settings(dev, &dev->orig_settings, dev->orig_settings.flags);
+
+               /* Restore any settings present in UCI which may have
+                * failed to apply so that they will be re-attempted
+                * the next time the device is brought up */
+               dev->settings.flags |= dev->settings.valid_flags;
        }
 
        return 0;
@@ -571,6 +576,9 @@ device_init_settings(struct device *dev, struct blob_attr **tb)
                s->flags |= DEV_OPT_EEE;
        }
 
+       /* Remember the settings present in UCI */
+       s->valid_flags = s->flags;
+
        cur = tb[DEV_ATTR_AUTH_VLAN];
        free(dev->config_auth_vlans);
        dev->config_auth_vlans = cur ? blob_memdup(cur) : NULL;