Re: [PATCH] inet: Ignore EEXIST/ESRCH when adding/removing routes

2013-01-04 Thread Patrik Flykt

Hi,

On Wed, 2012-12-05 at 16:43 -0500, Forest Bond wrote:
> From: Forest Bond 
> 
> This reduces spurious error messages in the logs.

That is a good thing to do, yes.

> ---
>  src/inet.c |   28 
>  1 files changed, 28 insertions(+), 0 deletions(-)
> 
> diff --git a/src/inet.c b/src/inet.c
> index 23b02a2..dcf8bee 100644
> --- a/src/inet.c
> +++ b/src/inet.c
> @@ -555,6 +555,8 @@ int connman_inet_add_network_route(int index, const char 
> *host,
>   rt.rt_dev = ifr.ifr_name;
>  
>   err = ioctl(sk, SIOCADDRT, &rt);
> + if (err < 0 && errno == EEXIST)
> + err = 0;
>   if (err < 0)
>   connman_error("Adding host route failed (%s)",
>   strerror(errno));

It seems the existing code is not doing a very good job here with error
values. I would like the code to always return the resulting -errno
value instead of the current sporadic -1 or ioctl return value. The
error printout should be suppressed when there is no real error just as
in your patch.

Do you think you would have time to spin another version of you patch
according to the above?

Cheers,

Patrik

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH] service: Restart wispr on nameserver change

2013-01-04 Thread Patrik Flykt

Hi,

On Wed, 2012-12-05 at 16:44 -0500, Forest Bond wrote:
> From: Forest Bond 
> 
> This is needed to make a service go online in the case where it was
> already connected and then manual IPv4 & nameservers settings are
> applied.  In that case, wispr is restarted with the new IP settings, but
> the nameservers have not been set yet, so the wispr test fails and the
> service remains in ready state.
> ---
>  src/service.c |   10 ++
>  1 files changed, 10 insertions(+), 0 deletions(-)
> 
> diff --git a/src/service.c b/src/service.c
> index 67889de..88470ad 100644
> --- a/src/service.c
> +++ b/src/service.c
> @@ -3106,6 +3106,16 @@ static DBusMessage *set_property(DBusConnection *conn,
>   update_nameservers(service);
>   dns_configuration_changed(service);
>  
> + if (__connman_service_is_connected_state(service,
> + CONNMAN_IPCONFIG_TYPE_IPV4))
> + __connman_wispr_start(service,
> + CONNMAN_IPCONFIG_TYPE_IPV4);
> +
> + if (__connman_service_is_connected_state(service,
> + CONNMAN_IPCONFIG_TYPE_IPV6))
> + __connman_wispr_start(service,
> + CONNMAN_IPCONFIG_TYPE_IPV6);
> +
>   service_save(service);
>   } else if (g_str_equal(name, "Timeservers.Configuration") == TRUE) {
>   DBusMessageIter entry;

This is all good, but in order to take every nameserver update into
account I think wispr check should be done in/around
update_nameservers() if the service is in state ready and nameservers
exist. The trouble here would be to figure out when
__connman_service_nameserver_remove() is being used and not start the
wispr check at that point.

But maybe that is too much work and we'll go with the proposed solution
anyway. I'll need to think about this some more. Any comments anyone?


Cheers,

Patrik


___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH v1 0/2] Memory profiling support

2013-01-04 Thread Daniel Wagner
From: Daniel Wagner 

Hi,

Here is an update on the previously called 'main: Add g_mem_profile()'.

cheers,
daniel

Daniel Wagner (2):
  main: Move signalfd setup down
  main: Add memory profiling support

 src/main.c | 181 ++---
 1 file changed, 102 insertions(+), 79 deletions(-)

-- 
1.8.0.rc0

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH v1 1/2] main: Move signalfd setup down

2013-01-04 Thread Daniel Wagner
From: Daniel Wagner 

In the next patch we like to access the option flags, therefore
move the signal_handler(), setup_signalfd and disconnect_callback()
after the parser functions and the option_* decleration.
---
 src/main.c | 158 ++---
 1 file changed, 79 insertions(+), 79 deletions(-)

diff --git a/src/main.c b/src/main.c
index 350d43b..3da527e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -342,85 +342,6 @@ static int config_init(const char *file)
return 0;
 }
 
-static GMainLoop *main_loop = NULL;
-
-static unsigned int __terminated = 0;
-
-static gboolean signal_handler(GIOChannel *channel, GIOCondition cond,
-   gpointer user_data)
-{
-   struct signalfd_siginfo si;
-   ssize_t result;
-   int fd;
-
-   if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP))
-   return FALSE;
-
-   fd = g_io_channel_unix_get_fd(channel);
-
-   result = read(fd, &si, sizeof(si));
-   if (result != sizeof(si))
-   return FALSE;
-
-   switch (si.ssi_signo) {
-   case SIGINT:
-   case SIGTERM:
-   if (__terminated == 0) {
-   connman_info("Terminating");
-   g_main_loop_quit(main_loop);
-   }
-
-   __terminated = 1;
-   break;
-   }
-
-   return TRUE;
-}
-
-static guint setup_signalfd(void)
-{
-   GIOChannel *channel;
-   guint source;
-   sigset_t mask;
-   int fd;
-
-   sigemptyset(&mask);
-   sigaddset(&mask, SIGINT);
-   sigaddset(&mask, SIGTERM);
-
-   if (sigprocmask(SIG_BLOCK, &mask, NULL) < 0) {
-   perror("Failed to set signal mask");
-   return 0;
-   }
-
-   fd = signalfd(-1, &mask, 0);
-   if (fd < 0) {
-   perror("Failed to create signal descriptor");
-   return 0;
-   }
-
-   channel = g_io_channel_unix_new(fd);
-
-   g_io_channel_set_close_on_unref(channel, TRUE);
-   g_io_channel_set_encoding(channel, NULL, NULL);
-   g_io_channel_set_buffered(channel, FALSE);
-
-   source = g_io_add_watch(channel,
-   G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
-   signal_handler, NULL);
-
-   g_io_channel_unref(channel);
-
-   return source;
-}
-
-static void disconnect_callback(DBusConnection *conn, void *user_data)
-{
-   connman_error("D-Bus disconnect");
-
-   g_main_loop_quit(main_loop);
-}
-
 static gchar *option_config = NULL;
 static gchar *option_debug = NULL;
 static gchar *option_device = NULL;
@@ -534,6 +455,85 @@ unsigned int connman_timeout_browser_launch(void) {
return connman_settings.timeout_browserlaunch;
 }
 
+static GMainLoop *main_loop = NULL;
+
+static unsigned int __terminated = 0;
+
+static gboolean signal_handler(GIOChannel *channel, GIOCondition cond,
+   gpointer user_data)
+{
+   struct signalfd_siginfo si;
+   ssize_t result;
+   int fd;
+
+   if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP))
+   return FALSE;
+
+   fd = g_io_channel_unix_get_fd(channel);
+
+   result = read(fd, &si, sizeof(si));
+   if (result != sizeof(si))
+   return FALSE;
+
+   switch (si.ssi_signo) {
+   case SIGINT:
+   case SIGTERM:
+   if (__terminated == 0) {
+   connman_info("Terminating");
+   g_main_loop_quit(main_loop);
+   }
+
+   __terminated = 1;
+   break;
+   }
+
+   return TRUE;
+}
+
+static guint setup_signalfd(void)
+{
+   GIOChannel *channel;
+   guint source;
+   sigset_t mask;
+   int fd;
+
+   sigemptyset(&mask);
+   sigaddset(&mask, SIGINT);
+   sigaddset(&mask, SIGTERM);
+
+   if (sigprocmask(SIG_BLOCK, &mask, NULL) < 0) {
+   perror("Failed to set signal mask");
+   return 0;
+   }
+
+   fd = signalfd(-1, &mask, 0);
+   if (fd < 0) {
+   perror("Failed to create signal descriptor");
+   return 0;
+   }
+
+   channel = g_io_channel_unix_new(fd);
+
+   g_io_channel_set_close_on_unref(channel, TRUE);
+   g_io_channel_set_encoding(channel, NULL, NULL);
+   g_io_channel_set_buffered(channel, FALSE);
+
+   source = g_io_add_watch(channel,
+   G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+   signal_handler, NULL);
+
+   g_io_channel_unref(channel);
+
+   return source;
+}
+
+static void disconnect_callback(DBusConnection *conn, void *user_data)
+{
+   connman_error("D-Bus disconnect");
+
+   g_main_loop_quit(main_loop);
+}
+
 int main(int argc, char *argv[])
 {
GOptionContext *context;
-- 
1.8.0.rc0

___
connman ma

[PATCH v1 2/2] main: Add memory profiling support

2013-01-04 Thread Daniel Wagner
From: Daniel Wagner 

When the debug option is set ('-d') then the glib memory profiling
subsystem is enabled. To see the profiling information send
a SIGRTMIN to connman, e.g. killall -34 connmand

Unfortunatly we need to parse argv by hand because no glib function
can be called before setting g_mem_set_vtable().

Another small hickup is that SIGRTMIN is redefined as 'int' by
glibc, therefore we can't add it as 'case' to the switch and
we need to add an ugly cast.
---
 src/main.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/src/main.c b/src/main.c
index 3da527e..4bc9ace 100644
--- a/src/main.c
+++ b/src/main.c
@@ -487,6 +487,9 @@ static gboolean signal_handler(GIOChannel *channel, 
GIOCondition cond,
break;
}
 
+   if (si.ssi_signo == (unsigned int)SIGRTMIN)
+   g_mem_profile();
+
return TRUE;
 }
 
@@ -500,6 +503,8 @@ static guint setup_signalfd(void)
sigemptyset(&mask);
sigaddset(&mask, SIGINT);
sigaddset(&mask, SIGTERM);
+   if (option_debug != NULL)
+   sigaddset(&mask, SIGRTMIN);
 
if (sigprocmask(SIG_BLOCK, &mask, NULL) < 0) {
perror("Failed to set signal mask");
@@ -534,6 +539,22 @@ static void disconnect_callback(DBusConnection *conn, void 
*user_data)
g_main_loop_quit(main_loop);
 }
 
+static void setup_memory_profiling(int argc, char *argv[])
+{
+   int i;
+
+   for (i = 0; i < argc; i++) {
+   if (argv[i] == NULL)
+   continue;
+
+   if (strncmp(argv[i], "-d", 2) != 0)
+   continue;
+
+   g_mem_set_vtable(glib_mem_profiler_table);
+   break;
+   }
+}
+
 int main(int argc, char *argv[])
 {
GOptionContext *context;
@@ -542,6 +563,8 @@ int main(int argc, char *argv[])
DBusError err;
guint signal;
 
+   setup_memory_profiling(argc, argv);
+
 #ifdef NEED_THREADS
if (g_thread_supported() == FALSE)
g_thread_init(NULL);
-- 
1.8.0.rc0

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [RFC 0/5] WiMAX plugin removal

2013-01-04 Thread Patrik Flykt
On Tue, 2012-12-11 at 16:36 +0200, patrik.fl...@linux.intel.com wrote:
> Time has come to remove WiMAX plugin due to being unsupported for a long
> time already. Speak up now and be prepared to maintain WiMAX if it is
> still needed!

Applied.

Patrik

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [RFC 0/2] Removal of storage migration

2013-01-04 Thread Patrik Flykt
On Fri, 2012-12-14 at 15:58 +0200, patrik.fl...@linux.intel.com wrote:
> This patch set removes the storage migration code. It is assumed that
> everybody is using at least ConnMan 1.1 at this point. The unfortunate
> distro in this respect is Debian, they might want to revert patch 01
> when they upgrade from their current ConnMan version 1.0-1.

The above text is not really correct. ConnMan 0.78 already implemented
saving of all settings into the current format. ConnMan 1.1 made a more
extensive effort of moving all services that had been unused since
ConnMan version 0.77 to the new format.

Rebased on top of the WiMAX removal patches, removed left-over
definition from connman.h also.

Applied.

Patrik

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH v1 1/2] main: Move signalfd setup down

2013-01-04 Thread Marcel Holtmann
Hi Daniel,

> In the next patch we like to access the option flags, therefore
> move the signal_handler(), setup_signalfd and disconnect_callback()
> after the parser functions and the option_* decleration.
> ---
>  src/main.c | 158 
> ++---
>  1 file changed, 79 insertions(+), 79 deletions(-)

this one makes no sense. Especially after looking at 2/2 now.

And I like to keep the scope of the option_* variables limited to
closely to main() as possible. Just so nobody goes and tries to screw
around with them.

Regards

Marcel


___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH v1 2/2] main: Add memory profiling support

2013-01-04 Thread Marcel Holtmann
Hi Daniel,

> When the debug option is set ('-d') then the glib memory profiling
> subsystem is enabled. To see the profiling information send
> a SIGRTMIN to connman, e.g. killall -34 connmand
> 
> Unfortunatly we need to parse argv by hand because no glib function
> can be called before setting g_mem_set_vtable().

Ugly :(

> 
> Another small hickup is that SIGRTMIN is redefined as 'int' by
> glibc, therefore we can't add it as 'case' to the switch and
> we need to add an ugly cast.

What now? Comment in the code would be a good idea.

> ---
>  src/main.c | 23 +++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/src/main.c b/src/main.c
> index 3da527e..4bc9ace 100644
> --- a/src/main.c
> +++ b/src/main.c
> @@ -487,6 +487,9 @@ static gboolean signal_handler(GIOChannel *channel, 
> GIOCondition cond,
>   break;
>   }
>  
> + if (si.ssi_signo == (unsigned int)SIGRTMIN)
> + g_mem_profile();
> +
>   return TRUE;
>  }
>  
> @@ -500,6 +503,8 @@ static guint setup_signalfd(void)
>   sigemptyset(&mask);
>   sigaddset(&mask, SIGINT);
>   sigaddset(&mask, SIGTERM);
> + if (option_debug != NULL)
> + sigaddset(&mask, SIGRTMIN);

You could pass it to setup_signalfd if you want SIGRTMIN enabled or not.
The hack around moving option_debug is a big excessive for just this
simple goal.

>  
>   if (sigprocmask(SIG_BLOCK, &mask, NULL) < 0) {
>   perror("Failed to set signal mask");
> @@ -534,6 +539,22 @@ static void disconnect_callback(DBusConnection *conn, 
> void *user_data)
>   g_main_loop_quit(main_loop);
>  }
>  
> +static void setup_memory_profiling(int argc, char *argv[])
> +{
> + int i;
> +
> + for (i = 0; i < argc; i++) {
> + if (argv[i] == NULL)
> + continue;

What do you want to continue to here. More argv[i] == NULL ;)

Can this be really NULL at any time ever actually.

> +
> + if (strncmp(argv[i], "-d", 2) != 0)
> + continue;
> +
> + g_mem_set_vtable(glib_mem_profiler_table);
> + break;
> + }
> +}
> +
>  int main(int argc, char *argv[])
>  {
>   GOptionContext *context;
> @@ -542,6 +563,8 @@ int main(int argc, char *argv[])
>   DBusError err;
>   guint signal;
>  
> + setup_memory_profiling(argc, argv);
> +
>  #ifdef NEED_THREADS
>   if (g_thread_supported() == FALSE)
>   g_thread_init(NULL);

Regards

Marcel


___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: connman wlan0 scan gets stuck?

2013-01-04 Thread Stan Hu
Ok, I think I figured out the root cause.  At a high level, I think
this is a bug in the interaction between wpa_supplicant, connman, and
the nl80211 driver.

Let's say you took your device somewhere and connected to SSID Alice.
connman saves a settings file in /var/lib/connman for this successful
connection.  Let's say you then moved your device and connected to
SSID Bob.  connman also saves another settings file for this
connection.

Now, when connman starts up, it asks wpa_supplicant to scan SSIDs
Alice and Bob and the frequencies on which the device last connected.
Since Alice doesn't exist, the nl80211 driver reports:

nl80211: Scan trigger failed: ret=-22 (Invalid argument)

wpa_supplicant never returns a successful scan, so connman gets stuck
waiting for the scan to complete.  If you call 'iwlist wlan0
scanning', this causes the nl80211 driver to do a full scan WITHOUT
the SSIDs.  wpa_supplicant returns back the results,connman resumes,
and everything works.

There are several problems I see here:

1) connman should timeout from the failed scan and retry
2) connman should only ask to scan SSIDs if they are present, or not
scan explicit SSIDs at all
3) The nl80211 driver should arguably not return an illegal argument
error if an SSID does not exist
4) If an error occurs, wpa_supplicant should return either empty scan
results or some error message on dbus

A quick fix is to erase all cached profiles in /var/lib/connman/wifi*
so that connman won't attempt to scan non-existing SSIDs, but I think
there should be something in the code to handle cases #1 and #2.

On Thu, Jan 3, 2013 at 11:31 PM, Raseel Bhagat
 wrote:
> Hi
>
> -Original Message-
> From: connman-boun...@connman.net [mailto:connman-boun...@connman.net] On 
> Behalf Of Stan Hu
> Sent: Friday, January 04, 2013 12:09 PM
> To: connman@connman.net
> Subject: connman wlan0 scan gets stuck?
>
>>I'm running connman v1.4 and wpa-supplicant v0.73 (old, I know), but
>>
>>Essentially connmand starts up in a state where no WiFi services are
>>listed unless I either:
>>
>>1) run 'iwlist scan'
>>2) clean out the /var/lib/connman/wifi* directory for the AP and restart 
>>connman
>
> I have been using connman v1.3.
> However, instead of calling "iwlist scan" , I do the following after running 
> connmand -n :
> test-connman enable  wifi
> test-connman scan wifi
> test-connman services
>
> Also, the periodic autoscan by wpa_supplicant seems to be working fine with 
> my setup.
>
> Can you try the above and see if you are still facing the issue ?
>
> Thanks,
> Raseel Bhagat
>
>
> ___
> connman mailing list
> connman@connman.net
> http://lists.connman.net/listinfo/connman
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: connman wlan0 scan gets stuck?

2013-01-04 Thread Felipe Ferreri Tonello

Hi Stan,

On 01/03/2013 10:38 PM, Stan Hu wrote:

I'm running connman v1.4 and wpa-supplicant v0.73 (old, I know), but
before I try upgrading everything--which is not a trivial matter since
the software needs to be deployed on hundreds of devices--I want to
understand the issue.


Can you scan for the first time?

Because I had this problem and I fixed updating wpa_supplicant to 1.0 or 
grater.


Regards,

Felipe Tonello

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman