@@ -25,6 +25,7 @@ struct inet_diag_handler {
void *info);
__u16 idiag_type;
__u16 idiag_info_size;
+ __u8 idiag_info_type;
};
struct inet_connection_sock;
@@ -113,9 +113,10 @@ enum {
INET_DIAG_DCTCPINFO,
INET_DIAG_PROTOCOL, /* response attribute only */
INET_DIAG_SKV6ONLY,
+ INET_DIAG_UDP_INFO,
};
-#define INET_DIAG_MAX INET_DIAG_SKV6ONLY
+#define INET_DIAG_MAX INET_DIAG_UDP_INFO
/* INET_DIAG_MEM */
@@ -37,5 +37,8 @@ struct udphdr {
#define UDP_ENCAP_ESPINUDP 2 /* draft-ietf-ipsec-udp-encaps-06 */
#define UDP_ENCAP_L2TPINUDP 3 /* rfc2661 */
+struct udp_info {
+};
+
#endif /* _UAPI_LINUX_UDP_H */
@@ -67,6 +67,7 @@ static const struct inet_diag_handler dccp_diag_handler = {
.idiag_get_info = dccp_diag_get_info,
.idiag_type = IPPROTO_DCCP,
.idiag_info_size = sizeof(struct tcp_info),
+ .idiag_info_type = INET_DIAG_INFO,
};
static int __init dccp_diag_init(void)
@@ -177,8 +177,17 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
if (sock_diag_put_meminfo(sk, skb, INET_DIAG_SKMEMINFO))
goto errout;
+ if ((ext & (1 << (INET_DIAG_INFO - 1))) && handler->idiag_info_size) {
+ attr = nla_reserve(skb, handler->idiag_info_type,
+ handler->idiag_info_size);
+ if (!attr)
+ goto errout;
+
+ info = nla_data(attr);
+ }
+ handler->idiag_get_info(sk, r, info);
+
if (!icsk) {
- handler->idiag_get_info(sk, r, NULL);
goto out;
}
@@ -204,15 +213,6 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
}
#undef EXPIRES_IN_MS
- if ((ext & (1 << (INET_DIAG_INFO - 1))) && handler->idiag_info_size) {
- attr = nla_reserve(skb, INET_DIAG_INFO,
- handler->idiag_info_size);
- if (!attr)
- goto errout;
-
- info = nla_data(attr);
- }
-
if (ext & (1 << (INET_DIAG_CONG - 1))) {
int err = 0;
@@ -225,8 +225,6 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
goto errout;
}
- handler->idiag_get_info(sk, r, info);
-
if (sk->sk_state < TCP_TIME_WAIT) {
union tcp_cc_info info;
size_t sz = 0;
@@ -1036,7 +1034,8 @@ int inet_diag_handler_get_info(struct sk_buff *skb, struct sock *sk)
}
attr = handler->idiag_info_size
- ? nla_reserve(skb, INET_DIAG_INFO, handler->idiag_info_size)
+ ? nla_reserve(skb, handler->idiag_info_type,
+ handler->idiag_info_size)
: NULL;
if (attr)
info = nla_data(attr);
@@ -52,6 +52,7 @@ static const struct inet_diag_handler tcp_diag_handler = {
.idiag_get_info = tcp_diag_get_info,
.idiag_type = IPPROTO_TCP,
.idiag_info_size = sizeof(struct tcp_info),
+ .idiag_info_type = INET_DIAG_INFO,
};
static int __init tcp_diag_init(void)
@@ -170,7 +170,8 @@ 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,
+ .idiag_info_size = sizeof(struct udp_info),
+ .idiag_info_type = INET_DIAG_UDP_INFO,
};
static void udplite_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
@@ -191,7 +192,8 @@ 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,
+ .idiag_info_size = sizeof(struct udp_info),
+ .idiag_info_type = INET_DIAG_UDP_INFO,
};
static int __init udp_diag_init(void)