1 /* Connection tracking via netlink socket. Allows for user space
2 * protocol helpers and general trouble making from userspace.
4 * (C) 2001 by Jay Schulist <jschlst@samba.org>
5 * (C) 2002-2006 by Harald Welte <laforge@gnumonks.org>
6 * (C) 2003 by Patrick Mchardy <kaber@trash.net>
7 * (C) 2005-2006 by Pablo Neira Ayuso <pablo@eurodev.net>
9 * I've reworked this stuff to use attributes instead of conntrack
10 * structures. 5.44 am. I need more tea. --pablo 05/07/11.
12 * Initial connection tracking via netlink development funded and
13 * generally made possible by Network Robots, Inc. (www.networkrobots.com)
15 * Further development of this code funded by Astaro AG (http://www.astaro.com)
17 * This software may be used and distributed according to the terms
18 * of the GNU General Public License, incorporated herein by reference.
20 * Derived from ip_conntrack_netlink.c: Port by Pablo Neira Ayuso (05/11/14)
23 #include <linux/init.h>
24 #include <linux/module.h>
25 #include <linux/kernel.h>
26 #include <linux/types.h>
27 #include <linux/timer.h>
28 #include <linux/skbuff.h>
29 #include <linux/errno.h>
30 #include <linux/netlink.h>
31 #include <linux/spinlock.h>
32 #include <linux/interrupt.h>
33 #include <linux/notifier.h>
35 #include <linux/netfilter.h>
36 #include <net/netfilter/nf_conntrack.h>
37 #include <net/netfilter/nf_conntrack_core.h>
38 #include <net/netfilter/nf_conntrack_expect.h>
39 #include <net/netfilter/nf_conntrack_helper.h>
40 #include <net/netfilter/nf_conntrack_l3proto.h>
41 #include <net/netfilter/nf_conntrack_l4proto.h>
42 #include <net/netfilter/nf_conntrack_tuple.h>
43 #ifdef CONFIG_NF_NAT_NEEDED
44 #include <net/netfilter/nf_nat_core.h>
45 #include <net/netfilter/nf_nat_protocol.h>
48 #include <linux/netfilter/nfnetlink.h>
49 #include <linux/netfilter/nfnetlink_conntrack.h>
51 MODULE_LICENSE("GPL");
53 static char __initdata version[] = "0.93";
56 ctnetlink_dump_tuples_proto(struct sk_buff *skb,
57 const struct nf_conntrack_tuple *tuple,
58 struct nf_conntrack_l4proto *l4proto)
61 struct nfattr *nest_parms = NFA_NEST(skb, CTA_TUPLE_PROTO);
63 NFA_PUT(skb, CTA_PROTO_NUM, sizeof(u_int8_t), &tuple->dst.protonum);
65 if (likely(l4proto->tuple_to_nfattr))
66 ret = l4proto->tuple_to_nfattr(skb, tuple);
68 NFA_NEST_END(skb, nest_parms);
77 ctnetlink_dump_tuples_ip(struct sk_buff *skb,
78 const struct nf_conntrack_tuple *tuple,
79 struct nf_conntrack_l3proto *l3proto)
82 struct nfattr *nest_parms = NFA_NEST(skb, CTA_TUPLE_IP);
84 if (likely(l3proto->tuple_to_nfattr))
85 ret = l3proto->tuple_to_nfattr(skb, tuple);
87 NFA_NEST_END(skb, nest_parms);
96 ctnetlink_dump_tuples(struct sk_buff *skb,
97 const struct nf_conntrack_tuple *tuple)
100 struct nf_conntrack_l3proto *l3proto;
101 struct nf_conntrack_l4proto *l4proto;
103 l3proto = nf_ct_l3proto_find_get(tuple->src.l3num);
104 ret = ctnetlink_dump_tuples_ip(skb, tuple, l3proto);
105 nf_ct_l3proto_put(l3proto);
107 if (unlikely(ret < 0))
110 l4proto = nf_ct_l4proto_find_get(tuple->src.l3num, tuple->dst.protonum);
111 ret = ctnetlink_dump_tuples_proto(skb, tuple, l4proto);
112 nf_ct_l4proto_put(l4proto);
118 ctnetlink_dump_status(struct sk_buff *skb, const struct nf_conn *ct)
120 __be32 status = htonl((u_int32_t) ct->status);
121 NFA_PUT(skb, CTA_STATUS, sizeof(status), &status);
129 ctnetlink_dump_timeout(struct sk_buff *skb, const struct nf_conn *ct)
131 long timeout_l = ct->timeout.expires - jiffies;
137 timeout = htonl(timeout_l / HZ);
139 NFA_PUT(skb, CTA_TIMEOUT, sizeof(timeout), &timeout);
147 ctnetlink_dump_protoinfo(struct sk_buff *skb, const struct nf_conn *ct)
149 struct nf_conntrack_l4proto *l4proto = nf_ct_l4proto_find_get(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num, ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum);
150 struct nfattr *nest_proto;
153 if (!l4proto->to_nfattr) {
154 nf_ct_l4proto_put(l4proto);
158 nest_proto = NFA_NEST(skb, CTA_PROTOINFO);
160 ret = l4proto->to_nfattr(skb, nest_proto, ct);
162 nf_ct_l4proto_put(l4proto);
164 NFA_NEST_END(skb, nest_proto);
169 nf_ct_l4proto_put(l4proto);
174 ctnetlink_dump_helpinfo(struct sk_buff *skb, const struct nf_conn *ct)
176 struct nfattr *nest_helper;
177 const struct nf_conn_help *help = nfct_help(ct);
179 if (!help || !help->helper)
182 nest_helper = NFA_NEST(skb, CTA_HELP);
183 NFA_PUT(skb, CTA_HELP_NAME, strlen(help->helper->name), help->helper->name);
185 if (help->helper->to_nfattr)
186 help->helper->to_nfattr(skb, ct);
188 NFA_NEST_END(skb, nest_helper);
196 #ifdef CONFIG_NF_CT_ACCT
198 ctnetlink_dump_counters(struct sk_buff *skb, const struct nf_conn *ct,
199 enum ip_conntrack_dir dir)
201 enum ctattr_type type = dir ? CTA_COUNTERS_REPLY: CTA_COUNTERS_ORIG;
202 struct nfattr *nest_count = NFA_NEST(skb, type);
205 tmp = htonl(ct->counters[dir].packets);
206 NFA_PUT(skb, CTA_COUNTERS32_PACKETS, sizeof(u_int32_t), &tmp);
208 tmp = htonl(ct->counters[dir].bytes);
209 NFA_PUT(skb, CTA_COUNTERS32_BYTES, sizeof(u_int32_t), &tmp);
211 NFA_NEST_END(skb, nest_count);
219 #define ctnetlink_dump_counters(a, b, c) (0)
222 #ifdef CONFIG_NF_CONNTRACK_MARK
224 ctnetlink_dump_mark(struct sk_buff *skb, const struct nf_conn *ct)
226 __be32 mark = htonl(ct->mark);
228 NFA_PUT(skb, CTA_MARK, sizeof(u_int32_t), &mark);
235 #define ctnetlink_dump_mark(a, b) (0)
239 ctnetlink_dump_id(struct sk_buff *skb, const struct nf_conn *ct)
241 __be32 id = htonl(ct->id);
242 NFA_PUT(skb, CTA_ID, sizeof(u_int32_t), &id);
250 ctnetlink_dump_use(struct sk_buff *skb, const struct nf_conn *ct)
252 __be32 use = htonl(atomic_read(&ct->ct_general.use));
254 NFA_PUT(skb, CTA_USE, sizeof(u_int32_t), &use);
261 #define tuple(ct, dir) (&(ct)->tuplehash[dir].tuple)
264 ctnetlink_fill_info(struct sk_buff *skb, u32 pid, u32 seq,
265 int event, int nowait,
266 const struct nf_conn *ct)
268 struct nlmsghdr *nlh;
269 struct nfgenmsg *nfmsg;
270 struct nfattr *nest_parms;
275 event |= NFNL_SUBSYS_CTNETLINK << 8;
276 nlh = NLMSG_PUT(skb, pid, seq, event, sizeof(struct nfgenmsg));
277 nfmsg = NLMSG_DATA(nlh);
279 nlh->nlmsg_flags = (nowait && pid) ? NLM_F_MULTI : 0;
280 nfmsg->nfgen_family =
281 ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num;
282 nfmsg->version = NFNETLINK_V0;
285 nest_parms = NFA_NEST(skb, CTA_TUPLE_ORIG);
286 if (ctnetlink_dump_tuples(skb, tuple(ct, IP_CT_DIR_ORIGINAL)) < 0)
288 NFA_NEST_END(skb, nest_parms);
290 nest_parms = NFA_NEST(skb, CTA_TUPLE_REPLY);
291 if (ctnetlink_dump_tuples(skb, tuple(ct, IP_CT_DIR_REPLY)) < 0)
293 NFA_NEST_END(skb, nest_parms);
295 if (ctnetlink_dump_status(skb, ct) < 0 ||
296 ctnetlink_dump_timeout(skb, ct) < 0 ||
297 ctnetlink_dump_counters(skb, ct, IP_CT_DIR_ORIGINAL) < 0 ||
298 ctnetlink_dump_counters(skb, ct, IP_CT_DIR_REPLY) < 0 ||
299 ctnetlink_dump_protoinfo(skb, ct) < 0 ||
300 ctnetlink_dump_helpinfo(skb, ct) < 0 ||
301 ctnetlink_dump_mark(skb, ct) < 0 ||
302 ctnetlink_dump_id(skb, ct) < 0 ||
303 ctnetlink_dump_use(skb, ct) < 0)
306 nlh->nlmsg_len = skb->tail - b;
311 skb_trim(skb, b - skb->data);
315 #ifdef CONFIG_NF_CONNTRACK_EVENTS
316 static int ctnetlink_conntrack_event(struct notifier_block *this,
317 unsigned long events, void *ptr)
319 struct nlmsghdr *nlh;
320 struct nfgenmsg *nfmsg;
321 struct nfattr *nest_parms;
322 struct nf_conn *ct = (struct nf_conn *)ptr;
326 unsigned int flags = 0, group;
328 /* ignore our fake conntrack entry */
329 if (ct == &nf_conntrack_untracked)
332 if (events & IPCT_DESTROY) {
333 type = IPCTNL_MSG_CT_DELETE;
334 group = NFNLGRP_CONNTRACK_DESTROY;
335 } else if (events & (IPCT_NEW | IPCT_RELATED)) {
336 type = IPCTNL_MSG_CT_NEW;
337 flags = NLM_F_CREATE|NLM_F_EXCL;
338 group = NFNLGRP_CONNTRACK_NEW;
339 } else if (events & (IPCT_STATUS | IPCT_PROTOINFO)) {
340 type = IPCTNL_MSG_CT_NEW;
341 group = NFNLGRP_CONNTRACK_UPDATE;
345 if (!nfnetlink_has_listeners(group))
348 skb = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC);
354 type |= NFNL_SUBSYS_CTNETLINK << 8;
355 nlh = NLMSG_PUT(skb, 0, 0, type, sizeof(struct nfgenmsg));
356 nfmsg = NLMSG_DATA(nlh);
358 nlh->nlmsg_flags = flags;
359 nfmsg->nfgen_family = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num;
360 nfmsg->version = NFNETLINK_V0;
363 nest_parms = NFA_NEST(skb, CTA_TUPLE_ORIG);
364 if (ctnetlink_dump_tuples(skb, tuple(ct, IP_CT_DIR_ORIGINAL)) < 0)
366 NFA_NEST_END(skb, nest_parms);
368 nest_parms = NFA_NEST(skb, CTA_TUPLE_REPLY);
369 if (ctnetlink_dump_tuples(skb, tuple(ct, IP_CT_DIR_REPLY)) < 0)
371 NFA_NEST_END(skb, nest_parms);
373 if (events & IPCT_DESTROY) {
374 if (ctnetlink_dump_counters(skb, ct, IP_CT_DIR_ORIGINAL) < 0 ||
375 ctnetlink_dump_counters(skb, ct, IP_CT_DIR_REPLY) < 0)
378 if (ctnetlink_dump_status(skb, ct) < 0)
381 if (ctnetlink_dump_timeout(skb, ct) < 0)
384 if (events & IPCT_PROTOINFO
385 && ctnetlink_dump_protoinfo(skb, ct) < 0)
388 if ((events & IPCT_HELPER || nfct_help(ct))
389 && ctnetlink_dump_helpinfo(skb, ct) < 0)
392 #ifdef CONFIG_NF_CONNTRACK_MARK
393 if ((events & IPCT_MARK || ct->mark)
394 && ctnetlink_dump_mark(skb, ct) < 0)
398 if (events & IPCT_COUNTER_FILLING &&
399 (ctnetlink_dump_counters(skb, ct, IP_CT_DIR_ORIGINAL) < 0 ||
400 ctnetlink_dump_counters(skb, ct, IP_CT_DIR_REPLY) < 0))
404 nlh->nlmsg_len = skb->tail - b;
405 nfnetlink_send(skb, 0, group, 0);
413 #endif /* CONFIG_NF_CONNTRACK_EVENTS */
415 static int ctnetlink_done(struct netlink_callback *cb)
418 nf_ct_put((struct nf_conn *)cb->args[1]);
422 #define L3PROTO(ct) ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num
425 ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
427 struct nf_conn *ct, *last;
428 struct nf_conntrack_tuple_hash *h;
430 struct nfgenmsg *nfmsg = NLMSG_DATA(cb->nlh);
431 u_int8_t l3proto = nfmsg->nfgen_family;
433 read_lock_bh(&nf_conntrack_lock);
434 last = (struct nf_conn *)cb->args[1];
435 for (; cb->args[0] < nf_conntrack_htable_size; cb->args[0]++) {
437 list_for_each_prev(i, &nf_conntrack_hash[cb->args[0]]) {
438 h = (struct nf_conntrack_tuple_hash *) i;
439 if (NF_CT_DIRECTION(h) != IP_CT_DIR_ORIGINAL)
441 ct = nf_ct_tuplehash_to_ctrack(h);
442 /* Dump entries of a given L3 protocol number.
443 * If it is not specified, ie. l3proto == 0,
444 * then dump everything. */
445 if (l3proto && L3PROTO(ct) != l3proto)
452 if (ctnetlink_fill_info(skb, NETLINK_CB(cb->skb).pid,
456 nf_conntrack_get(&ct->ct_general);
457 cb->args[1] = (unsigned long)ct;
460 #ifdef CONFIG_NF_CT_ACCT
461 if (NFNL_MSG_TYPE(cb->nlh->nlmsg_type) ==
462 IPCTNL_MSG_CT_GET_CTRZERO)
463 memset(&ct->counters, 0, sizeof(ct->counters));
472 read_unlock_bh(&nf_conntrack_lock);
480 ctnetlink_parse_tuple_ip(struct nfattr *attr, struct nf_conntrack_tuple *tuple)
482 struct nfattr *tb[CTA_IP_MAX];
483 struct nf_conntrack_l3proto *l3proto;
486 nfattr_parse_nested(tb, CTA_IP_MAX, attr);
488 l3proto = nf_ct_l3proto_find_get(tuple->src.l3num);
490 if (likely(l3proto->nfattr_to_tuple))
491 ret = l3proto->nfattr_to_tuple(tb, tuple);
493 nf_ct_l3proto_put(l3proto);
498 static const size_t cta_min_proto[CTA_PROTO_MAX] = {
499 [CTA_PROTO_NUM-1] = sizeof(u_int8_t),
503 ctnetlink_parse_tuple_proto(struct nfattr *attr,
504 struct nf_conntrack_tuple *tuple)
506 struct nfattr *tb[CTA_PROTO_MAX];
507 struct nf_conntrack_l4proto *l4proto;
510 nfattr_parse_nested(tb, CTA_PROTO_MAX, attr);
512 if (nfattr_bad_size(tb, CTA_PROTO_MAX, cta_min_proto))
515 if (!tb[CTA_PROTO_NUM-1])
517 tuple->dst.protonum = *(u_int8_t *)NFA_DATA(tb[CTA_PROTO_NUM-1]);
519 l4proto = nf_ct_l4proto_find_get(tuple->src.l3num, tuple->dst.protonum);
521 if (likely(l4proto->nfattr_to_tuple))
522 ret = l4proto->nfattr_to_tuple(tb, tuple);
524 nf_ct_l4proto_put(l4proto);
530 ctnetlink_parse_tuple(struct nfattr *cda[], struct nf_conntrack_tuple *tuple,
531 enum ctattr_tuple type, u_int8_t l3num)
533 struct nfattr *tb[CTA_TUPLE_MAX];
536 memset(tuple, 0, sizeof(*tuple));
538 nfattr_parse_nested(tb, CTA_TUPLE_MAX, cda[type-1]);
540 if (!tb[CTA_TUPLE_IP-1])
543 tuple->src.l3num = l3num;
545 err = ctnetlink_parse_tuple_ip(tb[CTA_TUPLE_IP-1], tuple);
549 if (!tb[CTA_TUPLE_PROTO-1])
552 err = ctnetlink_parse_tuple_proto(tb[CTA_TUPLE_PROTO-1], tuple);
556 /* orig and expect tuples get DIR_ORIGINAL */
557 if (type == CTA_TUPLE_REPLY)
558 tuple->dst.dir = IP_CT_DIR_REPLY;
560 tuple->dst.dir = IP_CT_DIR_ORIGINAL;
565 #ifdef CONFIG_NF_NAT_NEEDED
566 static const size_t cta_min_protonat[CTA_PROTONAT_MAX] = {
567 [CTA_PROTONAT_PORT_MIN-1] = sizeof(u_int16_t),
568 [CTA_PROTONAT_PORT_MAX-1] = sizeof(u_int16_t),
571 static int nfnetlink_parse_nat_proto(struct nfattr *attr,
572 const struct nf_conn *ct,
573 struct nf_nat_range *range)
575 struct nfattr *tb[CTA_PROTONAT_MAX];
576 struct nf_nat_protocol *npt;
578 nfattr_parse_nested(tb, CTA_PROTONAT_MAX, attr);
580 if (nfattr_bad_size(tb, CTA_PROTONAT_MAX, cta_min_protonat))
583 npt = nf_nat_proto_find_get(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum);
585 if (!npt->nfattr_to_range) {
586 nf_nat_proto_put(npt);
590 /* nfattr_to_range returns 1 if it parsed, 0 if not, neg. on error */
591 if (npt->nfattr_to_range(tb, range) > 0)
592 range->flags |= IP_NAT_RANGE_PROTO_SPECIFIED;
594 nf_nat_proto_put(npt);
599 static const size_t cta_min_nat[CTA_NAT_MAX] = {
600 [CTA_NAT_MINIP-1] = sizeof(u_int32_t),
601 [CTA_NAT_MAXIP-1] = sizeof(u_int32_t),
605 nfnetlink_parse_nat(struct nfattr *nat,
606 const struct nf_conn *ct, struct nf_nat_range *range)
608 struct nfattr *tb[CTA_NAT_MAX];
611 memset(range, 0, sizeof(*range));
613 nfattr_parse_nested(tb, CTA_NAT_MAX, nat);
615 if (nfattr_bad_size(tb, CTA_NAT_MAX, cta_min_nat))
618 if (tb[CTA_NAT_MINIP-1])
619 range->min_ip = *(__be32 *)NFA_DATA(tb[CTA_NAT_MINIP-1]);
621 if (!tb[CTA_NAT_MAXIP-1])
622 range->max_ip = range->min_ip;
624 range->max_ip = *(__be32 *)NFA_DATA(tb[CTA_NAT_MAXIP-1]);
627 range->flags |= IP_NAT_RANGE_MAP_IPS;
629 if (!tb[CTA_NAT_PROTO-1])
632 err = nfnetlink_parse_nat_proto(tb[CTA_NAT_PROTO-1], ct, range);
641 ctnetlink_parse_help(struct nfattr *attr, char **helper_name)
643 struct nfattr *tb[CTA_HELP_MAX];
645 nfattr_parse_nested(tb, CTA_HELP_MAX, attr);
647 if (!tb[CTA_HELP_NAME-1])
650 *helper_name = NFA_DATA(tb[CTA_HELP_NAME-1]);
655 static const size_t cta_min[CTA_MAX] = {
656 [CTA_STATUS-1] = sizeof(u_int32_t),
657 [CTA_TIMEOUT-1] = sizeof(u_int32_t),
658 [CTA_MARK-1] = sizeof(u_int32_t),
659 [CTA_USE-1] = sizeof(u_int32_t),
660 [CTA_ID-1] = sizeof(u_int32_t)
664 ctnetlink_del_conntrack(struct sock *ctnl, struct sk_buff *skb,
665 struct nlmsghdr *nlh, struct nfattr *cda[], int *errp)
667 struct nf_conntrack_tuple_hash *h;
668 struct nf_conntrack_tuple tuple;
670 struct nfgenmsg *nfmsg = NLMSG_DATA(nlh);
671 u_int8_t u3 = nfmsg->nfgen_family;
674 if (nfattr_bad_size(cda, CTA_MAX, cta_min))
677 if (cda[CTA_TUPLE_ORIG-1])
678 err = ctnetlink_parse_tuple(cda, &tuple, CTA_TUPLE_ORIG, u3);
679 else if (cda[CTA_TUPLE_REPLY-1])
680 err = ctnetlink_parse_tuple(cda, &tuple, CTA_TUPLE_REPLY, u3);
682 /* Flush the whole table */
683 nf_conntrack_flush();
690 h = nf_conntrack_find_get(&tuple, NULL);
694 ct = nf_ct_tuplehash_to_ctrack(h);
697 u_int32_t id = ntohl(*(__be32 *)NFA_DATA(cda[CTA_ID-1]));
703 if (del_timer(&ct->timeout))
704 ct->timeout.function((unsigned long)ct);
712 ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb,
713 struct nlmsghdr *nlh, struct nfattr *cda[], int *errp)
715 struct nf_conntrack_tuple_hash *h;
716 struct nf_conntrack_tuple tuple;
718 struct sk_buff *skb2 = NULL;
719 struct nfgenmsg *nfmsg = NLMSG_DATA(nlh);
720 u_int8_t u3 = nfmsg->nfgen_family;
723 if (nlh->nlmsg_flags & NLM_F_DUMP) {
726 #ifndef CONFIG_NF_CT_ACCT
727 if (NFNL_MSG_TYPE(nlh->nlmsg_type) == IPCTNL_MSG_CT_GET_CTRZERO)
730 if ((*errp = netlink_dump_start(ctnl, skb, nlh,
731 ctnetlink_dump_table,
732 ctnetlink_done)) != 0)
735 rlen = NLMSG_ALIGN(nlh->nlmsg_len);
742 if (nfattr_bad_size(cda, CTA_MAX, cta_min))
745 if (cda[CTA_TUPLE_ORIG-1])
746 err = ctnetlink_parse_tuple(cda, &tuple, CTA_TUPLE_ORIG, u3);
747 else if (cda[CTA_TUPLE_REPLY-1])
748 err = ctnetlink_parse_tuple(cda, &tuple, CTA_TUPLE_REPLY, u3);
755 h = nf_conntrack_find_get(&tuple, NULL);
759 ct = nf_ct_tuplehash_to_ctrack(h);
762 skb2 = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
768 err = ctnetlink_fill_info(skb2, NETLINK_CB(skb).pid, nlh->nlmsg_seq,
769 IPCTNL_MSG_CT_NEW, 1, ct);
774 err = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT);
787 ctnetlink_change_status(struct nf_conn *ct, struct nfattr *cda[])
790 unsigned int status = ntohl(*(__be32 *)NFA_DATA(cda[CTA_STATUS-1]));
791 d = ct->status ^ status;
793 if (d & (IPS_EXPECTED|IPS_CONFIRMED|IPS_DYING))
797 if (d & IPS_SEEN_REPLY && !(status & IPS_SEEN_REPLY))
798 /* SEEN_REPLY bit can only be set */
802 if (d & IPS_ASSURED && !(status & IPS_ASSURED))
803 /* ASSURED bit can only be set */
806 if (cda[CTA_NAT_SRC-1] || cda[CTA_NAT_DST-1]) {
807 #ifndef CONFIG_NF_NAT_NEEDED
810 struct nf_nat_range range;
812 if (cda[CTA_NAT_DST-1]) {
813 if (nfnetlink_parse_nat(cda[CTA_NAT_DST-1], ct,
816 if (nf_nat_initialized(ct,
817 HOOK2MANIP(NF_IP_PRE_ROUTING)))
819 nf_nat_setup_info(ct, &range, NF_IP_PRE_ROUTING);
821 if (cda[CTA_NAT_SRC-1]) {
822 if (nfnetlink_parse_nat(cda[CTA_NAT_SRC-1], ct,
825 if (nf_nat_initialized(ct,
826 HOOK2MANIP(NF_IP_POST_ROUTING)))
828 nf_nat_setup_info(ct, &range, NF_IP_POST_ROUTING);
833 /* Be careful here, modifying NAT bits can screw up things,
834 * so don't let users modify them directly if they don't pass
836 ct->status |= status & ~(IPS_NAT_DONE_MASK | IPS_NAT_MASK);
842 ctnetlink_change_helper(struct nf_conn *ct, struct nfattr *cda[])
844 struct nf_conntrack_helper *helper;
845 struct nf_conn_help *help = nfct_help(ct);
850 /* FIXME: we need to reallocate and rehash */
854 /* don't change helper of sibling connections */
858 err = ctnetlink_parse_help(cda[CTA_HELP-1], &helpname);
862 helper = __nf_conntrack_helper_find_byname(helpname);
864 if (!strcmp(helpname, ""))
872 /* we had a helper before ... */
873 nf_ct_remove_expectations(ct);
876 /* need to zero data of old helper */
877 memset(&help->help, 0, sizeof(help->help));
881 help->helper = helper;
887 ctnetlink_change_timeout(struct nf_conn *ct, struct nfattr *cda[])
889 u_int32_t timeout = ntohl(*(__be32 *)NFA_DATA(cda[CTA_TIMEOUT-1]));
891 if (!del_timer(&ct->timeout))
894 ct->timeout.expires = jiffies + timeout * HZ;
895 add_timer(&ct->timeout);
901 ctnetlink_change_protoinfo(struct nf_conn *ct, struct nfattr *cda[])
903 struct nfattr *tb[CTA_PROTOINFO_MAX], *attr = cda[CTA_PROTOINFO-1];
904 struct nf_conntrack_l4proto *l4proto;
905 u_int16_t npt = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum;
906 u_int16_t l3num = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num;
909 nfattr_parse_nested(tb, CTA_PROTOINFO_MAX, attr);
911 l4proto = nf_ct_l4proto_find_get(l3num, npt);
913 if (l4proto->from_nfattr)
914 err = l4proto->from_nfattr(tb, ct);
915 nf_ct_l4proto_put(l4proto);
921 ctnetlink_change_conntrack(struct nf_conn *ct, struct nfattr *cda[])
925 if (cda[CTA_HELP-1]) {
926 err = ctnetlink_change_helper(ct, cda);
931 if (cda[CTA_TIMEOUT-1]) {
932 err = ctnetlink_change_timeout(ct, cda);
937 if (cda[CTA_STATUS-1]) {
938 err = ctnetlink_change_status(ct, cda);
943 if (cda[CTA_PROTOINFO-1]) {
944 err = ctnetlink_change_protoinfo(ct, cda);
949 #if defined(CONFIG_NF_CONNTRACK_MARK)
951 ct->mark = ntohl(*(__be32 *)NFA_DATA(cda[CTA_MARK-1]));
958 ctnetlink_create_conntrack(struct nfattr *cda[],
959 struct nf_conntrack_tuple *otuple,
960 struct nf_conntrack_tuple *rtuple)
964 struct nf_conn_help *help;
966 ct = nf_conntrack_alloc(otuple, rtuple);
967 if (ct == NULL || IS_ERR(ct))
970 if (!cda[CTA_TIMEOUT-1])
972 ct->timeout.expires = ntohl(*(__be32 *)NFA_DATA(cda[CTA_TIMEOUT-1]));
974 ct->timeout.expires = jiffies + ct->timeout.expires * HZ;
975 ct->status |= IPS_CONFIRMED;
977 if (cda[CTA_STATUS-1]) {
978 err = ctnetlink_change_status(ct, cda);
983 if (cda[CTA_PROTOINFO-1]) {
984 err = ctnetlink_change_protoinfo(ct, cda);
989 #if defined(CONFIG_NF_CONNTRACK_MARK)
991 ct->mark = ntohl(*(__be32 *)NFA_DATA(cda[CTA_MARK-1]));
994 help = nfct_help(ct);
996 help->helper = nf_ct_helper_find_get(rtuple);
998 add_timer(&ct->timeout);
999 nf_conntrack_hash_insert(ct);
1001 if (help && help->helper)
1002 nf_ct_helper_put(help->helper);
1007 nf_conntrack_free(ct);
1012 ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
1013 struct nlmsghdr *nlh, struct nfattr *cda[], int *errp)
1015 struct nf_conntrack_tuple otuple, rtuple;
1016 struct nf_conntrack_tuple_hash *h = NULL;
1017 struct nfgenmsg *nfmsg = NLMSG_DATA(nlh);
1018 u_int8_t u3 = nfmsg->nfgen_family;
1021 if (nfattr_bad_size(cda, CTA_MAX, cta_min))
1024 if (cda[CTA_TUPLE_ORIG-1]) {
1025 err = ctnetlink_parse_tuple(cda, &otuple, CTA_TUPLE_ORIG, u3);
1030 if (cda[CTA_TUPLE_REPLY-1]) {
1031 err = ctnetlink_parse_tuple(cda, &rtuple, CTA_TUPLE_REPLY, u3);
1036 write_lock_bh(&nf_conntrack_lock);
1037 if (cda[CTA_TUPLE_ORIG-1])
1038 h = __nf_conntrack_find(&otuple, NULL);
1039 else if (cda[CTA_TUPLE_REPLY-1])
1040 h = __nf_conntrack_find(&rtuple, NULL);
1043 write_unlock_bh(&nf_conntrack_lock);
1045 if (nlh->nlmsg_flags & NLM_F_CREATE)
1046 err = ctnetlink_create_conntrack(cda, &otuple, &rtuple);
1049 /* implicit 'else' */
1051 /* we only allow nat config for new conntracks */
1052 if (cda[CTA_NAT_SRC-1] || cda[CTA_NAT_DST-1]) {
1057 /* We manipulate the conntrack inside the global conntrack table lock,
1058 * so there's no need to increase the refcount */
1060 if (!(nlh->nlmsg_flags & NLM_F_EXCL))
1061 err = ctnetlink_change_conntrack(nf_ct_tuplehash_to_ctrack(h), cda);
1064 write_unlock_bh(&nf_conntrack_lock);
1068 /***********************************************************************
1070 ***********************************************************************/
1073 ctnetlink_exp_dump_tuple(struct sk_buff *skb,
1074 const struct nf_conntrack_tuple *tuple,
1075 enum ctattr_expect type)
1077 struct nfattr *nest_parms = NFA_NEST(skb, type);
1079 if (ctnetlink_dump_tuples(skb, tuple) < 0)
1080 goto nfattr_failure;
1082 NFA_NEST_END(skb, nest_parms);
1091 ctnetlink_exp_dump_mask(struct sk_buff *skb,
1092 const struct nf_conntrack_tuple *tuple,
1093 const struct nf_conntrack_tuple *mask)
1096 struct nf_conntrack_l3proto *l3proto;
1097 struct nf_conntrack_l4proto *l4proto;
1098 struct nfattr *nest_parms = NFA_NEST(skb, CTA_EXPECT_MASK);
1100 l3proto = nf_ct_l3proto_find_get(tuple->src.l3num);
1101 ret = ctnetlink_dump_tuples_ip(skb, mask, l3proto);
1102 nf_ct_l3proto_put(l3proto);
1104 if (unlikely(ret < 0))
1105 goto nfattr_failure;
1107 l4proto = nf_ct_l4proto_find_get(tuple->src.l3num, tuple->dst.protonum);
1108 ret = ctnetlink_dump_tuples_proto(skb, mask, l4proto);
1109 nf_ct_l4proto_put(l4proto);
1110 if (unlikely(ret < 0))
1111 goto nfattr_failure;
1113 NFA_NEST_END(skb, nest_parms);
1122 ctnetlink_exp_dump_expect(struct sk_buff *skb,
1123 const struct nf_conntrack_expect *exp)
1125 struct nf_conn *master = exp->master;
1126 __be32 timeout = htonl((exp->timeout.expires - jiffies) / HZ);
1127 __be32 id = htonl(exp->id);
1129 if (ctnetlink_exp_dump_tuple(skb, &exp->tuple, CTA_EXPECT_TUPLE) < 0)
1130 goto nfattr_failure;
1131 if (ctnetlink_exp_dump_mask(skb, &exp->tuple, &exp->mask) < 0)
1132 goto nfattr_failure;
1133 if (ctnetlink_exp_dump_tuple(skb,
1134 &master->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
1135 CTA_EXPECT_MASTER) < 0)
1136 goto nfattr_failure;
1138 NFA_PUT(skb, CTA_EXPECT_TIMEOUT, sizeof(timeout), &timeout);
1139 NFA_PUT(skb, CTA_EXPECT_ID, sizeof(u_int32_t), &id);
1148 ctnetlink_exp_fill_info(struct sk_buff *skb, u32 pid, u32 seq,
1151 const struct nf_conntrack_expect *exp)
1153 struct nlmsghdr *nlh;
1154 struct nfgenmsg *nfmsg;
1159 event |= NFNL_SUBSYS_CTNETLINK_EXP << 8;
1160 nlh = NLMSG_PUT(skb, pid, seq, event, sizeof(struct nfgenmsg));
1161 nfmsg = NLMSG_DATA(nlh);
1163 nlh->nlmsg_flags = (nowait && pid) ? NLM_F_MULTI : 0;
1164 nfmsg->nfgen_family = exp->tuple.src.l3num;
1165 nfmsg->version = NFNETLINK_V0;
1168 if (ctnetlink_exp_dump_expect(skb, exp) < 0)
1169 goto nfattr_failure;
1171 nlh->nlmsg_len = skb->tail - b;
1176 skb_trim(skb, b - skb->data);
1180 #ifdef CONFIG_NF_CONNTRACK_EVENTS
1181 static int ctnetlink_expect_event(struct notifier_block *this,
1182 unsigned long events, void *ptr)
1184 struct nlmsghdr *nlh;
1185 struct nfgenmsg *nfmsg;
1186 struct nf_conntrack_expect *exp = (struct nf_conntrack_expect *)ptr;
1187 struct sk_buff *skb;
1192 if (events & IPEXP_NEW) {
1193 type = IPCTNL_MSG_EXP_NEW;
1194 flags = NLM_F_CREATE|NLM_F_EXCL;
1198 if (!nfnetlink_has_listeners(NFNLGRP_CONNTRACK_EXP_NEW))
1201 skb = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC);
1207 type |= NFNL_SUBSYS_CTNETLINK_EXP << 8;
1208 nlh = NLMSG_PUT(skb, 0, 0, type, sizeof(struct nfgenmsg));
1209 nfmsg = NLMSG_DATA(nlh);
1211 nlh->nlmsg_flags = flags;
1212 nfmsg->nfgen_family = exp->tuple.src.l3num;
1213 nfmsg->version = NFNETLINK_V0;
1216 if (ctnetlink_exp_dump_expect(skb, exp) < 0)
1217 goto nfattr_failure;
1219 nlh->nlmsg_len = skb->tail - b;
1220 nfnetlink_send(skb, 0, NFNLGRP_CONNTRACK_EXP_NEW, 0);
1231 ctnetlink_exp_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
1233 struct nf_conntrack_expect *exp = NULL;
1234 struct list_head *i;
1235 u_int32_t *id = (u_int32_t *) &cb->args[0];
1236 struct nfgenmsg *nfmsg = NLMSG_DATA(cb->nlh);
1237 u_int8_t l3proto = nfmsg->nfgen_family;
1239 read_lock_bh(&nf_conntrack_lock);
1240 list_for_each_prev(i, &nf_conntrack_expect_list) {
1241 exp = (struct nf_conntrack_expect *) i;
1242 if (l3proto && exp->tuple.src.l3num != l3proto)
1246 if (ctnetlink_exp_fill_info(skb, NETLINK_CB(cb->skb).pid,
1254 read_unlock_bh(&nf_conntrack_lock);
1259 static const size_t cta_min_exp[CTA_EXPECT_MAX] = {
1260 [CTA_EXPECT_TIMEOUT-1] = sizeof(u_int32_t),
1261 [CTA_EXPECT_ID-1] = sizeof(u_int32_t)
1265 ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
1266 struct nlmsghdr *nlh, struct nfattr *cda[], int *errp)
1268 struct nf_conntrack_tuple tuple;
1269 struct nf_conntrack_expect *exp;
1270 struct sk_buff *skb2;
1271 struct nfgenmsg *nfmsg = NLMSG_DATA(nlh);
1272 u_int8_t u3 = nfmsg->nfgen_family;
1275 if (nfattr_bad_size(cda, CTA_EXPECT_MAX, cta_min_exp))
1278 if (nlh->nlmsg_flags & NLM_F_DUMP) {
1281 if ((*errp = netlink_dump_start(ctnl, skb, nlh,
1282 ctnetlink_exp_dump_table,
1283 ctnetlink_done)) != 0)
1285 rlen = NLMSG_ALIGN(nlh->nlmsg_len);
1286 if (rlen > skb->len)
1288 skb_pull(skb, rlen);
1292 if (cda[CTA_EXPECT_MASTER-1])
1293 err = ctnetlink_parse_tuple(cda, &tuple, CTA_EXPECT_MASTER, u3);
1300 exp = nf_conntrack_expect_find_get(&tuple);
1304 if (cda[CTA_EXPECT_ID-1]) {
1305 __be32 id = *(__be32 *)NFA_DATA(cda[CTA_EXPECT_ID-1]);
1306 if (exp->id != ntohl(id)) {
1307 nf_conntrack_expect_put(exp);
1313 skb2 = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
1317 err = ctnetlink_exp_fill_info(skb2, NETLINK_CB(skb).pid,
1318 nlh->nlmsg_seq, IPCTNL_MSG_EXP_NEW,
1323 nf_conntrack_expect_put(exp);
1325 return netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT);
1330 nf_conntrack_expect_put(exp);
1335 ctnetlink_del_expect(struct sock *ctnl, struct sk_buff *skb,
1336 struct nlmsghdr *nlh, struct nfattr *cda[], int *errp)
1338 struct nf_conntrack_expect *exp, *tmp;
1339 struct nf_conntrack_tuple tuple;
1340 struct nf_conntrack_helper *h;
1341 struct nfgenmsg *nfmsg = NLMSG_DATA(nlh);
1342 u_int8_t u3 = nfmsg->nfgen_family;
1345 if (nfattr_bad_size(cda, CTA_EXPECT_MAX, cta_min_exp))
1348 if (cda[CTA_EXPECT_TUPLE-1]) {
1349 /* delete a single expect by tuple */
1350 err = ctnetlink_parse_tuple(cda, &tuple, CTA_EXPECT_TUPLE, u3);
1354 /* bump usage count to 2 */
1355 exp = nf_conntrack_expect_find_get(&tuple);
1359 if (cda[CTA_EXPECT_ID-1]) {
1360 __be32 id = *(__be32 *)NFA_DATA(cda[CTA_EXPECT_ID-1]);
1361 if (exp->id != ntohl(id)) {
1362 nf_conntrack_expect_put(exp);
1367 /* after list removal, usage count == 1 */
1368 nf_conntrack_unexpect_related(exp);
1369 /* have to put what we 'get' above.
1370 * after this line usage count == 0 */
1371 nf_conntrack_expect_put(exp);
1372 } else if (cda[CTA_EXPECT_HELP_NAME-1]) {
1373 char *name = NFA_DATA(cda[CTA_EXPECT_HELP_NAME-1]);
1375 /* delete all expectations for this helper */
1376 write_lock_bh(&nf_conntrack_lock);
1377 h = __nf_conntrack_helper_find_byname(name);
1379 write_unlock_bh(&nf_conntrack_lock);
1382 list_for_each_entry_safe(exp, tmp, &nf_conntrack_expect_list,
1384 struct nf_conn_help *m_help = nfct_help(exp->master);
1385 if (m_help->helper == h
1386 && del_timer(&exp->timeout)) {
1387 nf_ct_unlink_expect(exp);
1388 nf_conntrack_expect_put(exp);
1391 write_unlock_bh(&nf_conntrack_lock);
1393 /* This basically means we have to flush everything*/
1394 write_lock_bh(&nf_conntrack_lock);
1395 list_for_each_entry_safe(exp, tmp, &nf_conntrack_expect_list,
1397 if (del_timer(&exp->timeout)) {
1398 nf_ct_unlink_expect(exp);
1399 nf_conntrack_expect_put(exp);
1402 write_unlock_bh(&nf_conntrack_lock);
1408 ctnetlink_change_expect(struct nf_conntrack_expect *x, struct nfattr *cda[])
1414 ctnetlink_create_expect(struct nfattr *cda[], u_int8_t u3)
1416 struct nf_conntrack_tuple tuple, mask, master_tuple;
1417 struct nf_conntrack_tuple_hash *h = NULL;
1418 struct nf_conntrack_expect *exp;
1420 struct nf_conn_help *help;
1423 /* caller guarantees that those three CTA_EXPECT_* exist */
1424 err = ctnetlink_parse_tuple(cda, &tuple, CTA_EXPECT_TUPLE, u3);
1427 err = ctnetlink_parse_tuple(cda, &mask, CTA_EXPECT_MASK, u3);
1430 err = ctnetlink_parse_tuple(cda, &master_tuple, CTA_EXPECT_MASTER, u3);
1434 /* Look for master conntrack of this expectation */
1435 h = nf_conntrack_find_get(&master_tuple, NULL);
1438 ct = nf_ct_tuplehash_to_ctrack(h);
1439 help = nfct_help(ct);
1441 if (!help || !help->helper) {
1442 /* such conntrack hasn't got any helper, abort */
1447 exp = nf_conntrack_expect_alloc(ct);
1453 exp->expectfn = NULL;
1457 memcpy(&exp->tuple, &tuple, sizeof(struct nf_conntrack_tuple));
1458 memcpy(&exp->mask, &mask, sizeof(struct nf_conntrack_tuple));
1460 err = nf_conntrack_expect_related(exp);
1461 nf_conntrack_expect_put(exp);
1464 nf_ct_put(nf_ct_tuplehash_to_ctrack(h));
1469 ctnetlink_new_expect(struct sock *ctnl, struct sk_buff *skb,
1470 struct nlmsghdr *nlh, struct nfattr *cda[], int *errp)
1472 struct nf_conntrack_tuple tuple;
1473 struct nf_conntrack_expect *exp;
1474 struct nfgenmsg *nfmsg = NLMSG_DATA(nlh);
1475 u_int8_t u3 = nfmsg->nfgen_family;
1478 if (nfattr_bad_size(cda, CTA_EXPECT_MAX, cta_min_exp))
1481 if (!cda[CTA_EXPECT_TUPLE-1]
1482 || !cda[CTA_EXPECT_MASK-1]
1483 || !cda[CTA_EXPECT_MASTER-1])
1486 err = ctnetlink_parse_tuple(cda, &tuple, CTA_EXPECT_TUPLE, u3);
1490 write_lock_bh(&nf_conntrack_lock);
1491 exp = __nf_conntrack_expect_find(&tuple);
1494 write_unlock_bh(&nf_conntrack_lock);
1496 if (nlh->nlmsg_flags & NLM_F_CREATE)
1497 err = ctnetlink_create_expect(cda, u3);
1502 if (!(nlh->nlmsg_flags & NLM_F_EXCL))
1503 err = ctnetlink_change_expect(exp, cda);
1504 write_unlock_bh(&nf_conntrack_lock);
1509 #ifdef CONFIG_NF_CONNTRACK_EVENTS
1510 static struct notifier_block ctnl_notifier = {
1511 .notifier_call = ctnetlink_conntrack_event,
1514 static struct notifier_block ctnl_notifier_exp = {
1515 .notifier_call = ctnetlink_expect_event,
1519 static struct nfnl_callback ctnl_cb[IPCTNL_MSG_MAX] = {
1520 [IPCTNL_MSG_CT_NEW] = { .call = ctnetlink_new_conntrack,
1521 .attr_count = CTA_MAX, },
1522 [IPCTNL_MSG_CT_GET] = { .call = ctnetlink_get_conntrack,
1523 .attr_count = CTA_MAX, },
1524 [IPCTNL_MSG_CT_DELETE] = { .call = ctnetlink_del_conntrack,
1525 .attr_count = CTA_MAX, },
1526 [IPCTNL_MSG_CT_GET_CTRZERO] = { .call = ctnetlink_get_conntrack,
1527 .attr_count = CTA_MAX, },
1530 static struct nfnl_callback ctnl_exp_cb[IPCTNL_MSG_EXP_MAX] = {
1531 [IPCTNL_MSG_EXP_GET] = { .call = ctnetlink_get_expect,
1532 .attr_count = CTA_EXPECT_MAX, },
1533 [IPCTNL_MSG_EXP_NEW] = { .call = ctnetlink_new_expect,
1534 .attr_count = CTA_EXPECT_MAX, },
1535 [IPCTNL_MSG_EXP_DELETE] = { .call = ctnetlink_del_expect,
1536 .attr_count = CTA_EXPECT_MAX, },
1539 static struct nfnetlink_subsystem ctnl_subsys = {
1540 .name = "conntrack",
1541 .subsys_id = NFNL_SUBSYS_CTNETLINK,
1542 .cb_count = IPCTNL_MSG_MAX,
1546 static struct nfnetlink_subsystem ctnl_exp_subsys = {
1547 .name = "conntrack_expect",
1548 .subsys_id = NFNL_SUBSYS_CTNETLINK_EXP,
1549 .cb_count = IPCTNL_MSG_EXP_MAX,
1553 MODULE_ALIAS("ip_conntrack_netlink");
1554 MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_CTNETLINK);
1555 MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_CTNETLINK_EXP);
1557 static int __init ctnetlink_init(void)
1561 printk("ctnetlink v%s: registering with nfnetlink.\n", version);
1562 ret = nfnetlink_subsys_register(&ctnl_subsys);
1564 printk("ctnetlink_init: cannot register with nfnetlink.\n");
1568 ret = nfnetlink_subsys_register(&ctnl_exp_subsys);
1570 printk("ctnetlink_init: cannot register exp with nfnetlink.\n");
1571 goto err_unreg_subsys;
1574 #ifdef CONFIG_NF_CONNTRACK_EVENTS
1575 ret = nf_conntrack_register_notifier(&ctnl_notifier);
1577 printk("ctnetlink_init: cannot register notifier.\n");
1578 goto err_unreg_exp_subsys;
1581 ret = nf_conntrack_expect_register_notifier(&ctnl_notifier_exp);
1583 printk("ctnetlink_init: cannot expect register notifier.\n");
1584 goto err_unreg_notifier;
1590 #ifdef CONFIG_NF_CONNTRACK_EVENTS
1592 nf_conntrack_unregister_notifier(&ctnl_notifier);
1593 err_unreg_exp_subsys:
1594 nfnetlink_subsys_unregister(&ctnl_exp_subsys);
1597 nfnetlink_subsys_unregister(&ctnl_subsys);
1602 static void __exit ctnetlink_exit(void)
1604 printk("ctnetlink: unregistering from nfnetlink.\n");
1606 #ifdef CONFIG_NF_CONNTRACK_EVENTS
1607 nf_conntrack_expect_unregister_notifier(&ctnl_notifier_exp);
1608 nf_conntrack_unregister_notifier(&ctnl_notifier);
1611 nfnetlink_subsys_unregister(&ctnl_exp_subsys);
1612 nfnetlink_subsys_unregister(&ctnl_subsys);
1616 module_init(ctnetlink_init);
1617 module_exit(ctnetlink_exit);