unix_diag: Fixup RQLEN extension report
authorPavel Emelyanov <xemul@parallels.com>
Fri, 30 Dec 2011 00:54:39 +0000 (00:54 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 30 Dec 2011 21:46:02 +0000 (16:46 -0500)
While it's not too late fix the recently added RQLEN diag extension
to report rqlen and wqlen in the same way as TCP does.

I.e. for listening sockets the ack backlog length (which is the input
queue length for socket) in rqlen and the max ack backlog length in
wqlen, and what the CINQ/OUTQ ioctls do for established.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/unix_diag.h
net/unix/diag.c

index 93fdb782468a70e74f9d6621751b4452a42b8ecc..b1d2bf16b33c92fe4f5e27aafe5d34fe87d5fede 100644 (file)
@@ -46,4 +46,9 @@ struct unix_diag_vfs {
        __u32   udiag_vfs_dev;
 };
 
+struct unix_diag_rqlen {
+       __u32   udiag_rqueue;
+       __u32   udiag_wqueue;
+};
+
 #endif
index 98945f29da4f41f7739b46bb50c45448b901d8b4..6b7697fd911bd36af0fb0aca4731ab6ea5c09b42 100644 (file)
@@ -101,7 +101,18 @@ rtattr_failure:
 
 static int sk_diag_show_rqlen(struct sock *sk, struct sk_buff *nlskb)
 {
-       RTA_PUT_U32(nlskb, UNIX_DIAG_RQLEN, sk->sk_receive_queue.qlen);
+       struct unix_diag_rqlen *rql;
+
+       rql = UNIX_DIAG_PUT(nlskb, UNIX_DIAG_RQLEN, sizeof(*rql));
+
+       if (sk->sk_state == TCP_LISTEN) {
+               rql->udiag_rqueue = sk->sk_receive_queue.qlen;
+               rql->udiag_wqueue = sk->sk_max_ack_backlog;
+       } else {
+               rql->udiag_rqueue = (__u32)unix_inq_len(sk);
+               rql->udiag_wqueue = (__u32)unix_outq_len(sk);
+       }
+
        return 0;
 
 rtattr_failure: