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

2014-09-10 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 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

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

2014-09-10 Thread pasi . sjoholm
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;
+   }
}
 
dhcp->callback = callback;
-- 
1.9.1

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

[PATCH 0/2] dhcpv6 t1/t2 fallback-values and reset last_request during renew/rebind

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

Couple more issues which I found today playing with the stateful dhcpv6.

1. Protect T1/T2 timers to minimum of 10/16 seconds so that the
renew/rebind will not go grazy with smaller values.
2. 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.

Pasi Sjöholm (2):
  dhcpv6: Do not let rebind and renew go crazy due too low T1 and T2
  dhcpv6: Reset last_request to current time with renew and rebind

 src/dhcpv6.c | 7 +++
 1 file changed, 7 insertions(+)

-- 
1.9.1

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

Re: [PATCH] dhcpv6: Remove CONFIRM message sending when connecting a link

2014-09-10 Thread Patrik Flykt
On Wed, 2014-09-10 at 13:10 +0300, Jukka Rissanen wrote:
> The CONFIRM message is not sent any more as it does not make much
> sense because we do not save address expiration time so we cannot
> really know how long the saved address is valid anyway.
> 
> The reply to CONFIRM message does not send expiration times back
> to us so we cannot get them from server either. Because of this
> we need to start using SOLICITATION anyway when a link is
> connected.
> 
> Thanks to Pasi Sjöholm for reporting this.

Applied, thanks!

Patrik

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

Re: [PATCH v2] service: Reset the IPv6.Privacy to interface default when service is removed

2014-09-10 Thread Patrik Flykt
On Wed, 2014-09-10 at 13:42 +0300, pasi.sjoh...@jolla.com wrote:
> From: Pasi Sjöholm 
> 
> As service is removed the IPv6.Privacy needs to be also reset to interface
> default (ipdevice->ipv6_privacy).

Applied, thanks!


Patrik

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

RE: [PATCH] dhcpv6: Do solicitation instead of confirm if ipv6.privacy is true

2014-09-10 Thread Pasi Sjöholm
This one is obsole due "[PATCH] dhcpv6: Remove CONFIRM message sending when 
connecting a link".

Br,
Pasi

From: connman [connman-boun...@connman.net] on behalf of pasi.sjoh...@jolla.com 
[pasi.sjoh...@jolla.com]
Sent: Wednesday, September 10, 2014 12:58
To: connman@connman.net
Subject: [PATCH] dhcpv6: Do solicitation instead of confirm if ipv6.privacy is 
true

From: Pasi Sjöholm 

Confirm should not be used with ipv6 temporary addresses (IA_TA) as
dhcp server might ignore it. Eg. isc-dhcp-server does so.
---
 src/dhcpv6.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/dhcpv6.c b/src/dhcpv6.c
index dee2d81..e3f6e67 100644
--- a/src/dhcpv6.c
+++ b/src/dhcpv6.c
@@ -1944,6 +1944,7 @@ int __connman_dhcpv6_start(struct connman_network 
*network,
last_address = __connman_ipconfig_get_dhcp_address(ipconfig_ipv6);

if (prefixes && last_address &&
+   !__connman_ipconfig_ipv6_privacy_enabled(ipconfig_ipv6) &&
check_ipv6_addr_prefix(prefixes,
last_address) != 128) {
/*
--
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


[PATCH v2] service: Reset the IPv6.Privacy to interface default when service is removed

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

As service is removed the IPv6.Privacy needs to be also reset to interface
default (ipdevice->ipv6_privacy).
---
 src/connman.h  |  1 +
 src/ipconfig.c | 19 +++
 src/service.c  |  2 ++
 3 files changed, 22 insertions(+)

diff --git a/src/connman.h b/src/connman.h
index 4bee34d..a871e82 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -413,6 +413,7 @@ int __connman_ipconfig_load(struct connman_ipconfig 
*ipconfig,
 int __connman_ipconfig_save(struct connman_ipconfig *ipconfig,
GKeyFile *keyfile, const char *identifier, const char *prefix);
 bool __connman_ipconfig_ipv6_privacy_enabled(struct connman_ipconfig 
*ipconfig);
+int __connman_ipconfig_ipv6_reset_privacy(struct connman_ipconfig *ipconfig);
 int __connman_ipconfig_ipv6_set_privacy(struct connman_ipconfig *ipconfig,
const char *value);
 bool __connman_ipconfig_ipv6_is_enabled(struct connman_ipconfig *ipconfig);
diff --git a/src/ipconfig.c b/src/ipconfig.c
index fa4c0d6..d81a791 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -1774,6 +1774,25 @@ static int string2privacy(const char *privacy)
return 0;
 }
 
+int __connman_ipconfig_ipv6_reset_privacy(struct connman_ipconfig *ipconfig)
+{
+   struct connman_ipdevice *ipdevice;
+   int err;
+
+   if (!ipconfig)
+   return -EINVAL;
+
+   ipdevice = g_hash_table_lookup(ipdevice_hash,
+   
GINT_TO_POINTER(ipconfig->index));
+   if (!ipdevice)
+   return -ENODEV;
+
+   err = __connman_ipconfig_ipv6_set_privacy(ipconfig, privacy2string(
+   
ipdevice->ipv6_privacy));
+
+   return err;
+}
+
 int __connman_ipconfig_ipv6_set_privacy(struct connman_ipconfig *ipconfig,
const char *value)
 {
diff --git a/src/service.c b/src/service.c
index d96713d..8dc6580 100644
--- a/src/service.c
+++ b/src/service.c
@@ -4051,6 +4051,8 @@ bool __connman_service_remove(struct connman_service 
*service)
 
__connman_service_set_favorite(service, false);
 
+   __connman_ipconfig_ipv6_reset_privacy(service->ipconfig_ipv6);
+
service_save(service);
 
return true;
-- 
1.9.1

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

[PATCH] service: Reset the IPv6.Privacy to system default when service is removed

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

As service is removed the IPv6.Privacy needs to be also reset to interface
default (ipdevice->ipv6_privacy).
---
 src/connman.h  |  1 +
 src/ipconfig.c | 19 +++
 src/service.c  |  2 ++
 3 files changed, 22 insertions(+)

diff --git a/src/connman.h b/src/connman.h
index 4bee34d..a871e82 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -413,6 +413,7 @@ int __connman_ipconfig_load(struct connman_ipconfig 
*ipconfig,
 int __connman_ipconfig_save(struct connman_ipconfig *ipconfig,
GKeyFile *keyfile, const char *identifier, const char *prefix);
 bool __connman_ipconfig_ipv6_privacy_enabled(struct connman_ipconfig 
*ipconfig);
+int __connman_ipconfig_ipv6_reset_privacy(struct connman_ipconfig *ipconfig);
 int __connman_ipconfig_ipv6_set_privacy(struct connman_ipconfig *ipconfig,
const char *value);
 bool __connman_ipconfig_ipv6_is_enabled(struct connman_ipconfig *ipconfig);
diff --git a/src/ipconfig.c b/src/ipconfig.c
index fa4c0d6..d81a791 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -1774,6 +1774,25 @@ static int string2privacy(const char *privacy)
return 0;
 }
 
+int __connman_ipconfig_ipv6_reset_privacy(struct connman_ipconfig *ipconfig)
+{
+   struct connman_ipdevice *ipdevice;
+   int err;
+
+   if (!ipconfig)
+   return -EINVAL;
+
+   ipdevice = g_hash_table_lookup(ipdevice_hash,
+   
GINT_TO_POINTER(ipconfig->index));
+   if (!ipdevice)
+   return -ENODEV;
+
+   err = __connman_ipconfig_ipv6_set_privacy(ipconfig, privacy2string(
+   
ipdevice->ipv6_privacy));
+
+   return err;
+}
+
 int __connman_ipconfig_ipv6_set_privacy(struct connman_ipconfig *ipconfig,
const char *value)
 {
diff --git a/src/service.c b/src/service.c
index d96713d..8dc6580 100644
--- a/src/service.c
+++ b/src/service.c
@@ -4051,6 +4051,8 @@ bool __connman_service_remove(struct connman_service 
*service)
 
__connman_service_set_favorite(service, false);
 
+   __connman_ipconfig_ipv6_reset_privacy(service->ipconfig_ipv6);
+
service_save(service);
 
return true;
-- 
1.9.1

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

[PATCH] dhcpv6: Remove CONFIRM message sending when connecting a link

2014-09-10 Thread Jukka Rissanen
The CONFIRM message is not sent any more as it does not make much
sense because we do not save address expiration time so we cannot
really know how long the saved address is valid anyway.

The reply to CONFIRM message does not send expiration times back
to us so we cannot get them from server either. Because of this
we need to start using SOLICITATION anyway when a link is
connected.

Thanks to Pasi Sjöholm for reporting this.
---
 src/dhcpv6.c | 164 +--
 1 file changed, 12 insertions(+), 152 deletions(-)

diff --git a/src/dhcpv6.c b/src/dhcpv6.c
index dee2d81..a1a6e92 100644
--- a/src/dhcpv6.c
+++ b/src/dhcpv6.c
@@ -1769,145 +1769,11 @@ static gboolean start_solicitation(gpointer user_data)
return FALSE;
 }
 
-static void confirm_cb(GDHCPClient *dhcp_client, gpointer user_data)
-{
-   struct connman_dhcpv6 *dhcp = user_data;
-   int status = g_dhcpv6_client_get_status(dhcp_client);
-
-   DBG("dhcpv6 confirm msg %p status %d", dhcp, status);
-
-   clear_timer(dhcp);
-
-   g_dhcpv6_client_clear_retransmit(dhcp_client);
-
-   /*
-* If confirm fails, start from scratch.
-*/
-   if (status != 0) {
-   g_dhcp_client_unref(dhcp->dhcp_client);
-   start_solicitation(dhcp);
-   } else {
-   do_dad(dhcp_client, dhcp);
-   }
-}
-
-static int dhcpv6_confirm(struct connman_dhcpv6 *dhcp)
-{
-   GDHCPClient *dhcp_client;
-   GDHCPClientError error;
-   struct connman_service *service;
-   struct connman_ipconfig *ipconfig_ipv6;
-   int index, ret;
-
-   DBG("dhcp %p", dhcp);
-
-   index = connman_network_get_index(dhcp->network);
-
-   dhcp_client = g_dhcp_client_new(G_DHCP_IPV6, index, &error);
-   if (error != G_DHCP_CLIENT_ERROR_NONE) {
-   clear_timer(dhcp);
-   return -EINVAL;
-   }
-
-   if (getenv("CONNMAN_DHCPV6_DEBUG"))
-   g_dhcp_client_set_debug(dhcp_client, dhcpv6_debug, "DHCPv6");
-
-   service = connman_service_lookup_from_network(dhcp->network);
-   if (!service) {
-   clear_timer(dhcp);
-   g_dhcp_client_unref(dhcp_client);
-   return -EINVAL;
-   }
-
-   ret = set_duid(service, dhcp->network, dhcp_client, index);
-   if (ret < 0) {
-   clear_timer(dhcp);
-   g_dhcp_client_unref(dhcp_client);
-   return ret;
-   }
-
-   g_dhcp_client_set_request(dhcp_client, G_DHCPV6_CLIENTID);
-   g_dhcp_client_set_request(dhcp_client, G_DHCPV6_RAPID_COMMIT);
-
-   ipconfig_ipv6 = __connman_service_get_ip6config(service);
-   dhcp->use_ta = __connman_ipconfig_ipv6_privacy_enabled(ipconfig_ipv6);
-
-   g_dhcpv6_client_set_ia(dhcp_client, index,
-   dhcp->use_ta ? G_DHCPV6_IA_TA : G_DHCPV6_IA_NA,
-   NULL, NULL, TRUE,
-   __connman_ipconfig_get_dhcp_address(ipconfig_ipv6));
-
-   clear_callbacks(dhcp_client);
-
-   g_dhcp_client_register_event(dhcp_client,
-   G_DHCP_CLIENT_EVENT_CONFIRM,
-   confirm_cb, dhcp);
-
-   dhcp->dhcp_client = dhcp_client;
-
-   return g_dhcp_client_start(dhcp_client, NULL);
-}
-
-static gboolean timeout_confirm(gpointer user_data)
-{
-   struct connman_dhcpv6 *dhcp = user_data;
-
-   dhcp->RT = calc_delay(dhcp->RT, CNF_MAX_RT);
-
-   DBG("confirm RT timeout %d msec", dhcp->RT);
-
-   dhcp->timeout = g_timeout_add(dhcp->RT, timeout_confirm, dhcp);
-
-   g_dhcpv6_client_set_retransmit(dhcp->dhcp_client);
-
-   g_dhcp_client_start(dhcp->dhcp_client, NULL);
-
-   return FALSE;
-}
-
-static gboolean timeout_max_confirm(gpointer user_data)
-{
-   struct connman_dhcpv6 *dhcp = user_data;
-
-   dhcp->MRD = 0;
-
-   clear_timer(dhcp);
-
-   DBG("confirm max retransmit duration timeout");
-
-   g_dhcpv6_client_clear_retransmit(dhcp->dhcp_client);
-
-   if (dhcp->callback)
-   dhcp->callback(dhcp->network, CONNMAN_DHCPV6_STATUS_FAIL,
-   NULL);
-
-   return FALSE;
-}
-
-static gboolean start_confirm(gpointer user_data)
-{
-   struct connman_dhcpv6 *dhcp = user_data;
-
-   /* Set the confirm timeout, RFC 3315 chapter 14 */
-   dhcp->RT = CNF_TIMEOUT * (1 + get_random());
-
-   DBG("confirm initial RT timeout %d msec", dhcp->RT);
-
-   dhcp->timeout = g_timeout_add(dhcp->RT, timeout_confirm, dhcp);
-   dhcp->MRD = g_timeout_add(CNF_MAX_RD, timeout_max_confirm, dhcp);
-
-   dhcpv6_confirm(dhcp);
-
-   return FALSE;
-}
-
 int __connman_dhcpv6_start(struct connman_network *network,
GSList *prefixes, dhcpv6_cb callback)
 {
struct connman_service *service;
-   struct connman_ipconfig *ipconfig_ipv6;
struct connman_dhcpv6 *dhcp;
-

[PATCH] dhcpv6: Do solicitation instead of confirm if ipv6.privacy is true

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

Confirm should not be used with ipv6 temporary addresses (IA_TA) as
dhcp server might ignore it. Eg. isc-dhcp-server does so.
---
 src/dhcpv6.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/dhcpv6.c b/src/dhcpv6.c
index dee2d81..e3f6e67 100644
--- a/src/dhcpv6.c
+++ b/src/dhcpv6.c
@@ -1944,6 +1944,7 @@ int __connman_dhcpv6_start(struct connman_network 
*network,
last_address = __connman_ipconfig_get_dhcp_address(ipconfig_ipv6);
 
if (prefixes && last_address &&
+   !__connman_ipconfig_ipv6_privacy_enabled(ipconfig_ipv6) &&
check_ipv6_addr_prefix(prefixes,
last_address) != 128) {
/*
-- 
1.9.1

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

Re: agent, route questions with 1.25

2014-09-10 Thread Patrik Flykt

Hi,

On Fri, 2014-09-05 at 10:50 -0400, Mike Purvis wrote:
> Is there some way to make connman more persistent in trying to achieve a
> connection? My perception is that it basically tries once, fails, and then
> gives up for good.

Unfortunately not. There exists a category of WiFi APs that are very
eager to lock out devices if they fail to connect a few number of times
in a row. Trying to reconnect more agressively will just lock out
ConnMan from those networks.

> In any case, is /usr/local the default for a source installation? If so,
> this should definitely be clearly documented, especially when users are
> encouraged to install connman from source!

Usually distros install ConnMan in /usr, and set --localstatedir=/var
for ./configure. The documentation tries to keep it all sensible by not
explicitely writing something mysterious like {prefix}/usr/... in all
places. Then again /usr/local/ is the default installation prefix for
everything locally installed that comes from a tar ball, so this is set
as default for ConnMan as well.

Cheers,

Patrik


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


Re: [PATCH 0/2] Code cleanup in inet

2014-09-10 Thread Patrik Flykt
On Tue, 2014-09-09 at 23:06 -0400, Eduardo Abinader wrote:
> Remove two unused functions in inet.

Applied, thanks!

Patrik

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


Re: [PATCH 0/3] Fix setting of passphrase

2014-09-10 Thread Patrik Flykt
On Tue, 2014-09-09 at 14:29 +0300, Patrik Flykt wrote:
>   Hi,
> 
> Patch 03 fixes the issue with not being able to set a passphrase when
> it is defined in a .config file. The fix is to simply set the immutable
> flag after configuring the service.
> 
> In order to come this far, patch 02 moves around the part where a service
> is connected, directly or by running autoconnect. Also to not is that
> virtual, i.e. currently NFC provisioned WiFi networks, are not immutable.
> 
> While investigatin the issue, it was noticed that the configuration was
> checking for the service type in more than one place. With this patch all
> the service matching is now collected into one place and the literal
> service type names are replaced with the helper function from service.c.

All three patches applied.

Patrik

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