From 266c401164b8647647d4c78fbe4d0a92bdd95ef3 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Wed, 30 Oct 2013 20:26:07 -0400 Subject: [PATCH] revert /sys/class/net hack and just resync the cache to find any new devices that have appeared --- interface.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/interface.cpp b/interface.cpp index 56c9ea9..bcee13b 100644 --- a/interface.cpp +++ b/interface.cpp @@ -483,6 +483,10 @@ QStringList Interface::list() { return QStringList(); } + // fixes libnl "issue": https://github.com/tgraf/libnl/issues/49 + // the cache is apparently global to the kernel and must be resynced if a hotplug device goes away and comes back + nl_cache_resync(sock, link_cache, NULL, NULL); + int index = 1; forever { @@ -504,17 +508,6 @@ QStringList Interface::list() { nl_cache_free(link_cache); nl_socket_free(sock); - // workaround for libnl issue: https://github.com/tgraf/libnl/issues/49 - // find any interfaces libnl doesn't know about (e.g. USB wireless adapters after they're been unplugged and replugged) - QDir dir("/sys/class/net"); - QStringList interfaces = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); - - foreach(QString interface, interfaces) { - if(!linkList.contains(interface)) { - linkList << interface; - } - } - return linkList; }