Batch send support
Would adding this feature cause a breaking change? No
Is your feature request related to a problem? Please describe.
It's impossible to send multiple messages as a single socket send call through a NlRouter (or NlSocketHandle), which is, e.g., needed to send transactions changing nftables. (They consist of a start message, a list of change commands, and a end message, all of which are complete nlmsgs but must (afaict) be sent in a single send over the socket)
Describe the solution you'd like
A send method on the NlRouter which takes multiple messages to send as a batch. Not sure how to deal with the receive handle and sequence numbers here.
Describe alternatives you've considered
Currently, you need access to the underlying NlSocket to do such batch sends. A simpler solution would be adding a batch send method to NlSocketHandle to allow using at least this level of abstraction. Though this would it still make it impossible to use NlRouter when also sending batch messages.
Hi @LogicalOverflow, thanks for opening an issue about this. With regard to the sequence numbers, are you wondering whether they should be incremented or all the same? I'm happy to take a look at #271, but I think it would preferable to find a way to support this at the router level as well if possible. Do you know of any documentation for nftables that I could take a look at? If not, I'll see what I can find in the kernel code.
With regard to the sequence numbers, are you wondering whether they should be incremented or all the same?
Yes, both solutions don't feel to great: If we don't increment for each message in the batch, we have duplicate sequence numbers; if we do increment, we have to deal with that in the receive handle or return multiple receive handles.
I'm happy to take a look at https://github.com/jbaublitz/neli/pull/271, but I think it would preferable to find a way to support this at the router level as well if possible.
I would like router-level support as well, just didn't have time to properly implement that. #271 is more of an intermediate solution, so you can at least do batch sends over sockets.
Do you know of any documentation for nftables that I could take a look at? If not, I'll see what I can find in the kernel code.
nftables docs is, let's say, very minimal, esp. wrt. to the netlink interface; the nftables wiki has some helpful info on concepts here and there, but kernel code seems to be the best resource overall for the netlink interface. And libnfnl sources can be helpful as well.
With regard to the sequence numbers, are you wondering whether they should be incremented or all the same?
Yes, both solutions don't feel to great: If we don't increment for each message in the batch, we have duplicate sequence numbers; if we do increment, we have to deal with that in the receive handle or return multiple receive handles.
My understanding, having worked with netlink a fair amount, is that the sequence numbers are used to associate request and responses (outside of the multicast group case). I'm a little bit confused here because is there a corresponding response for each of the messages sent in the single send? If all of the messages are one logical unit, I would expect the sequence number to be the same for all of them as they are essentially grouped together, both in terms of the syscall and also in terms of their use.
I'll take a look at the kernel code when I'm able and see if I can get a better idea of the response type I should expect.