Send connman mailing list submissions to
[email protected]
To subscribe or unsubscribe via email, send a message with subject or
body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of connman digest..."
Today's Topics:
1. Re: [PATCH] firewall-nftables: Use nftnl_{chain|rule}_set_str() for
string attributes
(Daniel Wagner)
2. [PATCH 0/2] Simplify settings save code (Daniel Wagner)
3. [PATCH 1/2] service: Store configuration in empty keyfile
(Daniel Wagner)
4. [PATCH 2/2] storage: Remove unused __connman_storage_open_service()
(Daniel Wagner)
5. Re: simpler reproduction of connman error (Daniel Wagner)
----------------------------------------------------------------------
Date: Sat, 21 Dec 2019 15:30:56 +0100
From: Daniel Wagner <[email protected]>
Subject: Re: [PATCH] firewall-nftables: Use
nftnl_{chain|rule}_set_str() for string attributes
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On Sat, Dec 21, 2019 at 03:27:39PM +0100, Daniel Wagner wrote:
> Replace nftnl_{chain|rule}_set() with nftnl_{chain|rule}_set_str() to
> set string attributes. nftnl_{chain|rule}_set() have been deprecated
> with the commit message:
>
> These functions make assumptions on size of passed data pointer and
> therefore tend to hide programming mistakes. Instead either one of the
> type-specific setters or the generic *_set_data() setter should be
> used.
Patch applied.
------------------------------
Date: Sat, 21 Dec 2019 17:33:44 +0100
From: Daniel Wagner <[email protected]>
Subject: [PATCH 0/2] Simplify settings save code
To: [email protected]
Cc: Daniel Wagner <[email protected]>
Message-ID: <[email protected]>
Start with an empty kefile for storing the current configuration. Thus
we can drop the configuration update code.
Daniel Wagner (2):
service: Store configuration in empty keyfile
storage: Remove unused __connman_storage_open_service()
src/connman.h | 1 -
src/ipconfig.c | 62 +++++++++++++++++++++++++-------------------------
src/service.c | 59 +++++++++++++++--------------------------------
src/storage.c | 22 ------------------
4 files changed, 49 insertions(+), 95 deletions(-)
--
2.24.0
------------------------------
Date: Sat, 21 Dec 2019 17:33:45 +0100
From: Daniel Wagner <[email protected]>
Subject: [PATCH 1/2] service: Store configuration in empty keyfile
To: [email protected]
Cc: Daniel Wagner <[email protected]>
Message-ID: <[email protected]>
Instead loading the keyfile from disk with the old configuration,
start with an empty configuration. Because we do not have a previous
configuration which needs to be updated we can drop all the remove
code. This avoids complex code paths when switching from one
connnection method to the next one (dhcp to manual and back).
---
src/ipconfig.c | 62 +++++++++++++++++++++++++-------------------------
src/service.c | 59 +++++++++++++++--------------------------------
2 files changed, 49 insertions(+), 72 deletions(-)
diff --git a/src/ipconfig.c b/src/ipconfig.c
index 25657733571a..4a9d575039bc 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -2275,27 +2275,25 @@ int __connman_ipconfig_save(struct connman_ipconfig
*ipconfig,
g_key_file_set_string(keyfile, identifier, key, privacy);
g_free(key);
- key = g_strdup_printf("%sDHCP.LastAddress", prefix);
if (ipconfig->last_dhcp_address &&
- strlen(ipconfig->last_dhcp_address) > 0)
+ strlen(ipconfig->last_dhcp_address) > 0) {
+ key = g_strdup_printf("%sDHCP.LastAddress", prefix);
g_key_file_set_string(keyfile, identifier, key,
ipconfig->last_dhcp_address);
- else
- g_key_file_remove_key(keyfile, identifier, key, NULL);
- g_free(key);
+ g_free(key);
+ }
- key = g_strdup_printf("%sDHCP.LastPrefixes", prefix);
if (ipconfig->last_dhcpv6_prefixes &&
ipconfig->last_dhcpv6_prefixes[0]) {
guint len =
g_strv_length(ipconfig->last_dhcpv6_prefixes);
+ key = g_strdup_printf("%sDHCP.LastPrefixes", prefix);
g_key_file_set_string_list(keyfile, identifier, key,
(const gchar **)ipconfig->last_dhcpv6_prefixes,
len);
- } else
- g_key_file_remove_key(keyfile, identifier, key, NULL);
- g_free(key);
+ g_free(key);
+ }
}
switch (ipconfig->method) {
@@ -2303,14 +2301,13 @@ int __connman_ipconfig_save(struct connman_ipconfig
*ipconfig,
case CONNMAN_IPCONFIG_METHOD_MANUAL:
break;
case CONNMAN_IPCONFIG_METHOD_DHCP:
- key = g_strdup_printf("%sDHCP.LastAddress", prefix);
if (ipconfig->last_dhcp_address &&
- strlen(ipconfig->last_dhcp_address) > 0)
+ strlen(ipconfig->last_dhcp_address) > 0) {
+ key = g_strdup_printf("%sDHCP.LastAddress", prefix);
g_key_file_set_string(keyfile, identifier, key,
ipconfig->last_dhcp_address);
- else
- g_key_file_remove_key(keyfile, identifier, key, NULL);
- g_free(key);
+ g_free(key);
+ }
/* fall through */
case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
case CONNMAN_IPCONFIG_METHOD_OFF:
@@ -2318,37 +2315,40 @@ int __connman_ipconfig_save(struct connman_ipconfig
*ipconfig,
return 0;
}
- key = g_strdup_printf("%snetmask_prefixlen", prefix);
- if (ipconfig->address->prefixlen != 0)
+ if (ipconfig->address->prefixlen != 0) {
+ key = g_strdup_printf("%snetmask_prefixlen", prefix);
g_key_file_set_integer(keyfile, identifier,
key, ipconfig->address->prefixlen);
- g_free(key);
+ g_free(key);
+ }
- key = g_strdup_printf("%slocal_address", prefix);
- if (ipconfig->address->local)
+ if (ipconfig->address->local) {
+ key = g_strdup_printf("%slocal_address", prefix);
g_key_file_set_string(keyfile, identifier,
key, ipconfig->address->local);
- g_free(key);
+ g_free(key);
+ }
- key = g_strdup_printf("%speer_address", prefix);
- if (ipconfig->address->peer)
+ if (ipconfig->address->peer) {
+ key = g_strdup_printf("%speer_address", prefix);
g_key_file_set_string(keyfile, identifier,
key, ipconfig->address->peer);
- g_free(key);
+ g_free(key);
+ }
- key = g_strdup_printf("%sbroadcast_address", prefix);
- if (ipconfig->address->broadcast)
+ if (ipconfig->address->broadcast) {
+ key = g_strdup_printf("%sbroadcast_address", prefix);
g_key_file_set_string(keyfile, identifier,
key, ipconfig->address->broadcast);
- g_free(key);
+ g_free(key);
+ }
- key = g_strdup_printf("%sgateway", prefix);
- if (ipconfig->address->gateway)
+ if (ipconfig->address->gateway) {
+ key = g_strdup_printf("%sgateway", prefix);
g_key_file_set_string(keyfile, identifier,
key, ipconfig->address->gateway);
- else
- g_key_file_remove_key(keyfile, identifier, key, NULL);
- g_free(key);
+ g_free(key);
+ }
return 0;
}
diff --git a/src/service.c b/src/service.c
index 22e94f7bf3c7..4d1235e3cf1e 100644
--- a/src/service.c
+++ b/src/service.c
@@ -631,7 +631,7 @@ static int service_save(struct connman_service *service)
if (service->new_service)
return -ESRCH;
- keyfile = __connman_storage_open_service(service->identifier);
+ keyfile = g_key_file_new();
if (!keyfile)
return -EIO;
@@ -693,9 +693,6 @@ static int service_save(struct connman_service *service)
g_key_file_set_boolean(keyfile, service->identifier,
"Favorite", service->favorite);
- g_key_file_remove_key(keyfile, service->identifier,
- "Failure", NULL);
-
/* fall through */
case CONNMAN_SERVICE_TYPE_ETHERNET:
@@ -708,54 +705,45 @@ static int service_save(struct connman_service *service)
str = util_timeval_to_iso8601(&service->modified);
if (str) {
g_key_file_set_string(keyfile, service->identifier,
- "Modified", str);
+ "Modified", str);
g_free(str);
}
if (service->passphrase && strlen(service->passphrase) > 0)
g_key_file_set_string(keyfile, service->identifier,
- "Passphrase", service->passphrase);
- else
- g_key_file_remove_key(keyfile, service->identifier,
- "Passphrase", NULL);
+ "Passphrase", service->passphrase);
if (service->ipconfig_ipv4)
__connman_ipconfig_save(service->ipconfig_ipv4, keyfile,
- service->identifier, "IPv4.");
+ service->identifier, "IPv4.");
if (service->ipconfig_ipv6)
__connman_ipconfig_save(service->ipconfig_ipv6, keyfile,
- service->identifier, "IPv6.");
+ service->identifier, "IPv6.");
if (service->nameservers_config) {
guint len = g_strv_length(service->nameservers_config);
g_key_file_set_string_list(keyfile, service->identifier,
- "Nameservers",
+ "Nameservers",
(const gchar **) service->nameservers_config,
len);
- } else
- g_key_file_remove_key(keyfile, service->identifier,
- "Nameservers", NULL);
+ }
if (service->timeservers_config) {
guint len = g_strv_length(service->timeservers_config);
g_key_file_set_string_list(keyfile, service->identifier,
- "Timeservers",
+ "Timeservers",
(const gchar **) service->timeservers_config,
len);
- } else
- g_key_file_remove_key(keyfile, service->identifier,
- "Timeservers", NULL);
+ }
if (service->domains) {
guint len = g_strv_length(service->domains);
g_key_file_set_string_list(keyfile, service->identifier,
- "Domains",
+ "Domains",
(const gchar **) service->domains, len);
- } else
- g_key_file_remove_key(keyfile, service->identifier,
- "Domains", NULL);
+ }
cst_str = proxymethod2string(service->proxy_config);
if (cst_str)
@@ -768,9 +756,7 @@ static int service_save(struct connman_service *service)
g_key_file_set_string_list(keyfile, service->identifier,
"Proxy.Servers",
(const gchar **) service->proxies, len);
- } else
- g_key_file_remove_key(keyfile, service->identifier,
- "Proxy.Servers", NULL);
+ }
if (service->excludes) {
guint len = g_strv_length(service->excludes);
@@ -778,34 +764,25 @@ static int service_save(struct connman_service *service)
g_key_file_set_string_list(keyfile, service->identifier,
"Proxy.Excludes",
(const gchar **) service->excludes, len);
- } else
- g_key_file_remove_key(keyfile, service->identifier,
- "Proxy.Excludes", NULL);
+ }
if (service->pac && strlen(service->pac) > 0)
g_key_file_set_string(keyfile, service->identifier,
- "Proxy.URL", service->pac);
- else
- g_key_file_remove_key(keyfile, service->identifier,
- "Proxy.URL", NULL);
+ "Proxy.URL", service->pac);
if (service->mdns_config)
g_key_file_set_boolean(keyfile, service->identifier,
- "mDNS", TRUE);
- else
- g_key_file_remove_key(keyfile, service->identifier,
- "mDNS", NULL);
+ "mDNS", TRUE);
if (service->hidden_service)
- g_key_file_set_boolean(keyfile, service->identifier, "Hidden",
- TRUE);
+ g_key_file_set_boolean(keyfile, service->identifier,
+ "Hidden", TRUE);
if (service->config_file && strlen(service->config_file) > 0)
g_key_file_set_string(keyfile, service->identifier,
"Config.file", service->config_file);
- if (service->config_entry &&
- strlen(service->config_entry) > 0)
+ if (service->config_entry && strlen(service->config_entry) > 0)
g_key_file_set_string(keyfile, service->identifier,
"Config.ident", service->config_entry);
--
2.24.0
------------------------------
Date: Sat, 21 Dec 2019 17:33:46 +0100
From: Daniel Wagner <[email protected]>
Subject: [PATCH 2/2] storage: Remove unused
__connman_storage_open_service()
To: [email protected]
Cc: Daniel Wagner <[email protected]>
Message-ID: <[email protected]>
There is no user left for __connman_storage_open_service(). Thus
remove it.
---
src/connman.h | 1 -
src/storage.c | 22 ----------------------
2 files changed, 23 deletions(-)
diff --git a/src/connman.h b/src/connman.h
index e64739f2e4f4..2f404b45958d 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -273,7 +273,6 @@ void __connman_storage_delete_global(void);
GKeyFile *__connman_storage_load_config(const char *ident);
GKeyFile *__connman_storage_load_provider_config(const char *ident);
-GKeyFile *__connman_storage_open_service(const char *ident);
int __connman_storage_save_service(GKeyFile *keyfile, const char *ident);
GKeyFile *__connman_storage_load_provider(const char *identifier);
void __connman_storage_save_provider(GKeyFile *keyfile, const char
*identifier);
diff --git a/src/storage.c b/src/storage.c
index 5e877ef10375..90f03ebc76e3 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -161,28 +161,6 @@ GKeyFile *__connman_storage_load_provider_config(const
char *ident)
return keyfile;
}
-GKeyFile *__connman_storage_open_service(const char *service_id)
-{
- gchar *pathname;
- GKeyFile *keyfile = NULL;
-
- pathname = g_strdup_printf("%s/%s/%s", STORAGEDIR, service_id,
SETTINGS);
- if (!pathname)
- return NULL;
-
- keyfile = storage_load(pathname);
- if (keyfile) {
- g_free(pathname);
- return keyfile;
- }
-
- g_free(pathname);
-
- keyfile = g_key_file_new();
-
- return keyfile;
-}
-
gchar **connman_storage_get_services(void)
{
struct dirent *d;
--
2.24.0
------------------------------
Date: Sat, 21 Dec 2019 17:37:53 +0100
From: Daniel Wagner <[email protected]>
Subject: Re: simpler reproduction of connman error
To: Thomas Green <[email protected]>
Cc: connman <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
Hi Thomas,
I think I could reproduce it finally. After a bit of poking around I
think the problem is related with stale data in the settings
file. When switching between configuration mehtods (dhcp, manual) and
then disable autoconnect the settings file gets out of sync.
The good news is, we don't need to read and update the config
file. Instead we can just write it everytime from scratch. I've posted
a couple of patches which change the save code path. So this should
fix the problem you reported.
Thanks,
Daniel
------------------------------
Subject: Digest Footer
_______________________________________________
connman mailing list -- [email protected]
To unsubscribe send an email to [email protected]
------------------------------
End of connman Digest, Vol 50, Issue 12
***************************************