On Mon, Feb 20, 2006 at 02:31:05PM +0100, Patrick McHardy ([EMAIL PROTECTED]) 
wrote:
> Evgeniy Polyakov wrote:
> > Do not allocate and send new skb if there are no listeners.
> > cn_netlink_send() can return -ESRCH in this case.
> 
> I don't think it makes sense to return an error. netlink_has_listeners()
> can return false positives, so no error would still not mean that the
> packet was really delivered. cn_netlink_send also doesn't propagate the
> return code of netlink_broadcast, so nobody seems to be interested
> anyway.

Yep, return code of netlink_broadcast() also should be returned back.
Main idea is to show, that if error is returned, then data 100% was not
delivered, no matter where it was dropped.
And alhtough nobody really does not care about it, since there is
sequence number inside, I think better to indicate if message was
dropped or not.

Signed-off-by: Evgeniy Polyakov <[EMAIL PROTECTED]>

diff --git a/Documentation/connector/connector.txt 
b/Documentation/connector/connector.txt
index 57a314b..ad6e0ba 100644
--- a/Documentation/connector/connector.txt
+++ b/Documentation/connector/connector.txt
@@ -69,10 +69,11 @@ Unregisters new callback with connector 
 
 struct cb_id *id               - unique connector's user identifier.
 
-void cn_netlink_send(struct cn_msg *msg, u32 __groups, int gfp_mask);
+int cn_netlink_send(struct cn_msg *msg, u32 __groups, int gfp_mask);
 
 Sends message to the specified groups.  It can be safely called from
-any context, but may silently fail under strong memory pressure.
+softirq context, but may silently fail under strong memory pressure.
+If there are no listeners for given group -ESRCH can be returned.
 
 struct cn_msg *                        - message header(with attached data).
 u32 __group                    - destination group.
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index 505677f..89cc29f 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -97,6 +97,9 @@ int cn_netlink_send(struct cn_msg *msg, 
                group = __group;
        }
 
+       if (!netlink_has_listeners(dev->nls), group)
+               return -ESRCH;
+
        size = NLMSG_SPACE(sizeof(*msg) + msg->len);
 
        skb = alloc_skb(size, gfp_mask);
@@ -111,9 +114,7 @@ int cn_netlink_send(struct cn_msg *msg, 
 
        NETLINK_CB(skb).dst_group = group;
 
-       netlink_broadcast(dev->nls, skb, 0, group, gfp_mask);
-
-       return 0;
+       return netlink_broadcast(dev->nls, skb, 0, group, gfp_mask);
 
 nlmsg_failure:
        kfree_skb(skb);

-- 
        Evgeniy Polyakov
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to