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 v2 0/4] Device blacklisting (Patrik Flykt)
   2. [PATCH v2 1/4] detect: Remove detect.c (Patrik Flykt)
   3. [PATCH v2 3/4] rtnl: Send also interface name in the RTNL
      callback (Patrik Flykt)
   4. [PATCH v2 4/4] device: Check interface blacklist on receiving
      RTNL newlink (Patrik Flykt)
   5. [PATCH v2 2/4] rtnl: Always set service and device type
      (Patrik Flykt)
   6. Re: [PATCH v2 0/4] Device blacklisting (Jose Blanquicet)


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

Message: 1
Date: Wed, 31 May 2017 09:52:31 +0300
From: Patrik Flykt <[email protected]>
To: [email protected]
Subject: [PATCH v2 0/4] Device blacklisting
Message-ID: <[email protected]>


      Hi,

Version 2 contains only commit message fixes, so no changes to the
code. I'm still waiting for a particular person/project to test this,
but if you have noticed a problem with interface blacklisting, go
ahead and test. If it works properly I won't wait forever for that
particular person :-)


Cheers,

        Patrik


Patrik Flykt (4):
  detect: Remove detect.c
  rtnl: Always set service and device type
  rtnl: Send also interface name in the RTNL callback
  device: Check interface blacklist on receiving RTNL newlink

 Makefile.am    |   2 +-
 include/rtnl.h |   4 +-
 src/detect.c   | 133 ---------------------------------------------------------
 src/device.c   |  89 +++++++++++++++++++++++++++++++++++---
 src/main.c     |   2 -
 src/rtnl.c     |  26 +++--------
 6 files changed, 90 insertions(+), 166 deletions(-)
 delete mode 100644 src/detect.c

-- 
2.11.0



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

Message: 2
Date: Wed, 31 May 2017 09:52:32 +0300
From: Patrik Flykt <[email protected]>
To: [email protected]
Subject: [PATCH v2 1/4] detect: Remove detect.c
Message-ID: <[email protected]>

detect.c only deals with devices detected by information from kernel
RTNL updates. Simplify code dependencies by adding the same functionality
into device.c instead.
---
 Makefile.am  |   2 +-
 src/detect.c | 133 -----------------------------------------------------------
 src/device.c |  68 +++++++++++++++++++++++++++++-
 src/main.c   |   2 -
 4 files changed, 68 insertions(+), 137 deletions(-)
 delete mode 100644 src/detect.c

diff --git a/Makefile.am b/Makefile.am
index e67a7a55..72e84ebf 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -114,7 +114,7 @@ src_connmand_SOURCES = $(gdhcp_sources) $(gweb_sources) 
$(backtrace_sources) \
                        src/manager.c src/service.c \
                        src/clock.c src/timezone.c src/agent-connman.c \
                        src/agent.c src/notifier.c src/provider.c \
-                       src/resolver.c src/ipconfig.c src/detect.c src/inet.c \
+                       src/resolver.c src/ipconfig.c src/inet.c \
                        src/dhcp.c src/dhcpv6.c src/rtnl.c src/proxy.c \
                        src/utsname.c src/timeserver.c src/rfkill.c \
                        src/storage.c src/dbus.c src/config.c \
diff --git a/src/detect.c b/src/detect.c
deleted file mode 100644
index 6c039206..00000000
--- a/src/detect.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- *
- *  Connection Manager
- *
- *  Copyright (C) 2007-2013  Intel Corporation. All rights reserved.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 2 as
- *  published by the Free Software Foundation.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <glib.h>
-
-#include "connman.h"
-
-static GSList *device_list = NULL;
-
-static struct connman_device *find_device(int index)
-{
-       GSList *list;
-
-       for (list = device_list; list; list = list->next) {
-               struct connman_device *device = list->data;
-
-               if (connman_device_get_index(device) == index)
-                       return device;
-       }
-
-       return NULL;
-}
-
-static void detect_newlink(unsigned short type, int index,
-                                       unsigned flags, unsigned change)
-{
-       struct connman_device *device;
-       enum connman_device_type devtype;
-
-       DBG("type %d index %d", type, index);
-
-       devtype = __connman_rtnl_get_device_type(index);
-
-       switch (devtype) {
-       case CONNMAN_DEVICE_TYPE_UNKNOWN:
-       case CONNMAN_DEVICE_TYPE_VENDOR:
-       case CONNMAN_DEVICE_TYPE_BLUETOOTH:
-       case CONNMAN_DEVICE_TYPE_CELLULAR:
-       case CONNMAN_DEVICE_TYPE_GPS:
-               return;
-       case CONNMAN_DEVICE_TYPE_ETHERNET:
-       case CONNMAN_DEVICE_TYPE_WIFI:
-       case CONNMAN_DEVICE_TYPE_GADGET:
-               break;
-       }
-
-       device = find_device(index);
-       if (device)
-               return;
-
-       device = connman_device_create_from_index(index);
-       if (!device)
-               return;
-
-       if (connman_device_register(device) < 0) {
-               connman_device_unref(device);
-               return;
-       }
-
-       device_list = g_slist_prepend(device_list, device);
-}
-
-static void detect_dellink(unsigned short type, int index,
-                                       unsigned flags, unsigned change)
-{
-       struct connman_device *device;
-
-       DBG("type %d index %d", type, index);
-
-       device = find_device(index);
-       if (!device)
-               return;
-
-       device_list = g_slist_remove(device_list, device);
-
-       connman_device_unregister(device);
-       connman_device_unref(device);
-}
-
-static struct connman_rtnl detect_rtnl = {
-       .name           = "detect",
-       .priority       = CONNMAN_RTNL_PRIORITY_LOW,
-       .newlink        = detect_newlink,
-       .dellink        = detect_dellink,
-};
-
-int __connman_detect_init(void)
-{
-       DBG("");
-
-       return connman_rtnl_register(&detect_rtnl);
-}
-
-void __connman_detect_cleanup(void)
-{
-       GSList *list;
-
-       DBG("");
-
-       connman_rtnl_unregister(&detect_rtnl);
-
-       for (list = device_list; list; list = list->next) {
-               struct connman_device *device = list->data;
-
-               connman_device_unregister(device);
-               connman_device_unref(device);
-       }
-
-       g_slist_free(device_list);
-       device_list = NULL;
-}
diff --git a/src/device.c b/src/device.c
index 47112906..ebed8481 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1409,6 +1409,63 @@ static void cleanup_devices(void)
        g_strfreev(interfaces);
 }
 
+static void device_rtnl_newlink(unsigned short type, int index,
+                                       unsigned flags, unsigned change)
+{
+       struct connman_device *device;
+       enum connman_device_type devtype;
+
+       DBG("type %d index %d", type, index);
+
+       devtype = __connman_rtnl_get_device_type(index);
+
+       switch (devtype) {
+       case CONNMAN_DEVICE_TYPE_UNKNOWN:
+       case CONNMAN_DEVICE_TYPE_VENDOR:
+       case CONNMAN_DEVICE_TYPE_BLUETOOTH:
+       case CONNMAN_DEVICE_TYPE_CELLULAR:
+       case CONNMAN_DEVICE_TYPE_GPS:
+               return;
+       case CONNMAN_DEVICE_TYPE_ETHERNET:
+       case CONNMAN_DEVICE_TYPE_WIFI:
+       case CONNMAN_DEVICE_TYPE_GADGET:
+               break;
+       }
+
+       device = connman_device_find_by_index(index);
+       if (device)
+               return;
+
+       device = connman_device_create_from_index(index);
+       if (!device)
+               return;
+
+       if (connman_device_register(device) < 0)
+               connman_device_unref(device);
+}
+
+static void device_rtnl_dellink(unsigned short type, int index,
+                                       unsigned flags, unsigned change)
+{
+       struct connman_device *device;
+
+       DBG("type %d index %d", type, index);
+
+       device = connman_device_find_by_index(index);
+       if (!device)
+               return;
+
+       connman_device_unregister(device);
+       connman_device_unref(device);
+}
+
+static struct connman_rtnl device_rtnl = {
+       .name           = "device",
+       .priority       = CONNMAN_RTNL_PRIORITY_LOW,
+       .newlink        = device_rtnl_newlink,
+       .dellink        = device_rtnl_dellink,
+};
+
 int __connman_device_init(const char *device, const char *nodevice)
 {
        DBG("");
@@ -1421,13 +1478,22 @@ int __connman_device_init(const char *device, const 
char *nodevice)
 
        cleanup_devices();
 
-       return 0;
+       return connman_rtnl_register(&device_rtnl);
 }
 
 void __connman_device_cleanup(void)
 {
        DBG("");
 
+       connman_rtnl_unregister(&device_rtnl);
+
+       while (device_list) {
+               struct connman_device *device = device_list->data;
+
+               connman_device_unregister(device);
+               connman_device_unref(device);
+       }
+
        g_strfreev(nodevice_filter);
        g_strfreev(device_filter);
 }
diff --git a/src/main.c b/src/main.c
index b78a0461..a76234ca 100644
--- a/src/main.c
+++ b/src/main.c
@@ -755,7 +755,6 @@ int main(int argc, char *argv[])
        __connman_rtnl_init();
        __connman_task_init();
        __connman_proxy_init();
-       __connman_detect_init();
        __connman_session_init();
        __connman_timeserver_init();
        __connman_connection_init();
@@ -791,7 +790,6 @@ int main(int argc, char *argv[])
        __connman_provider_cleanup();
        __connman_connection_cleanup();
        __connman_timeserver_cleanup();
-       __connman_detect_cleanup();
        __connman_proxy_cleanup();
        __connman_task_cleanup();
        __connman_rtnl_cleanup();
-- 
2.11.0



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

Message: 3
Date: Wed, 31 May 2017 09:52:34 +0300
From: Patrik Flykt <[email protected]>
To: [email protected]
Subject: [PATCH v2 3/4] rtnl: Send also interface name in the RTNL
        callback
Message-ID: <[email protected]>

Since the interface name is known, send it to the RTNL callbacks.
Right now triggering of RTNL information on rtnl_trigger() is sending
the interface name as NULL since this information is not stored.
For the built-in code RTNL callbacks are registered during
initialization when no devices or networks have yet been created
so this will not be a problem.
---
 include/rtnl.h | 4 ++--
 src/device.c   | 6 ++++--
 src/rtnl.c     | 6 +++---
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/include/rtnl.h b/include/rtnl.h
index aa70f4d8..e25b0f57 100644
--- a/include/rtnl.h
+++ b/include/rtnl.h
@@ -47,9 +47,9 @@ void connman_rtnl_remove_watch(unsigned int id);
 struct connman_rtnl {
        const char *name;
        int priority;
-       void (*newlink) (unsigned short type, int index,
+       void (*newlink) (unsigned short type, int index, const char *ifname,
                                        unsigned flags, unsigned change);
-       void (*dellink) (unsigned short type, int index,
+       void (*dellink) (unsigned short type, int index, const char *ifname,
                                        unsigned flags, unsigned change);
        void (*newgateway) (int index, const char *gateway);
        void (*delgateway) (int index, const char *gateway);
diff --git a/src/device.c b/src/device.c
index ebed8481..aafe75a1 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1410,7 +1410,8 @@ static void cleanup_devices(void)
 }
 
 static void device_rtnl_newlink(unsigned short type, int index,
-                                       unsigned flags, unsigned change)
+                               const char *interface, unsigned flags,
+                               unsigned change)
 {
        struct connman_device *device;
        enum connman_device_type devtype;
@@ -1445,7 +1446,8 @@ static void device_rtnl_newlink(unsigned short type, int 
index,
 }
 
 static void device_rtnl_dellink(unsigned short type, int index,
-                                       unsigned flags, unsigned change)
+                               const char *interface, unsigned flags,
+                               unsigned change)
 {
        struct connman_device *device;
 
diff --git a/src/rtnl.c b/src/rtnl.c
index 0f8b218f..e34aa366 100644
--- a/src/rtnl.c
+++ b/src/rtnl.c
@@ -268,7 +268,7 @@ static void trigger_rtnl(int index, void *user_data)
                unsigned short type = 
__connman_ipconfig_get_type_from_index(index);
                unsigned int flags = 
__connman_ipconfig_get_flags_from_index(index);
 
-               rtnl->newlink(type, index, flags, 0);
+               rtnl->newlink(type, index, NULL, flags, 0);
        }
 
        if (rtnl->newgateway) {
@@ -464,7 +464,7 @@ static void process_newlink(unsigned short type, int index, 
unsigned flags,
                struct connman_rtnl *rtnl = list->data;
 
                if (rtnl->newlink)
-                       rtnl->newlink(type, index, flags, change);
+                       rtnl->newlink(type, index, ifname, flags, change);
        }
 
        /*
@@ -509,7 +509,7 @@ static void process_dellink(unsigned short type, int index, 
unsigned flags,
                struct connman_rtnl *rtnl = list->data;
 
                if (rtnl->dellink)
-                       rtnl->dellink(type, index, flags, change);
+                       rtnl->dellink(type, index, ifname, flags, change);
        }
 
        switch (type) {
-- 
2.11.0



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

Message: 4
Date: Wed, 31 May 2017 09:52:35 +0300
From: Patrik Flykt <[email protected]>
To: [email protected]
Subject: [PATCH v2 4/4] device: Check interface blacklist on receiving
        RTNL newlink
Message-ID: <[email protected]>

Check interface blacklist status when RTNL newlink messages are received.
If the interface already exists, i.e. the interface was renamed with
the new name blacklisted, remove the interface. Notice that blacklisting
is applied only on wifi, ethernet and gadget technologies as these are
the ones detected via RTNL messages. Bluetooth and cellular networks are
controlled via Bluez and oFono daemons from ConnMan, with ConnMan having
better control of which networks and therefore interfaces are meant to be
used.
---
 src/device.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/device.c b/src/device.c
index aafe75a1..d60089bd 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1215,12 +1215,6 @@ struct connman_device 
*connman_device_create_from_index(int index)
        if (!devname)
                return NULL;
 
-       if (__connman_device_isfiltered(devname)) {
-               connman_info("Ignoring interface %s (filtered)", devname);
-               g_free(devname);
-               return NULL;
-       }
-
        type = __connman_rtnl_get_device_type(index);
 
        switch (type) {
@@ -1434,6 +1428,19 @@ static void device_rtnl_newlink(unsigned short type, int 
index,
        }
 
        device = connman_device_find_by_index(index);
+
+       if (__connman_device_isfiltered(interface)) {
+
+               connman_info("Ignoring interface %s (filtered)", interface);
+
+               if (device) {
+                       connman_device_unregister(device);
+                       connman_device_unref(device);
+               }
+
+               return;
+       }
+
        if (device)
                return;
 
-- 
2.11.0



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

Message: 5
Date: Wed, 31 May 2017 09:52:33 +0300
From: Patrik Flykt <[email protected]>
To: [email protected]
Subject: [PATCH v2 2/4] rtnl: Always set service and device type
Message-ID: <[email protected]>

Always set a service and device type for a newly created RTNL
interface. With this change blacklisting will take place only
once, on device creation in connman_device_create_from_index().

Once past blacklisting in connman_device_create_from_index(),
the next device creation criteria is its device type. If an
unknown type were to be returned as a result of the previously
existing read_uevent() blacklisting code, the device would not
be created either. As all RTNL devices and their types are
remembered starting with reception of the first RTNL newlink,
__connman_rtnl_get_device_type() must always return the proper
device type in order to create the device.
---
 src/rtnl.c | 20 ++------------------
 1 file changed, 2 insertions(+), 18 deletions(-)

diff --git a/src/rtnl.c b/src/rtnl.c
index a094e257..0f8b218f 100644
--- a/src/rtnl.c
+++ b/src/rtnl.c
@@ -83,17 +83,6 @@ static void free_interface(gpointer data)
        g_free(interface);
 }
 
-static bool ether_blacklisted(const char *name)
-{
-       if (!name)
-               return true;
-
-       if (__connman_device_isfiltered(name))
-               return true;
-
-       return false;
-}
-
 static bool wext_interface(char *ifname)
 {
        struct iwreq wrq;
@@ -124,13 +113,8 @@ static void read_uevent(struct interface_data *interface)
 
        name = connman_inet_ifname(interface->index);
 
-       if (ether_blacklisted(name)) {
-               interface->service_type = CONNMAN_SERVICE_TYPE_UNKNOWN;
-               interface->device_type = CONNMAN_DEVICE_TYPE_UNKNOWN;
-       } else {
-               interface->service_type = CONNMAN_SERVICE_TYPE_ETHERNET;
-               interface->device_type = CONNMAN_DEVICE_TYPE_ETHERNET;
-       }
+       interface->service_type = CONNMAN_SERVICE_TYPE_ETHERNET;
+       interface->device_type = CONNMAN_DEVICE_TYPE_ETHERNET;
 
        filename = g_strdup_printf("/sys/class/net/%s/uevent", name);
 
-- 
2.11.0



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

Message: 6
Date: Wed, 31 May 2017 09:12:37 +0000
From: Jose Blanquicet <[email protected]>
To: Patrik Flykt <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v2 0/4] Device blacklisting
Message-ID:
        <cafc8ijj7qf6sjfu13ozhaorngg88vrsuqicj_8yjtwfvvwm...@mail.gmail.com>
Content-Type: text/plain; charset="UTF-8"

Hi Patrik,

On Wed, May 31, 2017 at 6:52 AM, Patrik Flykt wrote:
> Version 2 contains only commit message fixes, so no changes to the
> code. I'm still waiting for a particular person/project to test this,
> but if you have noticed a problem with interface blacklisting, go
> ahead and test. If it works properly I won't wait forever for that
> particular person :-)

In our environment where we only need to ignore some network
interfaces, we don't see any regression. Please, take into account we
don't modify interface name at runtime thus I did not test what this
path set is really fixing. I just would like to add that there is
something about GLib is now "complaining" at the initialization:

Connection Manager version 1.34
src/dbus.c:__connman_dbus_init()
src/inotify.c:__connman_inotify_init()
src/technology.c:__connman_technology_init()
src/notifier.c:__connman_notifier_init()
src/agent.c:__connman_agent_init()
src/service.c:__connman_service_init()
src/agent.c:connman_agent_driver_register() Registering driver
0x6bf180 name service
src/peer_service.c:__connman_peer_service_init()
src/peer.c:__connman_peer_init()
src/provider.c:__connman_provider_init()
src/notifier.c:connman_notifier_register() notifier 0x6bf1c0 name provider
src/network.c:__connman_network_init()
src/config.c:__connman_config_init()
src/inotify.c:create_watch() Add directory watch for /var/lib/connman
src/config.c:read_configs()
src/device.c:__connman_device_init()
src/inet.c:__connman_inet_get_address_netmask() index 4
src/device.c:cleanup_devices() cleaning up eth3 index 4
src/rtnl.c:connman_rtnl_register() rtnl 0x6bf0a0 name device

 GLib-CRITICAL **: g_hash_table_get_keys: assertion 'hash_table != NULL' failed
src/ippool.c:__connman_ippool_init()
src/firewall-iptables.c:__connman_firewall_init()
src/iptables.c:__connman_iptables_init()
src/nat.c:__connman_nat_init()

Regards,

Jose Blanquicet


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

Subject: Digest Footer

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


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

End of connman Digest, Vol 19, Issue 18
***************************************

Reply via email to