sock_diag: specify info_size per inet protocol
authorCraig Gallek <kraig@google.com>
Mon, 15 Jun 2015 15:26:19 +0000 (11:26 -0400)
committerDavid S. Miller <davem@davemloft.net>
Tue, 16 Jun 2015 02:49:22 +0000 (19:49 -0700)
Previously, there was no clear distinction between the inet protocols
that used struct tcp_info to report information and those that didn't.
This change adds a specific size attribute to the inet_diag_handler
struct which defines these interfaces.  This will make dispatching
sock_diag get_info requests identical for all inet protocols in a
following patch.

Tested: ss -au
Tested: ss -at
Signed-off-by: Craig Gallek <kraig@google.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/inet_diag.h
net/dccp/diag.c
net/ipv4/inet_diag.c
net/ipv4/tcp_diag.c
net/ipv4/udp_diag.c

index ac48b10c9395f992403f1377c63a3be47d90804a..0e707f0c1a3ed1e747bf11ec9477fbae95468bff 100644 (file)
@@ -24,6 +24,7 @@ struct inet_diag_handler {
                                          struct inet_diag_msg *r,
                                          void *info);
        __u16           idiag_type;
+       __u16           idiag_info_size;
 };
 
 struct inet_connection_sock;
index 5a45f8de5d99e5e20d93bd49843ed8e2717b2ddd..2d84303ea6bf7163f230cee4ea6f4da0e417f428 100644 (file)
@@ -66,6 +66,7 @@ static const struct inet_diag_handler dccp_diag_handler = {
        .dump_one        = dccp_diag_dump_one,
        .idiag_get_info  = dccp_diag_get_info,
        .idiag_type      = IPPROTO_DCCP,
+       .idiag_info_size = sizeof(struct tcp_info),
 };
 
 static int __init dccp_diag_init(void)
index 4d32262c7502cc22d13a9f3bd47ca72e8ee355e8..b1f01174bf32f2bff7434275e071f3fe7cbc546f 100644 (file)
@@ -200,9 +200,9 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
        }
 #undef EXPIRES_IN_MS
 
-       if (ext & (1 << (INET_DIAG_INFO - 1))) {
+       if ((ext & (1 << (INET_DIAG_INFO - 1))) && handler->idiag_info_size) {
                attr = nla_reserve(skb, INET_DIAG_INFO,
-                                  sizeof(struct tcp_info));
+                                  handler->idiag_info_size);
                if (!attr)
                        goto errout;
 
index 79b34a0f4a4ae519c3f66c511c989b92fca02b09..423e3881a40b211497ee5a84ddcf90227a13c5f7 100644 (file)
@@ -50,6 +50,7 @@ static const struct inet_diag_handler tcp_diag_handler = {
        .dump_one        = tcp_diag_dump_one,
        .idiag_get_info  = tcp_diag_get_info,
        .idiag_type      = IPPROTO_TCP,
+       .idiag_info_size = sizeof(struct tcp_info),
 };
 
 static int __init tcp_diag_init(void)
index b763c39ae1d734621a5f6872f9d41d442f476c92..6116604bf6e8fd64d82b5d9496197cb7e4accef7 100644 (file)
@@ -170,6 +170,7 @@ static const struct inet_diag_handler udp_diag_handler = {
        .dump_one        = udp_diag_dump_one,
        .idiag_get_info  = udp_diag_get_info,
        .idiag_type      = IPPROTO_UDP,
+       .idiag_info_size = 0,
 };
 
 static void udplite_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
@@ -190,6 +191,7 @@ static const struct inet_diag_handler udplite_diag_handler = {
        .dump_one        = udplite_diag_dump_one,
        .idiag_get_info  = udp_diag_get_info,
        .idiag_type      = IPPROTO_UDPLITE,
+       .idiag_info_size = 0,
 };
 
 static int __init udp_diag_init(void)