Skip to content

Commit cacb6ba

Browse files
Cyrill Gorcunovdavem330
authored andcommitted
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. Signed-off-by: Cyrill Gorcunov <[email protected]> CC: David Miller <[email protected]> CC: Eric Dumazet <[email protected]> CC: Pavel Emelyanov <[email protected]> Acked-by: Pavel Emelyanov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent efc7ce0 commit cacb6ba

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

net/ipv4/inet_diag.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,13 +892,16 @@ static int __inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
892892
struct inet_diag_req_v2 *r, struct nlattr *bc)
893893
{
894894
const struct inet_diag_handler *handler;
895+
int err = 0;
895896

896897
handler = inet_diag_lock_handler(r->sdiag_protocol);
897898
if (!IS_ERR(handler))
898899
handler->dump(skb, cb, r, bc);
900+
else
901+
err = PTR_ERR(handler);
899902
inet_diag_unlock_handler(handler);
900903

901-
return skb->len;
904+
return err ? : skb->len;
902905
}
903906

904907
static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)

0 commit comments

Comments
 (0)