system-linux: move device settings handling to device.c
authorFelix Fietkau <nbd@nbd.name>
Mon, 30 Nov 2020 11:08:32 +0000 (12:08 +0100)
committerFelix Fietkau <nbd@nbd.name>
Mon, 30 Nov 2020 11:08:32 +0000 (12:08 +0100)
Signed-off-by: Felix Fietkau <nbd@nbd.name>
device.c
system-linux.c

index 3e2b5e9da4265e9abd78f9139bec56bb27c0de03..627f1a244649e380aaf1d8acae91a8aab13a036a 100644 (file)
--- a/device.c
+++ b/device.c
@@ -143,10 +143,17 @@ static int set_device_state(struct device *dev, bool state)
                if (!dev->ifindex)
                        return -1;
 
+               system_if_get_settings(dev, &dev->orig_settings);
+               /* Only keep orig settings based on what needs to be set */
+               dev->orig_settings.valid_flags = dev->orig_settings.flags;
+               dev->orig_settings.flags &= dev->settings.flags;
+               system_if_apply_settings(dev, &dev->settings, dev->settings.flags);
+
                system_if_up(dev);
-       }
-       else
+       } else {
                system_if_down(dev);
+               system_if_apply_settings(dev, &dev->orig_settings, dev->orig_settings.flags);
+       }
 
        return 0;
 }
index d254b7cefd5c77489acff6e83875830ec2c68924..880cd232b8043136a325997a325083fa8d1f146e 100644 (file)
@@ -1717,19 +1717,12 @@ system_if_apply_settings(struct device *dev, struct device_settings *s, unsigned
 
 int system_if_up(struct device *dev)
 {
-       system_if_get_settings(dev, &dev->orig_settings);
-       /* Only keep orig settings based on what needs to be set */
-       dev->orig_settings.valid_flags = dev->orig_settings.flags;
-       dev->orig_settings.flags &= dev->settings.flags;
-       system_if_apply_settings(dev, &dev->settings, dev->settings.flags);
        return system_if_flags(dev->ifname, IFF_UP, 0);
 }
 
 int system_if_down(struct device *dev)
 {
-       int ret = system_if_flags(dev->ifname, 0, IFF_UP);
-       system_if_apply_settings(dev, &dev->orig_settings, dev->orig_settings.flags);
-       return ret;
+       return system_if_flags(dev->ifname, 0, IFF_UP);
 }
 
 struct if_check_data {