Upstream/technology: Do not use interface name when adding interface 34/11634/1
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Fri, 25 Oct 2013 08:24:40 +0000 (11:24 +0300)
committerChengyi Zhao <chengyi1.zhao@archermind.com>
Fri, 1 Nov 2013 01:23:56 +0000 (09:23 +0800)
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.

Upstream commit Id: 8c7e5d046ff2dbc7d969b097d74b9897b725e08d

Change-Id: Ie32e6e8d8896167caa7caaeb784c8f974c455a6e
Signed-off-by: Chengyi Zhao <chengyi1.zhao@archermind.com>
src/connman.h
src/rtnl.c
src/technology.c

index 495eef4..5507b15 100644 (file)
@@ -471,7 +471,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,
index c3d52e8..b259cd8 100644 (file)
@@ -481,7 +481,7 @@ static void process_newlink(unsigned short type, int index, unsigned flags,
         */
        if (interface != NULL)
                __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;
index 6dfdb6a..9796646 100644 (file)
@@ -1252,11 +1252,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:
@@ -1272,13 +1273,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 == NULL)
-               return;
+               goto out;
 
        for (tech_drivers = technology->driver_list; tech_drivers != NULL;
             tech_drivers = g_slist_next(tech_drivers)) {
@@ -1294,6 +1296,9 @@ void __connman_technology_add_interface(enum connman_service_type type,
         */
        if (technology->tethering_persistent == TRUE)
                enable_tethering(technology);
+
+out:
+       g_free(name);
 }
 
 void __connman_technology_remove_interface(enum connman_service_type type,