On Thu, 2017-01-12 at 20:02 +0100, Jason A. Donenfeld wrote: > Hi Dan, > > Thanks for your response. I'd thought about this, at least for > adding/removing wgpeers/wgipmasks and for configuring wgdevices. This > would fit into multiple smaller messages indeed. > > But what about fetching the list of all existing peers and ipmasks > atomically? It seems like with multiple calls, if I'm using some kind > of pagination, things could change in the process. That's why using > one big buffer was most appealing... Any ideas about this?
In addition to what others have said - netlink typically includes (and has helpers to do so) a generation counter that's updated whenever this list changes, and included in each message, so if userspace really cares (often not) it can retry the dump until the system was idle enough to get a consistent snapshot. It also looks to me like your existing API isn't even compat-safe due to u64 alignment (e.g. in wgpeer), proving once again that ioctl is a bad idea. johannes