[PATCH v2] ipconfig: Toggle interface IPv6 status if IPv6 ipconfig is enabled or disabled.
This is done so that if service is disconnected, the kernel created autoconf routes need to be cleared also. That can be done easiest by disabling IPv6 for that interface. The disabling of IPv6 is only done for autoconfigured interfaces. When service is connected, the IPv6 is enabled for the used interface. --- Hi, this is the second version of the patch. No code changes, just fixed the changelog to describe the problem properly. Regards, Jukka src/ipconfig.c | 61 ++- 1 files changed, 33 insertions(+), 28 deletions(-) diff --git a/src/ipconfig.c b/src/ipconfig.c index 14edb3d..62d3766 100644 --- a/src/ipconfig.c +++ b/src/ipconfig.c @@ -1351,6 +1351,34 @@ const char *__connman_ipconfig_get_proxy_autoconfig(struct connman_ipconfig *ipc return ipdevice-pac; } +static void disable_ipv6(struct connman_ipconfig *ipconfig) +{ + struct connman_ipdevice *ipdevice; + + DBG(); + + ipdevice = g_hash_table_lookup(ipdevice_hash, + GINT_TO_POINTER(ipconfig-index)); + if (ipdevice == NULL) + return; + + set_ipv6_state(ipdevice-ifname, FALSE); +} + +static void enable_ipv6(struct connman_ipconfig *ipconfig) +{ + struct connman_ipdevice *ipdevice; + + DBG(); + + ipdevice = g_hash_table_lookup(ipdevice_hash, + GINT_TO_POINTER(ipconfig-index)); + if (ipdevice == NULL) + return; + + set_ipv6_state(ipdevice-ifname, TRUE); +} + int __connman_ipconfig_enable(struct connman_ipconfig *ipconfig) { struct connman_ipdevice *ipdevice; @@ -1376,6 +1404,7 @@ int __connman_ipconfig_enable(struct connman_ipconfig *ipconfig) if (ipdevice-config_ipv6 == ipconfig) return -EALREADY; type = CONNMAN_IPCONFIG_TYPE_IPV6; + enable_ipv6(ipconfig); } else return -EINVAL; @@ -1459,6 +1488,10 @@ int __connman_ipconfig_disable(struct connman_ipconfig *ipconfig) if (ipdevice-config_ipv6 == ipconfig) { ipconfig_list = g_list_remove(ipconfig_list, ipconfig); + if (ipdevice-config_ipv6-method == + CONNMAN_IPCONFIG_METHOD_AUTO) + disable_ipv6(ipdevice-config_ipv6); + connman_ipaddress_clear(ipdevice-config_ipv6-system); connman_ipconfig_unref(ipdevice-config_ipv6); ipdevice-config_ipv6 = NULL; @@ -1662,34 +1695,6 @@ void __connman_ipconfig_append_ipv4config(struct connman_ipconfig *ipconfig, DBUS_TYPE_STRING, ipconfig-address-gateway); } -static void disable_ipv6(struct connman_ipconfig *ipconfig) -{ - struct connman_ipdevice *ipdevice; - - DBG(); - - ipdevice = g_hash_table_lookup(ipdevice_hash, - GINT_TO_POINTER(ipconfig-index)); - if (ipdevice == NULL) - return; - - set_ipv6_state(ipdevice-ifname, FALSE); -} - -static void enable_ipv6(struct connman_ipconfig *ipconfig) -{ - struct connman_ipdevice *ipdevice; - - DBG(); - - ipdevice = g_hash_table_lookup(ipdevice_hash, - GINT_TO_POINTER(ipconfig-index)); - if (ipdevice == NULL) - return; - - set_ipv6_state(ipdevice-ifname, TRUE); -} - int __connman_ipconfig_set_config(struct connman_ipconfig *ipconfig, DBusMessageIter *array) { -- 1.7.0.4 ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
[PATCH] ofono: Fix memory leak in network activation
--- plugins/ofono.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/plugins/ofono.c b/plugins/ofono.c index 29aaa61..066e9b7 100644 --- a/plugins/ofono.c +++ b/plugins/ofono.c @@ -444,7 +444,7 @@ static int set_network_active(struct connman_network *network, error = set_property(path, OFONO_CONTEXT_INTERFACE, Active, DBUS_TYPE_BOOLEAN, active, - set_active_reply, g_strdup(path), NULL); + set_active_reply, g_strdup(path), g_free); if (active == FALSE error == -EINPROGRESS) error = 0; -- 1.7.0.4 ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
[PATCH] ofono: Fix infinite recursion in network disconnect
--- If association takes too long and connection timeout goes off, then connman will try to disconnect and ends up in infinite recursion when __connman_network_disconnect() and connman_network_set_connected() call each other. Same bug was reported and fixed in wifi plugin too: http://www.mail-archive.com/connman@connman.net/msg02021.html http://www.mail-archive.com/connman@connman.net/msg02029.html - Henri plugins/ofono.c |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/plugins/ofono.c b/plugins/ofono.c index 29aaa61..66e5975 100644 --- a/plugins/ofono.c +++ b/plugins/ofono.c @@ -489,6 +489,8 @@ static int network_disconnect(struct connman_network *network) if (connman_network_get_index(network) 0) return -ENOTCONN; + connman_network_set_associating(network, FALSE); + return set_network_active(network, FALSE); } -- 1.7.0.4 ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
[PATCH privacy v2 0/3] Enable/disable IPv6 privacy extension
Hi, this is the v2 of the IPv6 privacy patch. This version makes the privacy setting configurable. The privacy setting can be changed in service API via IPv6.Configuration property. I used the same values for privacy setting as described in the kernel documentation Documentation/networking/ip-sysctl.txt file so that the mapping between those two is simple. By default the privacy setting is 1, meaning it is enabled but public addresses are prefered over temporary ones. The privacy value is only written to kernel if IPv6 method is AUTO. Note that the kernel might not activate the privacy mode immediately, it seems to require that interface goes down before activation. Same thing happens if privacy mode is disabled, the temporary addresses do not disappear until the interface is taken down. At least this was happening in my test system with kernel 2.6.32. Regards, Jukka Jukka Rissanen (3): doc: Add description about IPv6 privacy setting. ipconfig: Enable IPv6 privacy extension for autoconf addresses. test: Enable or disable IPv6 privacy extension. doc/service-api.txt | 18 src/ipconfig.c | 113 -- test/set-ipv6-method | 18 +--- 3 files changed, 138 insertions(+), 11 deletions(-) ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
[PATCH privacy v2 2/3] ipconfig: Enable IPv6 privacy extension for autoconf addresses.
--- src/ipconfig.c | 113 ++-- 1 files changed, 109 insertions(+), 4 deletions(-) diff --git a/src/ipconfig.c b/src/ipconfig.c index 1fb8281..481133b 100644 --- a/src/ipconfig.c +++ b/src/ipconfig.c @@ -51,6 +51,8 @@ struct connman_ipconfig { enum connman_ipconfig_method method; struct connman_ipaddress *address; struct connman_ipaddress *system; + + int ipv6_privacy; }; struct connman_ipdevice { @@ -79,6 +81,7 @@ struct connman_ipdevice { struct connman_ipconfig *config_ipv6; gboolean ipv6_enabled; + int ipv6_privacy; }; static GHashTable *ipdevice_hash = NULL; @@ -352,6 +355,67 @@ static void set_ipv6_state(gchar *ifname, gboolean enable) fclose(f); } +static int get_ipv6_privacy(gchar *ifname) +{ + gchar *path; + FILE *f; + int value; + + if (ifname == NULL) + return 0; + + path = g_strdup_printf(/proc/sys/net/ipv6/conf/%s/use_tempaddr, + ifname); + + if (path == NULL) + return 0; + + f = fopen(path, r); + + g_free(path); + + if (f == NULL) + return 0; + + if (fscanf(f, %d, value) = 0) + value = 0; + + fclose(f); + + return value; +} + +/* Enable the IPv6 privacy extension for stateless address autoconfiguration. + * The privacy extension is described in RFC 3041 and RFC 4941 + */ +static void set_ipv6_privacy(gchar *ifname, int value) +{ + gchar *path; + FILE *f; + + if (ifname == NULL) + return; + + path = g_strdup_printf(/proc/sys/net/ipv6/conf/%s/use_tempaddr, + ifname); + + if (path == NULL) + return; + + if (value 0) + value = 0; + + f = fopen(path, r+); + + g_free(path); + + if (f == NULL) + return; + + fprintf(f, %d, value); + fclose(f); +} + static void free_ipdevice(gpointer data) { struct connman_ipdevice *ipdevice = data; @@ -377,6 +441,7 @@ static void free_ipdevice(gpointer data) g_free(ipdevice-address); set_ipv6_state(ipdevice-ifname, ipdevice-ipv6_enabled); + set_ipv6_privacy(ipdevice-ifname, ipdevice-ipv6_privacy); g_free(ipdevice-ifname); g_free(ipdevice); @@ -474,6 +539,7 @@ void __connman_ipconfig_newlink(int index, unsigned short type, ipdevice-type = type; ipdevice-ipv6_enabled = get_ipv6_state(ipdevice-ifname); + ipdevice-ipv6_privacy = get_ipv6_privacy(ipdevice-ifname); ipdevice-address = g_strdup(address); @@ -926,6 +992,7 @@ static struct connman_ipconfig *create_ipv6config(int index) ipv6config-index = index; ipv6config-type = CONNMAN_IPCONFIG_TYPE_IPV6; ipv6config-method = CONNMAN_IPCONFIG_METHOD_AUTO; + ipv6config-ipv6_privacy = 1; ipv6config-address = connman_ipaddress_alloc(AF_INET6); if (ipv6config-address == NULL) { @@ -1496,6 +1563,9 @@ void __connman_ipconfig_append_ipv6(struct connman_ipconfig *ipconfig, if (ipconfig-system-gateway != NULL) connman_dbus_dict_append_basic(iter, Gateway, DBUS_TYPE_STRING, ipconfig-system-gateway); + + connman_dbus_dict_append_basic(iter, Privacy, + DBUS_TYPE_INT32, ipconfig-ipv6_privacy); } void __connman_ipconfig_append_ipv6config(struct connman_ipconfig *ipconfig, @@ -1536,6 +1606,9 @@ void __connman_ipconfig_append_ipv6config(struct connman_ipconfig *ipconfig, if (ipconfig-address-gateway != NULL) connman_dbus_dict_append_basic(iter, Gateway, DBUS_TYPE_STRING, ipconfig-address-gateway); + + connman_dbus_dict_append_basic(iter, Privacy, + DBUS_TYPE_INT32, ipconfig-ipv6_privacy); } void __connman_ipconfig_append_ipv4config(struct connman_ipconfig *ipconfig, @@ -1610,6 +1683,9 @@ static void enable_ipv6(struct connman_ipconfig *ipconfig) if (ipdevice == NULL) return; + if (ipconfig-method == CONNMAN_IPCONFIG_METHOD_AUTO) + set_ipv6_privacy(ipdevice-ifname, ipconfig-ipv6_privacy); + set_ipv6_state(ipdevice-ifname, TRUE); } @@ -1618,8 +1694,8 @@ int __connman_ipconfig_set_config(struct connman_ipconfig *ipconfig, { enum connman_ipconfig_method method = CONNMAN_IPCONFIG_METHOD_UNKNOWN; const char *address = NULL, *netmask = NULL, *gateway = NULL, - *prefix_length_string = NULL; - int prefix_length = 0; + *prefix_length_string = NULL, *privacy_string = NULL; + int prefix_length = 0, privacy = 1; DBusMessageIter dict; DBG(ipconfig %p, ipconfig); @@ -1678,12 +1754,24 @@ int
[PATCH privacy v2 3/3] test: Enable or disable IPv6 privacy extension.
--- test/set-ipv6-method | 18 +++--- 1 files changed, 11 insertions(+), 7 deletions(-) diff --git a/test/set-ipv6-method b/test/set-ipv6-method index 274e89b..c0b251e 100755 --- a/test/set-ipv6-method +++ b/test/set-ipv6-method @@ -4,7 +4,7 @@ import sys import dbus def print_usage(): - print Usage: %s service off|manual|auto [address [prefixlen] [gateway]] % (sys.argv[0]) + print Usage: %s service off|manual|auto [address [prefixlen] [gateway]] [privacy] % (sys.argv[0]) if (len(sys.argv) 3): print_usage() @@ -20,12 +20,16 @@ properties = service.GetProperties() print Setting method %s for %s % (sys.argv[2], sys.argv[1]) ipv6_configuration = { Method: sys.argv[2] } -if (len(sys.argv) 3): - ipv6_configuration[Address] = sys.argv[3] -if (len(sys.argv) 4): - ipv6_configuration[PrefixLength] = sys.argv[4] -if (len(sys.argv) 5): - ipv6_configuration[Gateway] = sys.argv[5] +if sys.argv[2] == auto: + if (len(sys.argv) 3): + ipv6_configuration[Privacy] = sys.argv[3] +else: + if (len(sys.argv) 3): + ipv6_configuration[Address] = sys.argv[3] + if (len(sys.argv) 4): + ipv6_configuration[PrefixLength] = sys.argv[4] + if (len(sys.argv) 5): + ipv6_configuration[Gateway] = sys.argv[5] service.SetProperty(IPv6.Configuration, ipv6_configuration) print New IPv6.Configuration: , ipv6_configuration -- 1.7.0.4 ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
[PATCH privacy v2 1/3] doc: Add description about IPv6 privacy setting.
--- doc/service-api.txt | 18 ++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/doc/service-api.txt b/doc/service-api.txt index b3e758e..55c5b6e 100644 --- a/doc/service-api.txt +++ b/doc/service-api.txt @@ -375,6 +375,24 @@ Properties string State [readonly] The current configured IPv6 gateway. + int32 Privacy [readonly] + + Enable or disable IPv6 privacy extension + that is described in RFC 4941. The value + has only meaning if Method is set to auto. + + Value = 0 means that privacy extension is + disabled and normal autoconf addresses are + used. + Value 1 means that privacy extension is + enabled and system prefers to use public + addresses over temporary addresses. + Value = 2 means that privacy extension is + enabled and system prefers temporary addresses + over public addresses. + + Default value is 1. + dict IPv6.Configuration [readwrite] Same values as IPv6 property. The IPv6 represents -- 1.7.0.4 ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
Re: Memory Leaks When Using Statistics (was Re: [PATCH 1/1]: Fix Memory-map and Double-free Errors in Statistics Handling (was Re: Connman-0.67 Crashes and/or Hangs on Start-up))
Hi Grant, On 17 February 2011 20:10, Grant Erickson maratho...@gmail.com wrote: To isolate the leaks, I systematically eliminated processes from the system until I was left with: - syslogd - klogd - wpa_supplicant - dbus-daemon - connmand I have run connmand under valgrind and it reports memory leaks in gsupplicant code. I sent earlier some memoryleak patches in various parts of connman but unfortunately I have lately had no time to find out where the latest supplicant leaks are. Regards, Jukka ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
[PATCH] Ignore Malformed Profiles
Ignore malformed profiles. That is, if there is no non-extension portion to the file (i.e. it is precisely named .profile), then ignore it. Passing such files to create_profile will result in a SIGABRT. Signed-off-by: Grant Erickson maratho...@gmail.com diff --git a/src/profile.c b/src/profile.c index 3018fdc..d690dd7 100644 --- a/src/profile.c +++ b/src/profile.c @@ -462,6 +462,17 @@ static int profile_init(void) if (ident == NULL) continue; + /* If there is no non-extension portion to the file +* (i.e. it is precisely named .profile), then ignore +* it. Passing such files to create_profile will result in +* a SIGABRT. +*/ + + if (file == ident) { + connman_info(Ignoring malformed profile '%s'\n, file); + continue; + } + str = g_string_new_len(file, ident - file); if (str == NULL) continue; -- 1.7.3.4 ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
[PATCH] Avoid More Double-Frees When Deallocating Statistics on a Failed Mapping
Added debugging statements and ensure, following calls to g_free, that the statistics file name field is set to NULL to ensure that a failed file mapping and a subsequent call to stats_free doesn't fault when trying to double-free it. Added an informational message when mmap fails with EINVAL in stats_file_remap. Signed-off-by: Grant Erickson maratho...@gmail.com diff --git a/src/stats.c b/src/stats.c index 679a372..243a9b8 100644 --- a/src/stats.c +++ b/src/stats.c @@ -214,26 +214,27 @@ static void stats_free(gpointer user_data) { struct stats_file *file = user_data; - msync(file-addr, file-len, MS_SYNC); + if (file) { + msync(file-addr, file-len, MS_SYNC); - munmap(file-addr, file-len); - file-addr = NULL; + munmap(file-addr, file-len); + file-addr = NULL; - TFR(close(file-fd)); - file-fd = -1; + TFR(close(file-fd)); + file-fd = -1; - if (file-history_name != NULL) { - g_free(file-history_name); - file-history_name = NULL; - } + if (file-history_name != NULL) { + g_free(file-history_name); + file-history_name = NULL; + } - if (file-name != NULL) { - g_free(file-name); - file-name = NULL; - } + if (file-name != NULL) { + g_free(file-name); + file-name = NULL; + } - if (file != NULL) g_free(file); + } } static void update_first(struct stats_file *file) @@ -275,6 +276,8 @@ static int stats_file_remap(struct stats_file *file, size_t size) void *addr; int err; + DBG(file %p size %u addr %p len %u, file, size, file-addr, file-len); + page_size = sysconf(_SC_PAGESIZE); new_size = (size + page_size - 1) ~(page_size - 1); @@ -288,9 +291,10 @@ static int stats_file_remap(struct stats_file *file, size_t size) if (file-addr == NULL) { /* * Though the buffer is not shared between processes, we still -* have to take MAP_SHARED because MAP_PRIVATE does not guarantee -* that writes will hit the file eventually. For more details -* please read the mmap man pages. +* have to take MAP_SHARED because MAP_PRIVATE does not +* guarantee that writes will hit the file without an explicit +* call to munmap or msync. For more details please read the +* mmap man pages. */ addr = mmap(NULL, new_size, PROT_READ | PROT_WRITE, MAP_SHARED, file-fd, 0); @@ -301,6 +305,10 @@ static int stats_file_remap(struct stats_file *file, size_t size) if (addr == MAP_FAILED) { connman_error(mmap error %s for %s, strerror(errno), file-name); + if (errno == EINVAL) { + connman_error(%s might be on a file system, such as JFFS2, that + does not allow shared writable mappings., file-name); + } return -errno; } @@ -315,6 +323,8 @@ static int stats_file_remap(struct stats_file *file, size_t size) static int stats_open(struct stats_file *file, const char *name) { + DBG(file %p name %s, file, name); + file-name = g_strdup(name); file-fd = TFR(open(file-name, O_RDWR | O_CREAT, 0644)); @@ -322,6 +332,7 @@ static int stats_open(struct stats_file *file, connman_error(open error %s for %s, strerror(errno), file-name); g_free(file-name); + file-name = NULL; return -errno; } @@ -337,6 +348,7 @@ static int stats_open_temp(struct stats_file *file) connman_error(create tempory file error %s for %s, strerror(errno), file-name); g_free(file-name); + file-name = NULL; return -errno; } @@ -350,6 +362,8 @@ static int stats_file_setup(struct stats_file *file) size_t size = 0; int err; + DBG(file %p fd %d name %s, file, file-fd, file-name); + err = fstat(file-fd, st); if (err 0) { connman_error(fstat error %s for %s\n, @@ -357,6 +371,7 @@ static int stats_file_setup(struct stats_file *file) TFR(close(file-fd)); g_free(file-name); + file-name = NULL; return -errno; } @@ -371,6 +386,7 @@ static int stats_file_setup(struct stats_file *file) if (err 0) { TFR(close(file-fd)); g_free(file-name); + file-name = NULL;
Re: [PATCH 1/1]: Fix Memory-map and Double-free Errors in Statistics Handling (was Re: Connman-0.67 Crashes and/or Hangs on Start-up)
On 2/17/11 12:13 PM, Daniel Wagner wrote: On 02/17/2011 05:38 PM, Grant Erickson wrote: Thanks for taking the time to submit a comment for the code detailing the motivation for selecting MAP_PRIVATE. I have done some more research to determine why the MAP_SHARED fails on my platform. From what I can see, this is a limitation of JFFS2. For it's mmap method, it specifies: % grep 'mmap' linux/fs/jffs2/*.c linux/fs/jffs2/file.c:.mmap =generic_file_readonly_mmap, So, in short, for JFFS2 users in a top-of-tree kernel, connman statistics will never work with a PROT_WRITE + MAP_SHARED mapping. Thanks for tracking this down. In this case, it might make sense to add some fallback. My idea is to use MAP_PRIVATE and write the whole contents into a file after a certain period. The whole idea behind MAP_SHARED is to make sure the data really hits the disk. But until now, nobody with deep understanding of filesystem under Linux has done a review. So the current approach might be bogus. So if you are fine with having a fallback to MAP_PRIVATE + periodic write a file, then we should add this feature. Opinions? Were I writing this anew, I think I'd have skipped the mmap altogether, maintained the statistics in memory and flushed things out to a file at the appropriate times. Working with what's there, I think I'd do away with MAP_SHARED, convert the mapping to MAP_PRIVATE and then call msync within the _stats_update path. All that is said, however, without a savvy perspective on how statistic are used within connman. Best, Grant ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
Re: [PATCH v2] ipconfig: Toggle interface IPv6 status if IPv6 ipconfig is enabled or disabled.
Hi Jukka, On Thu, Feb 17, 2011 at 09:59:30AM +0200, Jukka Rissanen wrote: This is done so that if service is disconnected, the kernel created autoconf routes need to be cleared also. That can be done easiest by disabling IPv6 for that interface. The disabling of IPv6 is only done for autoconfigured interfaces. When service is connected, the IPv6 is enabled for the used interface. Patch applied, thanks. Cheers, Samuel. -- Intel Open Source Technology Centre http://oss.intel.com/ ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
Re: [PATCH] ofono: Fix memory leak in network activation
Hi Henri, On Thu, Feb 17, 2011 at 01:51:25PM +0200, Henri Bragge wrote: --- plugins/ofono.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) Patch applied, thanks a lot. Cheers, Samuel. diff --git a/plugins/ofono.c b/plugins/ofono.c index 29aaa61..066e9b7 100644 --- a/plugins/ofono.c +++ b/plugins/ofono.c @@ -444,7 +444,7 @@ static int set_network_active(struct connman_network *network, error = set_property(path, OFONO_CONTEXT_INTERFACE, Active, DBUS_TYPE_BOOLEAN, active, - set_active_reply, g_strdup(path), NULL); + set_active_reply, g_strdup(path), g_free); if (active == FALSE error == -EINPROGRESS) error = 0; -- 1.7.0.4 ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman -- Intel Open Source Technology Centre http://oss.intel.com/ ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
Re: [PATCH] ofono: Fix infinite recursion in network disconnect
Hi Henri, On Thu, Feb 17, 2011 at 01:51:47PM +0200, Henri Bragge wrote: --- If association takes too long and connection timeout goes off, then connman will try to disconnect and ends up in infinite recursion when __connman_network_disconnect() and connman_network_set_connected() call each other. Thanks. The above comment should be part of the changelog. I added it manually while applying your patch, but for this sort of non trivial patches I'd like to get relevant changelogs. Cheers, Samuel. -- Intel Open Source Technology Centre http://oss.intel.com/ ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman