nl_recv() and handling truncated messages

David Ahern dsa at cumulusnetworks.com
Wed Dec 9 07:57:09 PST 2015


On 12/9/15 6:34 AM, Thomas Haller wrote:
>>> > >But this sounds good. How would you do it?
>> >
>> >It appears the only way to do this is with peeking.
> Hm yeah. To my understanding, it is not possible with recvmsg() to
> obtain the message only if the buffer is large enough.
>
> Without peek, the message gets effectively truncated and lost. With
> MSG_PEEK, you have to always call recvmsg() twice.
>
> It would be better to have a opportunistic MSG_PEEK, which reads the
> message if possible.
>
>
> Pretty bad (from recvmsg). Or maybe I am wrong and it is somehow
> possible... anybody??
>

It's not possible with the existing code, but an interesting feature ... 
e.g., add MSG_PEEK_OPPORTUNISTIC flag. If set and skb length is <= user 
buffer length copy the message.




More information about the libnl mailing list