Well, this is not much of an answer, but I believe it's the closest it can practically be.
Netlink doesn't store any group metadata AFAIK. Users of the protocol define their groups and what they want to do with them by hacking the nl_groups
bitfield. So you're not asking about Netlink; you're asking about Netlink's users. Furthermore, I've heard (though not actually bothered to implement) that even userspace can send multicast messages to arbitrary groups, even to other userspace clients, so the question is also not really kernel-scoped.
I'd be really surprised if there were a list lying around somewhere collecting this information for you. Netlink users are not meant to be static; One kernel will have a bunch of users, another kernel will have another bunch of users. Each user protocol will define its own multicast groups (if any). And that's not even counting protocols defined by stray out-of-tree kernel modules that don't have the common sense to use Generic Netlink instead of Netlink. :)
If you're hard pressed to find the fragment of this information which is readily available, you would have to notice from the Netlink socket API that kernel-side users of Netlink initialize nl_groups
via a control buffer field named dst_group
. So you'd have to find code that initializes this field. NETLINK_DNRTMSG
, for example, seems to have two groups... one called DNRNG_NLGRP_L1
, and another one called DNRNG_NLGRP_L2
... good luck figuring out what they are. :)
On the other hand, and as you've seen, userspace code interacts with the groups via nl_groups
. You'd have to find code that initializes this field. Since userspace code is even more scattered than the kernel's, you're facing a bit of an unreasonable task.
In other words, I feel your approach (for whatever it is that you're doing) is not exactly in line with Netlink's design. You don't list the multicast groups; your code already knows what they are for the specific protocol it's implementing and so it subscribes itself to it statically.