Re: [PATCH net-next v7 4/9] net: devmem: Implement TX path

From: Mina Almasry
Date: Fri Mar 21 2025 - 18:16:45 EST


On Tue, Mar 18, 2025 at 1:53 AM Paolo Abeni <pabeni@xxxxxxxxxx> wrote:
>
> Adding Kuniyuki.
>
> On 3/8/25 10:40 PM, Mina Almasry wrote:
> > @@ -931,10 +932,67 @@ int netdev_nl_bind_rx_doit(struct sk_buff *skb, struct genl_info *info)
> > return err;
> > }
> >
> > -/* stub */
> > int netdev_nl_bind_tx_doit(struct sk_buff *skb, struct genl_info *info)
> > {
> > - return 0;
> > + struct net_devmem_dmabuf_binding *binding;
> > + struct list_head *sock_binding_list;
> > + struct net_device *netdev;
> > + u32 ifindex, dmabuf_fd;
> > + struct sk_buff *rsp;
> > + int err = 0;
> > + void *hdr;
> > +
> > + if (GENL_REQ_ATTR_CHECK(info, NETDEV_A_DEV_IFINDEX) ||
> > + GENL_REQ_ATTR_CHECK(info, NETDEV_A_DMABUF_FD))
> > + return -EINVAL;
> > +
> > + ifindex = nla_get_u32(info->attrs[NETDEV_A_DEV_IFINDEX]);
> > + dmabuf_fd = nla_get_u32(info->attrs[NETDEV_A_DMABUF_FD]);
> > +
> > + sock_binding_list = genl_sk_priv_get(&netdev_nl_family,
> > + NETLINK_CB(skb).sk);
> > + if (IS_ERR(sock_binding_list))
> > + return PTR_ERR(sock_binding_list);
> > +
> > + rsp = genlmsg_new(GENLMSG_DEFAULT_SIZE, GFP_KERNEL);
> > + if (!rsp)
> > + return -ENOMEM;
> > +
> > + hdr = genlmsg_iput(rsp, info);
> > + if (!hdr) {
> > + err = -EMSGSIZE;
> > + goto err_genlmsg_free;
> > + }
> > +
> > + rtnl_lock();
>
> The above could possibly be a rtnl_net_lock(), right?
>
> (not strictily related to this series) The same for the existing
> rtnl_lock() call in netdev-genl.c, right?
>

Actually I think this can follow the example set in commit
1d22d3060b9b ("net: drop rtnl_lock for queue_mgmt operations") and
take the netdev_get_by_index_lock().


--
Thanks,
Mina