Skip to contentSkip to conversation

net: netlink: don't try unicast when dst_pid is zero for NETLINK_USERSOCK

PATCH In review Changli Gao 2 participants 3 messages May 13, 2011 – May 14, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: netlink: don't try unicast when dst_pid is zero for NETLINK_USERSOCK

For NETLINK_USERSOCK, no one listens on PID 0, so sending a message only to to a multicast group should not return -ECONNREFUSED.

---
 net/netlink/af_netlink.c |    2 ++
 1 file changed, 2 insertions(+)
net/netlink/af_netlink.c +2 -0
index c8f35b5..ba89304 100644
@@ -1379,6 +1379,8 @@ static int netlink_sendmsg(struct kiocb *kiocb, struct socket *sock,
 	if (dst_group) {
 		atomic_inc(&skb->users);
 		netlink_broadcast(sk, skb, dst_pid, dst_group, GFP_KERNEL);
+		if (dst_pid == 0 && sk->sk_protocol == NETLINK_USERSOCK)
+			return len;
 	}
 	err = netlink_unicast(sk, skb, dst_pid, msg->msg_flags&MSG_DONTWAIT);
 
maintainer
#1 lore raw

From: Changli Gao <[email protected]>
Date: Fri, 13 May 2011 14:24:54 +0800

Quoted 4 lines

For NETLINK_USERSOCK, no one listens on PID 0, so sending a message only to to a multicast group should not return -ECONNREFUSED.

I don't think this is a great idea, creating different semantics for NETLINK_USERSOCK vs. other types.

You have to set the pid to something which will receive the unicast message, and then you can also (on top of that) send it to a multicast group as well.

But the base operation is always the unicast send, and that is what determines success/failure of the operation.

I'm not applying this patch.

#2 lore raw
Quoted 11 lines · David Miller

From: Changli Gao <[email protected]>
Date: Fri, 13 May 2011 14:24:54 +0800

Quoted 4 lines

For NETLINK_USERSOCK, no one listens on PID 0, so sending a message only to to a multicast group should not return -ECONNREFUSED.

I don't think this is a great idea, creating different semantics for NETLINK_USERSOCK vs. other types.

Quoted 7 lines

You have to set the pid to something which will receive the unicast message, and then you can also (on top of that) send it to a multicast group as well.

But the base operation is always the unicast send, and that is what determines success/failure of the operation.

Yes, I have seen that the return value of netlink_broadcast() isn't returned to the caller, so the caller can't know whether the message broadcasted is sent successfully or not. It isn't a big problem, as netlink isn't a reliable datagram protocol. Without this patch applied, we can also send a message to a multicast group only, but ignore the -ECONNREFUSED error.

Thanks.

Signature · 2 lines
Regards,
Changli Gao([email protected])