diff options
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/netfilter/Kconfig | 10 | ||||
-rw-r--r-- | net/ipv6/netfilter/Makefile | 1 | ||||
-rw-r--r-- | net/ipv6/netfilter/ip6t_REDIRECT.c | 98 |
3 files changed, 0 insertions, 109 deletions
diff --git a/net/ipv6/netfilter/Kconfig b/net/ipv6/netfilter/Kconfig index 007bb450f04..c72532a60d8 100644 --- a/net/ipv6/netfilter/Kconfig +++ b/net/ipv6/netfilter/Kconfig | |||
@@ -209,16 +209,6 @@ config IP6_NF_TARGET_MASQUERADE | |||
209 | 209 | ||
210 | To compile it as a module, choose M here. If unsure, say N. | 210 | To compile it as a module, choose M here. If unsure, say N. |
211 | 211 | ||
212 | config IP6_NF_TARGET_REDIRECT | ||
213 | tristate "REDIRECT target support" | ||
214 | help | ||
215 | REDIRECT is a special case of NAT: all incoming connections are | ||
216 | mapped onto the incoming interface's address, causing the packets to | ||
217 | come to the local machine instead of passing through. This is | ||
218 | useful for transparent proxies. | ||
219 | |||
220 | To compile it as a module, choose M here. If unsure, say N. | ||
221 | |||
222 | config IP6_NF_TARGET_NPT | 212 | config IP6_NF_TARGET_NPT |
223 | tristate "NPT (Network Prefix translation) target support" | 213 | tristate "NPT (Network Prefix translation) target support" |
224 | help | 214 | help |
diff --git a/net/ipv6/netfilter/Makefile b/net/ipv6/netfilter/Makefile index de8e0d11338..2d11fcc2cf3 100644 --- a/net/ipv6/netfilter/Makefile +++ b/net/ipv6/netfilter/Makefile | |||
@@ -36,5 +36,4 @@ obj-$(CONFIG_IP6_NF_MATCH_RT) += ip6t_rt.o | |||
36 | # targets | 36 | # targets |
37 | obj-$(CONFIG_IP6_NF_TARGET_MASQUERADE) += ip6t_MASQUERADE.o | 37 | obj-$(CONFIG_IP6_NF_TARGET_MASQUERADE) += ip6t_MASQUERADE.o |
38 | obj-$(CONFIG_IP6_NF_TARGET_NPT) += ip6t_NPT.o | 38 | obj-$(CONFIG_IP6_NF_TARGET_NPT) += ip6t_NPT.o |
39 | obj-$(CONFIG_IP6_NF_TARGET_REDIRECT) += ip6t_REDIRECT.o | ||
40 | obj-$(CONFIG_IP6_NF_TARGET_REJECT) += ip6t_REJECT.o | 39 | obj-$(CONFIG_IP6_NF_TARGET_REJECT) += ip6t_REJECT.o |
diff --git a/net/ipv6/netfilter/ip6t_REDIRECT.c b/net/ipv6/netfilter/ip6t_REDIRECT.c deleted file mode 100644 index 60497a3c600..00000000000 --- a/net/ipv6/netfilter/ip6t_REDIRECT.c +++ /dev/null | |||
@@ -1,98 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2011 Patrick McHardy <kaber@trash.net> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | * | ||
8 | * Based on Rusty Russell's IPv4 REDIRECT target. Development of IPv6 | ||
9 | * NAT funded by Astaro. | ||
10 | */ | ||
11 | |||
12 | #include <linux/kernel.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/netfilter.h> | ||
15 | #include <linux/netfilter_ipv6.h> | ||
16 | #include <linux/netfilter/x_tables.h> | ||
17 | #include <net/addrconf.h> | ||
18 | #include <net/netfilter/nf_nat.h> | ||
19 | |||
20 | static const struct in6_addr loopback_addr = IN6ADDR_LOOPBACK_INIT; | ||
21 | |||
22 | static unsigned int | ||
23 | redirect_tg6(struct sk_buff *skb, const struct xt_action_param *par) | ||
24 | { | ||
25 | const struct nf_nat_range *range = par->targinfo; | ||
26 | struct nf_nat_range newrange; | ||
27 | struct in6_addr newdst; | ||
28 | enum ip_conntrack_info ctinfo; | ||
29 | struct nf_conn *ct; | ||
30 | |||
31 | ct = nf_ct_get(skb, &ctinfo); | ||
32 | if (par->hooknum == NF_INET_LOCAL_OUT) | ||
33 | newdst = loopback_addr; | ||
34 | else { | ||
35 | struct inet6_dev *idev; | ||
36 | struct inet6_ifaddr *ifa; | ||
37 | bool addr = false; | ||
38 | |||
39 | rcu_read_lock(); | ||
40 | idev = __in6_dev_get(skb->dev); | ||
41 | if (idev != NULL) { | ||
42 | list_for_each_entry(ifa, &idev->addr_list, if_list) { | ||
43 | newdst = ifa->addr; | ||
44 | addr = true; | ||
45 | break; | ||
46 | } | ||
47 | } | ||
48 | rcu_read_unlock(); | ||
49 | |||
50 | if (!addr) | ||
51 | return NF_DROP; | ||
52 | } | ||
53 | |||
54 | newrange.flags = range->flags | NF_NAT_RANGE_MAP_IPS; | ||
55 | newrange.min_addr.in6 = newdst; | ||
56 | newrange.max_addr.in6 = newdst; | ||
57 | newrange.min_proto = range->min_proto; | ||
58 | newrange.max_proto = range->max_proto; | ||
59 | |||
60 | return nf_nat_setup_info(ct, &newrange, NF_NAT_MANIP_DST); | ||
61 | } | ||
62 | |||
63 | static int redirect_tg6_checkentry(const struct xt_tgchk_param *par) | ||
64 | { | ||
65 | const struct nf_nat_range *range = par->targinfo; | ||
66 | |||
67 | if (range->flags & NF_NAT_RANGE_MAP_IPS) | ||
68 | return -EINVAL; | ||
69 | return 0; | ||
70 | } | ||
71 | |||
72 | static struct xt_target redirect_tg6_reg __read_mostly = { | ||
73 | .name = "REDIRECT", | ||
74 | .family = NFPROTO_IPV6, | ||
75 | .checkentry = redirect_tg6_checkentry, | ||
76 | .target = redirect_tg6, | ||
77 | .targetsize = sizeof(struct nf_nat_range), | ||
78 | .table = "nat", | ||
79 | .hooks = (1 << NF_INET_PRE_ROUTING) | (1 << NF_INET_LOCAL_OUT), | ||
80 | .me = THIS_MODULE, | ||
81 | }; | ||
82 | |||
83 | static int __init redirect_tg6_init(void) | ||
84 | { | ||
85 | return xt_register_target(&redirect_tg6_reg); | ||
86 | } | ||
87 | |||
88 | static void __exit redirect_tg6_exit(void) | ||
89 | { | ||
90 | xt_unregister_target(&redirect_tg6_reg); | ||
91 | } | ||
92 | |||
93 | module_init(redirect_tg6_init); | ||
94 | module_exit(redirect_tg6_exit); | ||
95 | |||
96 | MODULE_LICENSE("GPL"); | ||
97 | MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>"); | ||
98 | MODULE_DESCRIPTION("Xtables: Connection redirection to localhost"); | ||