diff mbox series

[netifd] device: restore cleared flags on device down

Message ID 20231205232258.2794460-1-erik.r.karlsson@gmail.com
State Accepted
Headers show
Series [netifd] device: restore cleared flags on device down | expand

Commit Message

Erik Karlsson Dec. 5, 2023, 11:22 p.m. UTC
From: Erik Karlsson <erik.karlsson@genexis.eu>

In case flags have been cleared because settings failed to apply,
restore them when the device is brought down so that they will be
re-attempted the next time the device is brought up.

Signed-off-by: Erik Karlsson <erik.karlsson@genexis.eu>
---
 device.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Paul D Dec. 6, 2023, 9:08 p.m. UTC | #1
Worth mentioning this new UEFI bootloader vuln which was unembargo'd today.


https://binarly.io/posts/The_Far_Reaching_Consequences_of_LogoFAIL/


Might affect a few devices out there, upon which OpenWRT runs.
diff mbox series

Patch

diff --git a/device.c b/device.c
index b352ee3..08325b8 100644
--- 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;