On 1/28/25 14:49, Willem de Bruijn wrote:
+struct net_devmem_dmabuf_binding * +net_devmem_get_sockc_binding(struct sock *sk, struct sockcm_cookie *sockc) +{
struct net_devmem_dmabuf_binding *binding;
int err = 0;
binding = net_devmem_lookup_dmabuf(sockc->dmabuf_id);
This lookup is from global xarray net_devmem_dmabuf_bindings.
Is there a check that the socket is sending out through the device to which this dmabuf was bound with netlink? Should there be? (e.g., SO_BINDTODEVICE).
Yes, I think it may be an issue if the user triggers a send from a different netdevice, because indeed when we bind a dmabuf we bind it to a specific netdevice.
One option is as you say to require TX sockets to be bound and to check that we're bound to the correct netdev. I also wonder if I can make this work without SO_BINDTODEVICE, by querying the netdev the sock is currently trying to send out on and doing a check in the tcp_sendmsg. I'm not sure if this is possible but I'll give it a look.
I was a bit quick on mentioning SO_BINDTODEVICE. Agreed that it is vastly preferable to not require that, but infer the device from the connected TCP sock.
I wonder why so? I'd imagine something like SO_BINDTODEVICE is a better way to go. The user has to do it anyway, otherwise packets might go to a different device and the user would suddenly start getting errors with no good way to alleviate them (apart from likes of SO_BINDTODEVICE). It's even worse if it works for a while but starts to unpredictably fail as time passes. With binding at least it'd fail fast if the setup is not done correctly.