sync netlink call with libnl

Hauke Mehrtens hauke at hauke-m.de
Mon Aug 22 07:19:55 PDT 2016


Hi,

I want to do a sync call from my user space program to a kernel driver 
with libnl.
For example to get the capabilities of a chip I want to do this:
1. create a message with the question for the driver
2. send that message with nl_send_auto()
3. kernel driver receives message
4. kernel driver sends answer to port id of sender and uses the same 
sequence number as in the revived message
5. user space waits for the ack or nack with the sequence number of the 
request or aborts after a timeout

How do I implement 5. ?
I am missing a function which waits for a message with a specific 
sequence number and returns when this was received or a timeout 
occurred.
Should I use select() on the file descriptor and then do nl_recv() when 
some data is there, parse it manually and retry if it wasn't the 
expected message?

I also have use cases where the driver sends notifications to the user 
space so netlink seams to be better fitted that ioctls.


Thanks for the help

Hauke



More information about the libnl mailing list