Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 1 | /* L3/L4 protocol support for nf_conntrack. */ |
| 2 | |
| 3 | /* (C) 1999-2001 Paul `Rusty' Russell |
| 4 | * (C) 2002-2006 Netfilter Core Team <coreteam@netfilter.org> |
| 5 | * (C) 2003,2004 USAGI/WIDE Project <http://www.linux-ipv6.org> |
Patrick McHardy | f229f6c | 2013-04-06 15:24:29 +0200 | [diff] [blame] | 6 | * (C) 2006-2012 Patrick McHardy <kaber@trash.net> |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/types.h> |
| 14 | #include <linux/netfilter.h> |
| 15 | #include <linux/module.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 16 | #include <linux/slab.h> |
Patrick McHardy | d62f9ed | 2006-11-29 02:35:17 +0100 | [diff] [blame] | 17 | #include <linux/mutex.h> |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 18 | #include <linux/vmalloc.h> |
| 19 | #include <linux/stddef.h> |
| 20 | #include <linux/err.h> |
| 21 | #include <linux/percpu.h> |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 22 | #include <linux/notifier.h> |
| 23 | #include <linux/kernel.h> |
| 24 | #include <linux/netdevice.h> |
| 25 | |
| 26 | #include <net/netfilter/nf_conntrack.h> |
| 27 | #include <net/netfilter/nf_conntrack_l3proto.h> |
Martin Josefsson | 605dcad | 2006-11-29 02:35:06 +0100 | [diff] [blame] | 28 | #include <net/netfilter/nf_conntrack_l4proto.h> |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 29 | #include <net/netfilter/nf_conntrack_core.h> |
| 30 | |
Arnd Bergmann | 0906a37 | 2010-03-09 20:59:15 +0100 | [diff] [blame] | 31 | static struct nf_conntrack_l4proto __rcu **nf_ct_protos[PF_MAX] __read_mostly; |
| 32 | struct nf_conntrack_l3proto __rcu *nf_ct_l3protos[AF_MAX] __read_mostly; |
Patrick McHardy | 13b1833 | 2006-12-02 22:11:25 -0800 | [diff] [blame] | 33 | EXPORT_SYMBOL_GPL(nf_ct_l3protos); |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 34 | |
Patrick McHardy | b19caa0 | 2007-03-14 16:37:52 -0700 | [diff] [blame] | 35 | static DEFINE_MUTEX(nf_ct_proto_mutex); |
Patrick McHardy | d62f9ed | 2006-11-29 02:35:17 +0100 | [diff] [blame] | 36 | |
Patrick McHardy | b19caa0 | 2007-03-14 16:37:52 -0700 | [diff] [blame] | 37 | #ifdef CONFIG_SYSCTL |
Patrick McHardy | d62f9ed | 2006-11-29 02:35:17 +0100 | [diff] [blame] | 38 | static int |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 39 | nf_ct_register_sysctl(struct net *net, |
| 40 | struct ctl_table_header **header, |
| 41 | const char *path, |
Gao feng | fa34fff | 2012-06-21 04:36:41 +0000 | [diff] [blame] | 42 | struct ctl_table *table) |
Patrick McHardy | d62f9ed | 2006-11-29 02:35:17 +0100 | [diff] [blame] | 43 | { |
| 44 | if (*header == NULL) { |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 45 | *header = register_net_sysctl(net, path, table); |
Patrick McHardy | d62f9ed | 2006-11-29 02:35:17 +0100 | [diff] [blame] | 46 | if (*header == NULL) |
| 47 | return -ENOMEM; |
| 48 | } |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 49 | |
Patrick McHardy | d62f9ed | 2006-11-29 02:35:17 +0100 | [diff] [blame] | 50 | return 0; |
| 51 | } |
| 52 | |
| 53 | static void |
| 54 | nf_ct_unregister_sysctl(struct ctl_table_header **header, |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 55 | struct ctl_table **table, |
Gao feng | fa34fff | 2012-06-21 04:36:41 +0000 | [diff] [blame] | 56 | unsigned int users) |
Patrick McHardy | d62f9ed | 2006-11-29 02:35:17 +0100 | [diff] [blame] | 57 | { |
Gao feng | fa34fff | 2012-06-21 04:36:41 +0000 | [diff] [blame] | 58 | if (users > 0) |
Patrick McHardy | d62f9ed | 2006-11-29 02:35:17 +0100 | [diff] [blame] | 59 | return; |
Pavel Emelyanov | b3fd3ff | 2008-01-09 00:34:02 -0800 | [diff] [blame] | 60 | |
Eric W. Biederman | 5dd3df1 | 2012-04-19 13:24:33 +0000 | [diff] [blame] | 61 | unregister_net_sysctl_table(*header); |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 62 | kfree(*table); |
Patrick McHardy | d62f9ed | 2006-11-29 02:35:17 +0100 | [diff] [blame] | 63 | *header = NULL; |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 64 | *table = NULL; |
Patrick McHardy | d62f9ed | 2006-11-29 02:35:17 +0100 | [diff] [blame] | 65 | } |
| 66 | #endif |
| 67 | |
Martin Josefsson | 605dcad | 2006-11-29 02:35:06 +0100 | [diff] [blame] | 68 | struct nf_conntrack_l4proto * |
| 69 | __nf_ct_l4proto_find(u_int16_t l3proto, u_int8_t l4proto) |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 70 | { |
| 71 | if (unlikely(l3proto >= AF_MAX || nf_ct_protos[l3proto] == NULL)) |
Martin Josefsson | 605dcad | 2006-11-29 02:35:06 +0100 | [diff] [blame] | 72 | return &nf_conntrack_l4proto_generic; |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 73 | |
Patrick McHardy | 923f490 | 2007-02-12 11:12:57 -0800 | [diff] [blame] | 74 | return rcu_dereference(nf_ct_protos[l3proto][l4proto]); |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 75 | } |
Patrick McHardy | 13b1833 | 2006-12-02 22:11:25 -0800 | [diff] [blame] | 76 | EXPORT_SYMBOL_GPL(__nf_ct_l4proto_find); |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 77 | |
| 78 | /* this is guaranteed to always return a valid protocol helper, since |
| 79 | * it falls back to generic_protocol */ |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 80 | struct nf_conntrack_l3proto * |
| 81 | nf_ct_l3proto_find_get(u_int16_t l3proto) |
| 82 | { |
| 83 | struct nf_conntrack_l3proto *p; |
| 84 | |
Patrick McHardy | 923f490 | 2007-02-12 11:12:57 -0800 | [diff] [blame] | 85 | rcu_read_lock(); |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 86 | p = __nf_ct_l3proto_find(l3proto); |
| 87 | if (!try_module_get(p->me)) |
Martin Josefsson | 605dcad | 2006-11-29 02:35:06 +0100 | [diff] [blame] | 88 | p = &nf_conntrack_l3proto_generic; |
Patrick McHardy | 923f490 | 2007-02-12 11:12:57 -0800 | [diff] [blame] | 89 | rcu_read_unlock(); |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 90 | |
| 91 | return p; |
| 92 | } |
Patrick McHardy | 13b1833 | 2006-12-02 22:11:25 -0800 | [diff] [blame] | 93 | EXPORT_SYMBOL_GPL(nf_ct_l3proto_find_get); |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 94 | |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 95 | int |
| 96 | nf_ct_l3proto_try_module_get(unsigned short l3proto) |
| 97 | { |
| 98 | int ret; |
| 99 | struct nf_conntrack_l3proto *p; |
| 100 | |
| 101 | retry: p = nf_ct_l3proto_find_get(l3proto); |
Martin Josefsson | 605dcad | 2006-11-29 02:35:06 +0100 | [diff] [blame] | 102 | if (p == &nf_conntrack_l3proto_generic) { |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 103 | ret = request_module("nf_conntrack-%d", l3proto); |
| 104 | if (!ret) |
| 105 | goto retry; |
| 106 | |
| 107 | return -EPROTOTYPE; |
| 108 | } |
| 109 | |
| 110 | return 0; |
| 111 | } |
Patrick McHardy | 13b1833 | 2006-12-02 22:11:25 -0800 | [diff] [blame] | 112 | EXPORT_SYMBOL_GPL(nf_ct_l3proto_try_module_get); |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 113 | |
| 114 | void nf_ct_l3proto_module_put(unsigned short l3proto) |
| 115 | { |
| 116 | struct nf_conntrack_l3proto *p; |
| 117 | |
Patrick McHardy | 3b254c5 | 2010-05-10 17:45:56 +0200 | [diff] [blame] | 118 | /* rcu_read_lock not necessary since the caller holds a reference, but |
| 119 | * taken anyways to avoid lockdep warnings in __nf_ct_l3proto_find() |
| 120 | */ |
| 121 | rcu_read_lock(); |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 122 | p = __nf_ct_l3proto_find(l3proto); |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 123 | module_put(p->me); |
Patrick McHardy | 3b254c5 | 2010-05-10 17:45:56 +0200 | [diff] [blame] | 124 | rcu_read_unlock(); |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 125 | } |
Patrick McHardy | 13b1833 | 2006-12-02 22:11:25 -0800 | [diff] [blame] | 126 | EXPORT_SYMBOL_GPL(nf_ct_l3proto_module_put); |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 127 | |
Pablo Neira Ayuso | c1ebd7d | 2012-03-22 23:40:01 +0100 | [diff] [blame] | 128 | struct nf_conntrack_l4proto * |
| 129 | nf_ct_l4proto_find_get(u_int16_t l3num, u_int8_t l4num) |
| 130 | { |
| 131 | struct nf_conntrack_l4proto *p; |
| 132 | |
| 133 | rcu_read_lock(); |
| 134 | p = __nf_ct_l4proto_find(l3num, l4num); |
| 135 | if (!try_module_get(p->me)) |
| 136 | p = &nf_conntrack_l4proto_generic; |
| 137 | rcu_read_unlock(); |
| 138 | |
| 139 | return p; |
| 140 | } |
| 141 | EXPORT_SYMBOL_GPL(nf_ct_l4proto_find_get); |
| 142 | |
| 143 | void nf_ct_l4proto_put(struct nf_conntrack_l4proto *p) |
| 144 | { |
| 145 | module_put(p->me); |
| 146 | } |
| 147 | EXPORT_SYMBOL_GPL(nf_ct_l4proto_put); |
| 148 | |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 149 | static int kill_l3proto(struct nf_conn *i, void *data) |
| 150 | { |
Patrick McHardy | 5e8fbe2 | 2008-04-14 11:15:52 +0200 | [diff] [blame] | 151 | return nf_ct_l3num(i) == ((struct nf_conntrack_l3proto *)data)->l3proto; |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 152 | } |
| 153 | |
Martin Josefsson | 605dcad | 2006-11-29 02:35:06 +0100 | [diff] [blame] | 154 | static int kill_l4proto(struct nf_conn *i, void *data) |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 155 | { |
Martin Josefsson | 605dcad | 2006-11-29 02:35:06 +0100 | [diff] [blame] | 156 | struct nf_conntrack_l4proto *l4proto; |
| 157 | l4proto = (struct nf_conntrack_l4proto *)data; |
Patrick McHardy | 5e8fbe2 | 2008-04-14 11:15:52 +0200 | [diff] [blame] | 158 | return nf_ct_protonum(i) == l4proto->l4proto && |
| 159 | nf_ct_l3num(i) == l4proto->l3proto; |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 160 | } |
| 161 | |
Gao feng | 524a53e | 2012-05-28 21:04:10 +0000 | [diff] [blame] | 162 | static struct nf_ip_net *nf_ct_l3proto_net(struct net *net, |
| 163 | struct nf_conntrack_l3proto *l3proto) |
| 164 | { |
| 165 | if (l3proto->l3proto == PF_INET) |
| 166 | return &net->ct.nf_ct_proto; |
| 167 | else |
| 168 | return NULL; |
| 169 | } |
| 170 | |
| 171 | static int nf_ct_l3proto_register_sysctl(struct net *net, |
| 172 | struct nf_conntrack_l3proto *l3proto) |
Patrick McHardy | d62f9ed | 2006-11-29 02:35:17 +0100 | [diff] [blame] | 173 | { |
| 174 | int err = 0; |
Gao feng | 524a53e | 2012-05-28 21:04:10 +0000 | [diff] [blame] | 175 | struct nf_ip_net *in = nf_ct_l3proto_net(net, l3proto); |
| 176 | /* nf_conntrack_l3proto_ipv6 doesn't support sysctl */ |
| 177 | if (in == NULL) |
| 178 | return 0; |
Patrick McHardy | d62f9ed | 2006-11-29 02:35:17 +0100 | [diff] [blame] | 179 | |
Gao feng | 524a53e | 2012-05-28 21:04:10 +0000 | [diff] [blame] | 180 | #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT) |
| 181 | if (in->ctl_table != NULL) { |
| 182 | err = nf_ct_register_sysctl(net, |
| 183 | &in->ctl_table_header, |
Patrick McHardy | d62f9ed | 2006-11-29 02:35:17 +0100 | [diff] [blame] | 184 | l3proto->ctl_table_path, |
Gao feng | fa34fff | 2012-06-21 04:36:41 +0000 | [diff] [blame] | 185 | in->ctl_table); |
Gao feng | 524a53e | 2012-05-28 21:04:10 +0000 | [diff] [blame] | 186 | if (err < 0) { |
| 187 | kfree(in->ctl_table); |
| 188 | in->ctl_table = NULL; |
| 189 | } |
Patrick McHardy | d62f9ed | 2006-11-29 02:35:17 +0100 | [diff] [blame] | 190 | } |
Patrick McHardy | d62f9ed | 2006-11-29 02:35:17 +0100 | [diff] [blame] | 191 | #endif |
| 192 | return err; |
| 193 | } |
| 194 | |
Gao feng | 524a53e | 2012-05-28 21:04:10 +0000 | [diff] [blame] | 195 | static void nf_ct_l3proto_unregister_sysctl(struct net *net, |
| 196 | struct nf_conntrack_l3proto *l3proto) |
Patrick McHardy | d62f9ed | 2006-11-29 02:35:17 +0100 | [diff] [blame] | 197 | { |
Gao feng | 524a53e | 2012-05-28 21:04:10 +0000 | [diff] [blame] | 198 | struct nf_ip_net *in = nf_ct_l3proto_net(net, l3proto); |
| 199 | |
| 200 | if (in == NULL) |
| 201 | return; |
| 202 | #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT) |
| 203 | if (in->ctl_table_header != NULL) |
| 204 | nf_ct_unregister_sysctl(&in->ctl_table_header, |
| 205 | &in->ctl_table, |
Gao feng | fa34fff | 2012-06-21 04:36:41 +0000 | [diff] [blame] | 206 | 0); |
Patrick McHardy | d62f9ed | 2006-11-29 02:35:17 +0100 | [diff] [blame] | 207 | #endif |
| 208 | } |
| 209 | |
Gao feng | 6330750 | 2013-01-21 22:10:33 +0000 | [diff] [blame] | 210 | int nf_ct_l3proto_register(struct nf_conntrack_l3proto *proto) |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 211 | { |
| 212 | int ret = 0; |
Eric Dumazet | 0e60ebe | 2010-11-15 18:17:21 +0100 | [diff] [blame] | 213 | struct nf_conntrack_l3proto *old; |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 214 | |
Patrick McHardy | 0661cca | 2007-03-14 16:38:48 -0700 | [diff] [blame] | 215 | if (proto->l3proto >= AF_MAX) |
| 216 | return -EBUSY; |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 217 | |
Holger Eitzenberger | d0dba72 | 2009-03-25 18:24:48 +0100 | [diff] [blame] | 218 | if (proto->tuple_to_nlattr && !proto->nlattr_tuple_size) |
| 219 | return -EINVAL; |
| 220 | |
Patrick McHardy | b19caa0 | 2007-03-14 16:37:52 -0700 | [diff] [blame] | 221 | mutex_lock(&nf_ct_proto_mutex); |
Eric Dumazet | 0e60ebe | 2010-11-15 18:17:21 +0100 | [diff] [blame] | 222 | old = rcu_dereference_protected(nf_ct_l3protos[proto->l3proto], |
| 223 | lockdep_is_held(&nf_ct_proto_mutex)); |
| 224 | if (old != &nf_conntrack_l3proto_generic) { |
Martin Josefsson | ae5718f | 2006-11-29 02:35:08 +0100 | [diff] [blame] | 225 | ret = -EBUSY; |
| 226 | goto out_unlock; |
| 227 | } |
Patrick McHardy | d62f9ed | 2006-11-29 02:35:17 +0100 | [diff] [blame] | 228 | |
Holger Eitzenberger | d0dba72 | 2009-03-25 18:24:48 +0100 | [diff] [blame] | 229 | if (proto->nlattr_tuple_size) |
| 230 | proto->nla_size = 3 * proto->nlattr_tuple_size(); |
| 231 | |
Patrick McHardy | 0661cca | 2007-03-14 16:38:48 -0700 | [diff] [blame] | 232 | rcu_assign_pointer(nf_ct_l3protos[proto->l3proto], proto); |
Martin Josefsson | ae5718f | 2006-11-29 02:35:08 +0100 | [diff] [blame] | 233 | |
| 234 | out_unlock: |
Patrick McHardy | b19caa0 | 2007-03-14 16:37:52 -0700 | [diff] [blame] | 235 | mutex_unlock(&nf_ct_proto_mutex); |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 236 | return ret; |
Gao feng | 524a53e | 2012-05-28 21:04:10 +0000 | [diff] [blame] | 237 | |
| 238 | } |
Gao feng | 6330750 | 2013-01-21 22:10:33 +0000 | [diff] [blame] | 239 | EXPORT_SYMBOL_GPL(nf_ct_l3proto_register); |
Gao feng | 524a53e | 2012-05-28 21:04:10 +0000 | [diff] [blame] | 240 | |
Gao feng | 6330750 | 2013-01-21 22:10:33 +0000 | [diff] [blame] | 241 | int nf_ct_l3proto_pernet_register(struct net *net, |
Gao feng | 524a53e | 2012-05-28 21:04:10 +0000 | [diff] [blame] | 242 | struct nf_conntrack_l3proto *proto) |
| 243 | { |
| 244 | int ret = 0; |
| 245 | |
Gao feng | 524a53e | 2012-05-28 21:04:10 +0000 | [diff] [blame] | 246 | if (proto->init_net) { |
| 247 | ret = proto->init_net(net); |
| 248 | if (ret < 0) |
| 249 | return ret; |
| 250 | } |
Gao feng | fa0f61f | 2012-06-21 04:36:38 +0000 | [diff] [blame] | 251 | |
Gao feng | 6330750 | 2013-01-21 22:10:33 +0000 | [diff] [blame] | 252 | return nf_ct_l3proto_register_sysctl(net, proto); |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 253 | } |
Gao feng | 6330750 | 2013-01-21 22:10:33 +0000 | [diff] [blame] | 254 | EXPORT_SYMBOL_GPL(nf_ct_l3proto_pernet_register); |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 255 | |
Gao feng | 6330750 | 2013-01-21 22:10:33 +0000 | [diff] [blame] | 256 | void nf_ct_l3proto_unregister(struct nf_conntrack_l3proto *proto) |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 257 | { |
Patrick McHardy | fe3eb20 | 2007-02-12 11:14:28 -0800 | [diff] [blame] | 258 | BUG_ON(proto->l3proto >= AF_MAX); |
Martin Josefsson | ae5718f | 2006-11-29 02:35:08 +0100 | [diff] [blame] | 259 | |
Patrick McHardy | b19caa0 | 2007-03-14 16:37:52 -0700 | [diff] [blame] | 260 | mutex_lock(&nf_ct_proto_mutex); |
Eric Dumazet | 0e60ebe | 2010-11-15 18:17:21 +0100 | [diff] [blame] | 261 | BUG_ON(rcu_dereference_protected(nf_ct_l3protos[proto->l3proto], |
| 262 | lockdep_is_held(&nf_ct_proto_mutex) |
| 263 | ) != proto); |
Patrick McHardy | 923f490 | 2007-02-12 11:12:57 -0800 | [diff] [blame] | 264 | rcu_assign_pointer(nf_ct_l3protos[proto->l3proto], |
| 265 | &nf_conntrack_l3proto_generic); |
Patrick McHardy | 0661cca | 2007-03-14 16:38:48 -0700 | [diff] [blame] | 266 | mutex_unlock(&nf_ct_proto_mutex); |
| 267 | |
| 268 | synchronize_rcu(); |
Gao feng | 524a53e | 2012-05-28 21:04:10 +0000 | [diff] [blame] | 269 | } |
Gao feng | 6330750 | 2013-01-21 22:10:33 +0000 | [diff] [blame] | 270 | EXPORT_SYMBOL_GPL(nf_ct_l3proto_unregister); |
Gao feng | 524a53e | 2012-05-28 21:04:10 +0000 | [diff] [blame] | 271 | |
Gao feng | 6330750 | 2013-01-21 22:10:33 +0000 | [diff] [blame] | 272 | void nf_ct_l3proto_pernet_unregister(struct net *net, |
Gao feng | 524a53e | 2012-05-28 21:04:10 +0000 | [diff] [blame] | 273 | struct nf_conntrack_l3proto *proto) |
| 274 | { |
Gao feng | 524a53e | 2012-05-28 21:04:10 +0000 | [diff] [blame] | 275 | nf_ct_l3proto_unregister_sysctl(net, proto); |
Patrick McHardy | d62f9ed | 2006-11-29 02:35:17 +0100 | [diff] [blame] | 276 | |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 277 | /* Remove all contrack entries for this protocol */ |
Florian Westphal | c655bc6 | 2013-07-29 15:41:55 +0200 | [diff] [blame] | 278 | nf_ct_iterate_cleanup(net, kill_l3proto, proto, 0, 0); |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 279 | } |
Gao feng | 6330750 | 2013-01-21 22:10:33 +0000 | [diff] [blame] | 280 | EXPORT_SYMBOL_GPL(nf_ct_l3proto_pernet_unregister); |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 281 | |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 282 | static struct nf_proto_net *nf_ct_l4proto_net(struct net *net, |
| 283 | struct nf_conntrack_l4proto *l4proto) |
| 284 | { |
Pablo Neira Ayuso | 0891147 | 2012-06-29 05:23:24 +0000 | [diff] [blame] | 285 | if (l4proto->get_net_proto) { |
| 286 | /* statically built-in protocols use static per-net */ |
| 287 | return l4proto->get_net_proto(net); |
| 288 | } else if (l4proto->net_id) { |
| 289 | /* ... and loadable protocols use dynamic per-net */ |
| 290 | return net_generic(net, *l4proto->net_id); |
Gao feng | 15f585b | 2012-05-28 21:04:11 +0000 | [diff] [blame] | 291 | } |
| 292 | return NULL; |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 293 | } |
| 294 | |
| 295 | static |
| 296 | int nf_ct_l4proto_register_sysctl(struct net *net, |
Gao feng | fa34fff | 2012-06-21 04:36:41 +0000 | [diff] [blame] | 297 | struct nf_proto_net *pn, |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 298 | struct nf_conntrack_l4proto *l4proto) |
Patrick McHardy | d62f9ed | 2006-11-29 02:35:17 +0100 | [diff] [blame] | 299 | { |
| 300 | int err = 0; |
| 301 | |
| 302 | #ifdef CONFIG_SYSCTL |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 303 | if (pn->ctl_table != NULL) { |
| 304 | err = nf_ct_register_sysctl(net, |
| 305 | &pn->ctl_table_header, |
Eric W. Biederman | f99e8f7 | 2012-04-19 13:43:55 +0000 | [diff] [blame] | 306 | "net/netfilter", |
Gao feng | fa34fff | 2012-06-21 04:36:41 +0000 | [diff] [blame] | 307 | pn->ctl_table); |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 308 | if (err < 0) { |
| 309 | if (!pn->users) { |
| 310 | kfree(pn->ctl_table); |
| 311 | pn->ctl_table = NULL; |
| 312 | } |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 313 | } |
Patrick McHardy | d62f9ed | 2006-11-29 02:35:17 +0100 | [diff] [blame] | 314 | } |
Patrick McHardy | a999e68 | 2006-11-29 02:35:20 +0100 | [diff] [blame] | 315 | #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 316 | if (l4proto->l3proto != AF_INET6 && pn->ctl_compat_table != NULL) { |
Gao feng | 12c26df | 2012-06-21 04:36:42 +0000 | [diff] [blame] | 317 | if (err < 0) { |
| 318 | nf_ct_kfree_compat_sysctl_table(pn); |
| 319 | goto out; |
| 320 | } |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 321 | err = nf_ct_register_sysctl(net, |
| 322 | &pn->ctl_compat_header, |
Eric W. Biederman | f99e8f7 | 2012-04-19 13:43:55 +0000 | [diff] [blame] | 323 | "net/ipv4/netfilter", |
Gao feng | fa34fff | 2012-06-21 04:36:41 +0000 | [diff] [blame] | 324 | pn->ctl_compat_table); |
Patrick McHardy | a999e68 | 2006-11-29 02:35:20 +0100 | [diff] [blame] | 325 | if (err == 0) |
| 326 | goto out; |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 327 | |
Gao feng | f28997e | 2012-06-21 04:36:40 +0000 | [diff] [blame] | 328 | nf_ct_kfree_compat_sysctl_table(pn); |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 329 | nf_ct_unregister_sysctl(&pn->ctl_table_header, |
| 330 | &pn->ctl_table, |
Gao feng | fa34fff | 2012-06-21 04:36:41 +0000 | [diff] [blame] | 331 | pn->users); |
Patrick McHardy | a999e68 | 2006-11-29 02:35:20 +0100 | [diff] [blame] | 332 | } |
Patrick McHardy | a999e68 | 2006-11-29 02:35:20 +0100 | [diff] [blame] | 333 | out: |
Gao feng | 12c26df | 2012-06-21 04:36:42 +0000 | [diff] [blame] | 334 | #endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */ |
Patrick McHardy | 933a41e | 2006-11-29 02:35:18 +0100 | [diff] [blame] | 335 | #endif /* CONFIG_SYSCTL */ |
Patrick McHardy | d62f9ed | 2006-11-29 02:35:17 +0100 | [diff] [blame] | 336 | return err; |
| 337 | } |
| 338 | |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 339 | static |
| 340 | void nf_ct_l4proto_unregister_sysctl(struct net *net, |
Gao feng | fa34fff | 2012-06-21 04:36:41 +0000 | [diff] [blame] | 341 | struct nf_proto_net *pn, |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 342 | struct nf_conntrack_l4proto *l4proto) |
Patrick McHardy | d62f9ed | 2006-11-29 02:35:17 +0100 | [diff] [blame] | 343 | { |
| 344 | #ifdef CONFIG_SYSCTL |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 345 | if (pn->ctl_table_header != NULL) |
| 346 | nf_ct_unregister_sysctl(&pn->ctl_table_header, |
| 347 | &pn->ctl_table, |
Gao feng | fa34fff | 2012-06-21 04:36:41 +0000 | [diff] [blame] | 348 | pn->users); |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 349 | |
Patrick McHardy | a999e68 | 2006-11-29 02:35:20 +0100 | [diff] [blame] | 350 | #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 351 | if (l4proto->l3proto != AF_INET6 && pn->ctl_compat_header != NULL) |
| 352 | nf_ct_unregister_sysctl(&pn->ctl_compat_header, |
| 353 | &pn->ctl_compat_table, |
Gao feng | fa34fff | 2012-06-21 04:36:41 +0000 | [diff] [blame] | 354 | 0); |
Patrick McHardy | a999e68 | 2006-11-29 02:35:20 +0100 | [diff] [blame] | 355 | #endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */ |
Patrick McHardy | 933a41e | 2006-11-29 02:35:18 +0100 | [diff] [blame] | 356 | #endif /* CONFIG_SYSCTL */ |
Patrick McHardy | d62f9ed | 2006-11-29 02:35:17 +0100 | [diff] [blame] | 357 | } |
| 358 | |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 359 | /* FIXME: Allow NULL functions and sub in pointers to generic for |
| 360 | them. --RR */ |
Gao feng | c296bb4 | 2013-01-23 12:51:10 +0100 | [diff] [blame] | 361 | int nf_ct_l4proto_register(struct nf_conntrack_l4proto *l4proto) |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 362 | { |
| 363 | int ret = 0; |
| 364 | |
Patrick McHardy | 0661cca | 2007-03-14 16:38:48 -0700 | [diff] [blame] | 365 | if (l4proto->l3proto >= PF_MAX) |
| 366 | return -EBUSY; |
Martin Josefsson | ae5718f | 2006-11-29 02:35:08 +0100 | [diff] [blame] | 367 | |
Holger Eitzenberger | d0dba72 | 2009-03-25 18:24:48 +0100 | [diff] [blame] | 368 | if ((l4proto->to_nlattr && !l4proto->nlattr_size) |
| 369 | || (l4proto->tuple_to_nlattr && !l4proto->nlattr_tuple_size)) |
| 370 | return -EINVAL; |
| 371 | |
Patrick McHardy | b19caa0 | 2007-03-14 16:37:52 -0700 | [diff] [blame] | 372 | mutex_lock(&nf_ct_proto_mutex); |
Patrick McHardy | c6a1e61 | 2007-03-14 16:39:07 -0700 | [diff] [blame] | 373 | if (!nf_ct_protos[l4proto->l3proto]) { |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 374 | /* l3proto may be loaded latter. */ |
Eric Dumazet | c5d277d | 2010-11-15 19:45:13 +0100 | [diff] [blame] | 375 | struct nf_conntrack_l4proto __rcu **proto_array; |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 376 | int i; |
| 377 | |
Patrick McHardy | c6a1e61 | 2007-03-14 16:39:07 -0700 | [diff] [blame] | 378 | proto_array = kmalloc(MAX_NF_CT_PROTO * |
| 379 | sizeof(struct nf_conntrack_l4proto *), |
| 380 | GFP_KERNEL); |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 381 | if (proto_array == NULL) { |
| 382 | ret = -ENOMEM; |
Patrick McHardy | b19caa0 | 2007-03-14 16:37:52 -0700 | [diff] [blame] | 383 | goto out_unlock; |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 384 | } |
Patrick McHardy | c6a1e61 | 2007-03-14 16:39:07 -0700 | [diff] [blame] | 385 | |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 386 | for (i = 0; i < MAX_NF_CT_PROTO; i++) |
Eric Dumazet | c5d277d | 2010-11-15 19:45:13 +0100 | [diff] [blame] | 387 | RCU_INIT_POINTER(proto_array[i], &nf_conntrack_l4proto_generic); |
Eric Dumazet | d817d29 | 2010-10-29 19:59:40 +0200 | [diff] [blame] | 388 | |
| 389 | /* Before making proto_array visible to lockless readers, |
| 390 | * we must make sure its content is committed to memory. |
| 391 | */ |
| 392 | smp_wmb(); |
| 393 | |
Patrick McHardy | c6a1e61 | 2007-03-14 16:39:07 -0700 | [diff] [blame] | 394 | nf_ct_protos[l4proto->l3proto] = proto_array; |
Eric Dumazet | 0e60ebe | 2010-11-15 18:17:21 +0100 | [diff] [blame] | 395 | } else if (rcu_dereference_protected( |
| 396 | nf_ct_protos[l4proto->l3proto][l4proto->l4proto], |
| 397 | lockdep_is_held(&nf_ct_proto_mutex) |
| 398 | ) != &nf_conntrack_l4proto_generic) { |
Patrick McHardy | c6a1e61 | 2007-03-14 16:39:07 -0700 | [diff] [blame] | 399 | ret = -EBUSY; |
| 400 | goto out_unlock; |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 401 | } |
| 402 | |
Holger Eitzenberger | d0dba72 | 2009-03-25 18:24:48 +0100 | [diff] [blame] | 403 | l4proto->nla_size = 0; |
| 404 | if (l4proto->nlattr_size) |
| 405 | l4proto->nla_size += l4proto->nlattr_size(); |
| 406 | if (l4proto->nlattr_tuple_size) |
| 407 | l4proto->nla_size += 3 * l4proto->nlattr_tuple_size(); |
| 408 | |
Patrick McHardy | c6a1e61 | 2007-03-14 16:39:07 -0700 | [diff] [blame] | 409 | rcu_assign_pointer(nf_ct_protos[l4proto->l3proto][l4proto->l4proto], |
| 410 | l4proto); |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 411 | out_unlock: |
Patrick McHardy | b19caa0 | 2007-03-14 16:37:52 -0700 | [diff] [blame] | 412 | mutex_unlock(&nf_ct_proto_mutex); |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 413 | return ret; |
| 414 | } |
Gao feng | c296bb4 | 2013-01-23 12:51:10 +0100 | [diff] [blame] | 415 | EXPORT_SYMBOL_GPL(nf_ct_l4proto_register); |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 416 | |
Gao feng | c296bb4 | 2013-01-23 12:51:10 +0100 | [diff] [blame] | 417 | int nf_ct_l4proto_pernet_register(struct net *net, |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 418 | struct nf_conntrack_l4proto *l4proto) |
| 419 | { |
| 420 | int ret = 0; |
Gao feng | fa34fff | 2012-06-21 04:36:41 +0000 | [diff] [blame] | 421 | struct nf_proto_net *pn = NULL; |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 422 | |
Gao feng | fa0f61f | 2012-06-21 04:36:38 +0000 | [diff] [blame] | 423 | if (l4proto->init_net) { |
Gao feng | f1caad2 | 2012-06-21 04:36:39 +0000 | [diff] [blame] | 424 | ret = l4proto->init_net(net, l4proto->l3proto); |
Gao feng | fa0f61f | 2012-06-21 04:36:38 +0000 | [diff] [blame] | 425 | if (ret < 0) |
Gao feng | fa34fff | 2012-06-21 04:36:41 +0000 | [diff] [blame] | 426 | goto out; |
Gao feng | fa0f61f | 2012-06-21 04:36:38 +0000 | [diff] [blame] | 427 | } |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 428 | |
Gao feng | fa34fff | 2012-06-21 04:36:41 +0000 | [diff] [blame] | 429 | pn = nf_ct_l4proto_net(net, l4proto); |
| 430 | if (pn == NULL) |
| 431 | goto out; |
| 432 | |
| 433 | ret = nf_ct_l4proto_register_sysctl(net, pn, l4proto); |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 434 | if (ret < 0) |
Gao feng | fa34fff | 2012-06-21 04:36:41 +0000 | [diff] [blame] | 435 | goto out; |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 436 | |
Gao feng | fa34fff | 2012-06-21 04:36:41 +0000 | [diff] [blame] | 437 | pn->users++; |
| 438 | out: |
Gao feng | fa0f61f | 2012-06-21 04:36:38 +0000 | [diff] [blame] | 439 | return ret; |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 440 | } |
Gao feng | c296bb4 | 2013-01-23 12:51:10 +0100 | [diff] [blame] | 441 | EXPORT_SYMBOL_GPL(nf_ct_l4proto_pernet_register); |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 442 | |
Gao feng | c296bb4 | 2013-01-23 12:51:10 +0100 | [diff] [blame] | 443 | void nf_ct_l4proto_unregister(struct nf_conntrack_l4proto *l4proto) |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 444 | { |
Patrick McHardy | fe3eb20 | 2007-02-12 11:14:28 -0800 | [diff] [blame] | 445 | BUG_ON(l4proto->l3proto >= PF_MAX); |
Martin Josefsson | ae5718f | 2006-11-29 02:35:08 +0100 | [diff] [blame] | 446 | |
Patrick McHardy | b19caa0 | 2007-03-14 16:37:52 -0700 | [diff] [blame] | 447 | mutex_lock(&nf_ct_proto_mutex); |
Eric Dumazet | 0e60ebe | 2010-11-15 18:17:21 +0100 | [diff] [blame] | 448 | BUG_ON(rcu_dereference_protected( |
| 449 | nf_ct_protos[l4proto->l3proto][l4proto->l4proto], |
| 450 | lockdep_is_held(&nf_ct_proto_mutex) |
| 451 | ) != l4proto); |
Patrick McHardy | 923f490 | 2007-02-12 11:12:57 -0800 | [diff] [blame] | 452 | rcu_assign_pointer(nf_ct_protos[l4proto->l3proto][l4proto->l4proto], |
| 453 | &nf_conntrack_l4proto_generic); |
Patrick McHardy | 0661cca | 2007-03-14 16:38:48 -0700 | [diff] [blame] | 454 | mutex_unlock(&nf_ct_proto_mutex); |
| 455 | |
| 456 | synchronize_rcu(); |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 457 | } |
Gao feng | c296bb4 | 2013-01-23 12:51:10 +0100 | [diff] [blame] | 458 | EXPORT_SYMBOL_GPL(nf_ct_l4proto_unregister); |
Patrick McHardy | d62f9ed | 2006-11-29 02:35:17 +0100 | [diff] [blame] | 459 | |
Gao feng | c296bb4 | 2013-01-23 12:51:10 +0100 | [diff] [blame] | 460 | void nf_ct_l4proto_pernet_unregister(struct net *net, |
Gao feng | 2c352f4 | 2012-05-28 21:04:09 +0000 | [diff] [blame] | 461 | struct nf_conntrack_l4proto *l4proto) |
| 462 | { |
Gao feng | fa34fff | 2012-06-21 04:36:41 +0000 | [diff] [blame] | 463 | struct nf_proto_net *pn = NULL; |
| 464 | |
Gao feng | fa34fff | 2012-06-21 04:36:41 +0000 | [diff] [blame] | 465 | pn = nf_ct_l4proto_net(net, l4proto); |
| 466 | if (pn == NULL) |
| 467 | return; |
| 468 | |
| 469 | pn->users--; |
| 470 | nf_ct_l4proto_unregister_sysctl(net, pn, l4proto); |
| 471 | |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 472 | /* Remove all contrack entries for this protocol */ |
Florian Westphal | c655bc6 | 2013-07-29 15:41:55 +0200 | [diff] [blame] | 473 | nf_ct_iterate_cleanup(net, kill_l4proto, l4proto, 0, 0); |
Martin Josefsson | 8f03dea | 2006-11-29 02:35:03 +0100 | [diff] [blame] | 474 | } |
Gao feng | c296bb4 | 2013-01-23 12:51:10 +0100 | [diff] [blame] | 475 | EXPORT_SYMBOL_GPL(nf_ct_l4proto_pernet_unregister); |
Patrick McHardy | ac5357e | 2007-03-14 16:38:25 -0700 | [diff] [blame] | 476 | |
Gao feng | 04d8700 | 2013-01-21 22:10:32 +0000 | [diff] [blame] | 477 | int nf_conntrack_proto_pernet_init(struct net *net) |
Patrick McHardy | ac5357e | 2007-03-14 16:38:25 -0700 | [diff] [blame] | 478 | { |
Patrick McHardy | ac5357e | 2007-03-14 16:38:25 -0700 | [diff] [blame] | 479 | int err; |
Gao feng | fa34fff | 2012-06-21 04:36:41 +0000 | [diff] [blame] | 480 | struct nf_proto_net *pn = nf_ct_l4proto_net(net, |
| 481 | &nf_conntrack_l4proto_generic); |
| 482 | |
Gao feng | f1caad2 | 2012-06-21 04:36:39 +0000 | [diff] [blame] | 483 | err = nf_conntrack_l4proto_generic.init_net(net, |
| 484 | nf_conntrack_l4proto_generic.l3proto); |
Gao feng | 15f585b | 2012-05-28 21:04:11 +0000 | [diff] [blame] | 485 | if (err < 0) |
| 486 | return err; |
| 487 | err = nf_ct_l4proto_register_sysctl(net, |
Gao feng | fa34fff | 2012-06-21 04:36:41 +0000 | [diff] [blame] | 488 | pn, |
Gao feng | 15f585b | 2012-05-28 21:04:11 +0000 | [diff] [blame] | 489 | &nf_conntrack_l4proto_generic); |
Patrick McHardy | ac5357e | 2007-03-14 16:38:25 -0700 | [diff] [blame] | 490 | if (err < 0) |
| 491 | return err; |
| 492 | |
Gao feng | fa34fff | 2012-06-21 04:36:41 +0000 | [diff] [blame] | 493 | pn->users++; |
Patrick McHardy | ac5357e | 2007-03-14 16:38:25 -0700 | [diff] [blame] | 494 | return 0; |
| 495 | } |
| 496 | |
Gao feng | 04d8700 | 2013-01-21 22:10:32 +0000 | [diff] [blame] | 497 | void nf_conntrack_proto_pernet_fini(struct net *net) |
Patrick McHardy | ac5357e | 2007-03-14 16:38:25 -0700 | [diff] [blame] | 498 | { |
Gao feng | fa34fff | 2012-06-21 04:36:41 +0000 | [diff] [blame] | 499 | struct nf_proto_net *pn = nf_ct_l4proto_net(net, |
| 500 | &nf_conntrack_l4proto_generic); |
| 501 | |
| 502 | pn->users--; |
Gao feng | 15f585b | 2012-05-28 21:04:11 +0000 | [diff] [blame] | 503 | nf_ct_l4proto_unregister_sysctl(net, |
Gao feng | fa34fff | 2012-06-21 04:36:41 +0000 | [diff] [blame] | 504 | pn, |
Gao feng | 15f585b | 2012-05-28 21:04:11 +0000 | [diff] [blame] | 505 | &nf_conntrack_l4proto_generic); |
Gao feng | 04d8700 | 2013-01-21 22:10:32 +0000 | [diff] [blame] | 506 | } |
| 507 | |
| 508 | int nf_conntrack_proto_init(void) |
| 509 | { |
| 510 | unsigned int i; |
| 511 | for (i = 0; i < AF_MAX; i++) |
| 512 | rcu_assign_pointer(nf_ct_l3protos[i], |
| 513 | &nf_conntrack_l3proto_generic); |
| 514 | return 0; |
| 515 | } |
| 516 | |
| 517 | void nf_conntrack_proto_fini(void) |
| 518 | { |
| 519 | unsigned int i; |
| 520 | /* free l3proto protocol tables */ |
| 521 | for (i = 0; i < PF_MAX; i++) |
| 522 | kfree(nf_ct_protos[i]); |
Patrick McHardy | ac5357e | 2007-03-14 16:38:25 -0700 | [diff] [blame] | 523 | } |