Skip to content

Commit 58a317f

Browse files
kaberummakynes
authored andcommitted
netfilter: ipv6: add IPv6 NAT support
Signed-off-by: Patrick McHardy <[email protected]>
1 parent 2cf545e commit 58a317f

File tree

13 files changed

+764
-2
lines changed

13 files changed

+764
-2
lines changed

include/linux/netfilter/nfnetlink_conntrack.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ enum ctattr_nat {
147147
CTA_NAT_V4_MAXIP,
148148
#define CTA_NAT_MAXIP CTA_NAT_V4_MAXIP
149149
CTA_NAT_PROTO,
150+
CTA_NAT_V6_MINIP,
151+
CTA_NAT_V6_MAXIP,
150152
__CTA_NAT_MAX
151153
};
152154
#define CTA_NAT_MAX (__CTA_NAT_MAX - 1)

include/net/netfilter/nf_nat_l3proto.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,10 @@ extern int nf_nat_icmp_reply_translation(struct sk_buff *skb,
4343
struct nf_conn *ct,
4444
enum ip_conntrack_info ctinfo,
4545
unsigned int hooknum);
46+
extern int nf_nat_icmpv6_reply_translation(struct sk_buff *skb,
47+
struct nf_conn *ct,
48+
enum ip_conntrack_info ctinfo,
49+
unsigned int hooknum,
50+
unsigned int hdrlen);
4651

4752
#endif /* _NF_NAT_L3PROTO_H */

include/net/netfilter/nf_nat_l4proto.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ extern const struct nf_nat_l4proto *__nf_nat_l4proto_find(u8 l3proto, u8 l4proto
5151
extern const struct nf_nat_l4proto nf_nat_l4proto_tcp;
5252
extern const struct nf_nat_l4proto nf_nat_l4proto_udp;
5353
extern const struct nf_nat_l4proto nf_nat_l4proto_icmp;
54+
extern const struct nf_nat_l4proto nf_nat_l4proto_icmpv6;
5455
extern const struct nf_nat_l4proto nf_nat_l4proto_unknown;
5556

5657
extern bool nf_nat_l4proto_in_range(const struct nf_conntrack_tuple *tuple,

include/net/netns/ipv6.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ struct netns_ipv6 {
4242
#ifdef CONFIG_SECURITY
4343
struct xt_table *ip6table_security;
4444
#endif
45+
struct xt_table *ip6table_nat;
4546
#endif
4647
struct rt6_info *ip6_null_entry;
4748
struct rt6_statistics *rt6_stats;

net/core/secure_seq.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr,
7676

7777
return hash[0];
7878
}
79+
EXPORT_SYMBOL(secure_ipv6_port_ephemeral);
7980
#endif
8081

8182
#ifdef CONFIG_INET

net/ipv6/netfilter/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ config NF_CONNTRACK_IPV6
2525

2626
To compile it as a module, choose M here. If unsure, say N.
2727

28+
config NF_NAT_IPV6
29+
tristate "IPv6 NAT"
30+
depends on NF_CONNTRACK_IPV6
31+
depends on NETFILTER_ADVANCED
32+
select NF_NAT
33+
help
34+
The IPv6 NAT option allows masquerading, port forwarding and other
35+
forms of full Network Address Port Translation. It is controlled by
36+
the `nat' table in ip6tables, see the man page for ip6tables(8).
37+
38+
To compile it as a module, choose M here. If unsure, say N.
39+
2840
config IP6_NF_IPTABLES
2941
tristate "IP6 tables support (required for filtering)"
3042
depends on INET && IPV6

net/ipv6/netfilter/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@ obj-$(CONFIG_IP6_NF_FILTER) += ip6table_filter.o
88
obj-$(CONFIG_IP6_NF_MANGLE) += ip6table_mangle.o
99
obj-$(CONFIG_IP6_NF_RAW) += ip6table_raw.o
1010
obj-$(CONFIG_IP6_NF_SECURITY) += ip6table_security.o
11+
obj-$(CONFIG_NF_NAT_IPV6) += ip6table_nat.o
1112

1213
# objects for l3 independent conntrack
1314
nf_conntrack_ipv6-y := nf_conntrack_l3proto_ipv6.o nf_conntrack_proto_icmpv6.o
1415

1516
# l3 independent conntrack
1617
obj-$(CONFIG_NF_CONNTRACK_IPV6) += nf_conntrack_ipv6.o nf_defrag_ipv6.o
1718

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
21+
1822
# defrag
1923
nf_defrag_ipv6-y := nf_defrag_ipv6_hooks.o nf_conntrack_reasm.o
2024
obj-$(CONFIG_NF_DEFRAG_IPV6) += nf_defrag_ipv6.o

0 commit comments

Comments
 (0)