wraith-wireless / PyRIC

Python wireless library for Linux
http://wraith-wireless.github.io/PyRIC
Other
93 stars 51 forks source link

"Invalid parameter" when opening interface socket on devices with low rmem_max #41

Open sm-Fifteen opened 6 years ago

sm-Fifteen commented 6 years ago

When creating a new socket to claim an interface, pyric uses a default value for tx and rx BUFSZ of 32768 bytes. It also checks that the selected value is smaller than the configured maximum socket buffer size, but since BUFSZ is hardcoded, said default value may cause socket initialization to fail. I'm currently working on an embedded system where rmem_max is 163840, which puts the output of _maxbufsz_ at 8192.

Out of the box, this is what I get :

Traceback (most recent call last):
  File "./test_iw.py", line 5, in <module>
    iface = pyw.getcard('wlan0')
  File "/usr/lib/python2.7/site-packages/pyric/pyw.py", line 269, in getcard
    if nlsock is None: return _nlstub_(getcard, dev)
  File "/usr/lib/python2.7/site-packages/pyric/pyw.py", line 2238, in _nlstub_
    raise pyric.error(e.errno, pyric.strerror(e.errno))
pyric.error: [Errno 22] Invalid parameter

It's also not very helpful how _nlstub_ swallows any errors thrown by libnl and replaces them with this not very descriptive message and stack-trace instead.

AchielC commented 5 years ago

I also have this problem. Did you find a solution?

sm-Fifteen commented 5 years ago

Instead of letting functions call _nlstub_, which is the part that initializes the netlink socket, you can just call nl_socket_alloc with your own values for rx and tx, and pass it to functions that require a netlink socket from then on.