2 * inet_diag.c Module for monitoring INET transport protocols sockets.
4 * Version: $Id: inet_diag.c,v 1.3 2002/02/01 22:01:04 davem Exp $
6 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
14 #include <linux/kernel.h>
15 #include <linux/module.h>
16 #include <linux/types.h>
17 #include <linux/fcntl.h>
18 #include <linux/random.h>
19 #include <linux/cache.h>
20 #include <linux/init.h>
21 #include <linux/time.h>
26 #include <net/inet_common.h>
27 #include <net/inet_connection_sock.h>
28 #include <net/inet_hashtables.h>
29 #include <net/inet_timewait_sock.h>
30 #include <net/inet6_hashtables.h>
31 #include <net/netlink.h>
33 #include <linux/inet.h>
34 #include <linux/stddef.h>
36 #include <linux/inet_diag.h>
38 static const struct inet_diag_handler **inet_diag_table;
40 struct inet_diag_entry {
49 static struct sock *idiagnl;
51 #define INET_DIAG_PUT(skb, attrtype, attrlen) \
52 RTA_DATA(__RTA_PUT(skb, attrtype, attrlen))
54 static int inet_csk_diag_fill(struct sock *sk,
56 int ext, u32 pid, u32 seq, u16 nlmsg_flags,
57 const struct nlmsghdr *unlh)
59 const struct inet_sock *inet = inet_sk(sk);
60 const struct inet_connection_sock *icsk = inet_csk(sk);
61 struct inet_diag_msg *r;
64 struct inet_diag_meminfo *minfo = NULL;
65 unsigned char *b = skb_tail_pointer(skb);
66 const struct inet_diag_handler *handler;
68 handler = inet_diag_table[unlh->nlmsg_type];
69 BUG_ON(handler == NULL);
71 nlh = NLMSG_PUT(skb, pid, seq, unlh->nlmsg_type, sizeof(*r));
72 nlh->nlmsg_flags = nlmsg_flags;
75 BUG_ON(sk->sk_state == TCP_TIME_WAIT);
77 if (ext & (1 << (INET_DIAG_MEMINFO - 1)))
78 minfo = INET_DIAG_PUT(skb, INET_DIAG_MEMINFO, sizeof(*minfo));
80 if (ext & (1 << (INET_DIAG_INFO - 1)))
81 info = INET_DIAG_PUT(skb, INET_DIAG_INFO,
82 handler->idiag_info_size);
84 if ((ext & (1 << (INET_DIAG_CONG - 1))) && icsk->icsk_ca_ops) {
85 const size_t len = strlen(icsk->icsk_ca_ops->name);
87 strcpy(INET_DIAG_PUT(skb, INET_DIAG_CONG, len + 1),
88 icsk->icsk_ca_ops->name);
91 r->idiag_family = sk->sk_family;
92 r->idiag_state = sk->sk_state;
96 r->id.idiag_if = sk->sk_bound_dev_if;
97 r->id.idiag_cookie[0] = (u32)(unsigned long)sk;
98 r->id.idiag_cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
100 r->id.idiag_sport = inet->sport;
101 r->id.idiag_dport = inet->dport;
102 r->id.idiag_src[0] = inet->rcv_saddr;
103 r->id.idiag_dst[0] = inet->daddr;
105 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
106 if (r->idiag_family == AF_INET6) {
107 struct ipv6_pinfo *np = inet6_sk(sk);
109 ipv6_addr_copy((struct in6_addr *)r->id.idiag_src,
111 ipv6_addr_copy((struct in6_addr *)r->id.idiag_dst,
116 #define EXPIRES_IN_MS(tmo) DIV_ROUND_UP((tmo - jiffies) * 1000, HZ)
118 if (icsk->icsk_pending == ICSK_TIME_RETRANS) {
120 r->idiag_retrans = icsk->icsk_retransmits;
121 r->idiag_expires = EXPIRES_IN_MS(icsk->icsk_timeout);
122 } else if (icsk->icsk_pending == ICSK_TIME_PROBE0) {
124 r->idiag_retrans = icsk->icsk_probes_out;
125 r->idiag_expires = EXPIRES_IN_MS(icsk->icsk_timeout);
126 } else if (timer_pending(&sk->sk_timer)) {
128 r->idiag_retrans = icsk->icsk_probes_out;
129 r->idiag_expires = EXPIRES_IN_MS(sk->sk_timer.expires);
132 r->idiag_expires = 0;
136 r->idiag_uid = sock_i_uid(sk);
137 r->idiag_inode = sock_i_ino(sk);
140 minfo->idiag_rmem = atomic_read(&sk->sk_rmem_alloc);
141 minfo->idiag_wmem = sk->sk_wmem_queued;
142 minfo->idiag_fmem = sk->sk_forward_alloc;
143 minfo->idiag_tmem = atomic_read(&sk->sk_wmem_alloc);
146 handler->idiag_get_info(sk, r, info);
148 if (sk->sk_state < TCP_TIME_WAIT &&
149 icsk->icsk_ca_ops && icsk->icsk_ca_ops->get_info)
150 icsk->icsk_ca_ops->get_info(sk, ext, skb);
152 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
161 static int inet_twsk_diag_fill(struct inet_timewait_sock *tw,
162 struct sk_buff *skb, int ext, u32 pid,
163 u32 seq, u16 nlmsg_flags,
164 const struct nlmsghdr *unlh)
167 struct inet_diag_msg *r;
168 const unsigned char *previous_tail = skb_tail_pointer(skb);
169 struct nlmsghdr *nlh = NLMSG_PUT(skb, pid, seq,
170 unlh->nlmsg_type, sizeof(*r));
173 BUG_ON(tw->tw_state != TCP_TIME_WAIT);
175 nlh->nlmsg_flags = nlmsg_flags;
177 tmo = tw->tw_ttd - jiffies;
181 r->idiag_family = tw->tw_family;
182 r->idiag_state = tw->tw_state;
184 r->idiag_retrans = 0;
185 r->id.idiag_if = tw->tw_bound_dev_if;
186 r->id.idiag_cookie[0] = (u32)(unsigned long)tw;
187 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
188 r->id.idiag_sport = tw->tw_sport;
189 r->id.idiag_dport = tw->tw_dport;
190 r->id.idiag_src[0] = tw->tw_rcv_saddr;
191 r->id.idiag_dst[0] = tw->tw_daddr;
192 r->idiag_state = tw->tw_substate;
194 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
199 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
200 if (tw->tw_family == AF_INET6) {
201 const struct inet6_timewait_sock *tw6 =
202 inet6_twsk((struct sock *)tw);
204 ipv6_addr_copy((struct in6_addr *)r->id.idiag_src,
205 &tw6->tw_v6_rcv_saddr);
206 ipv6_addr_copy((struct in6_addr *)r->id.idiag_dst,
210 nlh->nlmsg_len = skb_tail_pointer(skb) - previous_tail;
213 nlmsg_trim(skb, previous_tail);
217 static int sk_diag_fill(struct sock *sk, struct sk_buff *skb,
218 int ext, u32 pid, u32 seq, u16 nlmsg_flags,
219 const struct nlmsghdr *unlh)
221 if (sk->sk_state == TCP_TIME_WAIT)
222 return inet_twsk_diag_fill((struct inet_timewait_sock *)sk,
223 skb, ext, pid, seq, nlmsg_flags,
225 return inet_csk_diag_fill(sk, skb, ext, pid, seq, nlmsg_flags, unlh);
228 static int inet_diag_get_exact(struct sk_buff *in_skb,
229 const struct nlmsghdr *nlh)
233 struct inet_diag_req *req = NLMSG_DATA(nlh);
235 struct inet_hashinfo *hashinfo;
236 const struct inet_diag_handler *handler;
238 handler = inet_diag_table[nlh->nlmsg_type];
239 BUG_ON(handler == NULL);
240 hashinfo = handler->idiag_hashinfo;
242 if (req->idiag_family == AF_INET) {
243 sk = inet_lookup(hashinfo, req->id.idiag_dst[0],
244 req->id.idiag_dport, req->id.idiag_src[0],
245 req->id.idiag_sport, req->id.idiag_if);
247 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
248 else if (req->idiag_family == AF_INET6) {
249 sk = inet6_lookup(hashinfo,
250 (struct in6_addr *)req->id.idiag_dst,
252 (struct in6_addr *)req->id.idiag_src,
265 if ((req->id.idiag_cookie[0] != INET_DIAG_NOCOOKIE ||
266 req->id.idiag_cookie[1] != INET_DIAG_NOCOOKIE) &&
267 ((u32)(unsigned long)sk != req->id.idiag_cookie[0] ||
268 (u32)((((unsigned long)sk) >> 31) >> 1) != req->id.idiag_cookie[1]))
272 rep = alloc_skb(NLMSG_SPACE((sizeof(struct inet_diag_msg) +
273 sizeof(struct inet_diag_meminfo) +
274 handler->idiag_info_size + 64)),
279 err = sk_diag_fill(sk, rep, req->idiag_ext,
280 NETLINK_CB(in_skb).pid,
281 nlh->nlmsg_seq, 0, nlh);
283 WARN_ON(err == -EMSGSIZE);
287 err = netlink_unicast(idiagnl, rep, NETLINK_CB(in_skb).pid,
294 if (sk->sk_state == TCP_TIME_WAIT)
295 inet_twsk_put((struct inet_timewait_sock *)sk);
302 static int bitstring_match(const __be32 *a1, const __be32 *a2, int bits)
304 int words = bits >> 5;
309 if (memcmp(a1, a2, words << 2))
319 mask = htonl((0xffffffff) << (32 - bits));
321 if ((w1 ^ w2) & mask)
329 static int inet_diag_bc_run(const void *bc, int len,
330 const struct inet_diag_entry *entry)
334 const struct inet_diag_bc_op *op = bc;
337 case INET_DIAG_BC_NOP:
339 case INET_DIAG_BC_JMP:
342 case INET_DIAG_BC_S_GE:
343 yes = entry->sport >= op[1].no;
345 case INET_DIAG_BC_S_LE:
346 yes = entry->dport <= op[1].no;
348 case INET_DIAG_BC_D_GE:
349 yes = entry->dport >= op[1].no;
351 case INET_DIAG_BC_D_LE:
352 yes = entry->dport <= op[1].no;
354 case INET_DIAG_BC_AUTO:
355 yes = !(entry->userlocks & SOCK_BINDPORT_LOCK);
357 case INET_DIAG_BC_S_COND:
358 case INET_DIAG_BC_D_COND: {
359 struct inet_diag_hostcond *cond;
362 cond = (struct inet_diag_hostcond *)(op + 1);
363 if (cond->port != -1 &&
364 cond->port != (op->code == INET_DIAG_BC_S_COND ?
365 entry->sport : entry->dport)) {
370 if (cond->prefix_len == 0)
373 if (op->code == INET_DIAG_BC_S_COND)
378 if (bitstring_match(addr, cond->addr,
381 if (entry->family == AF_INET6 &&
382 cond->family == AF_INET) {
383 if (addr[0] == 0 && addr[1] == 0 &&
384 addr[2] == htonl(0xffff) &&
385 bitstring_match(addr + 3, cond->addr,
405 static int valid_cc(const void *bc, int len, int cc)
408 const struct inet_diag_bc_op *op = bc;
422 static int inet_diag_bc_audit(const void *bytecode, int bytecode_len)
424 const unsigned char *bc = bytecode;
425 int len = bytecode_len;
428 struct inet_diag_bc_op *op = (struct inet_diag_bc_op *)bc;
430 //printk("BC: %d %d %d {%d} / %d\n", op->code, op->yes, op->no, op[1].no, len);
432 case INET_DIAG_BC_AUTO:
433 case INET_DIAG_BC_S_COND:
434 case INET_DIAG_BC_D_COND:
435 case INET_DIAG_BC_S_GE:
436 case INET_DIAG_BC_S_LE:
437 case INET_DIAG_BC_D_GE:
438 case INET_DIAG_BC_D_LE:
439 if (op->yes < 4 || op->yes > len + 4)
441 case INET_DIAG_BC_JMP:
442 if (op->no < 4 || op->no > len + 4)
445 !valid_cc(bytecode, bytecode_len, len - op->no))
448 case INET_DIAG_BC_NOP:
449 if (op->yes < 4 || op->yes > len + 4)
458 return len == 0 ? 0 : -EINVAL;
461 static int inet_csk_diag_dump(struct sock *sk,
463 struct netlink_callback *cb)
465 struct inet_diag_req *r = NLMSG_DATA(cb->nlh);
467 if (cb->nlh->nlmsg_len > 4 + NLMSG_SPACE(sizeof(*r))) {
468 struct inet_diag_entry entry;
469 struct rtattr *bc = (struct rtattr *)(r + 1);
470 struct inet_sock *inet = inet_sk(sk);
472 entry.family = sk->sk_family;
473 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
474 if (entry.family == AF_INET6) {
475 struct ipv6_pinfo *np = inet6_sk(sk);
477 entry.saddr = np->rcv_saddr.s6_addr32;
478 entry.daddr = np->daddr.s6_addr32;
482 entry.saddr = &inet->rcv_saddr;
483 entry.daddr = &inet->daddr;
485 entry.sport = inet->num;
486 entry.dport = ntohs(inet->dport);
487 entry.userlocks = sk->sk_userlocks;
489 if (!inet_diag_bc_run(RTA_DATA(bc), RTA_PAYLOAD(bc), &entry))
493 return inet_csk_diag_fill(sk, skb, r->idiag_ext,
494 NETLINK_CB(cb->skb).pid,
495 cb->nlh->nlmsg_seq, NLM_F_MULTI, cb->nlh);
498 static int inet_twsk_diag_dump(struct inet_timewait_sock *tw,
500 struct netlink_callback *cb)
502 struct inet_diag_req *r = NLMSG_DATA(cb->nlh);
504 if (cb->nlh->nlmsg_len > 4 + NLMSG_SPACE(sizeof(*r))) {
505 struct inet_diag_entry entry;
506 struct rtattr *bc = (struct rtattr *)(r + 1);
508 entry.family = tw->tw_family;
509 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
510 if (tw->tw_family == AF_INET6) {
511 struct inet6_timewait_sock *tw6 =
512 inet6_twsk((struct sock *)tw);
513 entry.saddr = tw6->tw_v6_rcv_saddr.s6_addr32;
514 entry.daddr = tw6->tw_v6_daddr.s6_addr32;
518 entry.saddr = &tw->tw_rcv_saddr;
519 entry.daddr = &tw->tw_daddr;
521 entry.sport = tw->tw_num;
522 entry.dport = ntohs(tw->tw_dport);
525 if (!inet_diag_bc_run(RTA_DATA(bc), RTA_PAYLOAD(bc), &entry))
529 return inet_twsk_diag_fill(tw, skb, r->idiag_ext,
530 NETLINK_CB(cb->skb).pid,
531 cb->nlh->nlmsg_seq, NLM_F_MULTI, cb->nlh);
534 static int inet_diag_fill_req(struct sk_buff *skb, struct sock *sk,
535 struct request_sock *req, u32 pid, u32 seq,
536 const struct nlmsghdr *unlh)
538 const struct inet_request_sock *ireq = inet_rsk(req);
539 struct inet_sock *inet = inet_sk(sk);
540 unsigned char *b = skb_tail_pointer(skb);
541 struct inet_diag_msg *r;
542 struct nlmsghdr *nlh;
545 nlh = NLMSG_PUT(skb, pid, seq, unlh->nlmsg_type, sizeof(*r));
546 nlh->nlmsg_flags = NLM_F_MULTI;
549 r->idiag_family = sk->sk_family;
550 r->idiag_state = TCP_SYN_RECV;
552 r->idiag_retrans = req->retrans;
554 r->id.idiag_if = sk->sk_bound_dev_if;
555 r->id.idiag_cookie[0] = (u32)(unsigned long)req;
556 r->id.idiag_cookie[1] = (u32)(((unsigned long)req >> 31) >> 1);
558 tmo = req->expires - jiffies;
562 r->id.idiag_sport = inet->sport;
563 r->id.idiag_dport = ireq->rmt_port;
564 r->id.idiag_src[0] = ireq->loc_addr;
565 r->id.idiag_dst[0] = ireq->rmt_addr;
566 r->idiag_expires = jiffies_to_msecs(tmo);
569 r->idiag_uid = sock_i_uid(sk);
571 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
572 if (r->idiag_family == AF_INET6) {
573 ipv6_addr_copy((struct in6_addr *)r->id.idiag_src,
574 &inet6_rsk(req)->loc_addr);
575 ipv6_addr_copy((struct in6_addr *)r->id.idiag_dst,
576 &inet6_rsk(req)->rmt_addr);
579 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
588 static int inet_diag_dump_reqs(struct sk_buff *skb, struct sock *sk,
589 struct netlink_callback *cb)
591 struct inet_diag_entry entry;
592 struct inet_diag_req *r = NLMSG_DATA(cb->nlh);
593 struct inet_connection_sock *icsk = inet_csk(sk);
594 struct listen_sock *lopt;
595 struct rtattr *bc = NULL;
596 struct inet_sock *inet = inet_sk(sk);
598 int reqnum, s_reqnum;
602 s_reqnum = cb->args[4];
607 entry.family = sk->sk_family;
609 read_lock_bh(&icsk->icsk_accept_queue.syn_wait_lock);
611 lopt = icsk->icsk_accept_queue.listen_opt;
612 if (!lopt || !lopt->qlen)
615 if (cb->nlh->nlmsg_len > 4 + NLMSG_SPACE(sizeof(*r))) {
616 bc = (struct rtattr *)(r + 1);
617 entry.sport = inet->num;
618 entry.userlocks = sk->sk_userlocks;
621 for (j = s_j; j < lopt->nr_table_entries; j++) {
622 struct request_sock *req, *head = lopt->syn_table[j];
625 for (req = head; req; reqnum++, req = req->dl_next) {
626 struct inet_request_sock *ireq = inet_rsk(req);
628 if (reqnum < s_reqnum)
630 if (r->id.idiag_dport != ireq->rmt_port &&
636 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
637 (entry.family == AF_INET6) ?
638 inet6_rsk(req)->loc_addr.s6_addr32 :
642 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
643 (entry.family == AF_INET6) ?
644 inet6_rsk(req)->rmt_addr.s6_addr32 :
647 entry.dport = ntohs(ireq->rmt_port);
649 if (!inet_diag_bc_run(RTA_DATA(bc),
650 RTA_PAYLOAD(bc), &entry))
654 err = inet_diag_fill_req(skb, sk, req,
655 NETLINK_CB(cb->skb).pid,
656 cb->nlh->nlmsg_seq, cb->nlh);
659 cb->args[4] = reqnum;
668 read_unlock_bh(&icsk->icsk_accept_queue.syn_wait_lock);
673 static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
677 struct inet_diag_req *r = NLMSG_DATA(cb->nlh);
678 const struct inet_diag_handler *handler;
679 struct inet_hashinfo *hashinfo;
681 handler = inet_diag_table[cb->nlh->nlmsg_type];
682 BUG_ON(handler == NULL);
683 hashinfo = handler->idiag_hashinfo;
686 s_num = num = cb->args[2];
688 if (cb->args[0] == 0) {
689 if (!(r->idiag_states & (TCPF_LISTEN | TCPF_SYN_RECV)))
692 inet_listen_lock(hashinfo);
693 for (i = s_i; i < INET_LHTABLE_SIZE; i++) {
695 struct hlist_node *node;
698 sk_for_each(sk, node, &hashinfo->listening_hash[i]) {
699 struct inet_sock *inet = inet_sk(sk);
706 if (r->id.idiag_sport != inet->sport &&
710 if (!(r->idiag_states & TCPF_LISTEN) ||
715 if (inet_csk_diag_dump(sk, skb, cb) < 0) {
716 inet_listen_unlock(hashinfo);
721 if (!(r->idiag_states & TCPF_SYN_RECV))
724 if (inet_diag_dump_reqs(skb, sk, cb) < 0) {
725 inet_listen_unlock(hashinfo);
739 inet_listen_unlock(hashinfo);
742 s_i = num = s_num = 0;
745 if (!(r->idiag_states & ~(TCPF_LISTEN | TCPF_SYN_RECV)))
748 for (i = s_i; i < hashinfo->ehash_size; i++) {
749 struct inet_ehash_bucket *head = &hashinfo->ehash[i];
751 struct hlist_node *node;
756 read_lock_bh(&head->lock);
758 sk_for_each(sk, node, &head->chain) {
759 struct inet_sock *inet = inet_sk(sk);
763 if (!(r->idiag_states & (1 << sk->sk_state)))
765 if (r->id.idiag_sport != inet->sport &&
768 if (r->id.idiag_dport != inet->dport &&
771 if (inet_csk_diag_dump(sk, skb, cb) < 0) {
772 read_unlock_bh(&head->lock);
779 if (r->idiag_states & TCPF_TIME_WAIT) {
780 struct inet_timewait_sock *tw;
782 inet_twsk_for_each(tw, node,
787 if (r->id.idiag_sport != tw->tw_sport &&
790 if (r->id.idiag_dport != tw->tw_dport &&
793 if (inet_twsk_diag_dump(tw, skb, cb) < 0) {
794 read_unlock_bh(&head->lock);
801 read_unlock_bh(&head->lock);
810 static int inet_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
812 int hdrlen = sizeof(struct inet_diag_req);
814 if (nlh->nlmsg_type >= INET_DIAG_GETSOCK_MAX ||
815 nlmsg_len(nlh) < hdrlen)
818 if (inet_diag_table[nlh->nlmsg_type] == NULL)
821 if (nlh->nlmsg_flags & NLM_F_DUMP) {
822 if (nlmsg_attrlen(nlh, hdrlen)) {
825 attr = nlmsg_find_attr(nlh, hdrlen,
826 INET_DIAG_REQ_BYTECODE);
828 nla_len(attr) < sizeof(struct inet_diag_bc_op) ||
829 inet_diag_bc_audit(nla_data(attr), nla_len(attr)))
833 return netlink_dump_start(idiagnl, skb, nlh,
834 inet_diag_dump, NULL);
837 return inet_diag_get_exact(skb, nlh);
840 static DEFINE_MUTEX(inet_diag_mutex);
842 static void inet_diag_rcv(struct sk_buff *skb)
844 mutex_lock(&inet_diag_mutex);
845 netlink_rcv_skb(skb, &inet_diag_rcv_msg);
846 mutex_unlock(&inet_diag_mutex);
849 static DEFINE_SPINLOCK(inet_diag_register_lock);
851 int inet_diag_register(const struct inet_diag_handler *h)
853 const __u16 type = h->idiag_type;
856 if (type >= INET_DIAG_GETSOCK_MAX)
859 spin_lock(&inet_diag_register_lock);
861 if (inet_diag_table[type] == NULL) {
862 inet_diag_table[type] = h;
865 spin_unlock(&inet_diag_register_lock);
869 EXPORT_SYMBOL_GPL(inet_diag_register);
871 void inet_diag_unregister(const struct inet_diag_handler *h)
873 const __u16 type = h->idiag_type;
875 if (type >= INET_DIAG_GETSOCK_MAX)
878 spin_lock(&inet_diag_register_lock);
879 inet_diag_table[type] = NULL;
880 spin_unlock(&inet_diag_register_lock);
884 EXPORT_SYMBOL_GPL(inet_diag_unregister);
886 static int __init inet_diag_init(void)
888 const int inet_diag_table_size = (INET_DIAG_GETSOCK_MAX *
889 sizeof(struct inet_diag_handler *));
892 inet_diag_table = kzalloc(inet_diag_table_size, GFP_KERNEL);
893 if (!inet_diag_table)
896 idiagnl = netlink_kernel_create(&init_net, NETLINK_INET_DIAG, 0,
897 inet_diag_rcv, NULL, THIS_MODULE);
904 kfree(inet_diag_table);
908 static void __exit inet_diag_exit(void)
910 sock_release(idiagnl->sk_socket);
911 kfree(inet_diag_table);
914 module_init(inet_diag_init);
915 module_exit(inet_diag_exit);
916 MODULE_LICENSE("GPL");