int fd;
uint32_t pid;
int protocol;
- bool any_groups;
struct nl_dump *dump;
};
goto error;
}
sock->protocol = protocol;
- sock->any_groups = false;
sock->dump = NULL;
retval = alloc_pid(&sock->pid);
/* Tries to add 'sock' as a listener for 'multicast_group'. Returns 0 if
* successful, otherwise a positive errno value.
*
+ * A socket that is subscribed to a multicast group that receives asynchronous
+ * notifications must not be used for Netlink transactions or dumps, because
+ * transactions and dumps can cause notifications to be lost.
+ *
* Multicast group numbers are always positive.
*
* It is not an error to attempt to join a multicast group to which a socket
multicast_group, strerror(errno));
return errno;
}
- sock->any_groups = true;
return 0;
}
nlmsghdr->nlmsg_flags |= NLM_F_DUMP | NLM_F_ACK;
dump->seq = nlmsghdr->nlmsg_seq;
dump->buffer = NULL;
- if (sock->any_groups || sock->dump) {
- /* 'sock' might belong to some multicast group, or it already has an
- * ongoing dump. Clone the socket to avoid possibly intermixing
- * multicast messages or previous dump results with our results. */
+ if (sock->dump) {
+ /* 'sock' already has an ongoing dump. Clone the socket because
+ * Netlink only allows one dump at a time. */
dump->status = nl_sock_clone(sock, &dump->sock);
if (dump->status) {
return;