sd-netlink: refcount multicast groups

Track the number of matches installed for a given multicast group, and leave the
group once no matches depend on it.

In order to handle passed-in sockets that are already members of multicast groups
we initialize the refcount based on the membership once we take over the socket.
This way we will leave the socket in the state we found it once we finish with
it.

On kernels that do not fully support reading out the multicast group membership
we fall back to never leaving any groups (as before).
This commit is contained in:
Tom Gundersen
2015-10-15 18:59:08 +02:00
parent f10dc5a725
commit 9c5a882b7f
4 changed files with 205 additions and 16 deletions
+4
View File
@@ -126,6 +126,10 @@
#define SOL_NETLINK 270
#endif
#ifndef NETLINK_LIST_MEMBERSHIPS
#define NETLINK_LIST_MEMBERSHIPS 9
#endif
#if !HAVE_DECL_PIVOT_ROOT
static inline int pivot_root(const char *new_root, const char *put_old) {
return syscall(SYS_pivot_root, new_root, put_old);