From d6aab12f5335c45a008e84d600f77839b13d0565 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Thu, 15 Jul 2010 10:30:41 -0700 Subject: Fix proper detection for pure Ethernet technology types --- src/rtnl.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/rtnl.c b/src/rtnl.c index cbf9bb5d..0f3ba0fe 100644 --- a/src/rtnl.c +++ b/src/rtnl.c @@ -75,6 +75,22 @@ static void free_interface(gpointer data) g_free(interface); } +static connman_bool_t ether_blacklisted(const char *name) +{ + if (name == NULL) + return TRUE; + + /* virtual interface from VMware */ + if (g_str_has_prefix(name, "vmnet") == TRUE) + return TRUE; + + /* virtual interface from VirtualBox */ + if (g_str_has_prefix(name, "vboxnet") == TRUE) + return TRUE; + + return FALSE; +} + static void read_uevent(struct interface_data *interface) { char *filename, line[128]; @@ -377,17 +393,24 @@ static void process_newlink(unsigned short type, int index, unsigned flags, ifname, index, operstate, operstate2str(operstate)); - if (g_hash_table_lookup(interface_list, &index) == NULL) { + if (g_hash_table_lookup(interface_list, + GINT_TO_POINTER(index)) == NULL) { struct interface_data *interface; interface = g_new0(struct interface_data, 1); interface->index = index; interface->name = g_strdup(ifname); - g_hash_table_insert(interface_list, &index, interface); + g_hash_table_insert(interface_list, + GINT_TO_POINTER(index), interface); read_uevent(interface); + if (interface->type == CONNMAN_SERVICE_TYPE_UNKNOWN && + type == ARPHRD_ETHER && + ether_blacklisted(ifname) == FALSE) + interface->type = CONNMAN_SERVICE_TYPE_ETHERNET; + __connman_technology_add_interface(interface->type, interface->index, interface->name); } @@ -454,7 +477,7 @@ static void process_dellink(unsigned short type, int index, unsigned flags, break; } - g_hash_table_remove(interface_list, &index); + g_hash_table_remove(interface_list, GINT_TO_POINTER(index)); } static void extract_addr(struct ifaddrmsg *msg, int bytes, @@ -1228,7 +1251,7 @@ int __connman_rtnl_init(void) DBG(""); - interface_list = g_hash_table_new_full(g_int_hash, g_int_equal, + interface_list = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, free_interface); sk = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE); -- cgit v1.2.3