[PATCH autoconf v3 06/12] ipv6: Clear the IPv6 address if that address is removed from system

Samuel Ortiz sameo at linux.intel.com
Mon Jan 10 11:59:01 PST 2011


Hi Jukka,

On Mon, Jan 10, 2011 at 01:45:15PM +0000, Jukka.Rissanen at nokia.com wrote:
> Hi Samuel,
> 
> ext Samuel Ortiz wrote:
> > Hi Jukka,
> > 
> > On Fri, Jan 07, 2011 at 02:55:13PM +0200, Jukka Rissanen wrote:
> >> ---
> >>  src/ipconfig.c |    9 +++++++++
> >>  1 files changed, 9 insertions(+), 0 deletions(-)
> >> 
> >> diff --git a/src/ipconfig.c b/src/ipconfig.c index 7a14c42..2c0ede6
> >> 100644 --- a/src/ipconfig.c
> >> +++ b/src/ipconfig.c
> >> @@ -616,6 +616,15 @@ void __connman_ipconfig_deladdr(int index, int
> >>  	family, const char *label, ipdevice->address_list =
> >> g_slist_remove(ipdevice->address_list, ipaddress); 
> >> 
> >> +	if (family == AF_INET6 && ipdevice->config_ipv6 &&
> >> +		ipdevice->config_ipv6->system &&
> >> +		ipdevice->config_ipv6->system->prefixlen ==
> >> +						ipaddress->prefixlen &&
> >> +		g_strcmp0(ipdevice->config_ipv6->system->local,
> >> +				ipaddress->local) == 0) {
> >> +		connman_ipaddress_clear(ipdevice->config_ipv6->system); +	}
> >> +
> > Why do we need to do that for IPv6, and why can't we just do:
> > 
> > if (family == AF_INET6)
> > 	connman_ipaddress_clear(ipaddress);
> > 
> 
> The reason for the code is that if user sets IPv6 to OFF, then __connman_ipconfig_deladdr() will be called for each IPv6 address in the system. The patch removes the currently configured system address so that it won't be shown if the user gets services via dbus.
> 
I see what you mean, thanks.
I think it would make sense to clear the address every time deladdr is called,
not only for the IPv6 system address. Something like that:

diff --git a/src/ipconfig.c b/src/ipconfig.c
index 6ef39c5..bd664f3 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -682,7 +682,8 @@ void __connman_ipconfig_deladdr(int index, int family,
const
        ipdevice->address_list = g_slist_remove(ipdevice->address_list,
                                                                ipaddress);
 
-       connman_ipaddress_free(ipaddress);
+       connman_ipaddress_clear(ipaddress);
+       g_free(ipaddress);
 
        connman_info("%s {del} address %s/%u label %s", ipdevice->ifname,
                                                address, prefixlen, label);


> So without the patch list-services would return
> 
> IPv6 = { PrefixLength=64 Method=off Address=2001::1 }
I don't know if you actually tested it, but that would be de-referencing an
already freed pointer. So we definitely need to do something about it.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/



More information about the connman mailing list