RE: IPv6 being disabled in some scenarios

2014-09-11 Thread Pasi Sjöholm
Hi Arjuna,

>We are currently investigating an issue with IPv6 getting disabled during a
>sequence when a user switches WIFi networks.

Noticed the same thing yesterday and was about to look into it today. ;)

>The sequence of events from the client perspective is:
>2. The user disconnects from NetworkA and connects to NetworkB

I can reproduce the problem if switch to another wifi while being connected to 
another. However if especially disconnect from the wifi I'm being connected 
currently and then connect to another wifi-network the ipv6 does not get 
disabled.

>As a potential fix/workaround, I've made the following change to enable
>IPv6 if IPv6 is not idle to service_lower_up():

>--- a/connman/src/service.c
>+++ b/connman/src/service.c
>@@ -6038,6 +6038,9 @@ static void service_lower_up(struct connman_ipconfig
>*ipconfig)
>
>   DBG("%s lower up", __connman_ipconfig_get_ifname(ipconfig));
>
>+   if (is_idle_state(service,service->state_ipv6) == FALSE)
>+   __connman_ipconfig_enable_ipv6(service->ipconfig_ipv6);
>+
>stats_start(service);
>}

>Thoughts? I suspect there is a more elegant way of doing this, and would
>appreciate any feedback.

Looks fine to me but I'm not the one to decide if it's good. ;)

Br,
Pasi
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH 3/4] network: Remove expired ipv6 address lease set to interface

2014-09-11 Thread pasi . sjoholm
From: Pasi Sjöholm 

If ipv6 address leased from dhcpv6 server somehow gets expired
it needs to be removed from the interface and not to be left
in place.
---
 src/network.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/network.c b/src/network.c
index d3ad83b..3fac525 100644
--- a/src/network.c
+++ b/src/network.c
@@ -594,6 +594,8 @@ static void autoconf_ipv6_set(struct connman_network 
*network)
if (!ipconfig)
return;
 
+   __connman_ipconfig_address_remove(ipconfig);
+
index = __connman_ipconfig_get_index(ipconfig);
 
connman_network_ref(network);
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman

[PATCH 4/4] dhcpv6: Remove the old ipv6 address from the interface

2014-09-11 Thread pasi . sjoholm
From: Pasi Sjöholm 

If interface gets assigned a new ipv6 address during renew/rebind
we need to make sure that the old ipv6 address is removed from
the interface and not left in place.
---
 src/dhcpv6.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/dhcpv6.c b/src/dhcpv6.c
index a5a7621..5f8029f 100644
--- a/src/dhcpv6.c
+++ b/src/dhcpv6.c
@@ -631,6 +631,7 @@ static void set_address(int ifindex, struct 
connman_ipconfig *ipconfig,
/* Is this prefix part of the subnet we are suppose to use? */
prefix_len = check_ipv6_addr_prefix(prefixes, address);
 
+   __connman_ipconfig_address_remove(ipconfig);
__connman_ipconfig_set_local(ipconfig, address);
__connman_ipconfig_set_prefixlen(ipconfig, prefix_len);
 
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman

[PATCH 1/4] dhcpv6: Reset last_request to current time with renew and rebind

2014-09-11 Thread pasi . sjoholm
From: Pasi Sjöholm 

last_request needs to be set current time also with renew and
rebind or otherwise the values set by
g_dhcpv6_client_get_timeouts will not be changed.

This fixes the issues with __connman_dhcpv6_start_renew and
check_restart comparing incorrect started,expired-values to current
time after successful renew/rebind.
---
 src/dhcpv6.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/dhcpv6.c b/src/dhcpv6.c
index a1a6e92..a5a7621 100644
--- a/src/dhcpv6.c
+++ b/src/dhcpv6.c
@@ -1119,6 +1119,7 @@ static void rebind_cb(GDHCPClient *dhcp_client, gpointer 
user_data)
 {
DBG("");
 
+   g_dhcpv6_client_reset_request(dhcp_client);
g_dhcpv6_client_clear_retransmit(dhcp_client);
 
re_cb(REQ_REBIND, dhcp_client, user_data);
@@ -1306,6 +1307,7 @@ static void renew_cb(GDHCPClient *dhcp_client, gpointer 
user_data)
 {
DBG("");
 
+   g_dhcpv6_client_reset_request(dhcp_client);
g_dhcpv6_client_clear_retransmit(dhcp_client);
 
re_cb(REQ_RENEW, dhcp_client, user_data);
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman

[PATCH 2/4] gdhcp: RFC3315 18.1.3 Allow setting valid lifetime to lower value

2014-09-11 Thread pasi . sjoholm
From: Pasi Sjöholm 

Server's value for valid lifetime can be set lower during during
rebind/renew if server configuration has been changed or if the
server wants to remove the address from the IA by setting valid
life time to zero.
---
 gdhcp/client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdhcp/client.c b/gdhcp/client.c
index 45922f1..88c0419 100644
--- a/gdhcp/client.c
+++ b/gdhcp/client.c
@@ -2047,7 +2047,7 @@ static GList *get_addresses(GDHCPClient *dhcp_client,
memcpy(&dhcp_client->ia_ta, &addr,
sizeof(struct in6_addr));
 
-   if (valid > dhcp_client->expire)
+   if (valid != dhcp_client->expire)
dhcp_client->expire = valid;
}
 
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman

[PATCH 0/4] Bunch of fixes to stateful dhcpv6/ipv6 related issues

2014-09-11 Thread pasi . sjoholm
From: Pasi Sjöholm 

1. last_request needs to be reset to the current time during renew/rebind
or otherwise the lease will be dropped after the initial expiration-value
has been passed.

2. dhcpv6 server can set lower valid lifetime due new configuration or it 
wants to remove the currently leased address from the IA.

3. Currently the expired leased ipv6 address is left in place, this will
make sure that the expired address is removed from the interface.

4. dhcpv6 server can assign a new ipv6 address during renew/rebind and
this will make sure that the old address is not left in place as otherwise
we might end up with hundreds of old and expired ipv6 addresses on the 
interface.

Pasi Sjöholm (4):
  dhcpv6: Reset last_request to current time with renew and rebind
  gdhcp: RFC3315 18.1.3 Allow setting valid lifetime to lower value
  network: Remove expired ipv6 address lease set to interface
  dhcpv6: Remove the old ipv6 address from the interface

 gdhcp/client.c | 2 +-
 src/dhcpv6.c   | 3 +++
 src/network.c  | 2 ++
 3 files changed, 6 insertions(+), 1 deletion(-)

-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman

IPv6 being disabled in some scenarios

2014-09-11 Thread Arjuna S
Hello,

We are currently investigating an issue with IPv6 getting disabled during a
sequence when a user switches WIFi networks.

The sequence of events from the client perspective is:
1. The device is connected over WiFi to some NetworkA with both an IPv4
address via DHCP and several IPv6 addresses via autoconf via RA's.
2. The user disconnects from NetworkA and connects to NetworkB
3. The device successfully connects to NetworkB, and obtains an IPv4
address via DHCP, however there is no IPv6 Link-Local address present.
There are no IPv6 routers present on NetworkB so we get Global addresses
are resolved via RA's as well.

>From my look at the code and enabling debugging, this sequence appears to
be happening:

I. Starting at (3), ConnMan gets the connect request and sets up two
IPConfig contexts to track IPv4 and IPv6 states. It consequently enables
IPv6 in the process via enable_ipv6().
II. At some point during the association/connection process, likely a
behavior of the underlying WiFi driver, the state of the wlan0 interface
goes from  to  triggering a service_lower_down().
service_lower_down() eventually calls disable_ipv6()
III. Shortly afterwards, the interface returns to the 
state. However IPv6 is still disabled.

This is not 100% reproducible, and have confirmed that IPv6 is still set to
"AUTO" through connmanctl.

I've found the following recovers things:
- Restarting only ConnMan
- Disconnecting and reconnecting to NetworkB
- Setting IPv6 to auto again via "connmanctl config NetworkB --ipv6 AUTO"


As a potential fix/workaround, I've made the following change to enable
IPv6 if IPv6 is not idle to service_lower_up():

--- a/connman/src/service.c
+++ b/connman/src/service.c
@@ -6038,6 +6038,9 @@ static void service_lower_up(struct connman_ipconfig
*ipconfig)

DBG("%s lower up", __connman_ipconfig_get_ifname(ipconfig));

+   if (is_idle_state(service,service->state_ipv6) == FALSE)
+   __connman_ipconfig_enable_ipv6(service->ipconfig_ipv6);
+
stats_start(service);
 }

We have a relatively old version of ConnMan, 1.11 but I checked this
morning for anything that was obviously a fix for the same bug and didn't
find anything.

Thoughts? I suspect there is a more elegant way of doing this, and would
appreciate any feedback.


-- 
-- Arjuna
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Connecting to ieee8021x access point

2014-09-11 Thread Thomas Green
All,

I'm currently running connman 1.21.  I am trying to connect to a ieee8021x 
access point.  It never connects saying that the credentials that I'm supplying 
is incorrect.  I've traced this down to __connman_service_set_passphrase where 
the service->immutable value is true, so it never sets the passphrase or 
attempts to connect.   What, (and why) would the immutable value be set to 
true, and why would this prevent the passphrase to be set, and the connection 
attempt to proceed?  Or, was this a problem that has been fixed in a later 
release?  What, at this point would be the best way to proceed?

Tom
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH] dhcp: Without gateway, the IP is always considered changed when a lease is received

2014-09-11 Thread Peter Meerwald
From: Peter Meerwald 

Connman constantly updates the IP when a lease without gateway is received, e.g.
connmand[7607]: eth0.42 {del} route 0.0.0.0 gw 0.0.0.0 scope 253 
connmand[7607]: eth0.42 {add} route 0.0.0.0 gw 0.0.0.0 scope 253 
connmand[7607]: eth0.42 {del} route 0.0.0.0 gw 0.0.0.0 scope 253 
connmand[7607]: eth0.42 {add} route 0.0.0.0 gw 0.0.0.0 scope 253 

the problematic condition in dhcp.c/lease_available_cb() is:
if (!c_address || !c_gateway)
  ip_change = true;
i.e. no address or gateway configured -> IP changed?!

the remaining checks need to be fixed as well, g_strcmp0() already handles
the case when one or both of the strings is NULL

Signed-off-by: Peter Meerwald 
---
 src/dhcp.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/dhcp.c b/src/dhcp.c
index 4436164..1360de2 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -443,14 +443,12 @@ static void lease_available_cb(GDHCPClient *dhcp_client, 
gpointer user_data)
 
DBG("c_address %s", c_address);
 
-   if (address && c_address && g_strcmp0(address, c_address) != 0)
+   if (g_strcmp0(address, c_address) != 0)
ip_change = true;
-   else if (gateway && c_gateway && g_strcmp0(gateway, c_gateway) != 0)
+   else if (g_strcmp0(gateway, c_gateway) != 0)
ip_change = true;
else if (prefixlen != c_prefixlen)
ip_change = true;
-   else if (!c_address || !c_gateway)
-   ip_change = true;
else
ip_change = false;
 
-- 
1.7.9.5

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


RE: [PATCH 1/2] dhcpv6: Do not let rebind and renew go crazy due too low T1 and T2

2014-09-11 Thread Pasi Sjöholm
>This problem does not actually exist. RFC 3315 says "In a message sent
>by a server to a client, the client MUST use the values in the T1 and T2
>fields for the T1 and T2 parameters..." unless they are zero.

Yes, this patch can be dropped. No need for it really..

Br,
Pasi
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


RE: [PATCH 2/2] dhcpv6: Reset last_request to current time with renew and rebind

2014-09-11 Thread Pasi Sjöholm
It also seems that I'm too tired as the patch works just fine. I should not 
read wrong log files.

No renew_cb or rebind_cb are called when either one of timeouts.

--cut--
src/dhcpv6.c:__connman_dhcpv6_start_renew() network 0x14db258 dhcp 0x14b9a88
src/dhcpv6.c:__connman_dhcpv6_start_renew() T1 16 T2 48 expires 1410432815 
current 1410432516 started 1410432515
src/dhcpv6.c:__connman_dhcpv6_start_renew() renew after 15 secs
src/dhcpv6.c:start_renew() renew initial RT timeout 9470 msec
src/dhcpv6.c:dhcpv6_renew() dhcp 0x14b9a88
src/dhcpv6.c:dhcpv6_debug() DHCPv6: sending DHCPv6 renew message xid 0xaf1498
src/dhcpv6.c:renew_cb() 
src/dhcpv6.c:__connman_dhcpv6_start_renew() network 0x14db258 dhcp 0x14b9a88
src/dhcpv6.c:__connman_dhcpv6_start_renew() T1 16 T2 48 expires 1410432831 
current 1410432532 started 1410432531
src/dhcpv6.c:__connman_dhcpv6_start_renew() renew after 15 secs
src/dhcpv6.c:start_renew() renew initial RT timeout 10630 msec
src/dhcpv6.c:dhcpv6_renew() dhcp 0x14b9a88
src/dhcpv6.c:dhcpv6_debug() DHCPv6: sending DHCPv6 renew message xid 0x23628d
src/dhcpv6.c:renew_cb() 
src/dhcpv6.c:__connman_dhcpv6_start_renew() network 0x14db258 dhcp 0x14b9a88
src/dhcpv6.c:__connman_dhcpv6_start_renew() T1 16 T2 48 expires 1410432847 
current 1410432548 started 1410432547
src/dhcpv6.c:__connman_dhcpv6_start_renew() renew after 15 secs
src/dhcpv6.c:start_renew() renew initial RT timeout 9580 msec
src/dhcpv6.c:dhcpv6_renew() dhcp 0x14b9a88
src/dhcpv6.c:dhcpv6_debug() DHCPv6: sending DHCPv6 renew message xid 0x17df8c
src/dhcpv6.c:timeout_renew() renew RT timeout 19485 msec
src/dhcpv6.c:dhcpv6_debug() DHCPv6: sending DHCPv6 renew message xid 0x17df8c
src/dhcpv6.c:timeout_renew() renew RT timeout 38560 msec
src/dhcpv6.c:dhcpv6_debug() DHCPv6: sending DHCPv6 renew message xid 0x17df8c
src/dhcpv6.c:start_rebind() rebind initial RT timeout 10530 msec
src/dhcpv6.c:dhcpv6_rebind() dhcp 0x14b9a88
src/dhcpv6.c:dhcpv6_debug() DHCPv6: sending DHCPv6 rebind message xid 0x17df8c
src/dhcpv6.c:timeout_rebind() rebind RT timeout 20228 msec
src/dhcpv6.c:dhcpv6_debug() DHCPv6: sending DHCPv6 rebind message xid 0x17df8c
src/dhcpv6.c:timeout_rebind() rebind RT timeout 42033 msec
src/dhcpv6.c:dhcpv6_debug() DHCPv6: sending DHCPv6 rebind message xid 0x17df8c
src/dhcpv6.c:rebind_cb() 
src/dhcpv6.c:__connman_dhcpv6_start_renew() network 0x14db258 dhcp 0x14b9a88
src/dhcpv6.c:__connman_dhcpv6_start_renew() T1 16 T2 48 expires 1410432962 
current 1410432663 started 1410432662
src/dhcpv6.c:__connman_dhcpv6_start_renew() renew after 15 secs
src/dhcpv6.c:start_renew() renew initial RT timeout 10240 msec
src/dhcpv6.c:dhcpv6_renew() dhcp 0x14b9a88
src/dhcpv6.c:dhcpv6_debug() DHCPv6: sending DHCPv6 renew message xid 0x4b1203
src/dhcpv6.c:renew_cb() 
src/dhcpv6.c:__connman_dhcpv6_start_renew() network 0x14db258 dhcp 0x14b9a88
src/dhcpv6.c:__connman_dhcpv6_start_renew() T1 16 T2 48 expires 1410432978 
current 1410432679 started 1410432678
src/dhcpv6.c:__connman_dhcpv6_start_renew() renew after 15 secs
--cut--


Br,
Pasi

From: Pasi Sjöholm
Sent: Thursday, September 11, 2014 12:42
To: connman@connman.net
Subject: RE: [PATCH 2/2] dhcpv6: Reset last_request to current time with renew 
and rebind

It would seem that the last_request is also updated on timed out renew/rebind, 
so need to rework this patch.

From: connman [connman-boun...@connman.net] on behalf of pasi.sjoh...@jolla.com 
[pasi.sjoh...@jolla.com]
Sent: Thursday, September 11, 2014 01:03
To: connman@connman.net
Subject: [PATCH 2/2] dhcpv6: Reset last_request to current time with renew and 
rebind

From: Pasi Sjöholm 

last_request needs to be set current time also with renew and
rebind or otherwise the values set by
g_dhcpv6_client_get_timeouts will not be changed.

This fixes the issues with __connman_dhcpv6_start_renew and
check_restart comparing incorrect started,expired-values to current
time after successful renew/rebind.
---
 src/dhcpv6.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/dhcpv6.c b/src/dhcpv6.c
index 00dba3a..96bfb38 100644
--- a/src/dhcpv6.c
+++ b/src/dhcpv6.c
@@ -1119,6 +1119,7 @@ static void rebind_cb(GDHCPClient *dhcp_client, gpointer 
user_data)
 {
DBG("");

+   g_dhcpv6_client_reset_request(dhcp_client);
g_dhcpv6_client_clear_retransmit(dhcp_client);

re_cb(REQ_REBIND, dhcp_client, user_data);
@@ -1306,6 +1307,7 @@ static void renew_cb(GDHCPClient *dhcp_client, gpointer 
user_data)
 {
DBG("");

+   g_dhcpv6_client_reset_request(dhcp_client);
g_dhcpv6_client_clear_retransmit(dhcp_client);

re_cb(REQ_RENEW, dhcp_client, user_data);
--
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


RE: [PATCH 2/2] dhcpv6: Reset last_request to current time with renew and rebind

2014-09-11 Thread Pasi Sjöholm
It would seem that the last_request is also updated on timed out renew/rebind, 
so need to rework this patch.

From: connman [connman-boun...@connman.net] on behalf of pasi.sjoh...@jolla.com 
[pasi.sjoh...@jolla.com]
Sent: Thursday, September 11, 2014 01:03
To: connman@connman.net
Subject: [PATCH 2/2] dhcpv6: Reset last_request to current time with renew and 
rebind

From: Pasi Sjöholm 

last_request needs to be set current time also with renew and
rebind or otherwise the values set by
g_dhcpv6_client_get_timeouts will not be changed.

This fixes the issues with __connman_dhcpv6_start_renew and
check_restart comparing incorrect started,expired-values to current
time after successful renew/rebind.
---
 src/dhcpv6.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/dhcpv6.c b/src/dhcpv6.c
index 00dba3a..96bfb38 100644
--- a/src/dhcpv6.c
+++ b/src/dhcpv6.c
@@ -1119,6 +1119,7 @@ static void rebind_cb(GDHCPClient *dhcp_client, gpointer 
user_data)
 {
DBG("");

+   g_dhcpv6_client_reset_request(dhcp_client);
g_dhcpv6_client_clear_retransmit(dhcp_client);

re_cb(REQ_REBIND, dhcp_client, user_data);
@@ -1306,6 +1307,7 @@ static void renew_cb(GDHCPClient *dhcp_client, gpointer 
user_data)
 {
DBG("");

+   g_dhcpv6_client_reset_request(dhcp_client);
g_dhcpv6_client_clear_retransmit(dhcp_client);

re_cb(REQ_RENEW, dhcp_client, user_data);
--
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: [PATCH 1/2] dhcpv6: Do not let rebind and renew go crazy due too low T1 and T2

2014-09-11 Thread Patrik Flykt
On Thu, 2014-09-11 at 10:15 +0300, Patrik Flykt wrote:
> The second problem is that ConnMan needs to keep in mind also T2 and
> address expiry values. By only checking against T1 it is possible to
> construct a case where the server sets T1 to 5 seconds, T2 to 7
> seconds and address expiry to 9 seconds. That means the address
> expires from the server before ConnMan even gets to T1. Thus the check
> should be done with expiry time in mind, and expiry should be checked
> that it is greater than T2.

This problem does not actually exist. RFC 3315 says "In a message sent
by a server to a client, the client MUST use the values in the T1 and T2
fields for the T1 and T2 parameters..." unless they are zero.

Cheers,

Patrik


___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: [PATCH 1/2] dhcpv6: Do not let rebind and renew go crazy due too low T1 and T2

2014-09-11 Thread Patrik Flykt

Hi,

On Thu, 2014-09-11 at 01:03 +0300, pasi.sjoh...@jolla.com wrote:
> From: Pasi Sjöholm 
> 
> Force minimum T1 and T2 to prevent renew and rebind go grazy if
> the lease is not getting renew or rebound.
> ---
>  src/dhcpv6.c | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/src/dhcpv6.c b/src/dhcpv6.c
> index a1a6e92..00dba3a 100644
> --- a/src/dhcpv6.c
> +++ b/src/dhcpv6.c
> @@ -1428,6 +1428,11 @@ int __connman_dhcpv6_start_renew(struct 
> connman_network *network,
>*/
>   T1 = (expired - started) / 2;
>   T2 = (expired - started) / 10 * 8;
> +
> + if (T1 < 10) {
> + T1 = 10;
> + T2 = 16;
> + }
>   }

First of all, this check needs to be done on all values of T1, T2, not
only the ones ConnMan computes in response to them being zero.

The second problem is that ConnMan needs to keep in mind also T2 and
address expiry values. By only checking against T1 it is possible to
construct a case where the server sets T1 to 5 seconds, T2 to 7 seconds
and address expiry to 9 seconds. That means the address expires from the
server before ConnMan even gets to T1. Thus the check should be done
with expiry time in mind, and expiry should be checked that it is
greater than T2.

Cheers,

Patrik


___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman