* [PATCH] net: netlink: don't try unicast when dst_pid is zero for NETLINK_USERSOCK
@ 2011-05-13 6:24 Changli Gao
2011-05-13 20:48 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Changli Gao @ 2011-05-13 6:24 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Changli Gao
For NETLINK_USERSOCK, no one listens on PID 0, so sending a message only to
to a multicast group should not return -ECONNREFUSED.
Signed-off-by: Changli Gao <xiaosuo@gmail.com>
---
net/netlink/af_netlink.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index c8f35b5..ba89304 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -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);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net: netlink: don't try unicast when dst_pid is zero for NETLINK_USERSOCK
2011-05-13 6:24 [PATCH] net: netlink: don't try unicast when dst_pid is zero for NETLINK_USERSOCK Changli Gao
@ 2011-05-13 20:48 ` David Miller
2011-05-14 0:50 ` Changli Gao
0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2011-05-13 20:48 UTC (permalink / raw)
To: xiaosuo; +Cc: netdev
From: Changli Gao <xiaosuo@gmail.com>
Date: Fri, 13 May 2011 14:24:54 +0800
> For NETLINK_USERSOCK, no one listens on PID 0, so sending a message only to
> to a multicast group should not return -ECONNREFUSED.
>
> Signed-off-by: Changli Gao <xiaosuo@gmail.com>
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: netlink: don't try unicast when dst_pid is zero for NETLINK_USERSOCK
2011-05-13 20:48 ` David Miller
@ 2011-05-14 0:50 ` Changli Gao
0 siblings, 0 replies; 3+ messages in thread
From: Changli Gao @ 2011-05-14 0:50 UTC (permalink / raw)
To: David Miller; +Cc: netdev
On Sat, May 14, 2011 at 4:48 AM, David Miller <davem@davemloft.net> wrote:
> From: Changli Gao <xiaosuo@gmail.com>
> Date: Fri, 13 May 2011 14:24:54 +0800
>
>> For NETLINK_USERSOCK, no one listens on PID 0, so sending a message only to
>> to a multicast group should not return -ECONNREFUSED.
>>
>> Signed-off-by: Changli Gao <xiaosuo@gmail.com>
>
> 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.
>
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.
--
Regards,
Changli Gao(xiaosuo@gmail.com)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-05-14 0:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-13 6:24 [PATCH] net: netlink: don't try unicast when dst_pid is zero for NETLINK_USERSOCK Changli Gao
2011-05-13 20:48 ` David Miller
2011-05-14 0:50 ` Changli Gao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).