ipconfig: Catch interface name changes
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Tue, 11 Sep 2012 12:01:16 +0000 (15:01 +0300)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Thu, 13 Sep 2012 10:41:43 +0000 (13:41 +0300)
Update the ipdevice interface name if it is changed by udev.

src/ipconfig.c

index e2b6576..4d8c569 100644 (file)
@@ -632,8 +632,19 @@ void __connman_ipconfig_newlink(int index, unsigned short type,
                return;
 
        ipdevice = g_hash_table_lookup(ipdevice_hash, GINT_TO_POINTER(index));
-       if (ipdevice != NULL)
+       if (ipdevice != NULL) {
+               char *ifname = connman_inet_ifname(index);
+               if (g_strcmp0(ipdevice->ifname, ifname) != 0) {
+                       DBG("interface name changed %s -> %s",
+                               ipdevice->ifname, ifname);
+
+                       g_free(ipdevice->ifname);
+                       ipdevice->ifname = ifname;
+               } else
+                       g_free(ifname);
+
                goto update;
+       }
 
        ipdevice = g_try_new0(struct connman_ipdevice, 1);
        if (ipdevice == NULL)