Search code examples
socketslinux-device-drivernetlink

Use napi api with generic netlink sockets


I am currently going through the linux kernel (4.14) sources trying to find out whether the netdev NAPI can easily be used in combination with the generic netlink layer.
It seems to me like this wasn't thought of when NAPI was introduced into the kernel since the only call I can find to add NAPI is the netif_napi_add function. But this specifically links the struct napi to the netdevs (*struct netdev)->napi_list and I am not sure whether this adds a whole other layer complexity within the netdev driver layers which I don't see at the moment.

I would like to use the NAPI functionality with the generic netlink layer in order to use the NAPI functionality with the AF_NETLINK family implementing my own protocol.

Anyone has ever done this and can tell me whether he successfully uses NAPI with generic netlink layer implementing a user specific protocols?
Or anyone with more linux kernel knowledge can help me out whether this is possible before I spend more time down the linux kernel source rabbit hole.

Appreciate any insight I can get.


Solution

  • The linux kernel sources provide a function called init_dummy_netdev() which "initialize[s] the minimum amount of fields so it can be used to schedule NAPI polls without registering a full blown interface."

    If you search for it within the linux kernel sources you'll find drivers which implement this dummy interface and how to best use it.