sock-diag: Report shutdown for inet and unix sockets (v2)
authorPavel Emelyanov <xemul@parallels.com>
Tue, 23 Oct 2012 18:29:56 +0000 (22:29 +0400)
committerDavid S. Miller <davem@davemloft.net>
Tue, 23 Oct 2012 18:57:52 +0000 (14:57 -0400)
Make it simple -- just put new nlattr with just sk->sk_shutdown bits.

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

index 8c469af939aab33a2117d7361e247371c6303750..bbde90fa58380bb6d6940d9ec7454af7a4d55608 100644 (file)
@@ -109,9 +109,10 @@ enum {
        INET_DIAG_TOS,
        INET_DIAG_TCLASS,
        INET_DIAG_SKMEMINFO,
+       INET_DIAG_SHUTDOWN,
 };
 
-#define INET_DIAG_MAX INET_DIAG_SKMEMINFO
+#define INET_DIAG_MAX INET_DIAG_SHUTDOWN
 
 
 /* INET_DIAG_MEM */
index b1d2bf16b33c92fe4f5e27aafe5d34fe87d5fede..b8a24941db21e82b11d80d0912c057a54bcf7742 100644 (file)
@@ -37,6 +37,7 @@ enum {
        UNIX_DIAG_ICONS,
        UNIX_DIAG_RQLEN,
        UNIX_DIAG_MEMINFO,
+       UNIX_DIAG_SHUTDOWN,
 
        UNIX_DIAG_MAX,
 };
index 535584c00f9118fe33a17e79b858e66935f424f9..e5bad82d35842036b2a71bfb5c017c16b055d36b 100644 (file)
@@ -105,6 +105,9 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
        r->id.idiag_src[0] = inet->inet_rcv_saddr;
        r->id.idiag_dst[0] = inet->inet_daddr;
 
+       if (nla_put_u8(skb, INET_DIAG_SHUTDOWN, sk->sk_shutdown))
+               goto errout;
+
        /* IPv6 dual-stack sockets use inet->tos for IPv4 connections,
         * hence this needs to be included regardless of socket family.
         */
index 06748f108a5732e9f847cdffd0dafe0cb996c191..5ac19dc1d5e4ffe31394f7f8721efb7a0c2073bb 100644 (file)
@@ -151,6 +151,9 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct unix_diag_r
            sock_diag_put_meminfo(sk, skb, UNIX_DIAG_MEMINFO))
                goto out_nlmsg_trim;
 
+       if (nla_put_u8(skb, UNIX_DIAG_SHUTDOWN, sk->sk_shutdown))
+               goto out_nlmsg_trim;
+
        return nlmsg_end(skb, nlh);
 
 out_nlmsg_trim: