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 0/4] Device blacklisting (Patrik Flykt)
2. [PATCH 2/4] rtnl: Always set service and device type
(Patrik Flykt)
3. [PATCH 3/4] rtnl: Send also interface name in the RTNL
callback (Patrik Flykt)
4. [PATCH 1/4] detect: Remove detect.c (Patrik Flykt)
5. [PATCH 4/4] device: Check interface blacklist on receiving
RTNL newlink (Patrik Flykt)
----------------------------------------------------------------------
Message: 1
Date: Fri, 26 May 2017 13:14:04 +0300
From: Patrik Flykt <[email protected]>
To: [email protected]
Subject: [PATCH 0/4] Device blacklisting
Message-ID: <[email protected]>
Hi,
Blacklisting does not work when devices change their interface name,
but this patch set attempts to fix that. With the following changes
blacklisting the first interface name should make ConnMan aware of
the interface when it is renamed and vice versa.
In patch 1/4 the functionality provided by detect.c is merged with
device.c. The code in detect.c does nothing else, so this simplifies
dependencies between the files.
Patch 2/4 removes the additional blacklisting done by rtnl.c. This
additional check will set the device type to unknown, but after that
the device may get its device and service types set to correct values
again. This is confusing and will confuse blacklisting later on.
Patch 3/4 adds interface names to newlink and dellink callbacks. As
the only callbacks are registered for device.c during initialization
time, it does not matter that trigger_rtnl passes NULL as interface
name as there will not be any ipdevices at that time.
Patch 4/4 moves the interface blacklist checking to the RTNL newlink
callback as this callback is the only function in ConnMan that uses
connman_device_create_from_index where the check was located previously.
With this the new name of the interface can be checked and the device
unregistered should the blacklisting entry be only for the renamed
device name.
As this is a bit difficult to test, I hope to have somebody running
this during their builds. But if someone feels like it, please test.
The code in device.c should see a make-over, it's a bit clunky as it
is right now. It would be especially useful to colled all interface
index to interface name mapping into device.c to get rid of an extra
ioctl where ConnMan code currently maps index numbers to interface
name strings and/or back. This requires all plugins to submit
such information and the best approach here probably is to create a
new function that creates and registers a device into ConnMan's data
structures. But that's another patch set.
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: Fri, 26 May 2017 13:14:06 +0300
From: Patrik Flykt <[email protected]>
To: [email protected]
Subject: [PATCH 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
have been 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: 3
Date: Fri, 26 May 2017 13:14:07 +0300
From: Patrik Flykt <[email protected]>
To: [email protected]
Subject: [PATCH 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: Fri, 26 May 2017 13:14:05 +0300
From: Patrik Flykt <[email protected]>
To: [email protected]
Subject: [PATCH 1/4] detect: Remove detect.c
Message-ID: <[email protected]>
detect.c only deals with devices detected by kernel RTNL information.
Simplify code dependencies by adding the 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: 5
Date: Fri, 26 May 2017 13:14:08 +0300
From: Patrik Flykt <[email protected]>
To: [email protected]
Subject: [PATCH 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
has been applied only on the 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
------------------------------
Subject: Digest Footer
_______________________________________________
connman mailing list
[email protected]
https://lists.01.org/mailman/listinfo/connman
------------------------------
End of connman Digest, Vol 19, Issue 14
***************************************