[PATCH] doc: Update connmanctl's exit status

2015-10-28 Thread Jaakko Hannikainen
Connmanctl returns the status of the last executed command. Update
documentation to reflect this.
---
 doc/connmanctl.1.in | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/doc/connmanctl.1.in b/doc/connmanctl.1.in
index 0f891bd..07320bd 100644
--- a/doc/connmanctl.1.in
+++ b/doc/connmanctl.1.in
@@ -231,6 +231,12 @@ Listens for added or removed vpn connections.
 Listens for the changes to vpn connections, for example connecting to a VPN.
 .PP
 .SH
+EXIT STATUS
+In single command mode, \fBconnmanctl\fR returns 0 on success and nonzero on
+failure, and in interactive mode \fBconnmanctl\fR returns the status of the 
last
+command. The nonzero exit codes correspond with standard errno values, see
+\fBerrno.h\fR(3).
+.SH
 EXAMPLE
 Listing available technologies:
 .PP
-- 
2.6.1

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


Re: [PATCH 0/8] Man page overhaul

2015-10-28 Thread Patrik Flykt
On Mon, 2015-10-26 at 16:39 +0200, Jaakko Hannikainen wrote:
> This patchset rewrites half of the existing man pages and adds 4
> new ones, since the old ones were either badly formatted, incomplete
> or simply wrong. It also moves them under automake so that end users
> will see proper paths to connman's files instead of suggesting that
> they are probably under /var/lib/connman/.
> 
> Not many changes from the RFC version, mostly typos here and there.
> Mainly changed the build system parts, now only the last patch
> touches the build system. If/when the discussion about OpenVPN's MTUs
> reaches some end, the appropriate documentation should be updated.

Applied with v2 for patch 8/8, thanks!

Patrik

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


Re: [PATCH] Set exit value in connmanctl

2015-10-28 Thread Patrik Flykt

Hi,

On Tue, 2015-10-27 at 09:58 +0200, Mikko Tuumanen wrote:
> ---
>  client/agent.c|  2 +-
>  client/commands.c | 27 +--
>  client/dbus_helpers.c |  5 +++--
>  client/input.c|  6 --
>  client/input.h|  2 +-
>  5 files changed, 30 insertions(+), 12 deletions(-)
> 
> diff --git a/client/agent.c b/client/agent.c
> index d020889..b87d5bb 100644
> --- a/client/agent.c
> +++ b/client/agent.c
> @@ -235,7 +235,7 @@ static DBusMessage *agent_release(DBusConnection 
> *connection,
>   "VPNd\n");
>  
>   if (__connmanctl_is_interactive() == false)
> - __connmanctl_quit();
> + __connmanctl_quit(0);
>  
>   return dbus_message_new_method_return(message);
>  }
> diff --git a/client/commands.c b/client/commands.c
> index 3bfdfd7..ee56d46 100644
> --- a/client/commands.c
> +++ b/client/commands.c
> @@ -153,14 +153,21 @@ static int enable_return(DBusMessageIter *iter, const 
> char *error,
>   else
>   str = tech;
>  
> - if (!error)
> + int ret;

int ret = 0; should be declared together with the other variables. As a
nitpick the convention has been that variables with values were declared
first, then uninitialized variables.

> + if (!error) {
> + ret = 0;
>   fprintf(stdout, "Enabled %s\n", str);
> - else
> + } else {
> + if (!strncmp("Already ",error,8))
> + ret = -2;
> + else
> + ret = -1;

I don't think one can rely on the string here. It's a semi-descriptive
one that may be used for logging or other purposes, but not much else. 

The code is looking for -EINPROGRESS in dbus_method_reply(), so "proper"
values from errno*.h shall be used. What if this just sets the return
value to -EOPNOTSUPP?

>   fprintf(stderr, "Error %s: %s\n", str, error);
> + }
>  
>   g_free(user_data);
>  
> - return 0;
> + return ret;
>  }
>  
>  static int cmd_enable(char *args[], int num, struct connman_option *options)
> @@ -202,14 +209,22 @@ static int disable_return(DBusMessageIter *iter, const 
> char *error,
>   else
>   str = tech;
>  
> - if (!error)
> + int ret;
> + if (!error) {
> + ret = 0;
>   fprintf(stdout, "Disabled %s\n", str);
> - else
> + } else {
> + if (!strncmp("Already ", error, 8))
> + ret = -2;
> + else
> + ret = -1;
> +
>   fprintf(stderr, "Error %s: %s\n", str, error);
> + }

Same here.

>   g_free(user_data);
>  
> - return 0;
> + return ret;
>  }
>  
>  static int cmd_disable(char *args[], int num, struct connman_option *options)
> diff --git a/client/dbus_helpers.c b/client/dbus_helpers.c
> index 9c4cfee..fe55abf 100644
> --- a/client/dbus_helpers.c
> +++ b/client/dbus_helpers.c
> @@ -141,6 +141,7 @@ static void dbus_method_reply(DBusPendingCall *call, void 
> *user_data)
>   int res = 0;
>   DBusMessage *reply;
>   DBusMessageIter iter;
> + int exit_value = 0;
>  
>   __connmanctl_save_rl();
>  
> @@ -152,7 +153,7 @@ static void dbus_method_reply(DBusPendingCall *call, void 
> *user_data)
>   dbus_error_init();
>   dbus_set_error_from_message(, reply);
>  
> - callback->cb(NULL, err.message, callback->user_data);
> + exit_value = callback->cb(NULL, err.message, 
> callback->user_data);
>  
>   dbus_error_free();
>   goto end;
> @@ -164,7 +165,7 @@ static void dbus_method_reply(DBusPendingCall *call, void 
> *user_data)
>  end:
>   __connmanctl_redraw_rl();
>   if (__connmanctl_is_interactive() == false && res != -EINPROGRESS)
> - __connmanctl_quit();
> + __connmanctl_quit(exit_value);
>  
>   g_free(callback);
>   dbus_message_unref(reply);
> diff --git a/client/input.c b/client/input.c
> index e59df8a..f310d15 100644
> --- a/client/input.c
> +++ b/client/input.c
> @@ -42,9 +42,11 @@ static bool interactive = false;
>  static bool save_input;
>  static char *saved_line;
>  static int saved_point;
> +static int exit_status = 0;
>  
> -void __connmanctl_quit(void)
> +void __connmanctl_quit(int status)
>  {
> + exit_status = status;
>   if (main_loop)
>   g_main_loop_quit(main_loop);
>  }
> @@ -264,7 +266,7 @@ int __connmanctl_input_init(int argc, char *argv[])
>   main_loop = g_main_loop_new(NULL, FALSE);
>   g_main_loop_run(main_loop);
>  
> - err = 0;
> + err = exit_status;
>   }
>  
>   if (interactive) {
> diff --git a/client/input.h b/client/input.h
> index c7256a4..2136d13 100644
> --- a/client/input.h
> +++ b/client/input.h
> @@ -29,7 +29,7 @@
>  extern "C" {
>  #endif
>  
> -void __connmanctl_quit(void);
> +void __connmanctl_quit(int status);
>  bool 

Re: [PATCH v3] IPv6 timeserver for NTP

2015-10-28 Thread Naveen Singh
On Mon, Oct 26, 2015 at 12:46 AM, Patrik Flykt  wrote:

> On Fri, 2015-10-23 at 06:28 -0700, Naveen Singh wrote:
> > > I didn't notice sin_port being used anywhere, so this is not needed?
> > >
> > This is being used in current code so I decided to follow the current
> > code. In send_packet look for following line:
> > addr.sin_port = htons(123);
>
> Mmmkay. But the port sent to is a constant (123), so it need not be
> explicitely rembered. On the receiving end one needs to check the server
> address so that some other whimsical device sending data to ConnMan can
> be ignored.
>
Yes the receive path does that check anyway.
When we call send_packet from start_ntp we pass the sockaddr as
timeserver_addr (which is used for sending ntp request packet) I
initialized the port number. Please have a look in the patch that I am
sending

>
> Cheers,
>
> Patrik
>
>
> ___
> 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 0/5] Properly configure search domains for resolvers

2015-10-28 Thread pasi . sjoholm
From: Pasi Sjöholm 

While debugging append_domain issue reported Vladimir Pavljuchenkov
I noticed that dnsproxy did not do any appended_domain-queries with
nameserver/resolvers configured by IPv6-infrastructure.

After these five small patches the things seems to be right
and all the resolvers are queried with configured search domains
(DNSSL, DHCPv4/6 and manually configured).

DHCPv4/6: siirappi.com
DNSSL: google.com

Before:

--cut--
IP 192.168.189.99.57437 > 192.168.189.1.53: 54758+ A? bz. (20)
IP 192.168.189.99.57437 > 192.168.189.1.53: 24311+ A? bz.siirappi.com. (33)
IP6 2001:470:28:241:2456:88bd:a205:211c.31364 > 2001:470:28:241::1.53: 25855+ 
A? bz. (20)
IP 192.168.189.1.53 > 192.168.189.99.57437: 54758 0/1/0 (85)
IP 192.168.189.1.53 > 192.168.189.99.57437: 24311 1/0/0 A 1.2.3.4 (49)
IP6 2001:470:28:241::1.53 > 2001:470:28:241:2456:88bd:a205:211c.31364: 25855 
0/0/0 (20)
--cut--

After the patches:

--cut--
IP 192.168.189.99.57437 > 192.168.189.1.53: 62803+ A? bz. (20)
IP 192.168.189.99.57437 > 192.168.189.1.53: 56164+ A? bz.siirappi.com. (33)
IP 192.168.189.99.57437 > 192.168.189.1.53: 56164+ A? bz.google.com. (31)
IP6 2001:470:28:241:2456:88bd:a205:211c.33378 > 2001:470:28:241::1.53: 62803+ 
A? bz. (20)
IP6 2001:470:28:241:2456:88bd:a205:211c.33378 > 2001:470:28:241::1.53: 56164+ 
A? bz.siirappi.com. (33)
IP6 2001:470:28:241:2456:88bd:a205:211c.33378 > 2001:470:28:241::1.53: 56164+ 
A? bz.google.com. (31)
IP 192.168.189.1.53 > 192.168.189.99.57437: 62803 0/0/0 (20)
IP 192.168.189.1.53 > 192.168.189.99.57437: 56164 1/0/0 A 1.2.3.4 (49)
IP 192.168.189.1.53 > 192.168.189.99.57437: 56164 NXDomain 0/1/0 (81)
IP6 2001:470:28:241::1.53 > 2001:470:28:241:2456:88bd:a205:211c.33378: 62803 
0/0/0 (20)
IP6 2001:470:28:241::1.53 > 2001:470:28:241:2456:88bd:a205:211c.33378: 56164 
1/0/0 A 1.2.3.4 (49)
IP6 2001:470:28:241::1.53 > 2001:470:28:241:2456:88bd:a205:211c.33378: 56164 
NXDomain 0/0/0 (31)
--cut--

Pasi Sjöholm (5):
  dnsproxy: Rename append_domain() to append_or_remove_domain()
  dnsproxy: Remove domains from dns server domain list when needed
  service: Reconfigure search domains when nameservers have been
modified
  resolver: Reorder call to __connman_service_nameserver_append()
  resolver: Readd search domains back when resolvers are redone

 src/dnsproxy.c | 25 ++---
 src/resolver.c | 45 +
 src/service.c  | 12 ++--
 3 files changed, 61 insertions(+), 21 deletions(-)

-- 
2.1.4

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

[PATCH 1/5] dnsproxy: Rename append_domain() to append_or_remove_domain()

2015-10-28 Thread pasi . sjoholm
From: Pasi Sjöholm 

A new append_domain()- and remove_domain()-functions which both
call append_or_remove_domain()-function by setting boolean append-
variable accordingly.

This enables a capability to remove domains from the dns-server's
domain list.
---
 src/dnsproxy.c | 17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/dnsproxy.c b/src/dnsproxy.c
index c37eee9..1e8fcfb 100644
--- a/src/dnsproxy.c
+++ b/src/dnsproxy.c
@@ -2649,7 +2649,7 @@ static bool resolv(struct request_data *req,
return false;
 }
 
-static void append_domain(int index, const char *domain)
+static void append_or_remove_domain(int index, const char *domain, bool append)
 {
GSList *list;
 
@@ -2680,13 +2680,26 @@ static void append_domain(int index, const char *domain)
}
}
 
-   if (!dom_found) {
+   if (!dom_found && append) {
data->domains =
g_list_append(data->domains, g_strdup(domain));
+   } else if (dom_found && !append) {
+   data->domains =
+   g_list_remove(data->domains, dom);
}
}
 }
 
+static void append_domain(int index, const char *domain)
+{
+   append_or_remove_domain(index, domain, true);
+}
+
+static void remove_domain(int index, const char *domain)
+{
+   append_or_remove_domain(index, domain, false);
+}
+
 static void flush_requests(struct server_data *server)
 {
GSList *list;
-- 
2.1.4

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

[PATCH v2] wifi: Reset device->scanning if scan has not returned in 60 secs

2015-10-28 Thread pasi . sjoholm
From: Pasi Sjöholm 

Due unknown reason sometimes scan_callback()-function is not being called
after the scan has been succesfully initiated.

This will lead into deadlock situation where device->scanning is
indefinitely true and will forbid any future attemps of scanning available
wifi networks.

The deadlock can be manually sorted out by commanding wpa_supplicant
to scan available networks. If any networks are available and one or
more of them being autoconnectable ConnMan will connect them after
receiving NetworkAdded-signal from wpa_supplicant. This will cause
autoscan-feature to stop and setting the device->scanning to false.
---
 plugins/wifi.c | 50 +-
 1 file changed, 49 insertions(+), 1 deletion(-)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index dfe849f..1e6507b 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -61,6 +61,7 @@
 
 #define CLEANUP_TIMEOUT   8/* in seconds */
 #define INACTIVE_TIMEOUT  12   /* in seconds */
+#define SCAN_FAIL_TIMEOUT 60   /* in seconds */
 #define FAVORITE_MAXIMUM_RETRIES 2
 
 #define BGSCAN_DEFAULT "simple:30:-45:300"
@@ -131,6 +132,7 @@ struct wifi_data {
struct hidden_params *hidden;
bool postpone_hidden;
struct wifi_tethering_info *tethering_param;
+   unsigned int scan_fail_timeout;
/**
 * autoscan "emulation".
 */
@@ -817,9 +819,25 @@ static void reset_autoscan(struct connman_device *device)
connman_device_unref(device);
 }
 
+static gboolean scan_fail_timeout(gpointer data)
+{
+   struct connman_device *device = data;
+   struct wifi_data *wifi = connman_device_get_data(device);
+
+   DBG("");
+
+   if (!wifi)
+   return FALSE;
+
+   connman_device_set_scanning(device, CONNMAN_SERVICE_TYPE_WIFI, false);
+   wifi->scan_fail_timeout = 0;
+
+   return FALSE;
+}
+
 static void stop_autoscan(struct connman_device *device)
 {
-   const struct wifi_data *wifi = connman_device_get_data(device);
+   struct wifi_data *wifi = connman_device_get_data(device);
 
if (!wifi || !wifi->autoscan)
return;
@@ -827,6 +845,11 @@ static void stop_autoscan(struct connman_device *device)
reset_autoscan(device);
 
connman_device_set_scanning(device, CONNMAN_SERVICE_TYPE_WIFI, false);
+
+   if (wifi->scan_fail_timeout) {
+   g_source_remove(wifi->scan_fail_timeout);
+   wifi->scan_fail_timeout = 0;
+   }
 }
 
 static void check_p2p_technology(void)
@@ -876,6 +899,10 @@ static void wifi_remove(struct connman_device *device)
if (wifi->p2p_connection_timeout)
g_source_remove(wifi->p2p_connection_timeout);
 
+   if (wifi->scan_fail_timeout) {
+   g_source_remove(wifi->scan_fail_timeout);
+   }
+
remove_networks(device, wifi);
 
connman_device_set_powered(device, false);
@@ -1193,6 +1220,11 @@ static int throw_wifi_scan(struct connman_device *device,
if (ret == 0) {
connman_device_set_scanning(device,
CONNMAN_SERVICE_TYPE_WIFI, true);
+
+   wifi->scan_fail_timeout = g_timeout_add_seconds(
+   SCAN_FAIL_TIMEOUT,
+   scan_fail_timeout,
+   device);
} else
connman_device_unref(device);
 
@@ -1262,6 +1294,11 @@ static void scan_callback(int result, 
GSupplicantInterface *interface,
if (scanning) {
connman_device_set_scanning(device,
CONNMAN_SERVICE_TYPE_WIFI, false);
+
+   if (wifi && wifi->scan_fail_timeout) {
+   g_source_remove(wifi->scan_fail_timeout);
+   wifi->scan_fail_timeout = 0;
+   }
}
 
if (result != -ENOLINK)
@@ -1516,6 +1553,11 @@ static int wifi_disable(struct connman_device *device)
connman_device_unref(wifi->device);
}
 
+   if (wifi->scan_fail_timeout) {
+   g_source_remove(wifi->scan_fail_timeout);
+   wifi->scan_fail_timeout = 0;
+   }
+
/* In case of a user scan, device is still referenced */
if (connman_device_get_scanning(device)) {
connman_device_set_scanning(device,
@@ -1864,6 +1906,12 @@ static int wifi_scan(enum connman_service_type type,
if (ret == 0) {
connman_device_set_scanning(device,
CONNMAN_SERVICE_TYPE_WIFI, true);
+
+   wifi->scan_fail_timeout = g_timeout_add_seconds(
+   SCAN_FAIL_TIMEOUT,
+   scan_fail_timeout,
+   device);
+
} else {
g_supplicant_free_scan_params(scan_params);
 

[PATCH 4/5] resolver: Reorder call to __connman_service_nameserver_append()

2015-10-28 Thread pasi . sjoholm
From: Pasi Sjöholm 

__connman_service_nameserver_append() must be called after the
resolver entry has been appended to entry_list and dnsproxy
because otherwise searchdomain_add_all()-call on service
will not add the search domain configuration to nameserver
configured through RDNSS.
---
 src/resolver.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/resolver.c b/src/resolver.c
index 6a64938..53e9ebb 100644
--- a/src/resolver.c
+++ b/src/resolver.c
@@ -378,18 +378,6 @@ static int append_resolver(int index, const char *domain,
 
entry->timeout = g_timeout_add_seconds(interval,
resolver_refresh_cb, entry);
-
-   /*
-* We update the service only for those nameservers
-* that are automagically added via netlink (lifetime > 0)
-*/
-   if (server && entry->index >= 0) {
-   struct connman_service *service;
-   service = 
__connman_service_lookup_from_index(entry->index);
-   if (service)
-   __connman_service_nameserver_append(service,
-   server, true);
-   }
}
 
if (entry->index >= 0 && entry->server)
@@ -402,6 +390,18 @@ static int append_resolver(int index, const char *domain,
else
__connman_resolvfile_append(entry->index, domain, server);
 
+   /*
+* We update the service only for those nameservers
+* that are automagically added via netlink (lifetime > 0)
+*/
+   if (server && entry->index >= 0 && lifetime) {
+   struct connman_service *service;
+   service = __connman_service_lookup_from_index(entry->index);
+   if (service)
+   __connman_service_nameserver_append(service,
+   server, true);
+   }
+
return 0;
 }
 
-- 
2.1.4

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

[PATCH 2/5] dnsproxy: Remove domains from dns server domain list when needed

2015-10-28 Thread pasi . sjoholm
From: Pasi Sjöholm 

Whenever the remove_entries() is called the __connman_dnsproxy_remove()
must act properly eg. with triggered solver_expire_cb() the expired 
DNSSL-records
from the IPv6 RA's must be removed.
---
 src/dnsproxy.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/dnsproxy.c b/src/dnsproxy.c
index 1e8fcfb..a4682a7 100644
--- a/src/dnsproxy.c
+++ b/src/dnsproxy.c
@@ -2782,9 +2782,15 @@ int __connman_dnsproxy_remove(int index, const char 
*domain,
 {
DBG("index %d server %s", index, server);
 
-   if (!server)
+   if (!server && !domain)
return -EINVAL;
 
+   if (!server) {
+   remove_domain(index, domain);
+
+   return 0;
+   }
+
if (g_str_equal(server, "127.0.0.1"))
return -ENODEV;
 
-- 
2.1.4

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

[PATCH 5/5] resolver: Readd search domains back when resolvers are redone

2015-10-28 Thread pasi . sjoholm
From: Pasi Sjöholm 

Redoing dns servers will remove the current list of search domains
from the servers/resolvers (eg. RDNSS configured ones) therefore they need
to be added back.
---
 src/resolver.c | 21 +
 1 file changed, 21 insertions(+)

diff --git a/src/resolver.c b/src/resolver.c
index 53e9ebb..5c463be 100644
--- a/src/resolver.c
+++ b/src/resolver.c
@@ -600,6 +600,27 @@ int __connman_resolver_redo_servers(int index)
entry->server);
}
 
+   /*
+* We want to re-add all search domains back to search
+* domain lists as they just got removed for IPv6-servers (above).
+* Removal of search domains is not necessary
+* as there can be only one instance of each search domain
+* in the each dns-servers search domain list.
+*/
+
+   for (list = entry_list; list; list = list->next) {
+   struct entry_data *entry = list->data;
+
+   if (entry->index != index)
+   continue;
+
+   if (entry->server)
+   continue;
+
+   __connman_dnsproxy_append(entry->index, entry->domain,
+   NULL);
+   }
+
return 0;
 }
 
-- 
2.1.4

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

[PATCH 3/5] service: Reconfigure search domains when nameservers have been modified

2015-10-28 Thread pasi . sjoholm
From: Pasi Sjöholm 

searchdomain_add_all()-function must be called when nameservers are
modified for the service as the IPv4- and IPv6-ipconfig won't
become connected at the same time and calling searchdomain_add_all()
only once when the service becomes ready-state is not enough.

Also nameserver-configuration coming from eg. IPv6 RA RDNSS
(__connman_service_nameserver_append()) must have search domains
applied to it.
---
 src/service.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/service.c b/src/service.c
index e33284d..3fc5b60 100644
--- a/src/service.c
+++ b/src/service.c
@@ -134,6 +134,7 @@ static struct connman_ipconfig *create_ip4config(struct 
connman_service *service
 static struct connman_ipconfig *create_ip6config(struct connman_service 
*service,
int index);
 
+static int searchdomain_add_all(struct connman_service *service);
 
 struct find_data {
const char *path;
@@ -966,11 +967,7 @@ static int nameserver_add_all(struct connman_service 
*service,
service->nameservers_config[i]);
i++;
}
-
-   return 0;
-   }
-
-   if (service->nameservers) {
+   } else if (service->nameservers) {
while (service->nameservers[i]) {
nameserver_add(service, type,
service->nameservers[i]);
@@ -978,6 +975,8 @@ static int nameserver_add_all(struct connman_service 
*service,
}
}
 
+   searchdomain_add_all(service);
+
return 0;
 }
 
@@ -1121,6 +1120,8 @@ int __connman_service_nameserver_append(struct 
connman_service *service,
nameserver_add(service, CONNMAN_IPCONFIG_TYPE_ALL, nameserver);
}
 
+   searchdomain_add_all(service);
+
return 0;
 }
 
@@ -5378,7 +5379,6 @@ static int service_indicate_state(struct connman_service 
*service)
g_get_current_time(>modified);
service_save(service);
 
-   searchdomain_add_all(service);
dns_changed(service);
domain_changed(service);
proxy_changed(service);
-- 
2.1.4

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

Re: [PATCH] wifi: Reset device->scanning if scan has not returned in 15 secs

2015-10-28 Thread Pasi Sjöholm
On 28.10.2015 11:32, Patrik Flykt wrote:
>> From: Pasi Sjöholm 
>>
>> Due unknown reason sometimes device->scanning is not set to false after
>> wifi scanning (connman 1.30 and wpa_supplicant 2.5).
>> This is probably due callback-function not being called after wifi scan
>> and therefore it needs to have a timer to prevent deadlock.
>> ---
> 
> You probably have evidence that the callback is not called, right?
> Please state that in the commit message.

I don't have logs stored anymore on my disk but I'm rather sure that
wifi.c:scan_callback() is not being called when this happens as all
attemps to scan by connman are blocked by device->scanning being true (I
usually get bored after waiting for couple of hours ;)).

When the deadlock happens and I can manually ask wpa_supplicant to scan
available networks from the commandline. After doing this ConnMan will
survive from the deadlock through NetworkAdded being signaled and
autoconnectable network being available as ConnMan gets connected and
autoscan will be stopped.

The problem is hard to reproduce (no known steps) but it has happened to
me around 4 times within last few weeks.

> What will happen if wpa_supplicant will call the callback after 16
> seconds, i.e. after ConnMan has triggered scan_fail_timeout? Will there
> be any artefacts if this happens?

By quickly looking at the code there shouldn't be any issues but I can't
be 100% sure. In theory one could stop autoscan after scan has been
started and restart it immediately before the scan_callback gets called
to have the same effect and ConnMan must be able to handle it.

Currently the TIMEOUT defined in the dbus.c seems to be 30 secs and
after that the callback-function should be called if no reply has been
received (if I read and understand the code correctly). So having 60
seconds timeout should be ok as there should not be any calls coming
from wpa_supplicant after that.

I will modify the timeout and edit the commit message a bit.

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

Re: [PATCH] Set exit value in connmanctl

2015-10-28 Thread Patrik Flykt
On Tue, 2015-10-27 at 09:58 +0200, Mikko Tuumanen wrote:
> ---
>  client/agent.c|  2 +-
>  client/commands.c | 27 +--
>  client/dbus_helpers.c |  5 +++--
>  client/input.c|  6 --
>  client/input.h|  2 +-
>  5 files changed, 30 insertions(+), 12 deletions(-)

And a bit more description on the idea behind the change in the commit
message, if I may.

Cheers,

Patrik

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


Re: [PATCH] unit: IP pools exist as long as they are referenced

2015-10-28 Thread Patrik Flykt
On Fri, 2015-10-23 at 14:59 +0300, Patrik Flykt wrote:
> An IP pool exists after it has been created until it is unreferenced.
> Make no assumptions that the ip pool address range will not be
> re-assigned after it has ben unreferenced.
> ---
> 
> This behavior became obvious after changing the ip pool allocation
> with the previous patches. Nevertheless, the unit test assumes things
> that cannot be guaranteed and needs fixing.

Applied.

Patrik

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


Re: [PATCH 0/2] Keep same subnet when enabling/disabling tethering

2015-10-28 Thread Patrik Flykt
On Fri, 2015-10-23 at 14:38 +0300, Patrik Flykt wrote:
>   Hi,
> 
> Here is a simple fix for reusing the same IPv4 subnet when tethering.
> As before, the subnet is not guaranteed to always stay the same, but
> with this change its previous value should be reused if nothing else
> causes it to be changed.
> 
> The second patch removes an unused hash from ippool.c

Applied.

Patrik

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


Re: [PATCH] wifi: Reset device->scanning if scan has not returned in 15 secs

2015-10-28 Thread Patrik Flykt

Hi,

On Fri, 2015-10-23 at 00:47 +0300, pasi.sjoh...@jolla.com wrote:
> From: Pasi Sjöholm 
> 
> Due unknown reason sometimes device->scanning is not set to false after
> wifi scanning (connman 1.30 and wpa_supplicant 2.5).
> This is probably due callback-function not being called after wifi scan
> and therefore it needs to have a timer to prevent deadlock.
> ---

You probably have evidence that the callback is not called, right?
Please state that in the commit message.

What will happen if wpa_supplicant will call the callback after 16
seconds, i.e. after ConnMan has triggered scan_fail_timeout? Will there
be any artefacts if this happens?

Cheers,

Patrik

>  plugins/wifi.c | 50 +-
>  1 file changed, 49 insertions(+), 1 deletion(-)
> 
> diff --git a/plugins/wifi.c b/plugins/wifi.c
> index dfe849f..35d4fe6 100644
> --- a/plugins/wifi.c
> +++ b/plugins/wifi.c
> @@ -61,6 +61,7 @@
>  
>  #define CLEANUP_TIMEOUT   8  /* in seconds */
>  #define INACTIVE_TIMEOUT  12 /* in seconds */
> +#define SCAN_FAIL_TIMEOUT 15 /* in seconds */
>  #define FAVORITE_MAXIMUM_RETRIES 2
>  
>  #define BGSCAN_DEFAULT "simple:30:-45:300"
> @@ -131,6 +132,7 @@ struct wifi_data {
>   struct hidden_params *hidden;
>   bool postpone_hidden;
>   struct wifi_tethering_info *tethering_param;
> + unsigned int scan_fail_timeout;
>   /**
>* autoscan "emulation".
>*/
> @@ -817,9 +819,25 @@ static void reset_autoscan(struct connman_device *device)
>   connman_device_unref(device);
>  }
>  
> +static gboolean scan_fail_timeout(gpointer data)
> +{
> + struct connman_device *device = data;
> + struct wifi_data *wifi = connman_device_get_data(device);
> +
> + DBG("");
> +
> + if (!wifi)
> + return FALSE;
> +
> + connman_device_set_scanning(device, CONNMAN_SERVICE_TYPE_WIFI, false);
> + wifi->scan_fail_timeout = 0;
> +
> + return FALSE;
> +}
> +
>  static void stop_autoscan(struct connman_device *device)
>  {
> - const struct wifi_data *wifi = connman_device_get_data(device);
> + struct wifi_data *wifi = connman_device_get_data(device);
>  
>   if (!wifi || !wifi->autoscan)
>   return;
> @@ -827,6 +845,11 @@ static void stop_autoscan(struct connman_device *device)
>   reset_autoscan(device);
>  
>   connman_device_set_scanning(device, CONNMAN_SERVICE_TYPE_WIFI, false);
> +
> + if (wifi->scan_fail_timeout) {
> + g_source_remove(wifi->scan_fail_timeout);
> + wifi->scan_fail_timeout = 0;
> + }
>  }
>  
>  static void check_p2p_technology(void)
> @@ -876,6 +899,10 @@ static void wifi_remove(struct connman_device *device)
>   if (wifi->p2p_connection_timeout)
>   g_source_remove(wifi->p2p_connection_timeout);
>  
> + if (wifi->scan_fail_timeout) {
> + g_source_remove(wifi->scan_fail_timeout);
> + }
> +
>   remove_networks(device, wifi);
>  
>   connman_device_set_powered(device, false);
> @@ -1193,6 +1220,11 @@ static int throw_wifi_scan(struct connman_device 
> *device,
>   if (ret == 0) {
>   connman_device_set_scanning(device,
>   CONNMAN_SERVICE_TYPE_WIFI, true);
> +
> + wifi->scan_fail_timeout = g_timeout_add_seconds(
> + SCAN_FAIL_TIMEOUT,
> + scan_fail_timeout,
> + device);
>   } else
>   connman_device_unref(device);
>  
> @@ -1262,6 +1294,11 @@ static void scan_callback(int result, 
> GSupplicantInterface *interface,
>   if (scanning) {
>   connman_device_set_scanning(device,
>   CONNMAN_SERVICE_TYPE_WIFI, false);
> +
> + if (wifi && wifi->scan_fail_timeout) {
> + g_source_remove(wifi->scan_fail_timeout);
> + wifi->scan_fail_timeout = 0;
> + }
>   }
>  
>   if (result != -ENOLINK)
> @@ -1516,6 +1553,11 @@ static int wifi_disable(struct connman_device *device)
>   connman_device_unref(wifi->device);
>   }
>  
> + if (wifi->scan_fail_timeout) {
> + g_source_remove(wifi->scan_fail_timeout);
> + wifi->scan_fail_timeout = 0;
> + }
> +
>   /* In case of a user scan, device is still referenced */
>   if (connman_device_get_scanning(device)) {
>   connman_device_set_scanning(device,
> @@ -1864,6 +1906,12 @@ static int wifi_scan(enum connman_service_type type,
>   if (ret == 0) {
>   connman_device_set_scanning(device,
>   CONNMAN_SERVICE_TYPE_WIFI, true);
> +
> + wifi->scan_fail_timeout = g_timeout_add_seconds(
> + SCAN_FAIL_TIMEOUT,
> +