Whenever systemd-udev renames a device, the orginal ifindex is kept and consequently connman is unable to issue a proper create interface to reflect such device change. --- include/device.h | 1 + src/detect.c | 15 +++++++++++++-- src/device.c | 20 ++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/include/device.h b/include/device.h index 57b925c..9d4fa35 100644 --- a/include/device.h +++ b/include/device.h @@ -114,6 +114,7 @@ void connman_device_regdom_notify(struct connman_device *device, struct connman_device *connman_device_create_from_index(int index); struct connman_device *connman_device_find_by_index(int index); int connman_device_reconnect_service(struct connman_device *device); +bool connman_device_ifname_changed(struct connman_device *device, int index); struct connman_device_driver { const char *name; diff --git a/src/detect.c b/src/detect.c index 6c03920..2fc7f0a 100644 --- a/src/detect.c +++ b/src/detect.c @@ -43,6 +43,9 @@ static struct connman_device *find_device(int index) return NULL; } +static void detect_dellink(unsigned short type, int index, + unsigned flags, unsigned change); + static void detect_newlink(unsigned short type, int index, unsigned flags, unsigned change) { @@ -67,8 +70,16 @@ static void detect_newlink(unsigned short type, int index, } device = find_device(index); - if (device) - return; + if (device) { + /* + * Detect if device name has changed, despite same index + * If so, proceed with dellink and new device registering. + */ + if (!connman_device_ifname_changed(device, index)) + return; + else + detect_dellink(type, index, flags, change); + } device = connman_device_create_from_index(index); if (!device) diff --git a/src/device.c b/src/device.c index f0b7a4f..789c586 100644 --- a/src/device.c +++ b/src/device.c @@ -1456,3 +1456,23 @@ void __connman_device_cleanup(void) g_strfreev(nodevice_filter); g_strfreev(device_filter); } + +bool connman_device_ifname_changed(struct connman_device *device, int index) +{ + char *ifname; + bool ret = false; + + DBG(""); + + ifname = connman_inet_ifname(index); + if (!ifname) + return ret; + + if (strcmp(device->interface, ifname) != 0) { + ret = true; + } + + g_free(ifname); + + return ret; +} -- 1.9.1 _______________________________________________ connman mailing list connman@connman.net https://lists.connman.net/mailman/listinfo/connman