Send connman mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.01.org/mailman/listinfo/connman
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of connman digest..."


Today's Topics:

   1. [PATCH 3/3][v3] wifi: Abort tethering enabling if bridge
      creation/configuration fails (Jose Blanquicet)
   2. [PATCH] wifi: Reset correctly tethering flag in case of
      failure (Jose Blanquicet)
   3. Re: [PATCH 3/3][v3] wifi: Abort tethering enabling if bridge
      creation/configuration fails (Daniel Wagner)
   4. [PATCH] Removed redundant NULL check for netmask in
      get_route() (Nishant Chaprana)
   5. [PATCH] Removed redundant NULL check for nameservers in
      __connman_service_nameserver_remove() (Nishant Chaprana)
   6. Re: [PATCH] Removed redundant NULL check for netmask in
      get_route() (Daniel Wagner)
   7. Re: [PATCH] Removed redundant NULL check for nameservers in
      __connman_service_nameserver_remove() (Daniel Wagner)
   8. [PATCH 1/2][v2] stats: Fix bad file descriptor initialisation
      (Lukasz Nowak)
   9. [PATCH 2/2] stats: cleanup of stats file error handling
      (Lukasz Nowak)


----------------------------------------------------------------------

Message: 1
Date: Wed, 26 Oct 2016 08:39:30 +0000
From: Jose Blanquicet <[email protected]>
To: [email protected]
Subject: [PATCH 3/3][v3] wifi: Abort tethering enabling if bridge
        creation/configuration fails
Message-ID: <[email protected]>

In case there is an error while setting up the bridge for WiFi tethering, the
selected interface for tethering will remain removed and could not be use
anymore. This patch aims to avoid such a situation by using
connman_technology_tethering_notify()'s return value to abort tethering
enabling thus do not unnecessary remove the interface in case of something was
wrong with bridge.

---
 plugins/wifi.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index 8bde9c0..06124a6 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -3139,12 +3139,13 @@ static void sta_remove_callback(int result,
 
        if ((result < 0) || (info->wifi->ap_supported != WIFI_AP_SUPPORTED)) {
                info->wifi->tethering = true;
+               connman_technology_tethering_notify(info->technology, false);
 
                g_free(info->ifname);
                g_free(info->ssid);
                g_free(info);
 
-               if (info->wifi->ap_supported == WIFI_AP_SUPPORTED){
+               if (info->wifi->ap_supported == WIFI_AP_SUPPORTED) {
                        g_free(info->wifi->tethering_param->ssid);
                        g_free(info->wifi->tethering_param);
                        info->wifi->tethering_param = NULL;
@@ -3154,8 +3155,6 @@ static void sta_remove_callback(int result,
 
        info->wifi->interface = NULL;
 
-       connman_technology_tethering_notify(info->technology, true);
-
        g_supplicant_interface_create(info->ifname, driver, info->wifi->bridge,
                                                ap_create_callback,
                                                        info);
@@ -3171,7 +3170,7 @@ static int enable_wifi_tethering(struct 
connman_technology *technology,
        struct wifi_tethering_info *info;
        const char *ifname;
        unsigned int mode;
-       int err;
+       int err, berr = 0;
 
        for (list = iface_list; list; list = list->next) {
                wifi = list->data;
@@ -3230,6 +3229,10 @@ static int enable_wifi_tethering(struct 
connman_technology *technology,
                info->wifi->tethering = true;
                info->wifi->ap_supported = WIFI_AP_SUPPORTED;
 
+               berr = connman_technology_tethering_notify(technology, true);
+               if (berr < 0)
+                       goto failed;
+
                err = g_supplicant_interface_remove(interface,
                                                sta_remove_callback,
                                                        info);
@@ -3244,6 +3247,17 @@ static int enable_wifi_tethering(struct 
connman_technology *technology,
                g_free(info);
                g_free(wifi->tethering_param);
                wifi->tethering_param = NULL;
+
+               /*
+                * Remove bridge if it was correctly created but remove
+                * operation failed. Instead, if bridge creation failed then
+                * break out and do not try again on another interface,
+                * bridge set-up does not depend on it.
+                */
+               if (berr == 0)
+                       connman_technology_tethering_notify(technology, false);
+               else
+                       break;
        }
 
        return -EOPNOTSUPP;
-- 
1.9.1



------------------------------

Message: 2
Date: Wed, 26 Oct 2016 08:42:15 +0000
From: Jose Blanquicet <[email protected]>
To: [email protected]
Subject: [PATCH] wifi: Reset correctly tethering flag in case of
        failure
Message-ID: <[email protected]>

If remove interface procedure fails then tethering flag has to be actually
reset, i.e. set to false instead of true.

---
 plugins/wifi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index 8bde9c0..c23261e 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -3138,7 +3138,7 @@ static void sta_remove_callback(int result,
        DBG("ifname %s result %d ", info->ifname, result);
 
        if ((result < 0) || (info->wifi->ap_supported != WIFI_AP_SUPPORTED)) {
-               info->wifi->tethering = true;
+               info->wifi->tethering = false;
 
                g_free(info->ifname);
                g_free(info->ssid);
-- 
1.9.1



------------------------------

Message: 3
Date: Wed, 26 Oct 2016 11:06:22 +0200
From: Daniel Wagner <[email protected]>
To: Jose Blanquicet <[email protected]>, [email protected]
Subject: Re: [PATCH 3/3][v3] wifi: Abort tethering enabling if bridge
        creation/configuration fails
Message-ID: <[email protected]>
Content-Type: text/plain; charset=windows-1252; format=flowed

On 10/26/2016 10:39 AM, Jose Blanquicet wrote:
> In case there is an error while setting up the bridge for WiFi tethering, the
> selected interface for tethering will remain removed and could not be use
> anymore. This patch aims to avoid such a situation by using
> connman_technology_tethering_notify()'s return value to abort tethering
> enabling thus do not unnecessary remove the interface in case of something was
> wrong with bridge.

Both patches applied. git was not happy with this one. It didn't apply 
the first hunk. I did manually. Maybe when splitting your patches 
something went wrong.

Thanks,
Daniel


------------------------------

Message: 4
Date: Wed, 26 Oct 2016 18:31:33 +0530
From: Nishant Chaprana <[email protected]>
To: [email protected]
Cc: [email protected], Nishant Chaprana <[email protected]>
Subject: [PATCH] Removed redundant NULL check for netmask in
        get_route()
Message-ID: <[email protected]>

Signed-off-by: Nishant Chaprana <[email protected]>
---
 vpn/vpn-provider.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/vpn/vpn-provider.c b/vpn/vpn-provider.c
index 2c717fc..d2b3e3a 100644
--- a/vpn/vpn-provider.c
+++ b/vpn/vpn-provider.c
@@ -695,14 +695,11 @@ static struct vpn_route *get_route(char *route_str)
                        in_addr_t addr;
                        struct in_addr netmask_in;
                        unsigned char prefix_len = 32;
+                       char *ptr;
+                       long int value = strtol(netmask, &ptr, 10);
 
-                       if (netmask) {
-                               char *ptr;
-                               long int value = strtol(netmask, &ptr, 10);
-                               if (ptr != netmask && *ptr == '\0' &&
-                                                               value <= 32)
-                                       prefix_len = value;
-                       }
+                       if (ptr != netmask && *ptr == '\0' && value <= 32)
+                               prefix_len = value;
 
                        addr = 0xffffffff << (32 - prefix_len);
                        netmask_in.s_addr = htonl(addr);
-- 
1.9.1



------------------------------

Message: 5
Date: Wed, 26 Oct 2016 18:36:34 +0530
From: Nishant Chaprana <[email protected]>
To: [email protected]
Cc: [email protected], Nishant Chaprana <[email protected]>
Subject: [PATCH] Removed redundant NULL check for nameservers in
        __connman_service_nameserver_remove()
Message-ID: <[email protected]>

Signed-off-by: Nishant Chaprana <[email protected]>
---
 src/service.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/service.c b/src/service.c
index ee10e6c..f6a76f6 100644
--- a/src/service.c
+++ b/src/service.c
@@ -1164,7 +1164,7 @@ int __connman_service_nameserver_remove(struct 
connman_service *service,
        if (!nameservers)
                return 0;
 
-       for (i = 0; nameservers && nameservers[i]; i++)
+       for (i = 0; nameservers[i]; i++)
                if (g_strcmp0(nameservers[i], nameserver) == 0) {
                        found = true;
                        break;
-- 
1.9.1



------------------------------

Message: 6
Date: Wed, 26 Oct 2016 15:19:11 +0200
From: Daniel Wagner <[email protected]>
To: Nishant Chaprana <[email protected]>, [email protected]
Cc: [email protected]
Subject: Re: [PATCH] Removed redundant NULL check for netmask in
        get_route()
Message-ID: <[email protected]>
Content-Type: text/plain; charset=windows-1252; format=flowed

Thanks, patch applied. I just dropped the SoB as we don't do them in 
this project.


------------------------------

Message: 7
Date: Wed, 26 Oct 2016 15:19:24 +0200
From: Daniel Wagner <[email protected]>
To: Nishant Chaprana <[email protected]>, [email protected]
Cc: [email protected]
Subject: Re: [PATCH] Removed redundant NULL check for nameservers in
        __connman_service_nameserver_remove()
Message-ID: <[email protected]>
Content-Type: text/plain; charset=windows-1252; format=flowed

Thanks, patch applied. I just dropped the SoB as we don't do them in 
this project.


------------------------------

Message: 8
Date: Wed, 26 Oct 2016 18:13:02 +0100
From: Lukasz Nowak <[email protected]>
To: [email protected]
Subject: [PATCH 1/2][v2] stats: Fix bad file descriptor initialisation
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8

From: Lukasz Nowak <[email protected]>

Stats file code initialises its file descriptor field to 0.
But 0 is a valid fd value. -1 should be used instead.
This causes problems when an error happens before a stats file is open
(e.g. mkdir fails). The clean-up procedure, stats_free() calls close(fd).
When fd is 0, this first closes stdin, and then any files/sockets which
received fd=0, re-used by the OS.

Fixed several instances of bad file descriptor field handling,
in case of errors.
---
 src/stats.c | 15 +++++++++++++++
 src/util.c  |  4 ++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/stats.c b/src/stats.c
index 26343b1..c3ca738 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -378,6 +378,7 @@ static int stats_file_setup(struct stats_file *file)
                        strerror(errno), file->name);
 
                TFR(close(file->fd));
+               file->fd = -1;
                g_free(file->name);
                file->name = NULL;
 
@@ -393,6 +394,7 @@ static int stats_file_setup(struct stats_file *file)
        err = stats_file_remap(file, size);
        if (err < 0) {
                TFR(close(file->fd));
+               file->fd = -1;
                g_free(file->name);
                file->name = NULL;
 
@@ -649,6 +651,13 @@ static int stats_file_history_update(struct stats_file 
*data_file)
        bzero(history_file, sizeof(struct stats_file));
        bzero(temp_file, sizeof(struct stats_file));
 
+       /*
+        * 0 is a valid file descriptor - fd needs to be initialized
+        * to -1 to handle errors correctly
+        */
+       history_file->fd = -1;
+       temp_file->fd = -1;
+
        err = stats_open(history_file, data_file->history_name);
        if (err < 0)
                return err;
@@ -682,6 +691,12 @@ int __connman_stats_service_register(struct 
connman_service *service)
                if (!file)
                        return -ENOMEM;
 
+               /*
+                * 0 is a valid file descriptor - fd needs to be initialized
+                * to -1 to handle errors correctly
+                */
+               file->fd = -1;
+
                g_hash_table_insert(stats_hash, service, file);
        } else {
                return -EALREADY;
diff --git a/src/util.c b/src/util.c
index da32cc5..0a4413f 100644
--- a/src/util.c
+++ b/src/util.c
@@ -58,7 +58,7 @@ int __connman_util_init(void)
 {
        int r = 0;
 
-       if (f > 0)
+       if (f >= 0)
                return 0;
 
        f = open(URANDOM, O_RDONLY);
@@ -81,7 +81,7 @@ int __connman_util_init(void)
 
 void __connman_util_cleanup(void)
 {
-       if (f > 0)
+       if (f >= 0)
                close(f);
 
        f = -1;
-- 
2.7.4


------------------------------

Message: 9
Date: Wed, 26 Oct 2016 18:13:11 +0100
From: Lukasz Nowak <[email protected]>
To: [email protected]
Subject: [PATCH 2/2] stats: cleanup of stats file error handling
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8

From: Lukasz Nowak <[email protected]>

Moved mkdir before a stats file is created, to avoid
unnecessary further steps in case it fails.
Removed unnecessary conditions in clean-up.
---
 src/stats.c | 45 ++++++++++++++++++++-------------------------
 1 file changed, 20 insertions(+), 25 deletions(-)

diff --git a/src/stats.c b/src/stats.c
index c3ca738..98ce6d9 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -230,15 +230,11 @@ static void stats_free(gpointer user_data)
        TFR(close(file->fd));
        file->fd = -1;
 
-       if (file->history_name) {
-               g_free(file->history_name);
-               file->history_name = NULL;
-       }
+       g_free(file->history_name);
+       file->history_name = NULL;
 
-       if (file->name) {
-               g_free(file->name);
-               file->name = NULL;
-       }
+       g_free(file->name);
+       file->name = NULL;
 
        g_free(file);
 }
@@ -685,23 +681,6 @@ int __connman_stats_service_register(struct 
connman_service *service)
 
        DBG("service %p", service);
 
-       file = g_hash_table_lookup(stats_hash, service);
-       if (!file) {
-               file = g_try_new0(struct stats_file, 1);
-               if (!file)
-                       return -ENOMEM;
-
-               /*
-                * 0 is a valid file descriptor - fd needs to be initialized
-                * to -1 to handle errors correctly
-                */
-               file->fd = -1;
-
-               g_hash_table_insert(stats_hash, service, file);
-       } else {
-               return -EALREADY;
-       }
-
        dir = g_strdup_printf("%s/%s", STORAGEDIR,
                                __connman_service_get_ident(service));
 
@@ -718,6 +697,22 @@ int __connman_stats_service_register(struct 
connman_service *service)
        }
 
        g_free(dir);
+       file = g_hash_table_lookup(stats_hash, service);
+       if (!file) {
+               file = g_try_new0(struct stats_file, 1);
+               if (!file)
+                       return -ENOMEM;
+
+               /*
+                * 0 is a valid file descriptor - fd needs to be initialized
+                * to -1 to handle errors correctly
+                */
+               file->fd = -1;
+
+               g_hash_table_insert(stats_hash, service, file);
+       } else {
+               return -EALREADY;
+       }
 
        name = g_strdup_printf("%s/%s/data", STORAGEDIR,
                                __connman_service_get_ident(service));
-- 
2.7.4



------------------------------

Subject: Digest Footer

_______________________________________________
connman mailing list
[email protected]
https://lists.01.org/mailman/listinfo/connman


------------------------------

End of connman Digest, Vol 12, Issue 29
***************************************

Reply via email to