-
Notifications
You must be signed in to change notification settings - Fork 311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rtnl_link_get returns NULL for USB wireless indexes if it has ever been unplugged #49
Comments
Did you resync the cache after replugging the interface? |
That seemed to do it, thanks! I had no idea about the resync function until I dove into the source looking for it. Is there a note in the docs somewhere about needing to use it if you have hotplug devices? |
Unfortunately the caching system is not very well documented at this point. |
Actually I was wrong... it's still not working. I'm doing rtnl_cache_resync(sock, link_cache, NULL, NULL) right after I allocate the link cache, is that the correct way to use it? Any ideas? |
You have two options: [0] http://www.infradead.org/~tgr/libnl/doc/core.html#_cache_manager |
So what is the preferred way to manually resync the cache? |
I have a small application where I iterate through the interfaces of my system like so:
485 int index = 1;
486
487 forever {
488 struct rtnl_link *link = rtnl_link_get(link_cache, index);
489
490 if(link != NULL) {
491 char *name = rtnl_link_get_name(link);
492
493 qDebug() << "found interface: " << name;
494
495 linkList << name;
496
497 rtnl_link_put(link);
498 }else{
499 break;
500 }
501
502 ++index;
503 }
This works fine to detect all my ethernet interfaces as well as USB wireless, until the wireless adapter is unplugged. Once it is re-plugged, rtnl_link_get returns NULL for the index associated with the wireless adapter. All other system utilities such as ip, iw etc. continue to work fine after the adapter is re-plugged, just not libnl. As a workaround I instead read from /sys/class/net to find the system's interfaces until this issue is resolved. Any idea what could be wrong?
The text was updated successfully, but these errors were encountered: