assert_return(ret, -EINVAL);
- /* Note that 'rtnl' is curretly unused, if we start using it internally
+ /* Note that 'rtnl' is currently unused, if we start using it internally
we must take care to avoid problems due to mutual references between
busses and their queued messages. See sd-bus.
*/
}
sd_rtnl_message *sd_rtnl_message_unref(sd_rtnl_message *m) {
- if (m && REFCNT_DEC(m->n_ref) <= 0) {
+ if (m && REFCNT_DEC(m->n_ref) == 0) {
unsigned i;
free(m->hdr);
struct ucred *ucred = (void *)CMSG_DATA(cmsg);
/* from the kernel */
- if (ucred->uid == 0 && ucred->pid == 0)
+ if (ucred->pid == 0)
auth = true;
else
- log_debug("rtnl: ignoring message from uid %u pid %u", ucred->uid, ucred->pid);
+ log_debug("rtnl: ignoring message from PID "PID_FMT, ucred->pid);
} else if (cmsg->cmsg_level == SOL_NETLINK &&
cmsg->cmsg_type == NETLINK_PKTINFO &&
cmsg->cmsg_len == CMSG_LEN(sizeof(struct nl_pktinfo))) {
}
}
- if (!auth)
+ if (!auth) {
/* not from the kernel, ignore */
+ if (peek) {
+ /* drop the message */
+ r = recvmsg(fd, &msg, 0);
+ if (r < 0)
+ return (errno == EAGAIN || errno == EINTR) ? 0 : -errno;
+ }
+
return 0;
+ }
if (group)
*_group = group;
r = type_system_get_type(NULL, &nl_type, new_msg->nlmsg_type);
if (r < 0) {
if (r == -ENOTSUP)
- log_debug("sd-rtnl: ignored message with unknown type: %u",
+ log_debug("sd-rtnl: ignored message with unknown type: %i",
new_msg->nlmsg_type);
continue;