Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* This file contains all the functions required for the standalone |
| 2 | ip_nat module. |
| 3 | |
| 4 | These are not required by the compatibility layer. |
| 5 | */ |
| 6 | |
| 7 | /* (C) 1999-2001 Paul `Rusty' Russell |
| 8 | * (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org> |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License version 2 as |
| 12 | * published by the Free Software Foundation. |
| 13 | */ |
| 14 | |
| 15 | /* |
| 16 | * 23 Apr 2001: Harald Welte <laforge@gnumonks.org> |
| 17 | * - new API and handling of conntrack/nat helpers |
| 18 | * - now capable of multiple expectations for one master |
| 19 | * */ |
| 20 | |
| 21 | #include <linux/config.h> |
| 22 | #include <linux/types.h> |
| 23 | #include <linux/icmp.h> |
| 24 | #include <linux/ip.h> |
| 25 | #include <linux/netfilter.h> |
| 26 | #include <linux/netfilter_ipv4.h> |
| 27 | #include <linux/module.h> |
| 28 | #include <linux/skbuff.h> |
| 29 | #include <linux/proc_fs.h> |
| 30 | #include <net/ip.h> |
| 31 | #include <net/checksum.h> |
| 32 | #include <linux/spinlock.h> |
| 33 | |
Patrick McHardy | e45b1be | 2005-06-21 14:01:30 -0700 | [diff] [blame] | 34 | #define ASSERT_READ_LOCK(x) |
| 35 | #define ASSERT_WRITE_LOCK(x) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
| 37 | #include <linux/netfilter_ipv4/ip_nat.h> |
| 38 | #include <linux/netfilter_ipv4/ip_nat_rule.h> |
| 39 | #include <linux/netfilter_ipv4/ip_nat_protocol.h> |
| 40 | #include <linux/netfilter_ipv4/ip_nat_core.h> |
| 41 | #include <linux/netfilter_ipv4/ip_nat_helper.h> |
| 42 | #include <linux/netfilter_ipv4/ip_tables.h> |
| 43 | #include <linux/netfilter_ipv4/ip_conntrack_core.h> |
| 44 | #include <linux/netfilter_ipv4/listhelp.h> |
| 45 | |
| 46 | #if 0 |
| 47 | #define DEBUGP printk |
| 48 | #else |
| 49 | #define DEBUGP(format, args...) |
| 50 | #endif |
| 51 | |
| 52 | #define HOOKNAME(hooknum) ((hooknum) == NF_IP_POST_ROUTING ? "POST_ROUTING" \ |
| 53 | : ((hooknum) == NF_IP_PRE_ROUTING ? "PRE_ROUTING" \ |
| 54 | : ((hooknum) == NF_IP_LOCAL_OUT ? "LOCAL_OUT" \ |
| 55 | : ((hooknum) == NF_IP_LOCAL_IN ? "LOCAL_IN" \ |
| 56 | : "*ERROR*"))) |
| 57 | |
Patrick McHardy | eb9c7eb | 2006-01-06 23:06:30 -0800 | [diff] [blame] | 58 | #ifdef CONFIG_XFRM |
| 59 | static void nat_decode_session(struct sk_buff *skb, struct flowi *fl) |
| 60 | { |
| 61 | struct ip_conntrack *ct; |
| 62 | struct ip_conntrack_tuple *t; |
| 63 | enum ip_conntrack_info ctinfo; |
| 64 | enum ip_conntrack_dir dir; |
| 65 | unsigned long statusbit; |
| 66 | |
| 67 | ct = ip_conntrack_get(skb, &ctinfo); |
| 68 | if (ct == NULL) |
| 69 | return; |
| 70 | dir = CTINFO2DIR(ctinfo); |
| 71 | t = &ct->tuplehash[dir].tuple; |
| 72 | |
| 73 | if (dir == IP_CT_DIR_ORIGINAL) |
| 74 | statusbit = IPS_DST_NAT; |
| 75 | else |
| 76 | statusbit = IPS_SRC_NAT; |
| 77 | |
| 78 | if (ct->status & statusbit) { |
| 79 | fl->fl4_dst = t->dst.ip; |
| 80 | if (t->dst.protonum == IPPROTO_TCP || |
| 81 | t->dst.protonum == IPPROTO_UDP) |
| 82 | fl->fl_ip_dport = t->dst.u.tcp.port; |
| 83 | } |
| 84 | |
| 85 | statusbit ^= IPS_NAT_MASK; |
| 86 | |
| 87 | if (ct->status & statusbit) { |
| 88 | fl->fl4_src = t->src.ip; |
| 89 | if (t->dst.protonum == IPPROTO_TCP || |
| 90 | t->dst.protonum == IPPROTO_UDP) |
| 91 | fl->fl_ip_sport = t->src.u.tcp.port; |
| 92 | } |
| 93 | } |
| 94 | #endif |
| 95 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | static unsigned int |
| 97 | ip_nat_fn(unsigned int hooknum, |
| 98 | struct sk_buff **pskb, |
| 99 | const struct net_device *in, |
| 100 | const struct net_device *out, |
| 101 | int (*okfn)(struct sk_buff *)) |
| 102 | { |
| 103 | struct ip_conntrack *ct; |
| 104 | enum ip_conntrack_info ctinfo; |
| 105 | struct ip_nat_info *info; |
| 106 | /* maniptype == SRC for postrouting. */ |
| 107 | enum ip_nat_manip_type maniptype = HOOK2MANIP(hooknum); |
| 108 | |
| 109 | /* We never see fragments: conntrack defrags on pre-routing |
| 110 | and local-out, and ip_nat_out protects post-routing. */ |
| 111 | IP_NF_ASSERT(!((*pskb)->nh.iph->frag_off |
| 112 | & htons(IP_MF|IP_OFFSET))); |
| 113 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | /* If we had a hardware checksum before, it's now invalid */ |
| 115 | if ((*pskb)->ip_summed == CHECKSUM_HW) |
| 116 | if (skb_checksum_help(*pskb, (out == NULL))) |
| 117 | return NF_DROP; |
| 118 | |
| 119 | ct = ip_conntrack_get(*pskb, &ctinfo); |
| 120 | /* Can't track? It's not due to stress, or conntrack would |
| 121 | have dropped it. Hence it's the user's responsibilty to |
| 122 | packet filter it out, or implement conntrack/NAT for that |
| 123 | protocol. 8) --RR */ |
| 124 | if (!ct) { |
| 125 | /* Exception: ICMP redirect to new connection (not in |
| 126 | hash table yet). We must not let this through, in |
| 127 | case we're doing NAT to the same network. */ |
| 128 | if ((*pskb)->nh.iph->protocol == IPPROTO_ICMP) { |
| 129 | struct icmphdr _hdr, *hp; |
| 130 | |
| 131 | hp = skb_header_pointer(*pskb, |
| 132 | (*pskb)->nh.iph->ihl*4, |
| 133 | sizeof(_hdr), &_hdr); |
| 134 | if (hp != NULL && |
| 135 | hp->type == ICMP_REDIRECT) |
| 136 | return NF_DROP; |
| 137 | } |
| 138 | return NF_ACCEPT; |
| 139 | } |
| 140 | |
Harald Welte | 8b83bc7 | 2005-08-08 11:50:55 +0200 | [diff] [blame] | 141 | /* Don't try to NAT if this packet is not conntracked */ |
| 142 | if (ct == &ip_conntrack_untracked) |
| 143 | return NF_ACCEPT; |
| 144 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | switch (ctinfo) { |
| 146 | case IP_CT_RELATED: |
| 147 | case IP_CT_RELATED+IP_CT_IS_REPLY: |
| 148 | if ((*pskb)->nh.iph->protocol == IPPROTO_ICMP) { |
Harald Welte | 188bab3 | 2005-09-26 15:25:11 -0700 | [diff] [blame] | 149 | if (!ip_nat_icmp_reply_translation(pskb, ct, maniptype, |
| 150 | CTINFO2DIR(ctinfo))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | return NF_DROP; |
| 152 | else |
| 153 | return NF_ACCEPT; |
| 154 | } |
| 155 | /* Fall thru... (Only ICMPs can be IP_CT_IS_REPLY) */ |
| 156 | case IP_CT_NEW: |
| 157 | info = &ct->nat.info; |
| 158 | |
| 159 | /* Seen it before? This can happen for loopback, retrans, |
| 160 | or local packets.. */ |
| 161 | if (!ip_nat_initialized(ct, maniptype)) { |
| 162 | unsigned int ret; |
| 163 | |
Patrick McHardy | 03486a4 | 2005-09-06 15:09:43 -0700 | [diff] [blame] | 164 | if (unlikely(is_confirmed(ct))) |
| 165 | /* NAT module was loaded late */ |
| 166 | ret = alloc_null_binding_confirmed(ct, info, |
| 167 | hooknum); |
| 168 | else if (hooknum == NF_IP_LOCAL_IN) |
| 169 | /* LOCAL_IN hook doesn't have a chain! */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | ret = alloc_null_binding(ct, info, hooknum); |
| 171 | else |
| 172 | ret = ip_nat_rule_find(pskb, hooknum, |
| 173 | in, out, ct, |
| 174 | info); |
| 175 | |
| 176 | if (ret != NF_ACCEPT) { |
| 177 | return ret; |
| 178 | } |
| 179 | } else |
| 180 | DEBUGP("Already setup manip %s for ct %p\n", |
| 181 | maniptype == IP_NAT_MANIP_SRC ? "SRC" : "DST", |
| 182 | ct); |
| 183 | break; |
| 184 | |
| 185 | default: |
| 186 | /* ESTABLISHED */ |
| 187 | IP_NF_ASSERT(ctinfo == IP_CT_ESTABLISHED |
| 188 | || ctinfo == (IP_CT_ESTABLISHED+IP_CT_IS_REPLY)); |
| 189 | info = &ct->nat.info; |
| 190 | } |
| 191 | |
| 192 | IP_NF_ASSERT(info); |
Harald Welte | 188bab3 | 2005-09-26 15:25:11 -0700 | [diff] [blame] | 193 | return ip_nat_packet(ct, ctinfo, hooknum, pskb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | static unsigned int |
| 197 | ip_nat_in(unsigned int hooknum, |
| 198 | struct sk_buff **pskb, |
| 199 | const struct net_device *in, |
| 200 | const struct net_device *out, |
| 201 | int (*okfn)(struct sk_buff *)) |
| 202 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | unsigned int ret; |
Patrick McHardy | 8e249f0 | 2006-02-19 22:29:47 -0800 | [diff] [blame] | 204 | u_int32_t daddr = (*pskb)->nh.iph->daddr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | ret = ip_nat_fn(hooknum, pskb, in, out, okfn); |
| 207 | if (ret != NF_DROP && ret != NF_STOLEN |
Patrick McHardy | 8e249f0 | 2006-02-19 22:29:47 -0800 | [diff] [blame] | 208 | && daddr != (*pskb)->nh.iph->daddr) { |
| 209 | dst_release((*pskb)->dst); |
| 210 | (*pskb)->dst = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | } |
| 212 | return ret; |
| 213 | } |
| 214 | |
| 215 | static unsigned int |
| 216 | ip_nat_out(unsigned int hooknum, |
| 217 | struct sk_buff **pskb, |
| 218 | const struct net_device *in, |
| 219 | const struct net_device *out, |
| 220 | int (*okfn)(struct sk_buff *)) |
| 221 | { |
Patrick McHardy | 2354fea | 2006-05-03 23:19:26 -0700 | [diff] [blame] | 222 | #ifdef CONFIG_XFRM |
Patrick McHardy | 5c901da | 2006-01-06 23:05:36 -0800 | [diff] [blame] | 223 | struct ip_conntrack *ct; |
| 224 | enum ip_conntrack_info ctinfo; |
Patrick McHardy | 2354fea | 2006-05-03 23:19:26 -0700 | [diff] [blame] | 225 | #endif |
Patrick McHardy | 5c901da | 2006-01-06 23:05:36 -0800 | [diff] [blame] | 226 | unsigned int ret; |
| 227 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | /* root is playing with raw sockets. */ |
| 229 | if ((*pskb)->len < sizeof(struct iphdr) |
| 230 | || (*pskb)->nh.iph->ihl * 4 < sizeof(struct iphdr)) |
| 231 | return NF_ACCEPT; |
| 232 | |
Patrick McHardy | 5c901da | 2006-01-06 23:05:36 -0800 | [diff] [blame] | 233 | ret = ip_nat_fn(hooknum, pskb, in, out, okfn); |
Patrick McHardy | ee68cea | 2006-02-15 01:34:23 -0800 | [diff] [blame] | 234 | #ifdef CONFIG_XFRM |
Patrick McHardy | 5c901da | 2006-01-06 23:05:36 -0800 | [diff] [blame] | 235 | if (ret != NF_DROP && ret != NF_STOLEN |
| 236 | && (ct = ip_conntrack_get(*pskb, &ctinfo)) != NULL) { |
| 237 | enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo); |
| 238 | |
| 239 | if (ct->tuplehash[dir].tuple.src.ip != |
| 240 | ct->tuplehash[!dir].tuple.dst.ip |
Patrick McHardy | 5c901da | 2006-01-06 23:05:36 -0800 | [diff] [blame] | 241 | || ct->tuplehash[dir].tuple.src.u.all != |
| 242 | ct->tuplehash[!dir].tuple.dst.u.all |
Patrick McHardy | 5c901da | 2006-01-06 23:05:36 -0800 | [diff] [blame] | 243 | ) |
Patrick McHardy | ee68cea | 2006-02-15 01:34:23 -0800 | [diff] [blame] | 244 | return ip_xfrm_me_harder(pskb) == 0 ? ret : NF_DROP; |
Patrick McHardy | 5c901da | 2006-01-06 23:05:36 -0800 | [diff] [blame] | 245 | } |
Patrick McHardy | ee68cea | 2006-02-15 01:34:23 -0800 | [diff] [blame] | 246 | #endif |
Patrick McHardy | 5c901da | 2006-01-06 23:05:36 -0800 | [diff] [blame] | 247 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | static unsigned int |
| 251 | ip_nat_local_fn(unsigned int hooknum, |
| 252 | struct sk_buff **pskb, |
| 253 | const struct net_device *in, |
| 254 | const struct net_device *out, |
| 255 | int (*okfn)(struct sk_buff *)) |
| 256 | { |
Patrick McHardy | 4e8e9de | 2006-01-06 23:05:17 -0800 | [diff] [blame] | 257 | struct ip_conntrack *ct; |
| 258 | enum ip_conntrack_info ctinfo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | unsigned int ret; |
| 260 | |
| 261 | /* root is playing with raw sockets. */ |
| 262 | if ((*pskb)->len < sizeof(struct iphdr) |
| 263 | || (*pskb)->nh.iph->ihl * 4 < sizeof(struct iphdr)) |
| 264 | return NF_ACCEPT; |
| 265 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | ret = ip_nat_fn(hooknum, pskb, in, out, okfn); |
| 267 | if (ret != NF_DROP && ret != NF_STOLEN |
Patrick McHardy | 4e8e9de | 2006-01-06 23:05:17 -0800 | [diff] [blame] | 268 | && (ct = ip_conntrack_get(*pskb, &ctinfo)) != NULL) { |
| 269 | enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo); |
| 270 | |
| 271 | if (ct->tuplehash[dir].tuple.dst.ip != |
Patrick McHardy | 5c901da | 2006-01-06 23:05:36 -0800 | [diff] [blame] | 272 | ct->tuplehash[!dir].tuple.src.ip |
| 273 | #ifdef CONFIG_XFRM |
| 274 | || ct->tuplehash[dir].tuple.dst.u.all != |
Patrick McHardy | 8e249f0 | 2006-02-19 22:29:47 -0800 | [diff] [blame] | 275 | ct->tuplehash[!dir].tuple.src.u.all |
Patrick McHardy | 5c901da | 2006-01-06 23:05:36 -0800 | [diff] [blame] | 276 | #endif |
| 277 | ) |
Patrick McHardy | 4e8e9de | 2006-01-06 23:05:17 -0800 | [diff] [blame] | 278 | return ip_route_me_harder(pskb) == 0 ? ret : NF_DROP; |
| 279 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | return ret; |
| 281 | } |
| 282 | |
Patrick McHardy | e281e3a | 2005-04-24 18:41:38 -0700 | [diff] [blame] | 283 | static unsigned int |
| 284 | ip_nat_adjust(unsigned int hooknum, |
| 285 | struct sk_buff **pskb, |
| 286 | const struct net_device *in, |
| 287 | const struct net_device *out, |
| 288 | int (*okfn)(struct sk_buff *)) |
| 289 | { |
| 290 | struct ip_conntrack *ct; |
| 291 | enum ip_conntrack_info ctinfo; |
| 292 | |
| 293 | ct = ip_conntrack_get(*pskb, &ctinfo); |
| 294 | if (ct && test_bit(IPS_SEQ_ADJUST_BIT, &ct->status)) { |
| 295 | DEBUGP("ip_nat_standalone: adjusting sequence number\n"); |
| 296 | if (!ip_nat_seq_adjust(pskb, ct, ctinfo)) |
| 297 | return NF_DROP; |
| 298 | } |
| 299 | return NF_ACCEPT; |
| 300 | } |
| 301 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | /* We must be after connection tracking and before packet filtering. */ |
| 303 | |
Patrick McHardy | 964ddaa | 2006-04-06 14:09:49 -0700 | [diff] [blame] | 304 | static struct nf_hook_ops ip_nat_ops[] = { |
| 305 | /* Before packet filtering, change destination */ |
| 306 | { |
| 307 | .hook = ip_nat_in, |
| 308 | .owner = THIS_MODULE, |
| 309 | .pf = PF_INET, |
| 310 | .hooknum = NF_IP_PRE_ROUTING, |
| 311 | .priority = NF_IP_PRI_NAT_DST, |
| 312 | }, |
| 313 | /* After packet filtering, change source */ |
| 314 | { |
| 315 | .hook = ip_nat_out, |
| 316 | .owner = THIS_MODULE, |
| 317 | .pf = PF_INET, |
| 318 | .hooknum = NF_IP_POST_ROUTING, |
| 319 | .priority = NF_IP_PRI_NAT_SRC, |
| 320 | }, |
| 321 | /* After conntrack, adjust sequence number */ |
| 322 | { |
| 323 | .hook = ip_nat_adjust, |
| 324 | .owner = THIS_MODULE, |
| 325 | .pf = PF_INET, |
| 326 | .hooknum = NF_IP_POST_ROUTING, |
| 327 | .priority = NF_IP_PRI_NAT_SEQ_ADJUST, |
| 328 | }, |
| 329 | /* Before packet filtering, change destination */ |
| 330 | { |
| 331 | .hook = ip_nat_local_fn, |
| 332 | .owner = THIS_MODULE, |
| 333 | .pf = PF_INET, |
| 334 | .hooknum = NF_IP_LOCAL_OUT, |
| 335 | .priority = NF_IP_PRI_NAT_DST, |
| 336 | }, |
| 337 | /* After packet filtering, change source */ |
| 338 | { |
| 339 | .hook = ip_nat_fn, |
| 340 | .owner = THIS_MODULE, |
| 341 | .pf = PF_INET, |
| 342 | .hooknum = NF_IP_LOCAL_IN, |
| 343 | .priority = NF_IP_PRI_NAT_SRC, |
| 344 | }, |
| 345 | /* After conntrack, adjust sequence number */ |
| 346 | { |
| 347 | .hook = ip_nat_adjust, |
| 348 | .owner = THIS_MODULE, |
| 349 | .pf = PF_INET, |
| 350 | .hooknum = NF_IP_LOCAL_IN, |
| 351 | .priority = NF_IP_PRI_NAT_SEQ_ADJUST, |
| 352 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | }; |
| 354 | |
Patrick McHardy | 32292a7 | 2006-04-06 14:11:30 -0700 | [diff] [blame] | 355 | static int __init ip_nat_standalone_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | { |
| 357 | int ret = 0; |
| 358 | |
Harald Welte | 2e4e6a1 | 2006-01-12 13:30:04 -0800 | [diff] [blame] | 359 | need_conntrack(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | |
Patrick McHardy | eb9c7eb | 2006-01-06 23:06:30 -0800 | [diff] [blame] | 361 | #ifdef CONFIG_XFRM |
| 362 | BUG_ON(ip_nat_decode_session != NULL); |
| 363 | ip_nat_decode_session = nat_decode_session; |
| 364 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | ret = ip_nat_rule_init(); |
| 366 | if (ret < 0) { |
| 367 | printk("ip_nat_init: can't setup rules.\n"); |
Patrick McHardy | eb9c7eb | 2006-01-06 23:06:30 -0800 | [diff] [blame] | 368 | goto cleanup_decode_session; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | } |
Patrick McHardy | 964ddaa | 2006-04-06 14:09:49 -0700 | [diff] [blame] | 370 | ret = nf_register_hooks(ip_nat_ops, ARRAY_SIZE(ip_nat_ops)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | if (ret < 0) { |
Patrick McHardy | 964ddaa | 2006-04-06 14:09:49 -0700 | [diff] [blame] | 372 | printk("ip_nat_init: can't register hooks.\n"); |
Harald Welte | 188bab3 | 2005-09-26 15:25:11 -0700 | [diff] [blame] | 373 | goto cleanup_rule_init; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | return ret; |
| 376 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | cleanup_rule_init: |
| 378 | ip_nat_rule_cleanup(); |
Patrick McHardy | eb9c7eb | 2006-01-06 23:06:30 -0800 | [diff] [blame] | 379 | cleanup_decode_session: |
| 380 | #ifdef CONFIG_XFRM |
| 381 | ip_nat_decode_session = NULL; |
| 382 | synchronize_net(); |
| 383 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | return ret; |
| 385 | } |
| 386 | |
Andrew Morton | 65b4b4e | 2006-03-28 16:37:06 -0800 | [diff] [blame] | 387 | static void __exit ip_nat_standalone_fini(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | { |
Patrick McHardy | 32292a7 | 2006-04-06 14:11:30 -0700 | [diff] [blame] | 389 | nf_unregister_hooks(ip_nat_ops, ARRAY_SIZE(ip_nat_ops)); |
| 390 | ip_nat_rule_cleanup(); |
| 391 | #ifdef CONFIG_XFRM |
| 392 | ip_nat_decode_session = NULL; |
| 393 | synchronize_net(); |
| 394 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | } |
| 396 | |
Andrew Morton | 65b4b4e | 2006-03-28 16:37:06 -0800 | [diff] [blame] | 397 | module_init(ip_nat_standalone_init); |
| 398 | module_exit(ip_nat_standalone_fini); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | MODULE_LICENSE("GPL"); |