Skip to contentSkip to conversation

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

PATCH Applied Cyrill Gorcunov 3 participants 3 messages Nov 3, 2012 – Nov 4, 2012

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

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

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.

CC David Miller <[email protected]>
CC Eric Dumazet <[email protected]>
CC Pavel Emelyanov <[email protected]>
---
 net/ipv4/inet_diag.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
net/ipv4/inet_diag.c +4 -1
Index: 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)
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Cyrill Gorcunov

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.

Quoted 7 lines

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

CC David Miller <[email protected]>
CC Eric Dumazet <[email protected]>
CC Pavel Emelyanov <[email protected]>
maintainer Applied
#2 lore raw

From: Pavel Emelyanov <[email protected]>
Date: Sun, 04 Nov 2012 05:39:19 +0400

Quoted 10 lines · Cyrill Gorcunov
Quoted 9 lines

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.

Quoted 6 lines
Quoted 4 lines
CC David Miller <[email protected]>
CC Eric Dumazet <[email protected]>
CC Pavel Emelyanov <[email protected]>

Applied, thanks.