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/netlink.h>
37 #include <net/netfilter/nf_conntrack.h>
38 #include <net/netfilter/nf_conntrack_core.h>
39 #include <net/netfilter/nf_conntrack_expect.h>
40 #include <net/netfilter/nf_conntrack_helper.h>
41 #include <net/netfilter/nf_conntrack_l3proto.h>
42 #include <net/netfilter/nf_conntrack_l4proto.h>
43 #include <net/netfilter/nf_conntrack_tuple.h>
44 #ifdef CONFIG_NF_NAT_NEEDED
45 #include <net/netfilter/nf_nat_core.h>
46 #include <net/netfilter/nf_nat_protocol.h>
49 #include <linux/netfilter/nfnetlink.h>
50 #include <linux/netfilter/nfnetlink_conntrack.h>
52 MODULE_LICENSE("GPL");
54 static char __initdata version[] = "0.93";
57 ctnetlink_dump_tuples_proto(struct sk_buff *skb,
58 const struct nf_conntrack_tuple *tuple,
59 struct nf_conntrack_l4proto *l4proto)
62 struct nfattr *nest_parms = NFA_NEST(skb, CTA_TUPLE_PROTO);
64 NFA_PUT(skb, CTA_PROTO_NUM, sizeof(u_int8_t), &tuple->dst.protonum);
66 if (likely(l4proto->tuple_to_nfattr))
67 ret = l4proto->tuple_to_nfattr(skb, tuple);
69 NFA_NEST_END(skb, nest_parms);
78 ctnetlink_dump_tuples_ip(struct sk_buff *skb,
79 const struct nf_conntrack_tuple *tuple,
80 struct nf_conntrack_l3proto *l3proto)
83 struct nfattr *nest_parms = NFA_NEST(skb, CTA_TUPLE_IP);
85 if (likely(l3proto->tuple_to_nfattr))
86 ret = l3proto->tuple_to_nfattr(skb, tuple);
88 NFA_NEST_END(skb, nest_parms);
97 ctnetlink_dump_tuples(struct sk_buff *skb,
98 const struct nf_conntrack_tuple *tuple)
101 struct nf_conntrack_l3proto *l3proto;
102 struct nf_conntrack_l4proto *l4proto;
104 l3proto = nf_ct_l3proto_find_get(tuple->src.l3num);
105 ret = ctnetlink_dump_tuples_ip(skb, tuple, l3proto);
106 nf_ct_l3proto_put(l3proto);
108 if (unlikely(ret < 0))
111 l4proto = nf_ct_l4proto_find_get(tuple->src.l3num, tuple->dst.protonum);
112 ret = ctnetlink_dump_tuples_proto(skb, tuple, l4proto);
113 nf_ct_l4proto_put(l4proto);
119 ctnetlink_dump_status(struct sk_buff *skb, const struct nf_conn *ct)
121 __be32 status = htonl((u_int32_t) ct->status);
122 NFA_PUT(skb, CTA_STATUS, sizeof(status), &status);
130 ctnetlink_dump_timeout(struct sk_buff *skb, const struct nf_conn *ct)
132 long timeout_l = ct->timeout.expires - jiffies;
138 timeout = htonl(timeout_l / HZ);
140 NFA_PUT(skb, CTA_TIMEOUT, sizeof(timeout), &timeout);
148 ctnetlink_dump_protoinfo(struct sk_buff *skb, const struct nf_conn *ct)
150 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);
151 struct nfattr *nest_proto;
154 if (!l4proto->to_nfattr) {
155 nf_ct_l4proto_put(l4proto);
159 nest_proto = NFA_NEST(skb, CTA_PROTOINFO);
161 ret = l4proto->to_nfattr(skb, nest_proto, ct);
163 nf_ct_l4proto_put(l4proto);
165 NFA_NEST_END(skb, nest_proto);
170 nf_ct_l4proto_put(l4proto);
175 ctnetlink_dump_helpinfo(struct sk_buff *skb, const struct nf_conn *ct)
177 struct nfattr *nest_helper;
178 const struct nf_conn_help *help = nfct_help(ct);
180 if (!help || !help->helper)
183 nest_helper = NFA_NEST(skb, CTA_HELP);
184 NFA_PUT(skb, CTA_HELP_NAME, strlen(help->helper->name), help->helper->name);
186 if (help->helper->to_nfattr)
187 help->helper->to_nfattr(skb, ct);
189 NFA_NEST_END(skb, nest_helper);
197 #ifdef CONFIG_NF_CT_ACCT
199 ctnetlink_dump_counters(struct sk_buff *skb, const struct nf_conn *ct,
200 enum ip_conntrack_dir dir)
202 enum ctattr_type type = dir ? CTA_COUNTERS_REPLY: CTA_COUNTERS_ORIG;
203 struct nfattr *nest_count = NFA_NEST(skb, type);
206 tmp = htonl(ct->counters[dir].packets);
207 NFA_PUT(skb, CTA_COUNTERS32_PACKETS, sizeof(u_int32_t), &tmp);
209 tmp = htonl(ct->counters[dir].bytes);
210 NFA_PUT(skb, CTA_COUNTERS32_BYTES, sizeof(u_int32_t), &tmp);
212 NFA_NEST_END(skb, nest_count);
220 #define ctnetlink_dump_counters(a, b, c) (0)
223 #ifdef CONFIG_NF_CONNTRACK_MARK
225 ctnetlink_dump_mark(struct sk_buff *skb, const struct nf_conn *ct)
227 __be32 mark = htonl(ct->mark);
229 NFA_PUT(skb, CTA_MARK, sizeof(u_int32_t), &mark);
236 #define ctnetlink_dump_mark(a, b) (0)
240 ctnetlink_dump_id(struct sk_buff *skb, const struct nf_conn *ct)
242 __be32 id = htonl(ct->id);
243 NFA_PUT(skb, CTA_ID, sizeof(u_int32_t), &id);
251 ctnetlink_dump_use(struct sk_buff *skb, const struct nf_conn *ct)
253 __be32 use = htonl(atomic_read(&ct->ct_general.use));
255 NFA_PUT(skb, CTA_USE, sizeof(u_int32_t), &use);
262 #define tuple(ct, dir) (&(ct)->tuplehash[dir].tuple)
265 ctnetlink_fill_info(struct sk_buff *skb, u32 pid, u32 seq,
266 int event, int nowait,
267 const struct nf_conn *ct)
269 struct nlmsghdr *nlh;
270 struct nfgenmsg *nfmsg;
271 struct nfattr *nest_parms;
272 unsigned char *b = skb_tail_pointer(skb);
274 event |= NFNL_SUBSYS_CTNETLINK << 8;
275 nlh = NLMSG_PUT(skb, pid, seq, event, sizeof(struct nfgenmsg));
276 nfmsg = NLMSG_DATA(nlh);
278 nlh->nlmsg_flags = (nowait && pid) ? NLM_F_MULTI : 0;
279 nfmsg->nfgen_family =
280 ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num;
281 nfmsg->version = NFNETLINK_V0;
284 nest_parms = NFA_NEST(skb, CTA_TUPLE_ORIG);
285 if (ctnetlink_dump_tuples(skb, tuple(ct, IP_CT_DIR_ORIGINAL)) < 0)
287 NFA_NEST_END(skb, nest_parms);
289 nest_parms = NFA_NEST(skb, CTA_TUPLE_REPLY);
290 if (ctnetlink_dump_tuples(skb, tuple(ct, IP_CT_DIR_REPLY)) < 0)
292 NFA_NEST_END(skb, nest_parms);
294 if (ctnetlink_dump_status(skb, ct) < 0 ||
295 ctnetlink_dump_timeout(skb, ct) < 0 ||
296 ctnetlink_dump_counters(skb, ct, IP_CT_DIR_ORIGINAL) < 0 ||
297 ctnetlink_dump_counters(skb, ct, IP_CT_DIR_REPLY) < 0 ||
298 ctnetlink_dump_protoinfo(skb, ct) < 0 ||
299 ctnetlink_dump_helpinfo(skb, ct) < 0 ||
300 ctnetlink_dump_mark(skb, ct) < 0 ||
301 ctnetlink_dump_id(skb, ct) < 0 ||
302 ctnetlink_dump_use(skb, ct) < 0)
305 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
314 #ifdef CONFIG_NF_CONNTRACK_EVENTS
315 static int ctnetlink_conntrack_event(struct notifier_block *this,
316 unsigned long events, void *ptr)
318 struct nlmsghdr *nlh;
319 struct nfgenmsg *nfmsg;
320 struct nfattr *nest_parms;
321 struct nf_conn *ct = (struct nf_conn *)ptr;
325 unsigned int flags = 0, group;
327 /* ignore our fake conntrack entry */
328 if (ct == &nf_conntrack_untracked)
331 if (events & IPCT_DESTROY) {
332 type = IPCTNL_MSG_CT_DELETE;
333 group = NFNLGRP_CONNTRACK_DESTROY;
334 } else if (events & (IPCT_NEW | IPCT_RELATED)) {
335 type = IPCTNL_MSG_CT_NEW;
336 flags = NLM_F_CREATE|NLM_F_EXCL;
337 group = NFNLGRP_CONNTRACK_NEW;
338 } else if (events & (IPCT_STATUS | IPCT_PROTOINFO)) {
339 type = IPCTNL_MSG_CT_NEW;
340 group = NFNLGRP_CONNTRACK_UPDATE;
344 if (!nfnetlink_has_listeners(group))
347 skb = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC);
353 type |= NFNL_SUBSYS_CTNETLINK << 8;
354 nlh = NLMSG_PUT(skb, 0, 0, type, sizeof(struct nfgenmsg));
355 nfmsg = NLMSG_DATA(nlh);
357 nlh->nlmsg_flags = flags;
358 nfmsg->nfgen_family = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num;
359 nfmsg->version = NFNETLINK_V0;
362 nest_parms = NFA_NEST(skb, CTA_TUPLE_ORIG);
363 if (ctnetlink_dump_tuples(skb, tuple(ct, IP_CT_DIR_ORIGINAL)) < 0)
365 NFA_NEST_END(skb, nest_parms);
367 nest_parms = NFA_NEST(skb, CTA_TUPLE_REPLY);
368 if (ctnetlink_dump_tuples(skb, tuple(ct, IP_CT_DIR_REPLY)) < 0)
370 NFA_NEST_END(skb, nest_parms);
372 if (events & IPCT_DESTROY) {
373 if (ctnetlink_dump_counters(skb, ct, IP_CT_DIR_ORIGINAL) < 0 ||
374 ctnetlink_dump_counters(skb, ct, IP_CT_DIR_REPLY) < 0)
377 if (ctnetlink_dump_status(skb, ct) < 0)
380 if (ctnetlink_dump_timeout(skb, ct) < 0)
383 if (events & IPCT_PROTOINFO
384 && ctnetlink_dump_protoinfo(skb, ct) < 0)
387 if ((events & IPCT_HELPER || nfct_help(ct))
388 && ctnetlink_dump_helpinfo(skb, ct) < 0)
391 #ifdef CONFIG_NF_CONNTRACK_MARK
392 if ((events & IPCT_MARK || ct->mark)
393 && ctnetlink_dump_mark(skb, ct) < 0)
397 if (events & IPCT_COUNTER_FILLING &&
398 (ctnetlink_dump_counters(skb, ct, IP_CT_DIR_ORIGINAL) < 0 ||
399 ctnetlink_dump_counters(skb, ct, IP_CT_DIR_REPLY) < 0))
403 nlh->nlmsg_len = skb->tail - b;
404 nfnetlink_send(skb, 0, group, 0);
412 #endif /* CONFIG_NF_CONNTRACK_EVENTS */
414 static int ctnetlink_done(struct netlink_callback *cb)
417 nf_ct_put((struct nf_conn *)cb->args[1]);
421 #define L3PROTO(ct) ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num
424 ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
426 struct nf_conn *ct, *last;
427 struct nf_conntrack_tuple_hash *h;
429 struct nfgenmsg *nfmsg = NLMSG_DATA(cb->nlh);
430 u_int8_t l3proto = nfmsg->nfgen_family;
432 read_lock_bh(&nf_conntrack_lock);
433 last = (struct nf_conn *)cb->args[1];
434 for (; cb->args[0] < nf_conntrack_htable_size; cb->args[0]++) {
436 list_for_each_prev(i, &nf_conntrack_hash[cb->args[0]]) {
437 h = (struct nf_conntrack_tuple_hash *) i;
438 if (NF_CT_DIRECTION(h) != IP_CT_DIR_ORIGINAL)
440 ct = nf_ct_tuplehash_to_ctrack(h);
441 /* Dump entries of a given L3 protocol number.
442 * If it is not specified, ie. l3proto == 0,
443 * then dump everything. */
444 if (l3proto && L3PROTO(ct) != l3proto)
451 if (ctnetlink_fill_info(skb, NETLINK_CB(cb->skb).pid,
455 nf_conntrack_get(&ct->ct_general);
456 cb->args[1] = (unsigned long)ct;
459 #ifdef CONFIG_NF_CT_ACCT
460 if (NFNL_MSG_TYPE(cb->nlh->nlmsg_type) ==
461 IPCTNL_MSG_CT_GET_CTRZERO)
462 memset(&ct->counters, 0, sizeof(ct->counters));
471 read_unlock_bh(&nf_conntrack_lock);
479 ctnetlink_parse_tuple_ip(struct nfattr *attr, struct nf_conntrack_tuple *tuple)
481 struct nfattr *tb[CTA_IP_MAX];
482 struct nf_conntrack_l3proto *l3proto;
485 nfattr_parse_nested(tb, CTA_IP_MAX, attr);
487 l3proto = nf_ct_l3proto_find_get(tuple->src.l3num);
489 if (likely(l3proto->nfattr_to_tuple))
490 ret = l3proto->nfattr_to_tuple(tb, tuple);
492 nf_ct_l3proto_put(l3proto);
497 static const size_t cta_min_proto[CTA_PROTO_MAX] = {
498 [CTA_PROTO_NUM-1] = sizeof(u_int8_t),
502 ctnetlink_parse_tuple_proto(struct nfattr *attr,
503 struct nf_conntrack_tuple *tuple)
505 struct nfattr *tb[CTA_PROTO_MAX];
506 struct nf_conntrack_l4proto *l4proto;
509 nfattr_parse_nested(tb, CTA_PROTO_MAX, attr);
511 if (nfattr_bad_size(tb, CTA_PROTO_MAX, cta_min_proto))
514 if (!tb[CTA_PROTO_NUM-1])
516 tuple->dst.protonum = *(u_int8_t *)NFA_DATA(tb[CTA_PROTO_NUM-1]);
518 l4proto = nf_ct_l4proto_find_get(tuple->src.l3num, tuple->dst.protonum);
520 if (likely(l4proto->nfattr_to_tuple))
521 ret = l4proto->nfattr_to_tuple(tb, tuple);
523 nf_ct_l4proto_put(l4proto);
529 ctnetlink_parse_tuple(struct nfattr *cda[], struct nf_conntrack_tuple *tuple,
530 enum ctattr_tuple type, u_int8_t l3num)
532 struct nfattr *tb[CTA_TUPLE_MAX];
535 memset(tuple, 0, sizeof(*tuple));
537 nfattr_parse_nested(tb, CTA_TUPLE_MAX, cda[type-1]);
539 if (!tb[CTA_TUPLE_IP-1])
542 tuple->src.l3num = l3num;
544 err = ctnetlink_parse_tuple_ip(tb[CTA_TUPLE_IP-1], tuple);
548 if (!tb[CTA_TUPLE_PROTO-1])
551 err = ctnetlink_parse_tuple_proto(tb[CTA_TUPLE_PROTO-1], tuple);
555 /* orig and expect tuples get DIR_ORIGINAL */
556 if (type == CTA_TUPLE_REPLY)
557 tuple->dst.dir = IP_CT_DIR_REPLY;
559 tuple->dst.dir = IP_CT_DIR_ORIGINAL;
564 #ifdef CONFIG_NF_NAT_NEEDED
565 static const size_t cta_min_protonat[CTA_PROTONAT_MAX] = {
566 [CTA_PROTONAT_PORT_MIN-1] = sizeof(u_int16_t),
567 [CTA_PROTONAT_PORT_MAX-1] = sizeof(u_int16_t),
570 static int nfnetlink_parse_nat_proto(struct nfattr *attr,
571 const struct nf_conn *ct,
572 struct nf_nat_range *range)
574 struct nfattr *tb[CTA_PROTONAT_MAX];
575 struct nf_nat_protocol *npt;
577 nfattr_parse_nested(tb, CTA_PROTONAT_MAX, attr);
579 if (nfattr_bad_size(tb, CTA_PROTONAT_MAX, cta_min_protonat))
582 npt = nf_nat_proto_find_get(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum);
584 if (!npt->nfattr_to_range) {
585 nf_nat_proto_put(npt);
589 /* nfattr_to_range returns 1 if it parsed, 0 if not, neg. on error */
590 if (npt->nfattr_to_range(tb, range) > 0)
591 range->flags |= IP_NAT_RANGE_PROTO_SPECIFIED;
593 nf_nat_proto_put(npt);
598 static const size_t cta_min_nat[CTA_NAT_MAX] = {
599 [CTA_NAT_MINIP-1] = sizeof(u_int32_t),
600 [CTA_NAT_MAXIP-1] = sizeof(u_int32_t),
604 nfnetlink_parse_nat(struct nfattr *nat,
605 const struct nf_conn *ct, struct nf_nat_range *range)
607 struct nfattr *tb[CTA_NAT_MAX];
610 memset(range, 0, sizeof(*range));
612 nfattr_parse_nested(tb, CTA_NAT_MAX, nat);
614 if (nfattr_bad_size(tb, CTA_NAT_MAX, cta_min_nat))
617 if (tb[CTA_NAT_MINIP-1])
618 range->min_ip = *(__be32 *)NFA_DATA(tb[CTA_NAT_MINIP-1]);
620 if (!tb[CTA_NAT_MAXIP-1])
621 range->max_ip = range->min_ip;
623 range->max_ip = *(__be32 *)NFA_DATA(tb[CTA_NAT_MAXIP-1]);
626 range->flags |= IP_NAT_RANGE_MAP_IPS;
628 if (!tb[CTA_NAT_PROTO-1])
631 err = nfnetlink_parse_nat_proto(tb[CTA_NAT_PROTO-1], ct, range);
640 ctnetlink_parse_help(struct nfattr *attr, char **helper_name)
642 struct nfattr *tb[CTA_HELP_MAX];
644 nfattr_parse_nested(tb, CTA_HELP_MAX, attr);
646 if (!tb[CTA_HELP_NAME-1])
649 *helper_name = NFA_DATA(tb[CTA_HELP_NAME-1]);
654 static const size_t cta_min[CTA_MAX] = {
655 [CTA_STATUS-1] = sizeof(u_int32_t),
656 [CTA_TIMEOUT-1] = sizeof(u_int32_t),
657 [CTA_MARK-1] = sizeof(u_int32_t),
658 [CTA_USE-1] = sizeof(u_int32_t),
659 [CTA_ID-1] = sizeof(u_int32_t)
663 ctnetlink_del_conntrack(struct sock *ctnl, struct sk_buff *skb,
664 struct nlmsghdr *nlh, struct nfattr *cda[], int *errp)
666 struct nf_conntrack_tuple_hash *h;
667 struct nf_conntrack_tuple tuple;
669 struct nfgenmsg *nfmsg = NLMSG_DATA(nlh);
670 u_int8_t u3 = nfmsg->nfgen_family;
673 if (nfattr_bad_size(cda, CTA_MAX, cta_min))
676 if (cda[CTA_TUPLE_ORIG-1])
677 err = ctnetlink_parse_tuple(cda, &tuple, CTA_TUPLE_ORIG, u3);
678 else if (cda[CTA_TUPLE_REPLY-1])
679 err = ctnetlink_parse_tuple(cda, &tuple, CTA_TUPLE_REPLY, u3);
681 /* Flush the whole table */
682 nf_conntrack_flush();
689 h = nf_conntrack_find_get(&tuple, NULL);
693 ct = nf_ct_tuplehash_to_ctrack(h);
696 u_int32_t id = ntohl(*(__be32 *)NFA_DATA(cda[CTA_ID-1]));
702 if (del_timer(&ct->timeout))
703 ct->timeout.function((unsigned long)ct);
711 ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb,
712 struct nlmsghdr *nlh, struct nfattr *cda[], int *errp)
714 struct nf_conntrack_tuple_hash *h;
715 struct nf_conntrack_tuple tuple;
717 struct sk_buff *skb2 = NULL;
718 struct nfgenmsg *nfmsg = NLMSG_DATA(nlh);
719 u_int8_t u3 = nfmsg->nfgen_family;
722 if (nlh->nlmsg_flags & NLM_F_DUMP) {
725 #ifndef CONFIG_NF_CT_ACCT
726 if (NFNL_MSG_TYPE(nlh->nlmsg_type) == IPCTNL_MSG_CT_GET_CTRZERO)
729 if ((*errp = netlink_dump_start(ctnl, skb, nlh,
730 ctnetlink_dump_table,
731 ctnetlink_done)) != 0)
734 rlen = NLMSG_ALIGN(nlh->nlmsg_len);
741 if (nfattr_bad_size(cda, CTA_MAX, cta_min))
744 if (cda[CTA_TUPLE_ORIG-1])
745 err = ctnetlink_parse_tuple(cda, &tuple, CTA_TUPLE_ORIG, u3);
746 else if (cda[CTA_TUPLE_REPLY-1])
747 err = ctnetlink_parse_tuple(cda, &tuple, CTA_TUPLE_REPLY, u3);
754 h = nf_conntrack_find_get(&tuple, NULL);
758 ct = nf_ct_tuplehash_to_ctrack(h);
761 skb2 = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
767 err = ctnetlink_fill_info(skb2, NETLINK_CB(skb).pid, nlh->nlmsg_seq,
768 IPCTNL_MSG_CT_NEW, 1, ct);
773 err = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT);
786 ctnetlink_change_status(struct nf_conn *ct, struct nfattr *cda[])
789 unsigned int status = ntohl(*(__be32 *)NFA_DATA(cda[CTA_STATUS-1]));
790 d = ct->status ^ status;
792 if (d & (IPS_EXPECTED|IPS_CONFIRMED|IPS_DYING))
796 if (d & IPS_SEEN_REPLY && !(status & IPS_SEEN_REPLY))
797 /* SEEN_REPLY bit can only be set */
801 if (d & IPS_ASSURED && !(status & IPS_ASSURED))
802 /* ASSURED bit can only be set */
805 if (cda[CTA_NAT_SRC-1] || cda[CTA_NAT_DST-1]) {
806 #ifndef CONFIG_NF_NAT_NEEDED
809 struct nf_nat_range range;
811 if (cda[CTA_NAT_DST-1]) {
812 if (nfnetlink_parse_nat(cda[CTA_NAT_DST-1], ct,
815 if (nf_nat_initialized(ct,
816 HOOK2MANIP(NF_IP_PRE_ROUTING)))
818 nf_nat_setup_info(ct, &range, NF_IP_PRE_ROUTING);
820 if (cda[CTA_NAT_SRC-1]) {
821 if (nfnetlink_parse_nat(cda[CTA_NAT_SRC-1], ct,
824 if (nf_nat_initialized(ct,
825 HOOK2MANIP(NF_IP_POST_ROUTING)))
827 nf_nat_setup_info(ct, &range, NF_IP_POST_ROUTING);
832 /* Be careful here, modifying NAT bits can screw up things,
833 * so don't let users modify them directly if they don't pass
835 ct->status |= status & ~(IPS_NAT_DONE_MASK | IPS_NAT_MASK);
841 ctnetlink_change_helper(struct nf_conn *ct, struct nfattr *cda[])
843 struct nf_conntrack_helper *helper;
844 struct nf_conn_help *help = nfct_help(ct);
849 /* FIXME: we need to reallocate and rehash */
853 /* don't change helper of sibling connections */
857 err = ctnetlink_parse_help(cda[CTA_HELP-1], &helpname);
861 helper = __nf_conntrack_helper_find_byname(helpname);
863 if (!strcmp(helpname, ""))
871 /* we had a helper before ... */
872 nf_ct_remove_expectations(ct);
875 /* need to zero data of old helper */
876 memset(&help->help, 0, sizeof(help->help));
880 help->helper = helper;
886 ctnetlink_change_timeout(struct nf_conn *ct, struct nfattr *cda[])
888 u_int32_t timeout = ntohl(*(__be32 *)NFA_DATA(cda[CTA_TIMEOUT-1]));
890 if (!del_timer(&ct->timeout))
893 ct->timeout.expires = jiffies + timeout * HZ;
894 add_timer(&ct->timeout);
900 ctnetlink_change_protoinfo(struct nf_conn *ct, struct nfattr *cda[])
902 struct nfattr *tb[CTA_PROTOINFO_MAX], *attr = cda[CTA_PROTOINFO-1];
903 struct nf_conntrack_l4proto *l4proto;
904 u_int16_t npt = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum;
905 u_int16_t l3num = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num;
908 nfattr_parse_nested(tb, CTA_PROTOINFO_MAX, attr);
910 l4proto = nf_ct_l4proto_find_get(l3num, npt);
912 if (l4proto->from_nfattr)
913 err = l4proto->from_nfattr(tb, ct);
914 nf_ct_l4proto_put(l4proto);
920 ctnetlink_change_conntrack(struct nf_conn *ct, struct nfattr *cda[])
924 if (cda[CTA_HELP-1]) {
925 err = ctnetlink_change_helper(ct, cda);
930 if (cda[CTA_TIMEOUT-1]) {
931 err = ctnetlink_change_timeout(ct, cda);
936 if (cda[CTA_STATUS-1]) {
937 err = ctnetlink_change_status(ct, cda);
942 if (cda[CTA_PROTOINFO-1]) {
943 err = ctnetlink_change_protoinfo(ct, cda);
948 #if defined(CONFIG_NF_CONNTRACK_MARK)
950 ct->mark = ntohl(*(__be32 *)NFA_DATA(cda[CTA_MARK-1]));
957 ctnetlink_create_conntrack(struct nfattr *cda[],
958 struct nf_conntrack_tuple *otuple,
959 struct nf_conntrack_tuple *rtuple)
963 struct nf_conn_help *help;
965 ct = nf_conntrack_alloc(otuple, rtuple);
966 if (ct == NULL || IS_ERR(ct))
969 if (!cda[CTA_TIMEOUT-1])
971 ct->timeout.expires = ntohl(*(__be32 *)NFA_DATA(cda[CTA_TIMEOUT-1]));
973 ct->timeout.expires = jiffies + ct->timeout.expires * HZ;
974 ct->status |= IPS_CONFIRMED;
976 if (cda[CTA_STATUS-1]) {
977 err = ctnetlink_change_status(ct, cda);
982 if (cda[CTA_PROTOINFO-1]) {
983 err = ctnetlink_change_protoinfo(ct, cda);
988 #if defined(CONFIG_NF_CONNTRACK_MARK)
990 ct->mark = ntohl(*(__be32 *)NFA_DATA(cda[CTA_MARK-1]));
993 help = nfct_help(ct);
995 help->helper = nf_ct_helper_find_get(rtuple);
997 add_timer(&ct->timeout);
998 nf_conntrack_hash_insert(ct);
1000 if (help && help->helper)
1001 nf_ct_helper_put(help->helper);
1006 nf_conntrack_free(ct);
1011 ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
1012 struct nlmsghdr *nlh, struct nfattr *cda[], int *errp)
1014 struct nf_conntrack_tuple otuple, rtuple;
1015 struct nf_conntrack_tuple_hash *h = NULL;
1016 struct nfgenmsg *nfmsg = NLMSG_DATA(nlh);
1017 u_int8_t u3 = nfmsg->nfgen_family;
1020 if (nfattr_bad_size(cda, CTA_MAX, cta_min))
1023 if (cda[CTA_TUPLE_ORIG-1]) {
1024 err = ctnetlink_parse_tuple(cda, &otuple, CTA_TUPLE_ORIG, u3);
1029 if (cda[CTA_TUPLE_REPLY-1]) {
1030 err = ctnetlink_parse_tuple(cda, &rtuple, CTA_TUPLE_REPLY, u3);
1035 write_lock_bh(&nf_conntrack_lock);
1036 if (cda[CTA_TUPLE_ORIG-1])
1037 h = __nf_conntrack_find(&otuple, NULL);
1038 else if (cda[CTA_TUPLE_REPLY-1])
1039 h = __nf_conntrack_find(&rtuple, NULL);
1042 write_unlock_bh(&nf_conntrack_lock);
1044 if (nlh->nlmsg_flags & NLM_F_CREATE)
1045 err = ctnetlink_create_conntrack(cda, &otuple, &rtuple);
1048 /* implicit 'else' */
1050 /* we only allow nat config for new conntracks */
1051 if (cda[CTA_NAT_SRC-1] || cda[CTA_NAT_DST-1]) {
1056 /* We manipulate the conntrack inside the global conntrack table lock,
1057 * so there's no need to increase the refcount */
1059 if (!(nlh->nlmsg_flags & NLM_F_EXCL))
1060 err = ctnetlink_change_conntrack(nf_ct_tuplehash_to_ctrack(h), cda);
1063 write_unlock_bh(&nf_conntrack_lock);
1067 /***********************************************************************
1069 ***********************************************************************/
1072 ctnetlink_exp_dump_tuple(struct sk_buff *skb,
1073 const struct nf_conntrack_tuple *tuple,
1074 enum ctattr_expect type)
1076 struct nfattr *nest_parms = NFA_NEST(skb, type);
1078 if (ctnetlink_dump_tuples(skb, tuple) < 0)
1079 goto nfattr_failure;
1081 NFA_NEST_END(skb, nest_parms);
1090 ctnetlink_exp_dump_mask(struct sk_buff *skb,
1091 const struct nf_conntrack_tuple *tuple,
1092 const struct nf_conntrack_tuple *mask)
1095 struct nf_conntrack_l3proto *l3proto;
1096 struct nf_conntrack_l4proto *l4proto;
1097 struct nfattr *nest_parms = NFA_NEST(skb, CTA_EXPECT_MASK);
1099 l3proto = nf_ct_l3proto_find_get(tuple->src.l3num);
1100 ret = ctnetlink_dump_tuples_ip(skb, mask, l3proto);
1101 nf_ct_l3proto_put(l3proto);
1103 if (unlikely(ret < 0))
1104 goto nfattr_failure;
1106 l4proto = nf_ct_l4proto_find_get(tuple->src.l3num, tuple->dst.protonum);
1107 ret = ctnetlink_dump_tuples_proto(skb, mask, l4proto);
1108 nf_ct_l4proto_put(l4proto);
1109 if (unlikely(ret < 0))
1110 goto nfattr_failure;
1112 NFA_NEST_END(skb, nest_parms);
1121 ctnetlink_exp_dump_expect(struct sk_buff *skb,
1122 const struct nf_conntrack_expect *exp)
1124 struct nf_conn *master = exp->master;
1125 __be32 timeout = htonl((exp->timeout.expires - jiffies) / HZ);
1126 __be32 id = htonl(exp->id);
1128 if (ctnetlink_exp_dump_tuple(skb, &exp->tuple, CTA_EXPECT_TUPLE) < 0)
1129 goto nfattr_failure;
1130 if (ctnetlink_exp_dump_mask(skb, &exp->tuple, &exp->mask) < 0)
1131 goto nfattr_failure;
1132 if (ctnetlink_exp_dump_tuple(skb,
1133 &master->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
1134 CTA_EXPECT_MASTER) < 0)
1135 goto nfattr_failure;
1137 NFA_PUT(skb, CTA_EXPECT_TIMEOUT, sizeof(timeout), &timeout);
1138 NFA_PUT(skb, CTA_EXPECT_ID, sizeof(u_int32_t), &id);
1147 ctnetlink_exp_fill_info(struct sk_buff *skb, u32 pid, u32 seq,
1150 const struct nf_conntrack_expect *exp)
1152 struct nlmsghdr *nlh;
1153 struct nfgenmsg *nfmsg;
1154 unsigned char *b = skb_tail_pointer(skb);
1156 event |= NFNL_SUBSYS_CTNETLINK_EXP << 8;
1157 nlh = NLMSG_PUT(skb, pid, seq, event, sizeof(struct nfgenmsg));
1158 nfmsg = NLMSG_DATA(nlh);
1160 nlh->nlmsg_flags = (nowait && pid) ? NLM_F_MULTI : 0;
1161 nfmsg->nfgen_family = exp->tuple.src.l3num;
1162 nfmsg->version = NFNETLINK_V0;
1165 if (ctnetlink_exp_dump_expect(skb, exp) < 0)
1166 goto nfattr_failure;
1168 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
1177 #ifdef CONFIG_NF_CONNTRACK_EVENTS
1178 static int ctnetlink_expect_event(struct notifier_block *this,
1179 unsigned long events, void *ptr)
1181 struct nlmsghdr *nlh;
1182 struct nfgenmsg *nfmsg;
1183 struct nf_conntrack_expect *exp = (struct nf_conntrack_expect *)ptr;
1184 struct sk_buff *skb;
1189 if (events & IPEXP_NEW) {
1190 type = IPCTNL_MSG_EXP_NEW;
1191 flags = NLM_F_CREATE|NLM_F_EXCL;
1195 if (!nfnetlink_has_listeners(NFNLGRP_CONNTRACK_EXP_NEW))
1198 skb = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC);
1204 type |= NFNL_SUBSYS_CTNETLINK_EXP << 8;
1205 nlh = NLMSG_PUT(skb, 0, 0, type, sizeof(struct nfgenmsg));
1206 nfmsg = NLMSG_DATA(nlh);
1208 nlh->nlmsg_flags = flags;
1209 nfmsg->nfgen_family = exp->tuple.src.l3num;
1210 nfmsg->version = NFNETLINK_V0;
1213 if (ctnetlink_exp_dump_expect(skb, exp) < 0)
1214 goto nfattr_failure;
1216 nlh->nlmsg_len = skb->tail - b;
1217 nfnetlink_send(skb, 0, NFNLGRP_CONNTRACK_EXP_NEW, 0);
1228 ctnetlink_exp_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
1230 struct nf_conntrack_expect *exp = NULL;
1231 struct list_head *i;
1232 u_int32_t *id = (u_int32_t *) &cb->args[0];
1233 struct nfgenmsg *nfmsg = NLMSG_DATA(cb->nlh);
1234 u_int8_t l3proto = nfmsg->nfgen_family;
1236 read_lock_bh(&nf_conntrack_lock);
1237 list_for_each_prev(i, &nf_conntrack_expect_list) {
1238 exp = (struct nf_conntrack_expect *) i;
1239 if (l3proto && exp->tuple.src.l3num != l3proto)
1243 if (ctnetlink_exp_fill_info(skb, NETLINK_CB(cb->skb).pid,
1251 read_unlock_bh(&nf_conntrack_lock);
1256 static const size_t cta_min_exp[CTA_EXPECT_MAX] = {
1257 [CTA_EXPECT_TIMEOUT-1] = sizeof(u_int32_t),
1258 [CTA_EXPECT_ID-1] = sizeof(u_int32_t)
1262 ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
1263 struct nlmsghdr *nlh, struct nfattr *cda[], int *errp)
1265 struct nf_conntrack_tuple tuple;
1266 struct nf_conntrack_expect *exp;
1267 struct sk_buff *skb2;
1268 struct nfgenmsg *nfmsg = NLMSG_DATA(nlh);
1269 u_int8_t u3 = nfmsg->nfgen_family;
1272 if (nfattr_bad_size(cda, CTA_EXPECT_MAX, cta_min_exp))
1275 if (nlh->nlmsg_flags & NLM_F_DUMP) {
1278 if ((*errp = netlink_dump_start(ctnl, skb, nlh,
1279 ctnetlink_exp_dump_table,
1280 ctnetlink_done)) != 0)
1282 rlen = NLMSG_ALIGN(nlh->nlmsg_len);
1283 if (rlen > skb->len)
1285 skb_pull(skb, rlen);
1289 if (cda[CTA_EXPECT_MASTER-1])
1290 err = ctnetlink_parse_tuple(cda, &tuple, CTA_EXPECT_MASTER, u3);
1297 exp = nf_conntrack_expect_find_get(&tuple);
1301 if (cda[CTA_EXPECT_ID-1]) {
1302 __be32 id = *(__be32 *)NFA_DATA(cda[CTA_EXPECT_ID-1]);
1303 if (exp->id != ntohl(id)) {
1304 nf_conntrack_expect_put(exp);
1310 skb2 = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
1314 err = ctnetlink_exp_fill_info(skb2, NETLINK_CB(skb).pid,
1315 nlh->nlmsg_seq, IPCTNL_MSG_EXP_NEW,
1320 nf_conntrack_expect_put(exp);
1322 return netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT);
1327 nf_conntrack_expect_put(exp);
1332 ctnetlink_del_expect(struct sock *ctnl, struct sk_buff *skb,
1333 struct nlmsghdr *nlh, struct nfattr *cda[], int *errp)
1335 struct nf_conntrack_expect *exp, *tmp;
1336 struct nf_conntrack_tuple tuple;
1337 struct nf_conntrack_helper *h;
1338 struct nfgenmsg *nfmsg = NLMSG_DATA(nlh);
1339 u_int8_t u3 = nfmsg->nfgen_family;
1342 if (nfattr_bad_size(cda, CTA_EXPECT_MAX, cta_min_exp))
1345 if (cda[CTA_EXPECT_TUPLE-1]) {
1346 /* delete a single expect by tuple */
1347 err = ctnetlink_parse_tuple(cda, &tuple, CTA_EXPECT_TUPLE, u3);
1351 /* bump usage count to 2 */
1352 exp = nf_conntrack_expect_find_get(&tuple);
1356 if (cda[CTA_EXPECT_ID-1]) {
1357 __be32 id = *(__be32 *)NFA_DATA(cda[CTA_EXPECT_ID-1]);
1358 if (exp->id != ntohl(id)) {
1359 nf_conntrack_expect_put(exp);
1364 /* after list removal, usage count == 1 */
1365 nf_conntrack_unexpect_related(exp);
1366 /* have to put what we 'get' above.
1367 * after this line usage count == 0 */
1368 nf_conntrack_expect_put(exp);
1369 } else if (cda[CTA_EXPECT_HELP_NAME-1]) {
1370 char *name = NFA_DATA(cda[CTA_EXPECT_HELP_NAME-1]);
1372 /* delete all expectations for this helper */
1373 write_lock_bh(&nf_conntrack_lock);
1374 h = __nf_conntrack_helper_find_byname(name);
1376 write_unlock_bh(&nf_conntrack_lock);
1379 list_for_each_entry_safe(exp, tmp, &nf_conntrack_expect_list,
1381 struct nf_conn_help *m_help = nfct_help(exp->master);
1382 if (m_help->helper == h
1383 && del_timer(&exp->timeout)) {
1384 nf_ct_unlink_expect(exp);
1385 nf_conntrack_expect_put(exp);
1388 write_unlock_bh(&nf_conntrack_lock);
1390 /* This basically means we have to flush everything*/
1391 write_lock_bh(&nf_conntrack_lock);
1392 list_for_each_entry_safe(exp, tmp, &nf_conntrack_expect_list,
1394 if (del_timer(&exp->timeout)) {
1395 nf_ct_unlink_expect(exp);
1396 nf_conntrack_expect_put(exp);
1399 write_unlock_bh(&nf_conntrack_lock);
1405 ctnetlink_change_expect(struct nf_conntrack_expect *x, struct nfattr *cda[])
1411 ctnetlink_create_expect(struct nfattr *cda[], u_int8_t u3)
1413 struct nf_conntrack_tuple tuple, mask, master_tuple;
1414 struct nf_conntrack_tuple_hash *h = NULL;
1415 struct nf_conntrack_expect *exp;
1417 struct nf_conn_help *help;
1420 /* caller guarantees that those three CTA_EXPECT_* exist */
1421 err = ctnetlink_parse_tuple(cda, &tuple, CTA_EXPECT_TUPLE, u3);
1424 err = ctnetlink_parse_tuple(cda, &mask, CTA_EXPECT_MASK, u3);
1427 err = ctnetlink_parse_tuple(cda, &master_tuple, CTA_EXPECT_MASTER, u3);
1431 /* Look for master conntrack of this expectation */
1432 h = nf_conntrack_find_get(&master_tuple, NULL);
1435 ct = nf_ct_tuplehash_to_ctrack(h);
1436 help = nfct_help(ct);
1438 if (!help || !help->helper) {
1439 /* such conntrack hasn't got any helper, abort */
1444 exp = nf_conntrack_expect_alloc(ct);
1450 exp->expectfn = NULL;
1454 memcpy(&exp->tuple, &tuple, sizeof(struct nf_conntrack_tuple));
1455 memcpy(&exp->mask, &mask, sizeof(struct nf_conntrack_tuple));
1457 err = nf_conntrack_expect_related(exp);
1458 nf_conntrack_expect_put(exp);
1461 nf_ct_put(nf_ct_tuplehash_to_ctrack(h));
1466 ctnetlink_new_expect(struct sock *ctnl, struct sk_buff *skb,
1467 struct nlmsghdr *nlh, struct nfattr *cda[], int *errp)
1469 struct nf_conntrack_tuple tuple;
1470 struct nf_conntrack_expect *exp;
1471 struct nfgenmsg *nfmsg = NLMSG_DATA(nlh);
1472 u_int8_t u3 = nfmsg->nfgen_family;
1475 if (nfattr_bad_size(cda, CTA_EXPECT_MAX, cta_min_exp))
1478 if (!cda[CTA_EXPECT_TUPLE-1]
1479 || !cda[CTA_EXPECT_MASK-1]
1480 || !cda[CTA_EXPECT_MASTER-1])
1483 err = ctnetlink_parse_tuple(cda, &tuple, CTA_EXPECT_TUPLE, u3);
1487 write_lock_bh(&nf_conntrack_lock);
1488 exp = __nf_conntrack_expect_find(&tuple);
1491 write_unlock_bh(&nf_conntrack_lock);
1493 if (nlh->nlmsg_flags & NLM_F_CREATE)
1494 err = ctnetlink_create_expect(cda, u3);
1499 if (!(nlh->nlmsg_flags & NLM_F_EXCL))
1500 err = ctnetlink_change_expect(exp, cda);
1501 write_unlock_bh(&nf_conntrack_lock);
1506 #ifdef CONFIG_NF_CONNTRACK_EVENTS
1507 static struct notifier_block ctnl_notifier = {
1508 .notifier_call = ctnetlink_conntrack_event,
1511 static struct notifier_block ctnl_notifier_exp = {
1512 .notifier_call = ctnetlink_expect_event,
1516 static struct nfnl_callback ctnl_cb[IPCTNL_MSG_MAX] = {
1517 [IPCTNL_MSG_CT_NEW] = { .call = ctnetlink_new_conntrack,
1518 .attr_count = CTA_MAX, },
1519 [IPCTNL_MSG_CT_GET] = { .call = ctnetlink_get_conntrack,
1520 .attr_count = CTA_MAX, },
1521 [IPCTNL_MSG_CT_DELETE] = { .call = ctnetlink_del_conntrack,
1522 .attr_count = CTA_MAX, },
1523 [IPCTNL_MSG_CT_GET_CTRZERO] = { .call = ctnetlink_get_conntrack,
1524 .attr_count = CTA_MAX, },
1527 static struct nfnl_callback ctnl_exp_cb[IPCTNL_MSG_EXP_MAX] = {
1528 [IPCTNL_MSG_EXP_GET] = { .call = ctnetlink_get_expect,
1529 .attr_count = CTA_EXPECT_MAX, },
1530 [IPCTNL_MSG_EXP_NEW] = { .call = ctnetlink_new_expect,
1531 .attr_count = CTA_EXPECT_MAX, },
1532 [IPCTNL_MSG_EXP_DELETE] = { .call = ctnetlink_del_expect,
1533 .attr_count = CTA_EXPECT_MAX, },
1536 static struct nfnetlink_subsystem ctnl_subsys = {
1537 .name = "conntrack",
1538 .subsys_id = NFNL_SUBSYS_CTNETLINK,
1539 .cb_count = IPCTNL_MSG_MAX,
1543 static struct nfnetlink_subsystem ctnl_exp_subsys = {
1544 .name = "conntrack_expect",
1545 .subsys_id = NFNL_SUBSYS_CTNETLINK_EXP,
1546 .cb_count = IPCTNL_MSG_EXP_MAX,
1550 MODULE_ALIAS("ip_conntrack_netlink");
1551 MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_CTNETLINK);
1552 MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_CTNETLINK_EXP);
1554 static int __init ctnetlink_init(void)
1558 printk("ctnetlink v%s: registering with nfnetlink.\n", version);
1559 ret = nfnetlink_subsys_register(&ctnl_subsys);
1561 printk("ctnetlink_init: cannot register with nfnetlink.\n");
1565 ret = nfnetlink_subsys_register(&ctnl_exp_subsys);
1567 printk("ctnetlink_init: cannot register exp with nfnetlink.\n");
1568 goto err_unreg_subsys;
1571 #ifdef CONFIG_NF_CONNTRACK_EVENTS
1572 ret = nf_conntrack_register_notifier(&ctnl_notifier);
1574 printk("ctnetlink_init: cannot register notifier.\n");
1575 goto err_unreg_exp_subsys;
1578 ret = nf_conntrack_expect_register_notifier(&ctnl_notifier_exp);
1580 printk("ctnetlink_init: cannot expect register notifier.\n");
1581 goto err_unreg_notifier;
1587 #ifdef CONFIG_NF_CONNTRACK_EVENTS
1589 nf_conntrack_unregister_notifier(&ctnl_notifier);
1590 err_unreg_exp_subsys:
1591 nfnetlink_subsys_unregister(&ctnl_exp_subsys);
1594 nfnetlink_subsys_unregister(&ctnl_subsys);
1599 static void __exit ctnetlink_exit(void)
1601 printk("ctnetlink: unregistering from nfnetlink.\n");
1603 #ifdef CONFIG_NF_CONNTRACK_EVENTS
1604 nf_conntrack_expect_unregister_notifier(&ctnl_notifier_exp);
1605 nf_conntrack_unregister_notifier(&ctnl_notifier);
1608 nfnetlink_subsys_unregister(&ctnl_exp_subsys);
1609 nfnetlink_subsys_unregister(&ctnl_subsys);
1613 module_init(ctnetlink_init);
1614 module_exit(ctnetlink_exit);