diff options
| author | Pablo Neira Ayuso <pablo@netfilter.org> | 2014-11-26 06:46:50 -0500 |
|---|---|---|
| committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2014-11-27 07:08:42 -0500 |
| commit | b59eaf9e2871735ea7cc7e3dbf8bf83bddd786b9 (patch) | |
| tree | e566e49ab6f1736c5e5ce600ca5c9741f6c694a0 | |
| parent | 1b63d4b9b54cee6002757a8d20b537aa4037ae8f (diff) | |
netfilter: combine IPv4 and IPv6 nf_nat_redirect code in one module
This resolves linking problems with CONFIG_IPV6=n:
net/built-in.o: In function `redirect_tg6':
xt_REDIRECT.c:(.text+0x6d021): undefined reference to `nf_nat_redirect_ipv6'
Reported-by: Andreas Ruprecht <rupran@einserver.de>
Reported-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
| -rw-r--r-- | include/net/netfilter/ipv4/nf_nat_redirect.h | 9 | ||||
| -rw-r--r-- | include/net/netfilter/ipv6/nf_nat_redirect.h | 8 | ||||
| -rw-r--r-- | include/net/netfilter/nf_nat_redirect.h | 12 | ||||
| -rw-r--r-- | net/ipv4/netfilter/Kconfig | 8 | ||||
| -rw-r--r-- | net/ipv4/netfilter/Makefile | 1 | ||||
| -rw-r--r-- | net/ipv4/netfilter/nft_redir_ipv4.c | 2 | ||||
| -rw-r--r-- | net/ipv6/netfilter/Kconfig | 8 | ||||
| -rw-r--r-- | net/ipv6/netfilter/Makefile | 1 | ||||
| -rw-r--r-- | net/ipv6/netfilter/nf_nat_redirect_ipv6.c | 75 | ||||
| -rw-r--r-- | net/ipv6/netfilter/nft_redir_ipv6.c | 2 | ||||
| -rw-r--r-- | net/netfilter/Kconfig | 10 | ||||
| -rw-r--r-- | net/netfilter/Makefile | 1 | ||||
| -rw-r--r-- | net/netfilter/nf_nat_redirect.c (renamed from net/ipv4/netfilter/nf_nat_redirect_ipv4.c) | 47 | ||||
| -rw-r--r-- | net/netfilter/xt_REDIRECT.c | 3 |
14 files changed, 72 insertions, 115 deletions
diff --git a/include/net/netfilter/ipv4/nf_nat_redirect.h b/include/net/netfilter/ipv4/nf_nat_redirect.h deleted file mode 100644 index 19e1df3a0a4d..000000000000 --- a/include/net/netfilter/ipv4/nf_nat_redirect.h +++ /dev/null | |||
| @@ -1,9 +0,0 @@ | |||
| 1 | #ifndef _NF_NAT_REDIRECT_IPV4_H_ | ||
| 2 | #define _NF_NAT_REDIRECT_IPV4_H_ | ||
| 3 | |||
| 4 | unsigned int | ||
| 5 | nf_nat_redirect_ipv4(struct sk_buff *skb, | ||
| 6 | const struct nf_nat_ipv4_multi_range_compat *mr, | ||
| 7 | unsigned int hooknum); | ||
| 8 | |||
| 9 | #endif /* _NF_NAT_REDIRECT_IPV4_H_ */ | ||
diff --git a/include/net/netfilter/ipv6/nf_nat_redirect.h b/include/net/netfilter/ipv6/nf_nat_redirect.h deleted file mode 100644 index 1ebdffc461cc..000000000000 --- a/include/net/netfilter/ipv6/nf_nat_redirect.h +++ /dev/null | |||
| @@ -1,8 +0,0 @@ | |||
| 1 | #ifndef _NF_NAT_REDIRECT_IPV6_H_ | ||
| 2 | #define _NF_NAT_REDIRECT_IPV6_H_ | ||
| 3 | |||
| 4 | unsigned int | ||
| 5 | nf_nat_redirect_ipv6(struct sk_buff *skb, const struct nf_nat_range *range, | ||
| 6 | unsigned int hooknum); | ||
| 7 | |||
| 8 | #endif /* _NF_NAT_REDIRECT_IPV6_H_ */ | ||
diff --git a/include/net/netfilter/nf_nat_redirect.h b/include/net/netfilter/nf_nat_redirect.h new file mode 100644 index 000000000000..73b729543309 --- /dev/null +++ b/include/net/netfilter/nf_nat_redirect.h | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | #ifndef _NF_NAT_REDIRECT_H_ | ||
| 2 | #define _NF_NAT_REDIRECT_H_ | ||
| 3 | |||
| 4 | unsigned int | ||
| 5 | nf_nat_redirect_ipv4(struct sk_buff *skb, | ||
| 6 | const struct nf_nat_ipv4_multi_range_compat *mr, | ||
| 7 | unsigned int hooknum); | ||
| 8 | unsigned int | ||
| 9 | nf_nat_redirect_ipv6(struct sk_buff *skb, const struct nf_nat_range *range, | ||
| 10 | unsigned int hooknum); | ||
| 11 | |||
| 12 | #endif /* _NF_NAT_REDIRECT_H_ */ | ||
diff --git a/net/ipv4/netfilter/Kconfig b/net/ipv4/netfilter/Kconfig index 8358b2da1549..59f883d9cadf 100644 --- a/net/ipv4/netfilter/Kconfig +++ b/net/ipv4/netfilter/Kconfig | |||
| @@ -104,12 +104,6 @@ config NF_NAT_MASQUERADE_IPV4 | |||
| 104 | This is the kernel functionality to provide NAT in the masquerade | 104 | This is the kernel functionality to provide NAT in the masquerade |
| 105 | flavour (automatic source address selection). | 105 | flavour (automatic source address selection). |
| 106 | 106 | ||
| 107 | config NF_NAT_REDIRECT_IPV4 | ||
| 108 | tristate "IPv4 redirect support" | ||
| 109 | help | ||
| 110 | This is the kernel functionality to provide NAT in the redirect | ||
| 111 | flavour (redirect packets to local machine). | ||
| 112 | |||
| 113 | config NFT_MASQ_IPV4 | 107 | config NFT_MASQ_IPV4 |
| 114 | tristate "IPv4 masquerading support for nf_tables" | 108 | tristate "IPv4 masquerading support for nf_tables" |
| 115 | depends on NF_TABLES_IPV4 | 109 | depends on NF_TABLES_IPV4 |
| @@ -123,7 +117,7 @@ config NFT_REDIR_IPV4 | |||
| 123 | tristate "IPv4 redirect support for nf_tables" | 117 | tristate "IPv4 redirect support for nf_tables" |
| 124 | depends on NF_TABLES_IPV4 | 118 | depends on NF_TABLES_IPV4 |
| 125 | depends on NFT_REDIR | 119 | depends on NFT_REDIR |
| 126 | select NF_NAT_REDIRECT_IPV4 | 120 | select NF_NAT_REDIRECT |
| 127 | help | 121 | help |
| 128 | This is the expression that provides IPv4 redirect support for | 122 | This is the expression that provides IPv4 redirect support for |
| 129 | nf_tables. | 123 | nf_tables. |
diff --git a/net/ipv4/netfilter/Makefile b/net/ipv4/netfilter/Makefile index 902bcd1597bb..7fe6c703528f 100644 --- a/net/ipv4/netfilter/Makefile +++ b/net/ipv4/netfilter/Makefile | |||
| @@ -31,7 +31,6 @@ obj-$(CONFIG_NF_NAT_H323) += nf_nat_h323.o | |||
| 31 | obj-$(CONFIG_NF_NAT_PPTP) += nf_nat_pptp.o | 31 | obj-$(CONFIG_NF_NAT_PPTP) += nf_nat_pptp.o |
| 32 | obj-$(CONFIG_NF_NAT_SNMP_BASIC) += nf_nat_snmp_basic.o | 32 | obj-$(CONFIG_NF_NAT_SNMP_BASIC) += nf_nat_snmp_basic.o |
| 33 | obj-$(CONFIG_NF_NAT_MASQUERADE_IPV4) += nf_nat_masquerade_ipv4.o | 33 | obj-$(CONFIG_NF_NAT_MASQUERADE_IPV4) += nf_nat_masquerade_ipv4.o |
| 34 | obj-$(CONFIG_NF_NAT_REDIRECT_IPV4) += nf_nat_redirect_ipv4.o | ||
| 35 | 34 | ||
| 36 | # NAT protocols (nf_nat) | 35 | # NAT protocols (nf_nat) |
| 37 | obj-$(CONFIG_NF_NAT_PROTO_GRE) += nf_nat_proto_gre.o | 36 | obj-$(CONFIG_NF_NAT_PROTO_GRE) += nf_nat_proto_gre.o |
diff --git a/net/ipv4/netfilter/nft_redir_ipv4.c b/net/ipv4/netfilter/nft_redir_ipv4.c index 643c5967aa27..ff2d23d8c87a 100644 --- a/net/ipv4/netfilter/nft_redir_ipv4.c +++ b/net/ipv4/netfilter/nft_redir_ipv4.c | |||
| @@ -14,7 +14,7 @@ | |||
| 14 | #include <linux/netfilter/nf_tables.h> | 14 | #include <linux/netfilter/nf_tables.h> |
| 15 | #include <net/netfilter/nf_tables.h> | 15 | #include <net/netfilter/nf_tables.h> |
| 16 | #include <net/netfilter/nf_nat.h> | 16 | #include <net/netfilter/nf_nat.h> |
| 17 | #include <net/netfilter/ipv4/nf_nat_redirect.h> | 17 | #include <net/netfilter/nf_nat_redirect.h> |
| 18 | #include <net/netfilter/nft_redir.h> | 18 | #include <net/netfilter/nft_redir.h> |
| 19 | 19 | ||
| 20 | static void nft_redir_ipv4_eval(const struct nft_expr *expr, | 20 | static void nft_redir_ipv4_eval(const struct nft_expr *expr, |
diff --git a/net/ipv6/netfilter/Kconfig b/net/ipv6/netfilter/Kconfig index 0dbe5c7953e5..a069822936e6 100644 --- a/net/ipv6/netfilter/Kconfig +++ b/net/ipv6/netfilter/Kconfig | |||
| @@ -82,12 +82,6 @@ config NF_NAT_MASQUERADE_IPV6 | |||
| 82 | This is the kernel functionality to provide NAT in the masquerade | 82 | This is the kernel functionality to provide NAT in the masquerade |
| 83 | flavour (automatic source address selection) for IPv6. | 83 | flavour (automatic source address selection) for IPv6. |
| 84 | 84 | ||
| 85 | config NF_NAT_REDIRECT_IPV6 | ||
| 86 | tristate "IPv6 redirect support" | ||
| 87 | help | ||
| 88 | This is the kernel functionality to provide NAT in the redirect | ||
| 89 | flavour (redirect packet to local machine) for IPv6. | ||
| 90 | |||
| 91 | config NFT_MASQ_IPV6 | 85 | config NFT_MASQ_IPV6 |
| 92 | tristate "IPv6 masquerade support for nf_tables" | 86 | tristate "IPv6 masquerade support for nf_tables" |
| 93 | depends on NF_TABLES_IPV6 | 87 | depends on NF_TABLES_IPV6 |
| @@ -101,7 +95,7 @@ config NFT_REDIR_IPV6 | |||
| 101 | tristate "IPv6 redirect support for nf_tables" | 95 | tristate "IPv6 redirect support for nf_tables" |
| 102 | depends on NF_TABLES_IPV6 | 96 | depends on NF_TABLES_IPV6 |
| 103 | depends on NFT_REDIR | 97 | depends on NFT_REDIR |
| 104 | select NF_NAT_REDIRECT_IPV6 | 98 | select NF_NAT_REDIRECT |
| 105 | help | 99 | help |
| 106 | This is the expression that provides IPv4 redirect support for | 100 | This is the expression that provides IPv4 redirect support for |
| 107 | nf_tables. | 101 | nf_tables. |
diff --git a/net/ipv6/netfilter/Makefile b/net/ipv6/netfilter/Makefile index d2ac9f5f212c..c36e0a5490de 100644 --- a/net/ipv6/netfilter/Makefile +++ b/net/ipv6/netfilter/Makefile | |||
| @@ -19,7 +19,6 @@ obj-$(CONFIG_NF_CONNTRACK_IPV6) += nf_conntrack_ipv6.o | |||
| 19 | nf_nat_ipv6-y := nf_nat_l3proto_ipv6.o nf_nat_proto_icmpv6.o | 19 | nf_nat_ipv6-y := nf_nat_l3proto_ipv6.o nf_nat_proto_icmpv6.o |
| 20 | obj-$(CONFIG_NF_NAT_IPV6) += nf_nat_ipv6.o | 20 | obj-$(CONFIG_NF_NAT_IPV6) += nf_nat_ipv6.o |
| 21 | obj-$(CONFIG_NF_NAT_MASQUERADE_IPV6) += nf_nat_masquerade_ipv6.o | 21 | obj-$(CONFIG_NF_NAT_MASQUERADE_IPV6) += nf_nat_masquerade_ipv6.o |
| 22 | obj-$(CONFIG_NF_NAT_REDIRECT_IPV6) += nf_nat_redirect_ipv6.o | ||
| 23 | 22 | ||
| 24 | # defrag | 23 | # defrag |
| 25 | nf_defrag_ipv6-y := nf_defrag_ipv6_hooks.o nf_conntrack_reasm.o | 24 | nf_defrag_ipv6-y := nf_defrag_ipv6_hooks.o nf_conntrack_reasm.o |
diff --git a/net/ipv6/netfilter/nf_nat_redirect_ipv6.c b/net/ipv6/netfilter/nf_nat_redirect_ipv6.c deleted file mode 100644 index ea1308aeb048..000000000000 --- a/net/ipv6/netfilter/nf_nat_redirect_ipv6.c +++ /dev/null | |||
| @@ -1,75 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * (C) 1999-2001 Paul `Rusty' Russell | ||
| 3 | * (C) 2002-2006 Netfilter Core Team <coreteam@netfilter.org> | ||
| 4 | * Copyright (c) 2011 Patrick McHardy <kaber@trash.net> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License version 2 as | ||
| 8 | * published by the Free Software Foundation. | ||
| 9 | * | ||
| 10 | * Based on Rusty Russell's IPv4 REDIRECT target. Development of IPv6 | ||
| 11 | * NAT funded by Astaro. | ||
| 12 | */ | ||
| 13 | |||
| 14 | #include <linux/if.h> | ||
| 15 | #include <linux/inetdevice.h> | ||
| 16 | #include <linux/ip.h> | ||
| 17 | #include <linux/kernel.h> | ||
| 18 | #include <linux/module.h> | ||
| 19 | #include <linux/netdevice.h> | ||
| 20 | #include <linux/netfilter.h> | ||
| 21 | #include <linux/types.h> | ||
| 22 | #include <linux/netfilter_ipv6.h> | ||
| 23 | #include <linux/netfilter/x_tables.h> | ||
| 24 | #include <net/addrconf.h> | ||
| 25 | #include <net/checksum.h> | ||
| 26 | #include <net/protocol.h> | ||
| 27 | #include <net/netfilter/nf_nat.h> | ||
| 28 | #include <net/netfilter/ipv6/nf_nat_redirect.h> | ||
| 29 | |||
| 30 | static const struct in6_addr loopback_addr = IN6ADDR_LOOPBACK_INIT; | ||
| 31 | |||
| 32 | unsigned int | ||
| 33 | nf_nat_redirect_ipv6(struct sk_buff *skb, const struct nf_nat_range *range, | ||
| 34 | unsigned int hooknum) | ||
| 35 | { | ||
| 36 | struct nf_nat_range newrange; | ||
| 37 | struct in6_addr newdst; | ||
| 38 | enum ip_conntrack_info ctinfo; | ||
| 39 | struct nf_conn *ct; | ||
| 40 | |||
| 41 | ct = nf_ct_get(skb, &ctinfo); | ||
| 42 | if (hooknum == NF_INET_LOCAL_OUT) { | ||
| 43 | newdst = loopback_addr; | ||
| 44 | } else { | ||
| 45 | struct inet6_dev *idev; | ||
| 46 | struct inet6_ifaddr *ifa; | ||
| 47 | bool addr = false; | ||
| 48 | |||
| 49 | rcu_read_lock(); | ||
| 50 | idev = __in6_dev_get(skb->dev); | ||
| 51 | if (idev != NULL) { | ||
| 52 | list_for_each_entry(ifa, &idev->addr_list, if_list) { | ||
| 53 | newdst = ifa->addr; | ||
| 54 | addr = true; | ||
| 55 | break; | ||
| 56 | } | ||
| 57 | } | ||
| 58 | rcu_read_unlock(); | ||
| 59 | |||
| 60 | if (!addr) | ||
| 61 | return NF_DROP; | ||
| 62 | } | ||
| 63 | |||
| 64 | newrange.flags = range->flags | NF_NAT_RANGE_MAP_IPS; | ||
| 65 | newrange.min_addr.in6 = newdst; | ||
| 66 | newrange.max_addr.in6 = newdst; | ||
| 67 | newrange.min_proto = range->min_proto; | ||
| 68 | newrange.max_proto = range->max_proto; | ||
| 69 | |||
| 70 | return nf_nat_setup_info(ct, &newrange, NF_NAT_MANIP_DST); | ||
| 71 | } | ||
| 72 | EXPORT_SYMBOL_GPL(nf_nat_redirect_ipv6); | ||
| 73 | |||
| 74 | MODULE_LICENSE("GPL"); | ||
| 75 | MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>"); | ||
diff --git a/net/ipv6/netfilter/nft_redir_ipv6.c b/net/ipv6/netfilter/nft_redir_ipv6.c index 83420eeaad1c..2433a6bfb191 100644 --- a/net/ipv6/netfilter/nft_redir_ipv6.c +++ b/net/ipv6/netfilter/nft_redir_ipv6.c | |||
| @@ -15,7 +15,7 @@ | |||
| 15 | #include <net/netfilter/nf_tables.h> | 15 | #include <net/netfilter/nf_tables.h> |
| 16 | #include <net/netfilter/nf_nat.h> | 16 | #include <net/netfilter/nf_nat.h> |
| 17 | #include <net/netfilter/nft_redir.h> | 17 | #include <net/netfilter/nft_redir.h> |
| 18 | #include <net/netfilter/ipv6/nf_nat_redirect.h> | 18 | #include <net/netfilter/nf_nat_redirect.h> |
| 19 | 19 | ||
| 20 | static void nft_redir_ipv6_eval(const struct nft_expr *expr, | 20 | static void nft_redir_ipv6_eval(const struct nft_expr *expr, |
| 21 | struct nft_data data[NFT_REG_MAX + 1], | 21 | struct nft_data data[NFT_REG_MAX + 1], |
diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig index 57f15a9aa481..b02660fa9eb0 100644 --- a/net/netfilter/Kconfig +++ b/net/netfilter/Kconfig | |||
| @@ -411,6 +411,13 @@ config NF_NAT_TFTP | |||
| 411 | depends on NF_CONNTRACK && NF_NAT | 411 | depends on NF_CONNTRACK && NF_NAT |
| 412 | default NF_NAT && NF_CONNTRACK_TFTP | 412 | default NF_NAT && NF_CONNTRACK_TFTP |
| 413 | 413 | ||
| 414 | config NF_NAT_REDIRECT | ||
| 415 | tristate "IPv4/IPv6 redirect support" | ||
| 416 | depends on NF_NAT | ||
| 417 | help | ||
| 418 | This is the kernel functionality to redirect packets to local | ||
| 419 | machine through NAT. | ||
| 420 | |||
| 414 | config NETFILTER_SYNPROXY | 421 | config NETFILTER_SYNPROXY |
| 415 | tristate | 422 | tristate |
| 416 | 423 | ||
| @@ -844,8 +851,7 @@ config NETFILTER_XT_TARGET_RATEEST | |||
| 844 | config NETFILTER_XT_TARGET_REDIRECT | 851 | config NETFILTER_XT_TARGET_REDIRECT |
| 845 | tristate "REDIRECT target support" | 852 | tristate "REDIRECT target support" |
| 846 | depends on NF_NAT | 853 | depends on NF_NAT |
| 847 | select NF_NAT_REDIRECT_IPV4 if NF_NAT_IPV4 | 854 | select NF_NAT_REDIRECT |
| 848 | select NF_NAT_REDIRECT_IPV6 if NF_NAT_IPV6 | ||
| 849 | ---help--- | 855 | ---help--- |
| 850 | REDIRECT is a special case of NAT: all incoming connections are | 856 | REDIRECT is a special case of NAT: all incoming connections are |
| 851 | mapped onto the incoming interface's address, causing the packets to | 857 | mapped onto the incoming interface's address, causing the packets to |
diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile index f3eb4680f2ec..89f73a9e9874 100644 --- a/net/netfilter/Makefile +++ b/net/netfilter/Makefile | |||
| @@ -51,6 +51,7 @@ nf_nat-y := nf_nat_core.o nf_nat_proto_unknown.o nf_nat_proto_common.o \ | |||
| 51 | obj-$(CONFIG_NF_LOG_COMMON) += nf_log_common.o | 51 | obj-$(CONFIG_NF_LOG_COMMON) += nf_log_common.o |
| 52 | 52 | ||
| 53 | obj-$(CONFIG_NF_NAT) += nf_nat.o | 53 | obj-$(CONFIG_NF_NAT) += nf_nat.o |
| 54 | obj-$(CONFIG_NF_NAT_REDIRECT) += nf_nat_redirect.o | ||
| 54 | 55 | ||
| 55 | # NAT protocols (nf_nat) | 56 | # NAT protocols (nf_nat) |
| 56 | obj-$(CONFIG_NF_NAT_PROTO_DCCP) += nf_nat_proto_dccp.o | 57 | obj-$(CONFIG_NF_NAT_PROTO_DCCP) += nf_nat_proto_dccp.o |
diff --git a/net/ipv4/netfilter/nf_nat_redirect_ipv4.c b/net/netfilter/nf_nat_redirect.c index a220552fc532..97b75f9bfbcd 100644 --- a/net/ipv4/netfilter/nf_nat_redirect_ipv4.c +++ b/net/netfilter/nf_nat_redirect.c | |||
| @@ -20,12 +20,13 @@ | |||
| 20 | #include <linux/netfilter.h> | 20 | #include <linux/netfilter.h> |
| 21 | #include <linux/types.h> | 21 | #include <linux/types.h> |
| 22 | #include <linux/netfilter_ipv4.h> | 22 | #include <linux/netfilter_ipv4.h> |
| 23 | #include <linux/netfilter_ipv6.h> | ||
| 23 | #include <linux/netfilter/x_tables.h> | 24 | #include <linux/netfilter/x_tables.h> |
| 24 | #include <net/addrconf.h> | 25 | #include <net/addrconf.h> |
| 25 | #include <net/checksum.h> | 26 | #include <net/checksum.h> |
| 26 | #include <net/protocol.h> | 27 | #include <net/protocol.h> |
| 27 | #include <net/netfilter/nf_nat.h> | 28 | #include <net/netfilter/nf_nat.h> |
| 28 | #include <net/netfilter/ipv4/nf_nat_redirect.h> | 29 | #include <net/netfilter/nf_nat_redirect.h> |
| 29 | 30 | ||
| 30 | unsigned int | 31 | unsigned int |
| 31 | nf_nat_redirect_ipv4(struct sk_buff *skb, | 32 | nf_nat_redirect_ipv4(struct sk_buff *skb, |
| @@ -78,5 +79,49 @@ nf_nat_redirect_ipv4(struct sk_buff *skb, | |||
| 78 | } | 79 | } |
| 79 | EXPORT_SYMBOL_GPL(nf_nat_redirect_ipv4); | 80 | EXPORT_SYMBOL_GPL(nf_nat_redirect_ipv4); |
| 80 | 81 | ||
| 82 | static const struct in6_addr loopback_addr = IN6ADDR_LOOPBACK_INIT; | ||
| 83 | |||
| 84 | unsigned int | ||
| 85 | nf_nat_redirect_ipv6(struct sk_buff *skb, const struct nf_nat_range *range, | ||
| 86 | unsigned int hooknum) | ||
| 87 | { | ||
| 88 | struct nf_nat_range newrange; | ||
| 89 | struct in6_addr newdst; | ||
| 90 | enum ip_conntrack_info ctinfo; | ||
| 91 | struct nf_conn *ct; | ||
| 92 | |||
| 93 | ct = nf_ct_get(skb, &ctinfo); | ||
| 94 | if (hooknum == NF_INET_LOCAL_OUT) { | ||
| 95 | newdst = loopback_addr; | ||
| 96 | } else { | ||
| 97 | struct inet6_dev *idev; | ||
| 98 | struct inet6_ifaddr *ifa; | ||
| 99 | bool addr = false; | ||
| 100 | |||
| 101 | rcu_read_lock(); | ||
| 102 | idev = __in6_dev_get(skb->dev); | ||
| 103 | if (idev != NULL) { | ||
| 104 | list_for_each_entry(ifa, &idev->addr_list, if_list) { | ||
| 105 | newdst = ifa->addr; | ||
| 106 | addr = true; | ||
| 107 | break; | ||
| 108 | } | ||
| 109 | } | ||
| 110 | rcu_read_unlock(); | ||
| 111 | |||
| 112 | if (!addr) | ||
| 113 | return NF_DROP; | ||
| 114 | } | ||
| 115 | |||
| 116 | newrange.flags = range->flags | NF_NAT_RANGE_MAP_IPS; | ||
| 117 | newrange.min_addr.in6 = newdst; | ||
| 118 | newrange.max_addr.in6 = newdst; | ||
| 119 | newrange.min_proto = range->min_proto; | ||
| 120 | newrange.max_proto = range->max_proto; | ||
| 121 | |||
| 122 | return nf_nat_setup_info(ct, &newrange, NF_NAT_MANIP_DST); | ||
| 123 | } | ||
| 124 | EXPORT_SYMBOL_GPL(nf_nat_redirect_ipv6); | ||
| 125 | |||
| 81 | MODULE_LICENSE("GPL"); | 126 | MODULE_LICENSE("GPL"); |
| 82 | MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>"); | 127 | MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>"); |
diff --git a/net/netfilter/xt_REDIRECT.c b/net/netfilter/xt_REDIRECT.c index b6ec67efd900..03f0b370e178 100644 --- a/net/netfilter/xt_REDIRECT.c +++ b/net/netfilter/xt_REDIRECT.c | |||
| @@ -26,8 +26,7 @@ | |||
| 26 | #include <net/checksum.h> | 26 | #include <net/checksum.h> |
| 27 | #include <net/protocol.h> | 27 | #include <net/protocol.h> |
| 28 | #include <net/netfilter/nf_nat.h> | 28 | #include <net/netfilter/nf_nat.h> |
| 29 | #include <net/netfilter/ipv4/nf_nat_redirect.h> | 29 | #include <net/netfilter/nf_nat_redirect.h> |
| 30 | #include <net/netfilter/ipv6/nf_nat_redirect.h> | ||
| 31 | 30 | ||
| 32 | static unsigned int | 31 | static unsigned int |
| 33 | redirect_tg6(struct sk_buff *skb, const struct xt_action_param *par) | 32 | redirect_tg6(struct sk_buff *skb, const struct xt_action_param *par) |
