[ipxe-devel] [RESEND PATCH 3/5] [settings] Make settings applicators aware of the setting being modified

Ladi Prosek lprosek at redhat.com
Fri Mar 3 12:37:05 UTC 2017


Some settings applicators are only interested in explicit updates
of a specific setting. This commit adds a parameter to the apply
callback with the setting that has just changed. Callers pass NULL
setting to the callback in situations where the setting infrastructure
has changed and multiple settings may have been updated.

Signed-off-by: Ladi Prosek <lprosek at redhat.com>
---
 src/core/settings.c         | 10 +++++-----
 src/crypto/certstore.c      |  2 +-
 src/crypto/privkey.c        |  2 +-
 src/include/ipxe/settings.h |  3 ++-
 src/net/80211/net80211.c    |  4 ++--
 src/net/ipv4.c              |  2 +-
 src/net/tcp/syslogs.c       |  2 +-
 src/net/udp/dns.c           |  2 +-
 src/net/udp/syslog.c        |  2 +-
 src/net/udp/tftp.c          |  2 +-
 10 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/src/core/settings.c b/src/core/settings.c
index e60a882..72c6423 100644
--- a/src/core/settings.c
+++ b/src/core/settings.c
@@ -408,13 +408,13 @@ struct settings * find_settings ( const char *name ) {
  *
  * @ret rc		Return status code
  */
-static int apply_settings ( void ) {
+static int apply_settings ( const struct setting *setting ) {
 	struct settings_applicator *applicator;
 	int rc;
 
 	/* Call all settings applicators */
 	for_each_table_entry ( applicator, SETTINGS_APPLICATORS ) {
-		if ( ( rc = applicator->apply() ) != 0 ) {
+		if ( ( rc = applicator->apply ( setting ) ) != 0 ) {
 			DBG ( "Could not apply settings using applicator "
 			      "%p: %s\n", applicator, strerror ( rc ) );
 			return rc;
@@ -499,7 +499,7 @@ int register_settings ( struct settings *settings, struct settings *parent,
 	reprioritise_settings ( settings );
 
 	/* Apply potentially-updated settings */
-	apply_settings();
+	apply_settings ( NULL );
 
 	return 0;
 }
@@ -528,7 +528,7 @@ void unregister_settings ( struct settings *settings ) {
 	ref_put ( settings->refcnt );
 
 	/* Apply potentially-updated settings */
-	apply_settings();
+	apply_settings ( NULL );
 }
 
 /******************************************************************************
@@ -639,7 +639,7 @@ int store_setting ( struct settings *settings, const struct setting *setting,
 	 */
 	for ( ; settings ; settings = settings->parent ) {
 		if ( settings == &settings_root ) {
-			if ( ( rc = apply_settings() ) != 0 )
+			if ( ( rc = apply_settings ( setting ) ) != 0 )
 				return rc;
 			break;
 		}
diff --git a/src/crypto/certstore.c b/src/crypto/certstore.c
index cdf6fb4..585694d 100644
--- a/src/crypto/certstore.c
+++ b/src/crypto/certstore.c
@@ -264,7 +264,7 @@ static struct setting cert_setting __setting ( SETTING_CRYPTO, cert ) = {
  *
  * @ret rc		Return status code
  */
-static int certstore_apply_settings ( void ) {
+static int certstore_apply_settings ( const struct setting *setting __unused ) {
 	static struct x509_certificate *cert = NULL;
 	struct x509_certificate *old_cert;
 	void *cert_data;
diff --git a/src/crypto/privkey.c b/src/crypto/privkey.c
index 7ef0488..79de62a 100644
--- a/src/crypto/privkey.c
+++ b/src/crypto/privkey.c
@@ -88,7 +88,7 @@ static struct setting privkey_setting __setting ( SETTING_CRYPTO, privkey ) = {
  *
  * @ret rc		Return status code
  */
-static int privkey_apply_settings ( void ) {
+static int privkey_apply_settings ( const struct setting *setting __unused ) {
 	static void *key_data = NULL;
 	int len;
 
diff --git a/src/include/ipxe/settings.h b/src/include/ipxe/settings.h
index 341fc3c..49bc9da 100644
--- a/src/include/ipxe/settings.h
+++ b/src/include/ipxe/settings.h
@@ -251,9 +251,10 @@ struct setting_type {
 struct settings_applicator {
 	/** Apply updated settings
 	 *
+	 * @v setting		Updated setting, or NULL
 	 * @ret rc		Return status code
 	 */
-	int ( * apply ) ( void );
+	int ( * apply ) ( const struct setting *setting );
 };
 
 /** Settings applicator table */
diff --git a/src/net/80211/net80211.c b/src/net/80211/net80211.c
index 6291274..00c5daa 100644
--- a/src/net/80211/net80211.c
+++ b/src/net/80211/net80211.c
@@ -187,7 +187,7 @@ static void net80211_rx_frag ( struct net80211_device *dev,
  * @defgroup net80211_settings 802.11 settings handlers
  * @{
  */
-static int net80211_check_settings_update ( void );
+static int net80211_check_settings_update ( const struct setting *setting __unused );
 
 /** 802.11 settings applicator
  *
@@ -1891,7 +1891,7 @@ static void net80211_step_associate ( struct net80211_device *dev )
  * handshaker will be asked to update its state to match; if that is
  * impossible without reassociation, we reassociate.
  */
-static int net80211_check_settings_update ( void )
+static int net80211_check_settings_update ( const struct setting *setting __unused )
 {
 	struct net80211_device *dev;
 	char ssid[IEEE80211_MAX_SSID_LEN + 1];
diff --git a/src/net/ipv4.c b/src/net/ipv4.c
index b9ce5e7..42e3b00 100644
--- a/src/net/ipv4.c
+++ b/src/net/ipv4.c
@@ -903,7 +903,7 @@ static int ipv4_settings ( int ( * apply ) ( struct net_device *netdev,
  *
  * @ret rc		Return status code
  */
-static int ipv4_create_routes ( void ) {
+static int ipv4_create_routes ( const struct setting *setting __unused ) {
 	struct ipv4_miniroute *miniroute;
 	struct ipv4_miniroute *tmp;
 	int rc;
diff --git a/src/net/tcp/syslogs.c b/src/net/tcp/syslogs.c
index 0c07f86..c1dea09 100644
--- a/src/net/tcp/syslogs.c
+++ b/src/net/tcp/syslogs.c
@@ -205,7 +205,7 @@ const struct setting syslogs_setting __setting ( SETTING_MISC, syslogs ) = {
  *
  * @ret rc		Return status code
  */
-static int apply_syslogs_settings ( void ) {
+static int apply_syslogs_settings ( const struct setting *setting __unused ) {
 	static char *old_server;
 	char *server;
 	struct interface *socket;
diff --git a/src/net/udp/dns.c b/src/net/udp/dns.c
index e849472..7774b52 100644
--- a/src/net/udp/dns.c
+++ b/src/net/udp/dns.c
@@ -1113,7 +1113,7 @@ static void apply_dns_search ( void ) {
  *
  * @ret rc		Return status code
  */
-static int apply_dns_settings ( void ) {
+static int apply_dns_settings ( const struct setting *setting __unused ) {
 
 	/* Fetch DNS server address */
 	nameserver.sa.sa_family = 0;
diff --git a/src/net/udp/syslog.c b/src/net/udp/syslog.c
index a45fc45..756dd71 100644
--- a/src/net/udp/syslog.c
+++ b/src/net/udp/syslog.c
@@ -243,7 +243,7 @@ static void syslog_fix_name ( char *name ) {
  *
  * @ret rc		Return status code
  */
-static int apply_syslog_settings ( void ) {
+static int apply_syslog_settings ( const struct setting *setting __unused ) {
 	struct sockaddr old_logserver;
 	int rc;
 
diff --git a/src/net/udp/tftp.c b/src/net/udp/tftp.c
index 4255472..960fc43 100644
--- a/src/net/udp/tftp.c
+++ b/src/net/udp/tftp.c
@@ -1180,7 +1180,7 @@ struct uri_opener mtftp_uri_opener __uri_opener = {
  *
  * @ret rc		Return status code
  */
-static int tftp_apply_settings ( void ) {
+static int tftp_apply_settings ( const struct setting *setting __unused ) {
 	static struct in_addr tftp_server = { 0 };
 	struct in_addr new_tftp_server;
 	char uri_string[32];
-- 
2.7.4




More information about the ipxe-devel mailing list