Commit 3fd22af8 authored by Craig Gallek's avatar Craig Gallek Committed by David S. Miller

sock_diag: specify info_size per inet protocol

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: default avatarCraig Gallek <kraig@google.com>
Acked-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent eb4cb008
...@@ -24,6 +24,7 @@ struct inet_diag_handler { ...@@ -24,6 +24,7 @@ struct inet_diag_handler {
struct inet_diag_msg *r, struct inet_diag_msg *r,
void *info); void *info);
__u16 idiag_type; __u16 idiag_type;
__u16 idiag_info_size;
}; };
struct inet_connection_sock; struct inet_connection_sock;
......
...@@ -66,6 +66,7 @@ static const struct inet_diag_handler dccp_diag_handler = { ...@@ -66,6 +66,7 @@ static const struct inet_diag_handler dccp_diag_handler = {
.dump_one = dccp_diag_dump_one, .dump_one = dccp_diag_dump_one,
.idiag_get_info = dccp_diag_get_info, .idiag_get_info = dccp_diag_get_info,
.idiag_type = IPPROTO_DCCP, .idiag_type = IPPROTO_DCCP,
.idiag_info_size = sizeof(struct tcp_info),
}; };
static int __init dccp_diag_init(void) static int __init dccp_diag_init(void)
......
...@@ -200,9 +200,9 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk, ...@@ -200,9 +200,9 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
} }
#undef EXPIRES_IN_MS #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, attr = nla_reserve(skb, INET_DIAG_INFO,
sizeof(struct tcp_info)); handler->idiag_info_size);
if (!attr) if (!attr)
goto errout; goto errout;
......
...@@ -50,6 +50,7 @@ static const struct inet_diag_handler tcp_diag_handler = { ...@@ -50,6 +50,7 @@ static const struct inet_diag_handler tcp_diag_handler = {
.dump_one = tcp_diag_dump_one, .dump_one = tcp_diag_dump_one,
.idiag_get_info = tcp_diag_get_info, .idiag_get_info = tcp_diag_get_info,
.idiag_type = IPPROTO_TCP, .idiag_type = IPPROTO_TCP,
.idiag_info_size = sizeof(struct tcp_info),
}; };
static int __init tcp_diag_init(void) static int __init tcp_diag_init(void)
......
...@@ -170,6 +170,7 @@ static const struct inet_diag_handler udp_diag_handler = { ...@@ -170,6 +170,7 @@ static const struct inet_diag_handler udp_diag_handler = {
.dump_one = udp_diag_dump_one, .dump_one = udp_diag_dump_one,
.idiag_get_info = udp_diag_get_info, .idiag_get_info = udp_diag_get_info,
.idiag_type = IPPROTO_UDP, .idiag_type = IPPROTO_UDP,
.idiag_info_size = 0,
}; };
static void udplite_diag_dump(struct sk_buff *skb, struct netlink_callback *cb, 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 = { ...@@ -190,6 +191,7 @@ static const struct inet_diag_handler udplite_diag_handler = {
.dump_one = udplite_diag_dump_one, .dump_one = udplite_diag_dump_one,
.idiag_get_info = udp_diag_get_info, .idiag_get_info = udp_diag_get_info,
.idiag_type = IPPROTO_UDPLITE, .idiag_type = IPPROTO_UDPLITE,
.idiag_info_size = 0,
}; };
static int __init udp_diag_init(void) static int __init udp_diag_init(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment