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 | 5 ++++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index 36d5723..eb7b95e 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -518,7 +518,7 @@ 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);
 void __connman_technology_remove_interface(enum connman_service_type type,
-                               int index, const char *name, const char *ident);
+                               int index, const char *ident);
 void __connman_technology_notify_regdom_by_device(struct connman_device 
*device,
                                                int result, const char *alpha2);
 
diff --git a/src/rtnl.c b/src/rtnl.c
index 0d68337..74ece73 100644
--- a/src/rtnl.c
+++ b/src/rtnl.c
@@ -78,7 +78,7 @@ static void free_interface(gpointer data)
        struct interface_data *interface = data;
 
        __connman_technology_remove_interface(interface->service_type,
-                       interface->index, interface->name, interface->ident);
+                       interface->index, interface->ident);
 
        g_free(interface->ident);
        g_free(interface->name);
diff --git a/src/technology.c b/src/technology.c
index d0e9bbb..e6fe0f5 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -1266,11 +1266,12 @@ void __connman_technology_add_interface(enum 
connman_service_type type,
 }
 
 void __connman_technology_remove_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:
@@ -1286,8 +1287,10 @@ void __connman_technology_remove_interface(enum 
connman_service_type type,
                break;
        }
 
+       name = connman_inet_ifname(index);
        connman_info("Remove interface %s [ %s ]", name,
                                __connman_service_type2string(type));
+       g_free(name);
 
        technology = technology_find(type);
 
-- 
1.7.11.7

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

Reply via email to