Improve behaviour of Netlink Sockets
Subsystems (2)
Quoted 17 lines · James Chapman
Quoted 16 lines
- Have the kernel keep a list of async messages sent towards each socket rather than trying to deliver each message to the app immediately. Have the kernel send a netlink event message (say,
NETLINK_EVENT_WAKEUP) to the app when this queue first goes non-empty. No newNETLINK_EVENT_WAKEUPmessages are sent until the event queue goes empty again.- On receipt of
NETLINK_EVENT_WAKEUP, a process issues a netlink GET (or DUMP?) on its netlink socket to read its queued events.- If the socket event queue overruns, discard new events and flag the event queue as having lost messages. When the userspace app reads the event queue, it will discover that messages have been lost and can then re-read state from the kernel.
Quoted 4 lines
Quoted 2 lines
- Use a setsockopt on the netlink socket to have the socket configured in this polled-event mode.
That's basically how it works now.
Looks like I was proposing something similar to Jamal's intermediate queue. With the above scheme, there would be no need for userspace to periodically poll for events since that would be kicked off by the wakeup message. Also, while events are held in the kernel, they wouldn't be charged to the netlink socket -- instead they'd be limited by a system-wide count, sharing the event resource across all netlink sockets.
/james