diff mbox

net: inet_diag -- Return error code if protocol handler is missed

Message ID 20121103193034.GF6055@moon
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Cyrill Gorcunov Nov. 3, 2012, 7:30 p.m. UTC
We've observed that in case if UDP diag module is not
supported in kernel the netlink returns NLMSG_DONE without
notifying a caller that handler is missed.

This patch makes __inet_diag_dump to return error code instead.

So as example it become possible to detect such situation
and handle it gracefully on userspace level.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
CC: David Miller <davem@davemloft.net>
CC: Eric Dumazet <eric.dumazet@gmail.com>
CC: Pavel Emelyanov <xemul@parallels.com>
---
 net/ipv4/inet_diag.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

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

Comments

Pavel Emelyanov Nov. 4, 2012, 1:39 a.m. UTC | #1
On 11/03/2012 11:30 PM, Cyrill Gorcunov wrote:
> We've observed that in case if UDP diag module is not
> supported in kernel the netlink returns NLMSG_DONE without
> notifying a caller that handler is missed.
> 
> This patch makes __inet_diag_dump to return error code instead.
> 
> So as example it become possible to detect such situation
> and handle it gracefully on userspace level.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
> CC: David Miller <davem@davemloft.net>
> CC: Eric Dumazet <eric.dumazet@gmail.com>
> CC: Pavel Emelyanov <xemul@parallels.com>

Acked-by: Pavel Emelyanov <xemul@parallels.com>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Nov. 4, 2012, 5:57 a.m. UTC | #2
From: Pavel Emelyanov <xemul@parallels.com>
Date: Sun, 04 Nov 2012 05:39:19 +0400

> On 11/03/2012 11:30 PM, Cyrill Gorcunov wrote:
>> We've observed that in case if UDP diag module is not
>> supported in kernel the netlink returns NLMSG_DONE without
>> notifying a caller that handler is missed.
>> 
>> This patch makes __inet_diag_dump to return error code instead.
>> 
>> So as example it become possible to detect such situation
>> and handle it gracefully on userspace level.
>> 
>> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
>> CC: David Miller <davem@davemloft.net>
>> CC: Eric Dumazet <eric.dumazet@gmail.com>
>> CC: Pavel Emelyanov <xemul@parallels.com>
> 
> Acked-by: Pavel Emelyanov <xemul@parallels.com>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

Index: linux-2.6.git/net/ipv4/inet_diag.c
===================================================================
--- linux-2.6.git.orig/net/ipv4/inet_diag.c
+++ linux-2.6.git/net/ipv4/inet_diag.c
@@ -895,13 +895,16 @@  static int __inet_diag_dump(struct sk_bu
 		struct inet_diag_req_v2 *r, struct nlattr *bc)
 {
 	const struct inet_diag_handler *handler;
+	int err = 0;
 
 	handler = inet_diag_lock_handler(r->sdiag_protocol);
 	if (!IS_ERR(handler))
 		handler->dump(skb, cb, r, bc);
+	else
+		err = PTR_ERR(handler);
 	inet_diag_unlock_handler(handler);
 
-	return skb->len;
+	return err ? : skb->len;
 }
 
 static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)