Use always the interface index and only when interface name
is needed, then fetch the name. This minimizes races when
interface name changes because of udev rules.
---
 src/connman.h    | 2 +-
 src/rtnl.c       | 2 +-
 src/technology.c | 9 +++++++--
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index eb7b95e..e323385 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -516,7 +516,7 @@ int __connman_technology_remove_rfkill(unsigned int index,
 void __connman_technology_scan_started(struct connman_device *device);
 void __connman_technology_scan_stopped(struct connman_device *device);
 void __connman_technology_add_interface(enum connman_service_type type,
-                               int index, const char *name, const char *ident);
+                               int index, const char *ident);
 void __connman_technology_remove_interface(enum connman_service_type type,
                                int index, const char *ident);
 void __connman_technology_notify_regdom_by_device(struct connman_device 
*device,
diff --git a/src/rtnl.c b/src/rtnl.c
index 74ece73..e2e16d0 100644
--- a/src/rtnl.c
+++ b/src/rtnl.c
@@ -477,7 +477,7 @@ static void process_newlink(unsigned short type, int index, 
unsigned flags,
         */
        if (interface)
                __connman_technology_add_interface(interface->service_type,
-                       interface->index, interface->name, interface->ident);
+                       interface->index, interface->ident);
 
        for (list = watch_list; list; list = list->next) {
                struct watch_data *watch = list->data;
diff --git a/src/technology.c b/src/technology.c
index e6fe0f5..28f0ff4 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -1221,11 +1221,12 @@ static void enable_tethering(struct connman_technology 
*technology)
 }
 
 void __connman_technology_add_interface(enum connman_service_type type,
-                               int index, const char *name, const char *ident)
+                               int index, const char *ident)
 {
        struct connman_technology *technology;
        GSList *tech_drivers;
        struct connman_technology_driver *driver;
+       char *name;
 
        switch (type) {
        case CONNMAN_SERVICE_TYPE_UNKNOWN:
@@ -1241,13 +1242,14 @@ void __connman_technology_add_interface(enum 
connman_service_type type,
                break;
        }
 
+       name = connman_inet_ifname(index);
        connman_info("Adding interface %s [ %s ]", name,
                                __connman_service_type2string(type));
 
        technology = technology_find(type);
 
        if (!technology)
-               return;
+               goto out;
 
        for (tech_drivers = technology->driver_list; tech_drivers;
             tech_drivers = g_slist_next(tech_drivers)) {
@@ -1263,6 +1265,9 @@ void __connman_technology_add_interface(enum 
connman_service_type type,
         */
        if (technology->tethering_persistent)
                enable_tethering(technology);
+
+out:
+       g_free(name);
 }
 
 void __connman_technology_remove_interface(enum connman_service_type type,
-- 
1.7.11.7

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

Reply via email to