Hi Jukka,
2013/10/21 Jukka Rissanen <[email protected]> > 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/rtnl.c | 24 ++++++++++++------------ > 1 file changed, 12 insertions(+), 12 deletions(-) > > diff --git a/src/rtnl.c b/src/rtnl.c > index e2e16d0..f8f1429 100644 > --- a/src/rtnl.c > +++ b/src/rtnl.c > @@ -65,7 +65,6 @@ static guint update_timeout = 0; > > struct interface_data { > int index; > - char *name; > char *ident; > enum connman_service_type service_type; > enum connman_device_type device_type; > @@ -81,7 +80,6 @@ static void free_interface(gpointer data) > interface->index, interface->ident); > > g_free(interface->ident); > - g_free(interface->name); > g_free(interface); > } > > @@ -120,11 +118,13 @@ static bool wext_interface(char *ifname) > > static void read_uevent(struct interface_data *interface) > { > - char *filename, line[128]; > + char *filename, *name, line[128]; > bool found_devtype; > FILE *f; > > - if (ether_blacklisted(interface->name)) { > + name = connman_inet_ifname(interface->index); > + > + if (ether_blacklisted(name)) { > interface->service_type = CONNMAN_SERVICE_TYPE_UNKNOWN; > interface->device_type = CONNMAN_DEVICE_TYPE_UNKNOWN; > } else { > @@ -132,15 +132,14 @@ static void read_uevent(struct interface_data > *interface) > interface->device_type = CONNMAN_DEVICE_TYPE_ETHERNET; > } > > - filename = g_strdup_printf("/sys/class/net/%s/uevent", > - interface->name); > + filename = g_strdup_printf("/sys/class/net/%s/uevent", name); > > f = fopen(filename, "re"); > > g_free(filename); > > if (!f) > - return; > + goto out; > systemd-udevd concomitantly loads or controls modules, so maybe interface name will be renamed before excusing the code "filename = g_strdup_printf("/sys/class/net/%s/uevent", name);", so I think we could add the following code: - if (!f) + if (!f) { + interface->service_type = CONNMAN_SERVICE_TYPE_UNKNOWN; + interface->device_type = CONNMAN_DEVICE_TYPE_UNKNOWN; - return; + goto out; + } Because the code logic tells us the interface default service_type is CONNMAN_SERVICE_TYPE_ETHERNET and device_type is CONNMAN_DEVICE_TYPE_ETHERNET, when opening the file failed, all of types will be set to default type, this is not correct, maybe wlan0 interface will be treated as ethernet type. Please refer to the following log of starting connman, wlan0 interface is treated as ethernet type, not wifi type: connmand[175]: src/rtnl.c:rtnl_message() NEWLINK len 1072 type 16 flags 0x0002 seq 0 pid 175 connmand[175]: src/ipconfig.c:__connman_ipconfig_newlink() index 3 connmand[175]: wlp2s0 {create}index 3 type 1 <ETHER> connmand[175]: wlp2s0{update}flags 4098 <DOWN> connmand[175]: wlan0{newlink} index 3 address 0C:8B:FD:22:B8:7A mtu 1500 connmand[175]: wlan0 {newlink}index 3 operstate 2 <DOWN> connmand[175]: src/detect.c:detect_newlink() type 1 index 3 connmand[175]: src/device.c:connman_device_create() node 0c8bfd22b87a type 1 connmand[175]: src/device.c:connman_device_create() device 0x9223388 connmand[175]: src/device.c:connman_device_set_string() device 0x9223388 key Address value 0C:8B:FD:22:B8:7A connmand[175]: src/device.c:connman_device_register() device 0x9223388 name Ethernet connmand[175]: src/device.c:connman_device_register() driver 0x80f48e0 name ethernet connmand[175]: plugins/ethernet.c:ethernet_probe() device 0x9223388 connmand[175]: src/rtnl.c:connman_rtnl_add_newlink_watch() id 2 connmand[175]: plugins/ethernet.c:ethernet_newlink() index 3 flags 4098 change 0 connmand[175]: src/technology.c:__connman_technology_add_device() device 0x9223388 type Wired connmand[175]: src/technology.c:technology_get() type 2 connmand[175]: src/technology.c:technology_find() type 2 connmand[175]: src/device.c:__connman_device_enable() device 0x9223388 connmand[175]: plugins/ethernet.c:ethernet_enable() device 0x9223388 connmand[175]: Adding interface wlan0 [ ethernet ] URL: https://bugs.tizen.org/jira/browse/TIVI-1885. Cheers, Chengyi _______________________________________________ connman mailing list [email protected] https://lists.connman.net/mailman/listinfo/connman
