diff options
author | Patrick McHardy <kaber@trash.net> | 2011-12-23 07:59:49 -0500 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2011-12-23 08:36:43 -0500 |
commit | cbc9f2f4fcd70d5a627558ca9a881fa9391abf69 (patch) | |
tree | 37bc0efbcc8fda2250bca77bbd681167c96a2598 | |
parent | 3d058d7bc2c5671ae630e0b463be8a69b5783fb9 (diff) |
netfilter: nf_nat: export NAT definitions to userspace
Export the NAT definitions to userspace. So far userspace (specifically,
iptables) has been copying the headers files from include/net. Also
rename some structures and definitions in preparation for IPv6 NAT.
Since these have never been officially exported, this doesn't affect
existing userspace code.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
29 files changed, 185 insertions, 194 deletions
diff --git a/include/linux/netfilter/Kbuild b/include/linux/netfilter/Kbuild index a1b410c76fc3..d81f7719b01c 100644 --- a/include/linux/netfilter/Kbuild +++ b/include/linux/netfilter/Kbuild | |||
@@ -5,6 +5,7 @@ header-y += nf_conntrack_ftp.h | |||
5 | header-y += nf_conntrack_sctp.h | 5 | header-y += nf_conntrack_sctp.h |
6 | header-y += nf_conntrack_tcp.h | 6 | header-y += nf_conntrack_tcp.h |
7 | header-y += nf_conntrack_tuple_common.h | 7 | header-y += nf_conntrack_tuple_common.h |
8 | header-y += nf_nat.h | ||
8 | header-y += nfnetlink.h | 9 | header-y += nfnetlink.h |
9 | header-y += nfnetlink_compat.h | 10 | header-y += nfnetlink_compat.h |
10 | header-y += nfnetlink_conntrack.h | 11 | header-y += nfnetlink_conntrack.h |
diff --git a/include/linux/netfilter/nf_conntrack_tuple_common.h b/include/linux/netfilter/nf_conntrack_tuple_common.h index 2ea22b018a87..2f6bbc5b8125 100644 --- a/include/linux/netfilter/nf_conntrack_tuple_common.h +++ b/include/linux/netfilter/nf_conntrack_tuple_common.h | |||
@@ -7,6 +7,33 @@ enum ip_conntrack_dir { | |||
7 | IP_CT_DIR_MAX | 7 | IP_CT_DIR_MAX |
8 | }; | 8 | }; |
9 | 9 | ||
10 | /* The protocol-specific manipulable parts of the tuple: always in | ||
11 | * network order | ||
12 | */ | ||
13 | union nf_conntrack_man_proto { | ||
14 | /* Add other protocols here. */ | ||
15 | __be16 all; | ||
16 | |||
17 | struct { | ||
18 | __be16 port; | ||
19 | } tcp; | ||
20 | struct { | ||
21 | __be16 port; | ||
22 | } udp; | ||
23 | struct { | ||
24 | __be16 id; | ||
25 | } icmp; | ||
26 | struct { | ||
27 | __be16 port; | ||
28 | } dccp; | ||
29 | struct { | ||
30 | __be16 port; | ||
31 | } sctp; | ||
32 | struct { | ||
33 | __be16 key; /* GRE key is 32bit, PPtP only uses 16bit */ | ||
34 | } gre; | ||
35 | }; | ||
36 | |||
10 | #define CTINFO2DIR(ctinfo) ((ctinfo) >= IP_CT_IS_REPLY ? IP_CT_DIR_REPLY : IP_CT_DIR_ORIGINAL) | 37 | #define CTINFO2DIR(ctinfo) ((ctinfo) >= IP_CT_IS_REPLY ? IP_CT_DIR_REPLY : IP_CT_DIR_ORIGINAL) |
11 | 38 | ||
12 | #endif /* _NF_CONNTRACK_TUPLE_COMMON_H */ | 39 | #endif /* _NF_CONNTRACK_TUPLE_COMMON_H */ |
diff --git a/include/linux/netfilter/nf_nat.h b/include/linux/netfilter/nf_nat.h new file mode 100644 index 000000000000..8df2d13730b2 --- /dev/null +++ b/include/linux/netfilter/nf_nat.h | |||
@@ -0,0 +1,25 @@ | |||
1 | #ifndef _NETFILTER_NF_NAT_H | ||
2 | #define _NETFILTER_NF_NAT_H | ||
3 | |||
4 | #include <linux/netfilter.h> | ||
5 | #include <linux/netfilter/nf_conntrack_tuple_common.h> | ||
6 | |||
7 | #define NF_NAT_RANGE_MAP_IPS 1 | ||
8 | #define NF_NAT_RANGE_PROTO_SPECIFIED 2 | ||
9 | #define NF_NAT_RANGE_PROTO_RANDOM 4 | ||
10 | #define NF_NAT_RANGE_PERSISTENT 8 | ||
11 | |||
12 | struct nf_nat_ipv4_range { | ||
13 | unsigned int flags; | ||
14 | __be32 min_ip; | ||
15 | __be32 max_ip; | ||
16 | union nf_conntrack_man_proto min; | ||
17 | union nf_conntrack_man_proto max; | ||
18 | }; | ||
19 | |||
20 | struct nf_nat_ipv4_multi_range_compat { | ||
21 | unsigned int rangesize; | ||
22 | struct nf_nat_ipv4_range range[1]; | ||
23 | }; | ||
24 | |||
25 | #endif /* _NETFILTER_NF_NAT_H */ | ||
diff --git a/include/linux/netfilter_ipv4/Kbuild b/include/linux/netfilter_ipv4/Kbuild index c3b45480ecf7..f9930c87fff3 100644 --- a/include/linux/netfilter_ipv4/Kbuild +++ b/include/linux/netfilter_ipv4/Kbuild | |||
@@ -12,4 +12,3 @@ header-y += ipt_ah.h | |||
12 | header-y += ipt_ecn.h | 12 | header-y += ipt_ecn.h |
13 | header-y += ipt_realm.h | 13 | header-y += ipt_realm.h |
14 | header-y += ipt_ttl.h | 14 | header-y += ipt_ttl.h |
15 | header-y += nf_nat.h | ||
diff --git a/include/linux/netfilter_ipv4/nf_nat.h b/include/linux/netfilter_ipv4/nf_nat.h deleted file mode 100644 index 7a861d09fc86..000000000000 --- a/include/linux/netfilter_ipv4/nf_nat.h +++ /dev/null | |||
@@ -1,58 +0,0 @@ | |||
1 | #ifndef _LINUX_NF_NAT_H | ||
2 | #define _LINUX_NF_NAT_H | ||
3 | |||
4 | #include <linux/types.h> | ||
5 | |||
6 | #define IP_NAT_RANGE_MAP_IPS 1 | ||
7 | #define IP_NAT_RANGE_PROTO_SPECIFIED 2 | ||
8 | #define IP_NAT_RANGE_PROTO_RANDOM 4 | ||
9 | #define IP_NAT_RANGE_PERSISTENT 8 | ||
10 | |||
11 | /* The protocol-specific manipulable parts of the tuple. */ | ||
12 | union nf_conntrack_man_proto { | ||
13 | /* Add other protocols here. */ | ||
14 | __be16 all; | ||
15 | |||
16 | struct { | ||
17 | __be16 port; | ||
18 | } tcp; | ||
19 | struct { | ||
20 | __be16 port; | ||
21 | } udp; | ||
22 | struct { | ||
23 | __be16 id; | ||
24 | } icmp; | ||
25 | struct { | ||
26 | __be16 port; | ||
27 | } dccp; | ||
28 | struct { | ||
29 | __be16 port; | ||
30 | } sctp; | ||
31 | struct { | ||
32 | __be16 key; /* GRE key is 32bit, PPtP only uses 16bit */ | ||
33 | } gre; | ||
34 | }; | ||
35 | |||
36 | /* Single range specification. */ | ||
37 | struct nf_nat_range { | ||
38 | /* Set to OR of flags above. */ | ||
39 | unsigned int flags; | ||
40 | |||
41 | /* Inclusive: network order. */ | ||
42 | __be32 min_ip, max_ip; | ||
43 | |||
44 | /* Inclusive: network order */ | ||
45 | union nf_conntrack_man_proto min, max; | ||
46 | }; | ||
47 | |||
48 | /* For backwards compat: don't use in modern code. */ | ||
49 | struct nf_nat_multi_range_compat { | ||
50 | unsigned int rangesize; /* Must be 1. */ | ||
51 | |||
52 | /* hangs off end. */ | ||
53 | struct nf_nat_range range[1]; | ||
54 | }; | ||
55 | |||
56 | #define nf_nat_multi_range nf_nat_multi_range_compat | ||
57 | |||
58 | #endif | ||
diff --git a/include/net/netfilter/nf_conntrack_tuple.h b/include/net/netfilter/nf_conntrack_tuple.h index 2f8fb77bfdd1..aea3f8221be0 100644 --- a/include/net/netfilter/nf_conntrack_tuple.h +++ b/include/net/netfilter/nf_conntrack_tuple.h | |||
@@ -12,7 +12,6 @@ | |||
12 | 12 | ||
13 | #include <linux/netfilter/x_tables.h> | 13 | #include <linux/netfilter/x_tables.h> |
14 | #include <linux/netfilter/nf_conntrack_tuple_common.h> | 14 | #include <linux/netfilter/nf_conntrack_tuple_common.h> |
15 | #include <linux/netfilter_ipv4/nf_nat.h> | ||
16 | #include <linux/list_nulls.h> | 15 | #include <linux/list_nulls.h> |
17 | 16 | ||
18 | /* A `tuple' is a structure containing the information to uniquely | 17 | /* A `tuple' is a structure containing the information to uniquely |
diff --git a/include/net/netfilter/nf_nat.h b/include/net/netfilter/nf_nat.h index b8872df7285f..b4de990b55f1 100644 --- a/include/net/netfilter/nf_nat.h +++ b/include/net/netfilter/nf_nat.h | |||
@@ -1,14 +1,12 @@ | |||
1 | #ifndef _NF_NAT_H | 1 | #ifndef _NF_NAT_H |
2 | #define _NF_NAT_H | 2 | #define _NF_NAT_H |
3 | #include <linux/netfilter_ipv4.h> | 3 | #include <linux/netfilter_ipv4.h> |
4 | #include <linux/netfilter_ipv4/nf_nat.h> | 4 | #include <linux/netfilter/nf_nat.h> |
5 | #include <net/netfilter/nf_conntrack_tuple.h> | 5 | #include <net/netfilter/nf_conntrack_tuple.h> |
6 | 6 | ||
7 | #define NF_NAT_MAPPING_TYPE_MAX_NAMELEN 16 | ||
8 | |||
9 | enum nf_nat_manip_type { | 7 | enum nf_nat_manip_type { |
10 | IP_NAT_MANIP_SRC, | 8 | NF_NAT_MANIP_SRC, |
11 | IP_NAT_MANIP_DST | 9 | NF_NAT_MANIP_DST |
12 | }; | 10 | }; |
13 | 11 | ||
14 | /* SRC manip occurs POST_ROUTING or LOCAL_IN */ | 12 | /* SRC manip occurs POST_ROUTING or LOCAL_IN */ |
@@ -52,7 +50,7 @@ struct nf_conn_nat { | |||
52 | 50 | ||
53 | /* Set up the info structure to map into this range. */ | 51 | /* Set up the info structure to map into this range. */ |
54 | extern unsigned int nf_nat_setup_info(struct nf_conn *ct, | 52 | extern unsigned int nf_nat_setup_info(struct nf_conn *ct, |
55 | const struct nf_nat_range *range, | 53 | const struct nf_nat_ipv4_range *range, |
56 | enum nf_nat_manip_type maniptype); | 54 | enum nf_nat_manip_type maniptype); |
57 | 55 | ||
58 | /* Is this tuple already taken? (not by us)*/ | 56 | /* Is this tuple already taken? (not by us)*/ |
diff --git a/include/net/netfilter/nf_nat_core.h b/include/net/netfilter/nf_nat_core.h index 3dc7b98effeb..b13d8d18d595 100644 --- a/include/net/netfilter/nf_nat_core.h +++ b/include/net/netfilter/nf_nat_core.h | |||
@@ -20,7 +20,7 @@ extern int nf_nat_icmp_reply_translation(struct nf_conn *ct, | |||
20 | static inline int nf_nat_initialized(struct nf_conn *ct, | 20 | static inline int nf_nat_initialized(struct nf_conn *ct, |
21 | enum nf_nat_manip_type manip) | 21 | enum nf_nat_manip_type manip) |
22 | { | 22 | { |
23 | if (manip == IP_NAT_MANIP_SRC) | 23 | if (manip == NF_NAT_MANIP_SRC) |
24 | return ct->status & IPS_SRC_NAT_DONE; | 24 | return ct->status & IPS_SRC_NAT_DONE; |
25 | else | 25 | else |
26 | return ct->status & IPS_DST_NAT_DONE; | 26 | return ct->status & IPS_DST_NAT_DONE; |
diff --git a/include/net/netfilter/nf_nat_protocol.h b/include/net/netfilter/nf_nat_protocol.h index 93cc90d28e66..7156c002b59c 100644 --- a/include/net/netfilter/nf_nat_protocol.h +++ b/include/net/netfilter/nf_nat_protocol.h | |||
@@ -4,7 +4,7 @@ | |||
4 | #include <net/netfilter/nf_nat.h> | 4 | #include <net/netfilter/nf_nat.h> |
5 | #include <linux/netfilter/nfnetlink_conntrack.h> | 5 | #include <linux/netfilter/nfnetlink_conntrack.h> |
6 | 6 | ||
7 | struct nf_nat_range; | 7 | struct nf_nat_ipv4_range; |
8 | 8 | ||
9 | struct nf_nat_protocol { | 9 | struct nf_nat_protocol { |
10 | /* Protocol number. */ | 10 | /* Protocol number. */ |
@@ -30,15 +30,15 @@ struct nf_nat_protocol { | |||
30 | possible. Per-protocol part of tuple is initialized to the | 30 | possible. Per-protocol part of tuple is initialized to the |
31 | incoming packet. */ | 31 | incoming packet. */ |
32 | void (*unique_tuple)(struct nf_conntrack_tuple *tuple, | 32 | void (*unique_tuple)(struct nf_conntrack_tuple *tuple, |
33 | const struct nf_nat_range *range, | 33 | const struct nf_nat_ipv4_range *range, |
34 | enum nf_nat_manip_type maniptype, | 34 | enum nf_nat_manip_type maniptype, |
35 | const struct nf_conn *ct); | 35 | const struct nf_conn *ct); |
36 | 36 | ||
37 | int (*range_to_nlattr)(struct sk_buff *skb, | 37 | int (*range_to_nlattr)(struct sk_buff *skb, |
38 | const struct nf_nat_range *range); | 38 | const struct nf_nat_ipv4_range *range); |
39 | 39 | ||
40 | int (*nlattr_to_range)(struct nlattr *tb[], | 40 | int (*nlattr_to_range)(struct nlattr *tb[], |
41 | struct nf_nat_range *range); | 41 | struct nf_nat_ipv4_range *range); |
42 | }; | 42 | }; |
43 | 43 | ||
44 | /* Protocol registration. */ | 44 | /* Protocol registration. */ |
@@ -61,14 +61,14 @@ extern bool nf_nat_proto_in_range(const struct nf_conntrack_tuple *tuple, | |||
61 | const union nf_conntrack_man_proto *max); | 61 | const union nf_conntrack_man_proto *max); |
62 | 62 | ||
63 | extern void nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple, | 63 | extern void nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple, |
64 | const struct nf_nat_range *range, | 64 | const struct nf_nat_ipv4_range *range, |
65 | enum nf_nat_manip_type maniptype, | 65 | enum nf_nat_manip_type maniptype, |
66 | const struct nf_conn *ct, | 66 | const struct nf_conn *ct, |
67 | u_int16_t *rover); | 67 | u_int16_t *rover); |
68 | 68 | ||
69 | extern int nf_nat_proto_range_to_nlattr(struct sk_buff *skb, | 69 | extern int nf_nat_proto_range_to_nlattr(struct sk_buff *skb, |
70 | const struct nf_nat_range *range); | 70 | const struct nf_nat_ipv4_range *range); |
71 | extern int nf_nat_proto_nlattr_to_range(struct nlattr *tb[], | 71 | extern int nf_nat_proto_nlattr_to_range(struct nlattr *tb[], |
72 | struct nf_nat_range *range); | 72 | struct nf_nat_ipv4_range *range); |
73 | 73 | ||
74 | #endif /*_NF_NAT_PROTO_H*/ | 74 | #endif /*_NF_NAT_PROTO_H*/ |
diff --git a/net/ipv4/netfilter/ipt_MASQUERADE.c b/net/ipv4/netfilter/ipt_MASQUERADE.c index 9931152a78b5..2f210c79dc87 100644 --- a/net/ipv4/netfilter/ipt_MASQUERADE.c +++ b/net/ipv4/netfilter/ipt_MASQUERADE.c | |||
@@ -30,9 +30,9 @@ MODULE_DESCRIPTION("Xtables: automatic-address SNAT"); | |||
30 | /* FIXME: Multiple targets. --RR */ | 30 | /* FIXME: Multiple targets. --RR */ |
31 | static int masquerade_tg_check(const struct xt_tgchk_param *par) | 31 | static int masquerade_tg_check(const struct xt_tgchk_param *par) |
32 | { | 32 | { |
33 | const struct nf_nat_multi_range_compat *mr = par->targinfo; | 33 | const struct nf_nat_ipv4_multi_range_compat *mr = par->targinfo; |
34 | 34 | ||
35 | if (mr->range[0].flags & IP_NAT_RANGE_MAP_IPS) { | 35 | if (mr->range[0].flags & NF_NAT_RANGE_MAP_IPS) { |
36 | pr_debug("bad MAP_IPS.\n"); | 36 | pr_debug("bad MAP_IPS.\n"); |
37 | return -EINVAL; | 37 | return -EINVAL; |
38 | } | 38 | } |
@@ -49,8 +49,8 @@ masquerade_tg(struct sk_buff *skb, const struct xt_action_param *par) | |||
49 | struct nf_conn *ct; | 49 | struct nf_conn *ct; |
50 | struct nf_conn_nat *nat; | 50 | struct nf_conn_nat *nat; |
51 | enum ip_conntrack_info ctinfo; | 51 | enum ip_conntrack_info ctinfo; |
52 | struct nf_nat_range newrange; | 52 | struct nf_nat_ipv4_range newrange; |
53 | const struct nf_nat_multi_range_compat *mr; | 53 | const struct nf_nat_ipv4_multi_range_compat *mr; |
54 | const struct rtable *rt; | 54 | const struct rtable *rt; |
55 | __be32 newsrc; | 55 | __be32 newsrc; |
56 | 56 | ||
@@ -79,13 +79,13 @@ masquerade_tg(struct sk_buff *skb, const struct xt_action_param *par) | |||
79 | nat->masq_index = par->out->ifindex; | 79 | nat->masq_index = par->out->ifindex; |
80 | 80 | ||
81 | /* Transfer from original range. */ | 81 | /* Transfer from original range. */ |
82 | newrange = ((struct nf_nat_range) | 82 | newrange = ((struct nf_nat_ipv4_range) |
83 | { mr->range[0].flags | IP_NAT_RANGE_MAP_IPS, | 83 | { mr->range[0].flags | NF_NAT_RANGE_MAP_IPS, |
84 | newsrc, newsrc, | 84 | newsrc, newsrc, |
85 | mr->range[0].min, mr->range[0].max }); | 85 | mr->range[0].min, mr->range[0].max }); |
86 | 86 | ||
87 | /* Hand modified range to generic setup. */ | 87 | /* Hand modified range to generic setup. */ |
88 | return nf_nat_setup_info(ct, &newrange, IP_NAT_MANIP_SRC); | 88 | return nf_nat_setup_info(ct, &newrange, NF_NAT_MANIP_SRC); |
89 | } | 89 | } |
90 | 90 | ||
91 | static int | 91 | static int |
@@ -139,7 +139,7 @@ static struct xt_target masquerade_tg_reg __read_mostly = { | |||
139 | .name = "MASQUERADE", | 139 | .name = "MASQUERADE", |
140 | .family = NFPROTO_IPV4, | 140 | .family = NFPROTO_IPV4, |
141 | .target = masquerade_tg, | 141 | .target = masquerade_tg, |
142 | .targetsize = sizeof(struct nf_nat_multi_range_compat), | 142 | .targetsize = sizeof(struct nf_nat_ipv4_multi_range_compat), |
143 | .table = "nat", | 143 | .table = "nat", |
144 | .hooks = 1 << NF_INET_POST_ROUTING, | 144 | .hooks = 1 << NF_INET_POST_ROUTING, |
145 | .checkentry = masquerade_tg_check, | 145 | .checkentry = masquerade_tg_check, |
diff --git a/net/ipv4/netfilter/ipt_NETMAP.c b/net/ipv4/netfilter/ipt_NETMAP.c index 6cdb298f1035..b5bfbbabf70d 100644 --- a/net/ipv4/netfilter/ipt_NETMAP.c +++ b/net/ipv4/netfilter/ipt_NETMAP.c | |||
@@ -24,9 +24,9 @@ MODULE_DESCRIPTION("Xtables: 1:1 NAT mapping of IPv4 subnets"); | |||
24 | 24 | ||
25 | static int netmap_tg_check(const struct xt_tgchk_param *par) | 25 | static int netmap_tg_check(const struct xt_tgchk_param *par) |
26 | { | 26 | { |
27 | const struct nf_nat_multi_range_compat *mr = par->targinfo; | 27 | const struct nf_nat_ipv4_multi_range_compat *mr = par->targinfo; |
28 | 28 | ||
29 | if (!(mr->range[0].flags & IP_NAT_RANGE_MAP_IPS)) { | 29 | if (!(mr->range[0].flags & NF_NAT_RANGE_MAP_IPS)) { |
30 | pr_debug("bad MAP_IPS.\n"); | 30 | pr_debug("bad MAP_IPS.\n"); |
31 | return -EINVAL; | 31 | return -EINVAL; |
32 | } | 32 | } |
@@ -43,8 +43,8 @@ netmap_tg(struct sk_buff *skb, const struct xt_action_param *par) | |||
43 | struct nf_conn *ct; | 43 | struct nf_conn *ct; |
44 | enum ip_conntrack_info ctinfo; | 44 | enum ip_conntrack_info ctinfo; |
45 | __be32 new_ip, netmask; | 45 | __be32 new_ip, netmask; |
46 | const struct nf_nat_multi_range_compat *mr = par->targinfo; | 46 | const struct nf_nat_ipv4_multi_range_compat *mr = par->targinfo; |
47 | struct nf_nat_range newrange; | 47 | struct nf_nat_ipv4_range newrange; |
48 | 48 | ||
49 | NF_CT_ASSERT(par->hooknum == NF_INET_PRE_ROUTING || | 49 | NF_CT_ASSERT(par->hooknum == NF_INET_PRE_ROUTING || |
50 | par->hooknum == NF_INET_POST_ROUTING || | 50 | par->hooknum == NF_INET_POST_ROUTING || |
@@ -61,8 +61,8 @@ netmap_tg(struct sk_buff *skb, const struct xt_action_param *par) | |||
61 | new_ip = ip_hdr(skb)->saddr & ~netmask; | 61 | new_ip = ip_hdr(skb)->saddr & ~netmask; |
62 | new_ip |= mr->range[0].min_ip & netmask; | 62 | new_ip |= mr->range[0].min_ip & netmask; |
63 | 63 | ||
64 | newrange = ((struct nf_nat_range) | 64 | newrange = ((struct nf_nat_ipv4_range) |
65 | { mr->range[0].flags | IP_NAT_RANGE_MAP_IPS, | 65 | { mr->range[0].flags | NF_NAT_RANGE_MAP_IPS, |
66 | new_ip, new_ip, | 66 | new_ip, new_ip, |
67 | mr->range[0].min, mr->range[0].max }); | 67 | mr->range[0].min, mr->range[0].max }); |
68 | 68 | ||
@@ -74,7 +74,7 @@ static struct xt_target netmap_tg_reg __read_mostly = { | |||
74 | .name = "NETMAP", | 74 | .name = "NETMAP", |
75 | .family = NFPROTO_IPV4, | 75 | .family = NFPROTO_IPV4, |
76 | .target = netmap_tg, | 76 | .target = netmap_tg, |
77 | .targetsize = sizeof(struct nf_nat_multi_range_compat), | 77 | .targetsize = sizeof(struct nf_nat_ipv4_multi_range_compat), |
78 | .table = "nat", | 78 | .table = "nat", |
79 | .hooks = (1 << NF_INET_PRE_ROUTING) | | 79 | .hooks = (1 << NF_INET_PRE_ROUTING) | |
80 | (1 << NF_INET_POST_ROUTING) | | 80 | (1 << NF_INET_POST_ROUTING) | |
diff --git a/net/ipv4/netfilter/ipt_REDIRECT.c b/net/ipv4/netfilter/ipt_REDIRECT.c index 18a0656505a0..7c0103a5203e 100644 --- a/net/ipv4/netfilter/ipt_REDIRECT.c +++ b/net/ipv4/netfilter/ipt_REDIRECT.c | |||
@@ -28,9 +28,9 @@ MODULE_DESCRIPTION("Xtables: Connection redirection to localhost"); | |||
28 | /* FIXME: Take multiple ranges --RR */ | 28 | /* FIXME: Take multiple ranges --RR */ |
29 | static int redirect_tg_check(const struct xt_tgchk_param *par) | 29 | static int redirect_tg_check(const struct xt_tgchk_param *par) |
30 | { | 30 | { |
31 | const struct nf_nat_multi_range_compat *mr = par->targinfo; | 31 | const struct nf_nat_ipv4_multi_range_compat *mr = par->targinfo; |
32 | 32 | ||
33 | if (mr->range[0].flags & IP_NAT_RANGE_MAP_IPS) { | 33 | if (mr->range[0].flags & NF_NAT_RANGE_MAP_IPS) { |
34 | pr_debug("bad MAP_IPS.\n"); | 34 | pr_debug("bad MAP_IPS.\n"); |
35 | return -EINVAL; | 35 | return -EINVAL; |
36 | } | 36 | } |
@@ -47,8 +47,8 @@ redirect_tg(struct sk_buff *skb, const struct xt_action_param *par) | |||
47 | struct nf_conn *ct; | 47 | struct nf_conn *ct; |
48 | enum ip_conntrack_info ctinfo; | 48 | enum ip_conntrack_info ctinfo; |
49 | __be32 newdst; | 49 | __be32 newdst; |
50 | const struct nf_nat_multi_range_compat *mr = par->targinfo; | 50 | const struct nf_nat_ipv4_multi_range_compat *mr = par->targinfo; |
51 | struct nf_nat_range newrange; | 51 | struct nf_nat_ipv4_range newrange; |
52 | 52 | ||
53 | NF_CT_ASSERT(par->hooknum == NF_INET_PRE_ROUTING || | 53 | NF_CT_ASSERT(par->hooknum == NF_INET_PRE_ROUTING || |
54 | par->hooknum == NF_INET_LOCAL_OUT); | 54 | par->hooknum == NF_INET_LOCAL_OUT); |
@@ -76,20 +76,20 @@ redirect_tg(struct sk_buff *skb, const struct xt_action_param *par) | |||
76 | } | 76 | } |
77 | 77 | ||
78 | /* Transfer from original range. */ | 78 | /* Transfer from original range. */ |
79 | newrange = ((struct nf_nat_range) | 79 | newrange = ((struct nf_nat_ipv4_range) |
80 | { mr->range[0].flags | IP_NAT_RANGE_MAP_IPS, | 80 | { mr->range[0].flags | NF_NAT_RANGE_MAP_IPS, |
81 | newdst, newdst, | 81 | newdst, newdst, |
82 | mr->range[0].min, mr->range[0].max }); | 82 | mr->range[0].min, mr->range[0].max }); |
83 | 83 | ||
84 | /* Hand modified range to generic setup. */ | 84 | /* Hand modified range to generic setup. */ |
85 | return nf_nat_setup_info(ct, &newrange, IP_NAT_MANIP_DST); | 85 | return nf_nat_setup_info(ct, &newrange, NF_NAT_MANIP_DST); |
86 | } | 86 | } |
87 | 87 | ||
88 | static struct xt_target redirect_tg_reg __read_mostly = { | 88 | static struct xt_target redirect_tg_reg __read_mostly = { |
89 | .name = "REDIRECT", | 89 | .name = "REDIRECT", |
90 | .family = NFPROTO_IPV4, | 90 | .family = NFPROTO_IPV4, |
91 | .target = redirect_tg, | 91 | .target = redirect_tg, |
92 | .targetsize = sizeof(struct nf_nat_multi_range_compat), | 92 | .targetsize = sizeof(struct nf_nat_ipv4_multi_range_compat), |
93 | .table = "nat", | 93 | .table = "nat", |
94 | .hooks = (1 << NF_INET_PRE_ROUTING) | (1 << NF_INET_LOCAL_OUT), | 94 | .hooks = (1 << NF_INET_PRE_ROUTING) | (1 << NF_INET_LOCAL_OUT), |
95 | .checkentry = redirect_tg_check, | 95 | .checkentry = redirect_tg_check, |
diff --git a/net/ipv4/netfilter/nf_nat_core.c b/net/ipv4/netfilter/nf_nat_core.c index 447bc5cfdc6c..58ab7a4611dd 100644 --- a/net/ipv4/netfilter/nf_nat_core.c +++ b/net/ipv4/netfilter/nf_nat_core.c | |||
@@ -82,14 +82,14 @@ EXPORT_SYMBOL(nf_nat_used_tuple); | |||
82 | * that meet the constraints of range. */ | 82 | * that meet the constraints of range. */ |
83 | static int | 83 | static int |
84 | in_range(const struct nf_conntrack_tuple *tuple, | 84 | in_range(const struct nf_conntrack_tuple *tuple, |
85 | const struct nf_nat_range *range) | 85 | const struct nf_nat_ipv4_range *range) |
86 | { | 86 | { |
87 | const struct nf_nat_protocol *proto; | 87 | const struct nf_nat_protocol *proto; |
88 | int ret = 0; | 88 | int ret = 0; |
89 | 89 | ||
90 | /* If we are supposed to map IPs, then we must be in the | 90 | /* If we are supposed to map IPs, then we must be in the |
91 | range specified, otherwise let this drag us onto a new src IP. */ | 91 | range specified, otherwise let this drag us onto a new src IP. */ |
92 | if (range->flags & IP_NAT_RANGE_MAP_IPS) { | 92 | if (range->flags & NF_NAT_RANGE_MAP_IPS) { |
93 | if (ntohl(tuple->src.u3.ip) < ntohl(range->min_ip) || | 93 | if (ntohl(tuple->src.u3.ip) < ntohl(range->min_ip) || |
94 | ntohl(tuple->src.u3.ip) > ntohl(range->max_ip)) | 94 | ntohl(tuple->src.u3.ip) > ntohl(range->max_ip)) |
95 | return 0; | 95 | return 0; |
@@ -97,8 +97,8 @@ in_range(const struct nf_conntrack_tuple *tuple, | |||
97 | 97 | ||
98 | rcu_read_lock(); | 98 | rcu_read_lock(); |
99 | proto = __nf_nat_proto_find(tuple->dst.protonum); | 99 | proto = __nf_nat_proto_find(tuple->dst.protonum); |
100 | if (!(range->flags & IP_NAT_RANGE_PROTO_SPECIFIED) || | 100 | if (!(range->flags & NF_NAT_RANGE_PROTO_SPECIFIED) || |
101 | proto->in_range(tuple, IP_NAT_MANIP_SRC, | 101 | proto->in_range(tuple, NF_NAT_MANIP_SRC, |
102 | &range->min, &range->max)) | 102 | &range->min, &range->max)) |
103 | ret = 1; | 103 | ret = 1; |
104 | rcu_read_unlock(); | 104 | rcu_read_unlock(); |
@@ -123,7 +123,7 @@ static int | |||
123 | find_appropriate_src(struct net *net, u16 zone, | 123 | find_appropriate_src(struct net *net, u16 zone, |
124 | const struct nf_conntrack_tuple *tuple, | 124 | const struct nf_conntrack_tuple *tuple, |
125 | struct nf_conntrack_tuple *result, | 125 | struct nf_conntrack_tuple *result, |
126 | const struct nf_nat_range *range) | 126 | const struct nf_nat_ipv4_range *range) |
127 | { | 127 | { |
128 | unsigned int h = hash_by_src(net, zone, tuple); | 128 | unsigned int h = hash_by_src(net, zone, tuple); |
129 | const struct nf_conn_nat *nat; | 129 | const struct nf_conn_nat *nat; |
@@ -157,7 +157,7 @@ find_appropriate_src(struct net *net, u16 zone, | |||
157 | */ | 157 | */ |
158 | static void | 158 | static void |
159 | find_best_ips_proto(u16 zone, struct nf_conntrack_tuple *tuple, | 159 | find_best_ips_proto(u16 zone, struct nf_conntrack_tuple *tuple, |
160 | const struct nf_nat_range *range, | 160 | const struct nf_nat_ipv4_range *range, |
161 | const struct nf_conn *ct, | 161 | const struct nf_conn *ct, |
162 | enum nf_nat_manip_type maniptype) | 162 | enum nf_nat_manip_type maniptype) |
163 | { | 163 | { |
@@ -166,10 +166,10 @@ find_best_ips_proto(u16 zone, struct nf_conntrack_tuple *tuple, | |||
166 | u_int32_t minip, maxip, j; | 166 | u_int32_t minip, maxip, j; |
167 | 167 | ||
168 | /* No IP mapping? Do nothing. */ | 168 | /* No IP mapping? Do nothing. */ |
169 | if (!(range->flags & IP_NAT_RANGE_MAP_IPS)) | 169 | if (!(range->flags & NF_NAT_RANGE_MAP_IPS)) |
170 | return; | 170 | return; |
171 | 171 | ||
172 | if (maniptype == IP_NAT_MANIP_SRC) | 172 | if (maniptype == NF_NAT_MANIP_SRC) |
173 | var_ipp = &tuple->src.u3.ip; | 173 | var_ipp = &tuple->src.u3.ip; |
174 | else | 174 | else |
175 | var_ipp = &tuple->dst.u3.ip; | 175 | var_ipp = &tuple->dst.u3.ip; |
@@ -189,7 +189,7 @@ find_best_ips_proto(u16 zone, struct nf_conntrack_tuple *tuple, | |||
189 | minip = ntohl(range->min_ip); | 189 | minip = ntohl(range->min_ip); |
190 | maxip = ntohl(range->max_ip); | 190 | maxip = ntohl(range->max_ip); |
191 | j = jhash_2words((__force u32)tuple->src.u3.ip, | 191 | j = jhash_2words((__force u32)tuple->src.u3.ip, |
192 | range->flags & IP_NAT_RANGE_PERSISTENT ? | 192 | range->flags & NF_NAT_RANGE_PERSISTENT ? |
193 | 0 : (__force u32)tuple->dst.u3.ip ^ zone, 0); | 193 | 0 : (__force u32)tuple->dst.u3.ip ^ zone, 0); |
194 | j = ((u64)j * (maxip - minip + 1)) >> 32; | 194 | j = ((u64)j * (maxip - minip + 1)) >> 32; |
195 | *var_ipp = htonl(minip + j); | 195 | *var_ipp = htonl(minip + j); |
@@ -204,7 +204,7 @@ find_best_ips_proto(u16 zone, struct nf_conntrack_tuple *tuple, | |||
204 | static void | 204 | static void |
205 | get_unique_tuple(struct nf_conntrack_tuple *tuple, | 205 | get_unique_tuple(struct nf_conntrack_tuple *tuple, |
206 | const struct nf_conntrack_tuple *orig_tuple, | 206 | const struct nf_conntrack_tuple *orig_tuple, |
207 | const struct nf_nat_range *range, | 207 | const struct nf_nat_ipv4_range *range, |
208 | struct nf_conn *ct, | 208 | struct nf_conn *ct, |
209 | enum nf_nat_manip_type maniptype) | 209 | enum nf_nat_manip_type maniptype) |
210 | { | 210 | { |
@@ -219,8 +219,8 @@ get_unique_tuple(struct nf_conntrack_tuple *tuple, | |||
219 | This is only required for source (ie. NAT/masq) mappings. | 219 | This is only required for source (ie. NAT/masq) mappings. |
220 | So far, we don't do local source mappings, so multiple | 220 | So far, we don't do local source mappings, so multiple |
221 | manips not an issue. */ | 221 | manips not an issue. */ |
222 | if (maniptype == IP_NAT_MANIP_SRC && | 222 | if (maniptype == NF_NAT_MANIP_SRC && |
223 | !(range->flags & IP_NAT_RANGE_PROTO_RANDOM)) { | 223 | !(range->flags & NF_NAT_RANGE_PROTO_RANDOM)) { |
224 | /* try the original tuple first */ | 224 | /* try the original tuple first */ |
225 | if (in_range(orig_tuple, range)) { | 225 | if (in_range(orig_tuple, range)) { |
226 | if (!nf_nat_used_tuple(orig_tuple, ct)) { | 226 | if (!nf_nat_used_tuple(orig_tuple, ct)) { |
@@ -247,8 +247,8 @@ get_unique_tuple(struct nf_conntrack_tuple *tuple, | |||
247 | proto = __nf_nat_proto_find(orig_tuple->dst.protonum); | 247 | proto = __nf_nat_proto_find(orig_tuple->dst.protonum); |
248 | 248 | ||
249 | /* Only bother mapping if it's not already in range and unique */ | 249 | /* Only bother mapping if it's not already in range and unique */ |
250 | if (!(range->flags & IP_NAT_RANGE_PROTO_RANDOM)) { | 250 | if (!(range->flags & NF_NAT_RANGE_PROTO_RANDOM)) { |
251 | if (range->flags & IP_NAT_RANGE_PROTO_SPECIFIED) { | 251 | if (range->flags & NF_NAT_RANGE_PROTO_SPECIFIED) { |
252 | if (proto->in_range(tuple, maniptype, &range->min, | 252 | if (proto->in_range(tuple, maniptype, &range->min, |
253 | &range->max) && | 253 | &range->max) && |
254 | (range->min.all == range->max.all || | 254 | (range->min.all == range->max.all || |
@@ -267,7 +267,7 @@ out: | |||
267 | 267 | ||
268 | unsigned int | 268 | unsigned int |
269 | nf_nat_setup_info(struct nf_conn *ct, | 269 | nf_nat_setup_info(struct nf_conn *ct, |
270 | const struct nf_nat_range *range, | 270 | const struct nf_nat_ipv4_range *range, |
271 | enum nf_nat_manip_type maniptype) | 271 | enum nf_nat_manip_type maniptype) |
272 | { | 272 | { |
273 | struct net *net = nf_ct_net(ct); | 273 | struct net *net = nf_ct_net(ct); |
@@ -284,8 +284,8 @@ nf_nat_setup_info(struct nf_conn *ct, | |||
284 | } | 284 | } |
285 | } | 285 | } |
286 | 286 | ||
287 | NF_CT_ASSERT(maniptype == IP_NAT_MANIP_SRC || | 287 | NF_CT_ASSERT(maniptype == NF_NAT_MANIP_SRC || |
288 | maniptype == IP_NAT_MANIP_DST); | 288 | maniptype == NF_NAT_MANIP_DST); |
289 | BUG_ON(nf_nat_initialized(ct, maniptype)); | 289 | BUG_ON(nf_nat_initialized(ct, maniptype)); |
290 | 290 | ||
291 | /* What we've got will look like inverse of reply. Normally | 291 | /* What we've got will look like inverse of reply. Normally |
@@ -306,13 +306,13 @@ nf_nat_setup_info(struct nf_conn *ct, | |||
306 | nf_conntrack_alter_reply(ct, &reply); | 306 | nf_conntrack_alter_reply(ct, &reply); |
307 | 307 | ||
308 | /* Non-atomic: we own this at the moment. */ | 308 | /* Non-atomic: we own this at the moment. */ |
309 | if (maniptype == IP_NAT_MANIP_SRC) | 309 | if (maniptype == NF_NAT_MANIP_SRC) |
310 | ct->status |= IPS_SRC_NAT; | 310 | ct->status |= IPS_SRC_NAT; |
311 | else | 311 | else |
312 | ct->status |= IPS_DST_NAT; | 312 | ct->status |= IPS_DST_NAT; |
313 | } | 313 | } |
314 | 314 | ||
315 | if (maniptype == IP_NAT_MANIP_SRC) { | 315 | if (maniptype == NF_NAT_MANIP_SRC) { |
316 | unsigned int srchash; | 316 | unsigned int srchash; |
317 | 317 | ||
318 | srchash = hash_by_src(net, nf_ct_zone(ct), | 318 | srchash = hash_by_src(net, nf_ct_zone(ct), |
@@ -327,7 +327,7 @@ nf_nat_setup_info(struct nf_conn *ct, | |||
327 | } | 327 | } |
328 | 328 | ||
329 | /* It's done. */ | 329 | /* It's done. */ |
330 | if (maniptype == IP_NAT_MANIP_DST) | 330 | if (maniptype == NF_NAT_MANIP_DST) |
331 | ct->status |= IPS_DST_NAT_DONE; | 331 | ct->status |= IPS_DST_NAT_DONE; |
332 | else | 332 | else |
333 | ct->status |= IPS_SRC_NAT_DONE; | 333 | ct->status |= IPS_SRC_NAT_DONE; |
@@ -361,7 +361,7 @@ manip_pkt(u_int16_t proto, | |||
361 | 361 | ||
362 | iph = (void *)skb->data + iphdroff; | 362 | iph = (void *)skb->data + iphdroff; |
363 | 363 | ||
364 | if (maniptype == IP_NAT_MANIP_SRC) { | 364 | if (maniptype == NF_NAT_MANIP_SRC) { |
365 | csum_replace4(&iph->check, iph->saddr, target->src.u3.ip); | 365 | csum_replace4(&iph->check, iph->saddr, target->src.u3.ip); |
366 | iph->saddr = target->src.u3.ip; | 366 | iph->saddr = target->src.u3.ip; |
367 | } else { | 367 | } else { |
@@ -381,7 +381,7 @@ unsigned int nf_nat_packet(struct nf_conn *ct, | |||
381 | unsigned long statusbit; | 381 | unsigned long statusbit; |
382 | enum nf_nat_manip_type mtype = HOOK2MANIP(hooknum); | 382 | enum nf_nat_manip_type mtype = HOOK2MANIP(hooknum); |
383 | 383 | ||
384 | if (mtype == IP_NAT_MANIP_SRC) | 384 | if (mtype == NF_NAT_MANIP_SRC) |
385 | statusbit = IPS_SRC_NAT; | 385 | statusbit = IPS_SRC_NAT; |
386 | else | 386 | else |
387 | statusbit = IPS_DST_NAT; | 387 | statusbit = IPS_DST_NAT; |
@@ -447,7 +447,7 @@ int nf_nat_icmp_reply_translation(struct nf_conn *ct, | |||
447 | return 0; | 447 | return 0; |
448 | } | 448 | } |
449 | 449 | ||
450 | if (manip == IP_NAT_MANIP_SRC) | 450 | if (manip == NF_NAT_MANIP_SRC) |
451 | statusbit = IPS_SRC_NAT; | 451 | statusbit = IPS_SRC_NAT; |
452 | else | 452 | else |
453 | statusbit = IPS_DST_NAT; | 453 | statusbit = IPS_DST_NAT; |
@@ -602,7 +602,7 @@ static const struct nla_policy protonat_nla_policy[CTA_PROTONAT_MAX+1] = { | |||
602 | 602 | ||
603 | static int nfnetlink_parse_nat_proto(struct nlattr *attr, | 603 | static int nfnetlink_parse_nat_proto(struct nlattr *attr, |
604 | const struct nf_conn *ct, | 604 | const struct nf_conn *ct, |
605 | struct nf_nat_range *range) | 605 | struct nf_nat_ipv4_range *range) |
606 | { | 606 | { |
607 | struct nlattr *tb[CTA_PROTONAT_MAX+1]; | 607 | struct nlattr *tb[CTA_PROTONAT_MAX+1]; |
608 | const struct nf_nat_protocol *npt; | 608 | const struct nf_nat_protocol *npt; |
@@ -626,7 +626,7 @@ static const struct nla_policy nat_nla_policy[CTA_NAT_MAX+1] = { | |||
626 | 626 | ||
627 | static int | 627 | static int |
628 | nfnetlink_parse_nat(const struct nlattr *nat, | 628 | nfnetlink_parse_nat(const struct nlattr *nat, |
629 | const struct nf_conn *ct, struct nf_nat_range *range) | 629 | const struct nf_conn *ct, struct nf_nat_ipv4_range *range) |
630 | { | 630 | { |
631 | struct nlattr *tb[CTA_NAT_MAX+1]; | 631 | struct nlattr *tb[CTA_NAT_MAX+1]; |
632 | int err; | 632 | int err; |
@@ -646,7 +646,7 @@ nfnetlink_parse_nat(const struct nlattr *nat, | |||
646 | range->max_ip = nla_get_be32(tb[CTA_NAT_MAXIP]); | 646 | range->max_ip = nla_get_be32(tb[CTA_NAT_MAXIP]); |
647 | 647 | ||
648 | if (range->min_ip) | 648 | if (range->min_ip) |
649 | range->flags |= IP_NAT_RANGE_MAP_IPS; | 649 | range->flags |= NF_NAT_RANGE_MAP_IPS; |
650 | 650 | ||
651 | if (!tb[CTA_NAT_PROTO]) | 651 | if (!tb[CTA_NAT_PROTO]) |
652 | return 0; | 652 | return 0; |
@@ -663,7 +663,7 @@ nfnetlink_parse_nat_setup(struct nf_conn *ct, | |||
663 | enum nf_nat_manip_type manip, | 663 | enum nf_nat_manip_type manip, |
664 | const struct nlattr *attr) | 664 | const struct nlattr *attr) |
665 | { | 665 | { |
666 | struct nf_nat_range range; | 666 | struct nf_nat_ipv4_range range; |
667 | 667 | ||
668 | if (nfnetlink_parse_nat(attr, ct, &range) < 0) | 668 | if (nfnetlink_parse_nat(attr, ct, &range) < 0) |
669 | return -EINVAL; | 669 | return -EINVAL; |
diff --git a/net/ipv4/netfilter/nf_nat_h323.c b/net/ipv4/netfilter/nf_nat_h323.c index b9a1136addbd..dc1dd912baf4 100644 --- a/net/ipv4/netfilter/nf_nat_h323.c +++ b/net/ipv4/netfilter/nf_nat_h323.c | |||
@@ -398,7 +398,7 @@ static int nat_h245(struct sk_buff *skb, struct nf_conn *ct, | |||
398 | static void ip_nat_q931_expect(struct nf_conn *new, | 398 | static void ip_nat_q931_expect(struct nf_conn *new, |
399 | struct nf_conntrack_expect *this) | 399 | struct nf_conntrack_expect *this) |
400 | { | 400 | { |
401 | struct nf_nat_range range; | 401 | struct nf_nat_ipv4_range range; |
402 | 402 | ||
403 | if (this->tuple.src.u3.ip != 0) { /* Only accept calls from GK */ | 403 | if (this->tuple.src.u3.ip != 0) { /* Only accept calls from GK */ |
404 | nf_nat_follow_master(new, this); | 404 | nf_nat_follow_master(new, this); |
@@ -409,16 +409,16 @@ static void ip_nat_q931_expect(struct nf_conn *new, | |||
409 | BUG_ON(new->status & IPS_NAT_DONE_MASK); | 409 | BUG_ON(new->status & IPS_NAT_DONE_MASK); |
410 | 410 | ||
411 | /* Change src to where master sends to */ | 411 | /* Change src to where master sends to */ |
412 | range.flags = IP_NAT_RANGE_MAP_IPS; | 412 | range.flags = NF_NAT_RANGE_MAP_IPS; |
413 | range.min_ip = range.max_ip = new->tuplehash[!this->dir].tuple.src.u3.ip; | 413 | range.min_ip = range.max_ip = new->tuplehash[!this->dir].tuple.src.u3.ip; |
414 | nf_nat_setup_info(new, &range, IP_NAT_MANIP_SRC); | 414 | nf_nat_setup_info(new, &range, NF_NAT_MANIP_SRC); |
415 | 415 | ||
416 | /* For DST manip, map port here to where it's expected. */ | 416 | /* For DST manip, map port here to where it's expected. */ |
417 | range.flags = (IP_NAT_RANGE_MAP_IPS | IP_NAT_RANGE_PROTO_SPECIFIED); | 417 | range.flags = (NF_NAT_RANGE_MAP_IPS | NF_NAT_RANGE_PROTO_SPECIFIED); |
418 | range.min = range.max = this->saved_proto; | 418 | range.min = range.max = this->saved_proto; |
419 | range.min_ip = range.max_ip = | 419 | range.min_ip = range.max_ip = |
420 | new->master->tuplehash[!this->dir].tuple.src.u3.ip; | 420 | new->master->tuplehash[!this->dir].tuple.src.u3.ip; |
421 | nf_nat_setup_info(new, &range, IP_NAT_MANIP_DST); | 421 | nf_nat_setup_info(new, &range, NF_NAT_MANIP_DST); |
422 | } | 422 | } |
423 | 423 | ||
424 | /****************************************************************************/ | 424 | /****************************************************************************/ |
@@ -496,21 +496,21 @@ static int nat_q931(struct sk_buff *skb, struct nf_conn *ct, | |||
496 | static void ip_nat_callforwarding_expect(struct nf_conn *new, | 496 | static void ip_nat_callforwarding_expect(struct nf_conn *new, |
497 | struct nf_conntrack_expect *this) | 497 | struct nf_conntrack_expect *this) |
498 | { | 498 | { |
499 | struct nf_nat_range range; | 499 | struct nf_nat_ipv4_range range; |
500 | 500 | ||
501 | /* This must be a fresh one. */ | 501 | /* This must be a fresh one. */ |
502 | BUG_ON(new->status & IPS_NAT_DONE_MASK); | 502 | BUG_ON(new->status & IPS_NAT_DONE_MASK); |
503 | 503 | ||
504 | /* Change src to where master sends to */ | 504 | /* Change src to where master sends to */ |
505 | range.flags = IP_NAT_RANGE_MAP_IPS; | 505 | range.flags = NF_NAT_RANGE_MAP_IPS; |
506 | range.min_ip = range.max_ip = new->tuplehash[!this->dir].tuple.src.u3.ip; | 506 | range.min_ip = range.max_ip = new->tuplehash[!this->dir].tuple.src.u3.ip; |
507 | nf_nat_setup_info(new, &range, IP_NAT_MANIP_SRC); | 507 | nf_nat_setup_info(new, &range, NF_NAT_MANIP_SRC); |
508 | 508 | ||
509 | /* For DST manip, map port here to where it's expected. */ | 509 | /* For DST manip, map port here to where it's expected. */ |
510 | range.flags = (IP_NAT_RANGE_MAP_IPS | IP_NAT_RANGE_PROTO_SPECIFIED); | 510 | range.flags = (NF_NAT_RANGE_MAP_IPS | NF_NAT_RANGE_PROTO_SPECIFIED); |
511 | range.min = range.max = this->saved_proto; | 511 | range.min = range.max = this->saved_proto; |
512 | range.min_ip = range.max_ip = this->saved_ip; | 512 | range.min_ip = range.max_ip = this->saved_ip; |
513 | nf_nat_setup_info(new, &range, IP_NAT_MANIP_DST); | 513 | nf_nat_setup_info(new, &range, NF_NAT_MANIP_DST); |
514 | } | 514 | } |
515 | 515 | ||
516 | /****************************************************************************/ | 516 | /****************************************************************************/ |
diff --git a/net/ipv4/netfilter/nf_nat_helper.c b/net/ipv4/netfilter/nf_nat_helper.c index ebc5f8894f99..049e8b7c3188 100644 --- a/net/ipv4/netfilter/nf_nat_helper.c +++ b/net/ipv4/netfilter/nf_nat_helper.c | |||
@@ -430,22 +430,22 @@ nf_nat_seq_adjust(struct sk_buff *skb, | |||
430 | void nf_nat_follow_master(struct nf_conn *ct, | 430 | void nf_nat_follow_master(struct nf_conn *ct, |
431 | struct nf_conntrack_expect *exp) | 431 | struct nf_conntrack_expect *exp) |
432 | { | 432 | { |
433 | struct nf_nat_range range; | 433 | struct nf_nat_ipv4_range range; |
434 | 434 | ||
435 | /* This must be a fresh one. */ | 435 | /* This must be a fresh one. */ |
436 | BUG_ON(ct->status & IPS_NAT_DONE_MASK); | 436 | BUG_ON(ct->status & IPS_NAT_DONE_MASK); |
437 | 437 | ||
438 | /* Change src to where master sends to */ | 438 | /* Change src to where master sends to */ |
439 | range.flags = IP_NAT_RANGE_MAP_IPS; | 439 | range.flags = NF_NAT_RANGE_MAP_IPS; |
440 | range.min_ip = range.max_ip | 440 | range.min_ip = range.max_ip |
441 | = ct->master->tuplehash[!exp->dir].tuple.dst.u3.ip; | 441 | = ct->master->tuplehash[!exp->dir].tuple.dst.u3.ip; |
442 | nf_nat_setup_info(ct, &range, IP_NAT_MANIP_SRC); | 442 | nf_nat_setup_info(ct, &range, NF_NAT_MANIP_SRC); |
443 | 443 | ||
444 | /* For DST manip, map port here to where it's expected. */ | 444 | /* For DST manip, map port here to where it's expected. */ |
445 | range.flags = (IP_NAT_RANGE_MAP_IPS | IP_NAT_RANGE_PROTO_SPECIFIED); | 445 | range.flags = (NF_NAT_RANGE_MAP_IPS | NF_NAT_RANGE_PROTO_SPECIFIED); |
446 | range.min = range.max = exp->saved_proto; | 446 | range.min = range.max = exp->saved_proto; |
447 | range.min_ip = range.max_ip | 447 | range.min_ip = range.max_ip |
448 | = ct->master->tuplehash[!exp->dir].tuple.src.u3.ip; | 448 | = ct->master->tuplehash[!exp->dir].tuple.src.u3.ip; |
449 | nf_nat_setup_info(ct, &range, IP_NAT_MANIP_DST); | 449 | nf_nat_setup_info(ct, &range, NF_NAT_MANIP_DST); |
450 | } | 450 | } |
451 | EXPORT_SYMBOL(nf_nat_follow_master); | 451 | EXPORT_SYMBOL(nf_nat_follow_master); |
diff --git a/net/ipv4/netfilter/nf_nat_pptp.c b/net/ipv4/netfilter/nf_nat_pptp.c index 3e8284ba46b8..c273d58980ae 100644 --- a/net/ipv4/netfilter/nf_nat_pptp.c +++ b/net/ipv4/netfilter/nf_nat_pptp.c | |||
@@ -47,7 +47,7 @@ static void pptp_nat_expected(struct nf_conn *ct, | |||
47 | struct nf_conntrack_tuple t; | 47 | struct nf_conntrack_tuple t; |
48 | const struct nf_ct_pptp_master *ct_pptp_info; | 48 | const struct nf_ct_pptp_master *ct_pptp_info; |
49 | const struct nf_nat_pptp *nat_pptp_info; | 49 | const struct nf_nat_pptp *nat_pptp_info; |
50 | struct nf_nat_range range; | 50 | struct nf_nat_ipv4_range range; |
51 | 51 | ||
52 | ct_pptp_info = &nfct_help(master)->help.ct_pptp_info; | 52 | ct_pptp_info = &nfct_help(master)->help.ct_pptp_info; |
53 | nat_pptp_info = &nfct_nat(master)->help.nat_pptp_info; | 53 | nat_pptp_info = &nfct_nat(master)->help.nat_pptp_info; |
@@ -88,24 +88,24 @@ static void pptp_nat_expected(struct nf_conn *ct, | |||
88 | BUG_ON(ct->status & IPS_NAT_DONE_MASK); | 88 | BUG_ON(ct->status & IPS_NAT_DONE_MASK); |
89 | 89 | ||
90 | /* Change src to where master sends to */ | 90 | /* Change src to where master sends to */ |
91 | range.flags = IP_NAT_RANGE_MAP_IPS; | 91 | range.flags = NF_NAT_RANGE_MAP_IPS; |
92 | range.min_ip = range.max_ip | 92 | range.min_ip = range.max_ip |
93 | = ct->master->tuplehash[!exp->dir].tuple.dst.u3.ip; | 93 | = ct->master->tuplehash[!exp->dir].tuple.dst.u3.ip; |
94 | if (exp->dir == IP_CT_DIR_ORIGINAL) { | 94 | if (exp->dir == IP_CT_DIR_ORIGINAL) { |
95 | range.flags |= IP_NAT_RANGE_PROTO_SPECIFIED; | 95 | range.flags |= NF_NAT_RANGE_PROTO_SPECIFIED; |
96 | range.min = range.max = exp->saved_proto; | 96 | range.min = range.max = exp->saved_proto; |
97 | } | 97 | } |
98 | nf_nat_setup_info(ct, &range, IP_NAT_MANIP_SRC); | 98 | nf_nat_setup_info(ct, &range, NF_NAT_MANIP_SRC); |
99 | 99 | ||
100 | /* For DST manip, map port here to where it's expected. */ | 100 | /* For DST manip, map port here to where it's expected. */ |
101 | range.flags = IP_NAT_RANGE_MAP_IPS; | 101 | range.flags = NF_NAT_RANGE_MAP_IPS; |
102 | range.min_ip = range.max_ip | 102 | range.min_ip = range.max_ip |
103 | = ct->master->tuplehash[!exp->dir].tuple.src.u3.ip; | 103 | = ct->master->tuplehash[!exp->dir].tuple.src.u3.ip; |
104 | if (exp->dir == IP_CT_DIR_REPLY) { | 104 | if (exp->dir == IP_CT_DIR_REPLY) { |
105 | range.flags |= IP_NAT_RANGE_PROTO_SPECIFIED; | 105 | range.flags |= NF_NAT_RANGE_PROTO_SPECIFIED; |
106 | range.min = range.max = exp->saved_proto; | 106 | range.min = range.max = exp->saved_proto; |
107 | } | 107 | } |
108 | nf_nat_setup_info(ct, &range, IP_NAT_MANIP_DST); | 108 | nf_nat_setup_info(ct, &range, NF_NAT_MANIP_DST); |
109 | } | 109 | } |
110 | 110 | ||
111 | /* outbound packets == from PNS to PAC */ | 111 | /* outbound packets == from PNS to PAC */ |
diff --git a/net/ipv4/netfilter/nf_nat_proto_common.c b/net/ipv4/netfilter/nf_nat_proto_common.c index a3d997618602..47fff91c9ae6 100644 --- a/net/ipv4/netfilter/nf_nat_proto_common.c +++ b/net/ipv4/netfilter/nf_nat_proto_common.c | |||
@@ -26,7 +26,7 @@ bool nf_nat_proto_in_range(const struct nf_conntrack_tuple *tuple, | |||
26 | { | 26 | { |
27 | __be16 port; | 27 | __be16 port; |
28 | 28 | ||
29 | if (maniptype == IP_NAT_MANIP_SRC) | 29 | if (maniptype == NF_NAT_MANIP_SRC) |
30 | port = tuple->src.u.all; | 30 | port = tuple->src.u.all; |
31 | else | 31 | else |
32 | port = tuple->dst.u.all; | 32 | port = tuple->dst.u.all; |
@@ -37,7 +37,7 @@ bool nf_nat_proto_in_range(const struct nf_conntrack_tuple *tuple, | |||
37 | EXPORT_SYMBOL_GPL(nf_nat_proto_in_range); | 37 | EXPORT_SYMBOL_GPL(nf_nat_proto_in_range); |
38 | 38 | ||
39 | void nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple, | 39 | void nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple, |
40 | const struct nf_nat_range *range, | 40 | const struct nf_nat_ipv4_range *range, |
41 | enum nf_nat_manip_type maniptype, | 41 | enum nf_nat_manip_type maniptype, |
42 | const struct nf_conn *ct, | 42 | const struct nf_conn *ct, |
43 | u_int16_t *rover) | 43 | u_int16_t *rover) |
@@ -46,15 +46,15 @@ void nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple, | |||
46 | __be16 *portptr; | 46 | __be16 *portptr; |
47 | u_int16_t off; | 47 | u_int16_t off; |
48 | 48 | ||
49 | if (maniptype == IP_NAT_MANIP_SRC) | 49 | if (maniptype == NF_NAT_MANIP_SRC) |
50 | portptr = &tuple->src.u.all; | 50 | portptr = &tuple->src.u.all; |
51 | else | 51 | else |
52 | portptr = &tuple->dst.u.all; | 52 | portptr = &tuple->dst.u.all; |
53 | 53 | ||
54 | /* If no range specified... */ | 54 | /* If no range specified... */ |
55 | if (!(range->flags & IP_NAT_RANGE_PROTO_SPECIFIED)) { | 55 | if (!(range->flags & NF_NAT_RANGE_PROTO_SPECIFIED)) { |
56 | /* If it's dst rewrite, can't change port */ | 56 | /* If it's dst rewrite, can't change port */ |
57 | if (maniptype == IP_NAT_MANIP_DST) | 57 | if (maniptype == NF_NAT_MANIP_DST) |
58 | return; | 58 | return; |
59 | 59 | ||
60 | if (ntohs(*portptr) < 1024) { | 60 | if (ntohs(*portptr) < 1024) { |
@@ -75,9 +75,9 @@ void nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple, | |||
75 | range_size = ntohs(range->max.all) - min + 1; | 75 | range_size = ntohs(range->max.all) - min + 1; |
76 | } | 76 | } |
77 | 77 | ||
78 | if (range->flags & IP_NAT_RANGE_PROTO_RANDOM) | 78 | if (range->flags & NF_NAT_RANGE_PROTO_RANDOM) |
79 | off = secure_ipv4_port_ephemeral(tuple->src.u3.ip, tuple->dst.u3.ip, | 79 | off = secure_ipv4_port_ephemeral(tuple->src.u3.ip, tuple->dst.u3.ip, |
80 | maniptype == IP_NAT_MANIP_SRC | 80 | maniptype == NF_NAT_MANIP_SRC |
81 | ? tuple->dst.u.all | 81 | ? tuple->dst.u.all |
82 | : tuple->src.u.all); | 82 | : tuple->src.u.all); |
83 | else | 83 | else |
@@ -87,7 +87,7 @@ void nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple, | |||
87 | *portptr = htons(min + off % range_size); | 87 | *portptr = htons(min + off % range_size); |
88 | if (++i != range_size && nf_nat_used_tuple(tuple, ct)) | 88 | if (++i != range_size && nf_nat_used_tuple(tuple, ct)) |
89 | continue; | 89 | continue; |
90 | if (!(range->flags & IP_NAT_RANGE_PROTO_RANDOM)) | 90 | if (!(range->flags & NF_NAT_RANGE_PROTO_RANDOM)) |
91 | *rover = off; | 91 | *rover = off; |
92 | return; | 92 | return; |
93 | } | 93 | } |
@@ -97,7 +97,7 @@ EXPORT_SYMBOL_GPL(nf_nat_proto_unique_tuple); | |||
97 | 97 | ||
98 | #if defined(CONFIG_NF_CT_NETLINK) || defined(CONFIG_NF_CT_NETLINK_MODULE) | 98 | #if defined(CONFIG_NF_CT_NETLINK) || defined(CONFIG_NF_CT_NETLINK_MODULE) |
99 | int nf_nat_proto_range_to_nlattr(struct sk_buff *skb, | 99 | int nf_nat_proto_range_to_nlattr(struct sk_buff *skb, |
100 | const struct nf_nat_range *range) | 100 | const struct nf_nat_ipv4_range *range) |
101 | { | 101 | { |
102 | NLA_PUT_BE16(skb, CTA_PROTONAT_PORT_MIN, range->min.all); | 102 | NLA_PUT_BE16(skb, CTA_PROTONAT_PORT_MIN, range->min.all); |
103 | NLA_PUT_BE16(skb, CTA_PROTONAT_PORT_MAX, range->max.all); | 103 | NLA_PUT_BE16(skb, CTA_PROTONAT_PORT_MAX, range->max.all); |
@@ -109,16 +109,16 @@ nla_put_failure: | |||
109 | EXPORT_SYMBOL_GPL(nf_nat_proto_nlattr_to_range); | 109 | EXPORT_SYMBOL_GPL(nf_nat_proto_nlattr_to_range); |
110 | 110 | ||
111 | int nf_nat_proto_nlattr_to_range(struct nlattr *tb[], | 111 | int nf_nat_proto_nlattr_to_range(struct nlattr *tb[], |
112 | struct nf_nat_range *range) | 112 | struct nf_nat_ipv4_range *range) |
113 | { | 113 | { |
114 | if (tb[CTA_PROTONAT_PORT_MIN]) { | 114 | if (tb[CTA_PROTONAT_PORT_MIN]) { |
115 | range->min.all = nla_get_be16(tb[CTA_PROTONAT_PORT_MIN]); | 115 | range->min.all = nla_get_be16(tb[CTA_PROTONAT_PORT_MIN]); |
116 | range->max.all = range->min.tcp.port; | 116 | range->max.all = range->min.tcp.port; |
117 | range->flags |= IP_NAT_RANGE_PROTO_SPECIFIED; | 117 | range->flags |= NF_NAT_RANGE_PROTO_SPECIFIED; |
118 | } | 118 | } |
119 | if (tb[CTA_PROTONAT_PORT_MAX]) { | 119 | if (tb[CTA_PROTONAT_PORT_MAX]) { |
120 | range->max.all = nla_get_be16(tb[CTA_PROTONAT_PORT_MAX]); | 120 | range->max.all = nla_get_be16(tb[CTA_PROTONAT_PORT_MAX]); |
121 | range->flags |= IP_NAT_RANGE_PROTO_SPECIFIED; | 121 | range->flags |= NF_NAT_RANGE_PROTO_SPECIFIED; |
122 | } | 122 | } |
123 | return 0; | 123 | return 0; |
124 | } | 124 | } |
diff --git a/net/ipv4/netfilter/nf_nat_proto_dccp.c b/net/ipv4/netfilter/nf_nat_proto_dccp.c index 570faf2667b2..c43d5b366d0d 100644 --- a/net/ipv4/netfilter/nf_nat_proto_dccp.c +++ b/net/ipv4/netfilter/nf_nat_proto_dccp.c | |||
@@ -24,7 +24,7 @@ static u_int16_t dccp_port_rover; | |||
24 | 24 | ||
25 | static void | 25 | static void |
26 | dccp_unique_tuple(struct nf_conntrack_tuple *tuple, | 26 | dccp_unique_tuple(struct nf_conntrack_tuple *tuple, |
27 | const struct nf_nat_range *range, | 27 | const struct nf_nat_ipv4_range *range, |
28 | enum nf_nat_manip_type maniptype, | 28 | enum nf_nat_manip_type maniptype, |
29 | const struct nf_conn *ct) | 29 | const struct nf_conn *ct) |
30 | { | 30 | { |
@@ -54,7 +54,7 @@ dccp_manip_pkt(struct sk_buff *skb, | |||
54 | iph = (struct iphdr *)(skb->data + iphdroff); | 54 | iph = (struct iphdr *)(skb->data + iphdroff); |
55 | hdr = (struct dccp_hdr *)(skb->data + hdroff); | 55 | hdr = (struct dccp_hdr *)(skb->data + hdroff); |
56 | 56 | ||
57 | if (maniptype == IP_NAT_MANIP_SRC) { | 57 | if (maniptype == NF_NAT_MANIP_SRC) { |
58 | oldip = iph->saddr; | 58 | oldip = iph->saddr; |
59 | newip = tuple->src.u3.ip; | 59 | newip = tuple->src.u3.ip; |
60 | newport = tuple->src.u.dccp.port; | 60 | newport = tuple->src.u.dccp.port; |
diff --git a/net/ipv4/netfilter/nf_nat_proto_gre.c b/net/ipv4/netfilter/nf_nat_proto_gre.c index bc8d83a31c73..9b1c629d7a00 100644 --- a/net/ipv4/netfilter/nf_nat_proto_gre.c +++ b/net/ipv4/netfilter/nf_nat_proto_gre.c | |||
@@ -39,7 +39,7 @@ MODULE_DESCRIPTION("Netfilter NAT protocol helper module for GRE"); | |||
39 | /* generate unique tuple ... */ | 39 | /* generate unique tuple ... */ |
40 | static void | 40 | static void |
41 | gre_unique_tuple(struct nf_conntrack_tuple *tuple, | 41 | gre_unique_tuple(struct nf_conntrack_tuple *tuple, |
42 | const struct nf_nat_range *range, | 42 | const struct nf_nat_ipv4_range *range, |
43 | enum nf_nat_manip_type maniptype, | 43 | enum nf_nat_manip_type maniptype, |
44 | const struct nf_conn *ct) | 44 | const struct nf_conn *ct) |
45 | { | 45 | { |
@@ -52,12 +52,12 @@ gre_unique_tuple(struct nf_conntrack_tuple *tuple, | |||
52 | if (!ct->master) | 52 | if (!ct->master) |
53 | return; | 53 | return; |
54 | 54 | ||
55 | if (maniptype == IP_NAT_MANIP_SRC) | 55 | if (maniptype == NF_NAT_MANIP_SRC) |
56 | keyptr = &tuple->src.u.gre.key; | 56 | keyptr = &tuple->src.u.gre.key; |
57 | else | 57 | else |
58 | keyptr = &tuple->dst.u.gre.key; | 58 | keyptr = &tuple->dst.u.gre.key; |
59 | 59 | ||
60 | if (!(range->flags & IP_NAT_RANGE_PROTO_SPECIFIED)) { | 60 | if (!(range->flags & NF_NAT_RANGE_PROTO_SPECIFIED)) { |
61 | pr_debug("%p: NATing GRE PPTP\n", ct); | 61 | pr_debug("%p: NATing GRE PPTP\n", ct); |
62 | min = 1; | 62 | min = 1; |
63 | range_size = 0xffff; | 63 | range_size = 0xffff; |
@@ -99,7 +99,7 @@ gre_manip_pkt(struct sk_buff *skb, unsigned int iphdroff, | |||
99 | 99 | ||
100 | /* we only have destination manip of a packet, since 'source key' | 100 | /* we only have destination manip of a packet, since 'source key' |
101 | * is not present in the packet itself */ | 101 | * is not present in the packet itself */ |
102 | if (maniptype != IP_NAT_MANIP_DST) | 102 | if (maniptype != NF_NAT_MANIP_DST) |
103 | return true; | 103 | return true; |
104 | switch (greh->version) { | 104 | switch (greh->version) { |
105 | case GRE_VERSION_1701: | 105 | case GRE_VERSION_1701: |
diff --git a/net/ipv4/netfilter/nf_nat_proto_icmp.c b/net/ipv4/netfilter/nf_nat_proto_icmp.c index 9f4dc1235dc7..8f87b4bebf2b 100644 --- a/net/ipv4/netfilter/nf_nat_proto_icmp.c +++ b/net/ipv4/netfilter/nf_nat_proto_icmp.c | |||
@@ -30,7 +30,7 @@ icmp_in_range(const struct nf_conntrack_tuple *tuple, | |||
30 | 30 | ||
31 | static void | 31 | static void |
32 | icmp_unique_tuple(struct nf_conntrack_tuple *tuple, | 32 | icmp_unique_tuple(struct nf_conntrack_tuple *tuple, |
33 | const struct nf_nat_range *range, | 33 | const struct nf_nat_ipv4_range *range, |
34 | enum nf_nat_manip_type maniptype, | 34 | enum nf_nat_manip_type maniptype, |
35 | const struct nf_conn *ct) | 35 | const struct nf_conn *ct) |
36 | { | 36 | { |
@@ -40,7 +40,7 @@ icmp_unique_tuple(struct nf_conntrack_tuple *tuple, | |||
40 | 40 | ||
41 | range_size = ntohs(range->max.icmp.id) - ntohs(range->min.icmp.id) + 1; | 41 | range_size = ntohs(range->max.icmp.id) - ntohs(range->min.icmp.id) + 1; |
42 | /* If no range specified... */ | 42 | /* If no range specified... */ |
43 | if (!(range->flags & IP_NAT_RANGE_PROTO_SPECIFIED)) | 43 | if (!(range->flags & NF_NAT_RANGE_PROTO_SPECIFIED)) |
44 | range_size = 0xFFFF; | 44 | range_size = 0xFFFF; |
45 | 45 | ||
46 | for (i = 0; ; ++id) { | 46 | for (i = 0; ; ++id) { |
diff --git a/net/ipv4/netfilter/nf_nat_proto_sctp.c b/net/ipv4/netfilter/nf_nat_proto_sctp.c index bd5a80a62a5b..4e70dc6fad21 100644 --- a/net/ipv4/netfilter/nf_nat_proto_sctp.c +++ b/net/ipv4/netfilter/nf_nat_proto_sctp.c | |||
@@ -19,7 +19,7 @@ static u_int16_t nf_sctp_port_rover; | |||
19 | 19 | ||
20 | static void | 20 | static void |
21 | sctp_unique_tuple(struct nf_conntrack_tuple *tuple, | 21 | sctp_unique_tuple(struct nf_conntrack_tuple *tuple, |
22 | const struct nf_nat_range *range, | 22 | const struct nf_nat_ipv4_range *range, |
23 | enum nf_nat_manip_type maniptype, | 23 | enum nf_nat_manip_type maniptype, |
24 | const struct nf_conn *ct) | 24 | const struct nf_conn *ct) |
25 | { | 25 | { |
@@ -46,7 +46,7 @@ sctp_manip_pkt(struct sk_buff *skb, | |||
46 | iph = (struct iphdr *)(skb->data + iphdroff); | 46 | iph = (struct iphdr *)(skb->data + iphdroff); |
47 | hdr = (struct sctphdr *)(skb->data + hdroff); | 47 | hdr = (struct sctphdr *)(skb->data + hdroff); |
48 | 48 | ||
49 | if (maniptype == IP_NAT_MANIP_SRC) { | 49 | if (maniptype == NF_NAT_MANIP_SRC) { |
50 | /* Get rid of src ip and src pt */ | 50 | /* Get rid of src ip and src pt */ |
51 | oldip = iph->saddr; | 51 | oldip = iph->saddr; |
52 | newip = tuple->src.u3.ip; | 52 | newip = tuple->src.u3.ip; |
diff --git a/net/ipv4/netfilter/nf_nat_proto_tcp.c b/net/ipv4/netfilter/nf_nat_proto_tcp.c index 0d67bb80130f..6fcc865dc2ee 100644 --- a/net/ipv4/netfilter/nf_nat_proto_tcp.c +++ b/net/ipv4/netfilter/nf_nat_proto_tcp.c | |||
@@ -23,7 +23,7 @@ static u_int16_t tcp_port_rover; | |||
23 | 23 | ||
24 | static void | 24 | static void |
25 | tcp_unique_tuple(struct nf_conntrack_tuple *tuple, | 25 | tcp_unique_tuple(struct nf_conntrack_tuple *tuple, |
26 | const struct nf_nat_range *range, | 26 | const struct nf_nat_ipv4_range *range, |
27 | enum nf_nat_manip_type maniptype, | 27 | enum nf_nat_manip_type maniptype, |
28 | const struct nf_conn *ct) | 28 | const struct nf_conn *ct) |
29 | { | 29 | { |
@@ -55,7 +55,7 @@ tcp_manip_pkt(struct sk_buff *skb, | |||
55 | iph = (struct iphdr *)(skb->data + iphdroff); | 55 | iph = (struct iphdr *)(skb->data + iphdroff); |
56 | hdr = (struct tcphdr *)(skb->data + hdroff); | 56 | hdr = (struct tcphdr *)(skb->data + hdroff); |
57 | 57 | ||
58 | if (maniptype == IP_NAT_MANIP_SRC) { | 58 | if (maniptype == NF_NAT_MANIP_SRC) { |
59 | /* Get rid of src ip and src pt */ | 59 | /* Get rid of src ip and src pt */ |
60 | oldip = iph->saddr; | 60 | oldip = iph->saddr; |
61 | newip = tuple->src.u3.ip; | 61 | newip = tuple->src.u3.ip; |
diff --git a/net/ipv4/netfilter/nf_nat_proto_udp.c b/net/ipv4/netfilter/nf_nat_proto_udp.c index 0b1b8601cba7..18ea44ebfff7 100644 --- a/net/ipv4/netfilter/nf_nat_proto_udp.c +++ b/net/ipv4/netfilter/nf_nat_proto_udp.c | |||
@@ -22,7 +22,7 @@ static u_int16_t udp_port_rover; | |||
22 | 22 | ||
23 | static void | 23 | static void |
24 | udp_unique_tuple(struct nf_conntrack_tuple *tuple, | 24 | udp_unique_tuple(struct nf_conntrack_tuple *tuple, |
25 | const struct nf_nat_range *range, | 25 | const struct nf_nat_ipv4_range *range, |
26 | enum nf_nat_manip_type maniptype, | 26 | enum nf_nat_manip_type maniptype, |
27 | const struct nf_conn *ct) | 27 | const struct nf_conn *ct) |
28 | { | 28 | { |
@@ -47,7 +47,7 @@ udp_manip_pkt(struct sk_buff *skb, | |||
47 | iph = (struct iphdr *)(skb->data + iphdroff); | 47 | iph = (struct iphdr *)(skb->data + iphdroff); |
48 | hdr = (struct udphdr *)(skb->data + hdroff); | 48 | hdr = (struct udphdr *)(skb->data + hdroff); |
49 | 49 | ||
50 | if (maniptype == IP_NAT_MANIP_SRC) { | 50 | if (maniptype == NF_NAT_MANIP_SRC) { |
51 | /* Get rid of src ip and src pt */ | 51 | /* Get rid of src ip and src pt */ |
52 | oldip = iph->saddr; | 52 | oldip = iph->saddr; |
53 | newip = tuple->src.u3.ip; | 53 | newip = tuple->src.u3.ip; |
diff --git a/net/ipv4/netfilter/nf_nat_proto_udplite.c b/net/ipv4/netfilter/nf_nat_proto_udplite.c index f83ef23e2ab7..a17b75b9e2a7 100644 --- a/net/ipv4/netfilter/nf_nat_proto_udplite.c +++ b/net/ipv4/netfilter/nf_nat_proto_udplite.c | |||
@@ -21,7 +21,7 @@ static u_int16_t udplite_port_rover; | |||
21 | 21 | ||
22 | static void | 22 | static void |
23 | udplite_unique_tuple(struct nf_conntrack_tuple *tuple, | 23 | udplite_unique_tuple(struct nf_conntrack_tuple *tuple, |
24 | const struct nf_nat_range *range, | 24 | const struct nf_nat_ipv4_range *range, |
25 | enum nf_nat_manip_type maniptype, | 25 | enum nf_nat_manip_type maniptype, |
26 | const struct nf_conn *ct) | 26 | const struct nf_conn *ct) |
27 | { | 27 | { |
@@ -47,7 +47,7 @@ udplite_manip_pkt(struct sk_buff *skb, | |||
47 | iph = (struct iphdr *)(skb->data + iphdroff); | 47 | iph = (struct iphdr *)(skb->data + iphdroff); |
48 | hdr = (struct udphdr *)(skb->data + hdroff); | 48 | hdr = (struct udphdr *)(skb->data + hdroff); |
49 | 49 | ||
50 | if (maniptype == IP_NAT_MANIP_SRC) { | 50 | if (maniptype == NF_NAT_MANIP_SRC) { |
51 | /* Get rid of src ip and src pt */ | 51 | /* Get rid of src ip and src pt */ |
52 | oldip = iph->saddr; | 52 | oldip = iph->saddr; |
53 | newip = tuple->src.u3.ip; | 53 | newip = tuple->src.u3.ip; |
diff --git a/net/ipv4/netfilter/nf_nat_proto_unknown.c b/net/ipv4/netfilter/nf_nat_proto_unknown.c index a50f2bc1c732..ab8e8c132168 100644 --- a/net/ipv4/netfilter/nf_nat_proto_unknown.c +++ b/net/ipv4/netfilter/nf_nat_proto_unknown.c | |||
@@ -27,7 +27,7 @@ static bool unknown_in_range(const struct nf_conntrack_tuple *tuple, | |||
27 | } | 27 | } |
28 | 28 | ||
29 | static void unknown_unique_tuple(struct nf_conntrack_tuple *tuple, | 29 | static void unknown_unique_tuple(struct nf_conntrack_tuple *tuple, |
30 | const struct nf_nat_range *range, | 30 | const struct nf_nat_ipv4_range *range, |
31 | enum nf_nat_manip_type maniptype, | 31 | enum nf_nat_manip_type maniptype, |
32 | const struct nf_conn *ct) | 32 | const struct nf_conn *ct) |
33 | { | 33 | { |
diff --git a/net/ipv4/netfilter/nf_nat_rule.c b/net/ipv4/netfilter/nf_nat_rule.c index 733c9abc1cbd..d2a9dc314e0e 100644 --- a/net/ipv4/netfilter/nf_nat_rule.c +++ b/net/ipv4/netfilter/nf_nat_rule.c | |||
@@ -44,7 +44,7 @@ ipt_snat_target(struct sk_buff *skb, const struct xt_action_param *par) | |||
44 | { | 44 | { |
45 | struct nf_conn *ct; | 45 | struct nf_conn *ct; |
46 | enum ip_conntrack_info ctinfo; | 46 | enum ip_conntrack_info ctinfo; |
47 | const struct nf_nat_multi_range_compat *mr = par->targinfo; | 47 | const struct nf_nat_ipv4_multi_range_compat *mr = par->targinfo; |
48 | 48 | ||
49 | NF_CT_ASSERT(par->hooknum == NF_INET_POST_ROUTING || | 49 | NF_CT_ASSERT(par->hooknum == NF_INET_POST_ROUTING || |
50 | par->hooknum == NF_INET_LOCAL_IN); | 50 | par->hooknum == NF_INET_LOCAL_IN); |
@@ -56,7 +56,7 @@ ipt_snat_target(struct sk_buff *skb, const struct xt_action_param *par) | |||
56 | ctinfo == IP_CT_RELATED_REPLY)); | 56 | ctinfo == IP_CT_RELATED_REPLY)); |
57 | NF_CT_ASSERT(par->out != NULL); | 57 | NF_CT_ASSERT(par->out != NULL); |
58 | 58 | ||
59 | return nf_nat_setup_info(ct, &mr->range[0], IP_NAT_MANIP_SRC); | 59 | return nf_nat_setup_info(ct, &mr->range[0], NF_NAT_MANIP_SRC); |
60 | } | 60 | } |
61 | 61 | ||
62 | static unsigned int | 62 | static unsigned int |
@@ -64,7 +64,7 @@ ipt_dnat_target(struct sk_buff *skb, const struct xt_action_param *par) | |||
64 | { | 64 | { |
65 | struct nf_conn *ct; | 65 | struct nf_conn *ct; |
66 | enum ip_conntrack_info ctinfo; | 66 | enum ip_conntrack_info ctinfo; |
67 | const struct nf_nat_multi_range_compat *mr = par->targinfo; | 67 | const struct nf_nat_ipv4_multi_range_compat *mr = par->targinfo; |
68 | 68 | ||
69 | NF_CT_ASSERT(par->hooknum == NF_INET_PRE_ROUTING || | 69 | NF_CT_ASSERT(par->hooknum == NF_INET_PRE_ROUTING || |
70 | par->hooknum == NF_INET_LOCAL_OUT); | 70 | par->hooknum == NF_INET_LOCAL_OUT); |
@@ -74,12 +74,12 @@ ipt_dnat_target(struct sk_buff *skb, const struct xt_action_param *par) | |||
74 | /* Connection must be valid and new. */ | 74 | /* Connection must be valid and new. */ |
75 | NF_CT_ASSERT(ct && (ctinfo == IP_CT_NEW || ctinfo == IP_CT_RELATED)); | 75 | NF_CT_ASSERT(ct && (ctinfo == IP_CT_NEW || ctinfo == IP_CT_RELATED)); |
76 | 76 | ||
77 | return nf_nat_setup_info(ct, &mr->range[0], IP_NAT_MANIP_DST); | 77 | return nf_nat_setup_info(ct, &mr->range[0], NF_NAT_MANIP_DST); |
78 | } | 78 | } |
79 | 79 | ||
80 | static int ipt_snat_checkentry(const struct xt_tgchk_param *par) | 80 | static int ipt_snat_checkentry(const struct xt_tgchk_param *par) |
81 | { | 81 | { |
82 | const struct nf_nat_multi_range_compat *mr = par->targinfo; | 82 | const struct nf_nat_ipv4_multi_range_compat *mr = par->targinfo; |
83 | 83 | ||
84 | /* Must be a valid range */ | 84 | /* Must be a valid range */ |
85 | if (mr->rangesize != 1) { | 85 | if (mr->rangesize != 1) { |
@@ -91,7 +91,7 @@ static int ipt_snat_checkentry(const struct xt_tgchk_param *par) | |||
91 | 91 | ||
92 | static int ipt_dnat_checkentry(const struct xt_tgchk_param *par) | 92 | static int ipt_dnat_checkentry(const struct xt_tgchk_param *par) |
93 | { | 93 | { |
94 | const struct nf_nat_multi_range_compat *mr = par->targinfo; | 94 | const struct nf_nat_ipv4_multi_range_compat *mr = par->targinfo; |
95 | 95 | ||
96 | /* Must be a valid range */ | 96 | /* Must be a valid range */ |
97 | if (mr->rangesize != 1) { | 97 | if (mr->rangesize != 1) { |
@@ -105,13 +105,13 @@ static unsigned int | |||
105 | alloc_null_binding(struct nf_conn *ct, unsigned int hooknum) | 105 | alloc_null_binding(struct nf_conn *ct, unsigned int hooknum) |
106 | { | 106 | { |
107 | /* Force range to this IP; let proto decide mapping for | 107 | /* Force range to this IP; let proto decide mapping for |
108 | per-proto parts (hence not IP_NAT_RANGE_PROTO_SPECIFIED). | 108 | per-proto parts (hence not NF_NAT_RANGE_PROTO_SPECIFIED). |
109 | */ | 109 | */ |
110 | struct nf_nat_range range; | 110 | struct nf_nat_ipv4_range range; |
111 | 111 | ||
112 | range.flags = 0; | 112 | range.flags = 0; |
113 | pr_debug("Allocating NULL binding for %p (%pI4)\n", ct, | 113 | pr_debug("Allocating NULL binding for %p (%pI4)\n", ct, |
114 | HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC ? | 114 | HOOK2MANIP(hooknum) == NF_NAT_MANIP_SRC ? |
115 | &ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip : | 115 | &ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip : |
116 | &ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip); | 116 | &ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip); |
117 | 117 | ||
@@ -140,7 +140,7 @@ int nf_nat_rule_find(struct sk_buff *skb, | |||
140 | static struct xt_target ipt_snat_reg __read_mostly = { | 140 | static struct xt_target ipt_snat_reg __read_mostly = { |
141 | .name = "SNAT", | 141 | .name = "SNAT", |
142 | .target = ipt_snat_target, | 142 | .target = ipt_snat_target, |
143 | .targetsize = sizeof(struct nf_nat_multi_range_compat), | 143 | .targetsize = sizeof(struct nf_nat_ipv4_multi_range_compat), |
144 | .table = "nat", | 144 | .table = "nat", |
145 | .hooks = (1 << NF_INET_POST_ROUTING) | (1 << NF_INET_LOCAL_IN), | 145 | .hooks = (1 << NF_INET_POST_ROUTING) | (1 << NF_INET_LOCAL_IN), |
146 | .checkentry = ipt_snat_checkentry, | 146 | .checkentry = ipt_snat_checkentry, |
@@ -150,7 +150,7 @@ static struct xt_target ipt_snat_reg __read_mostly = { | |||
150 | static struct xt_target ipt_dnat_reg __read_mostly = { | 150 | static struct xt_target ipt_dnat_reg __read_mostly = { |
151 | .name = "DNAT", | 151 | .name = "DNAT", |
152 | .target = ipt_dnat_target, | 152 | .target = ipt_dnat_target, |
153 | .targetsize = sizeof(struct nf_nat_multi_range_compat), | 153 | .targetsize = sizeof(struct nf_nat_ipv4_multi_range_compat), |
154 | .table = "nat", | 154 | .table = "nat", |
155 | .hooks = (1 << NF_INET_PRE_ROUTING) | (1 << NF_INET_LOCAL_OUT), | 155 | .hooks = (1 << NF_INET_PRE_ROUTING) | (1 << NF_INET_LOCAL_OUT), |
156 | .checkentry = ipt_dnat_checkentry, | 156 | .checkentry = ipt_dnat_checkentry, |
diff --git a/net/ipv4/netfilter/nf_nat_sip.c b/net/ipv4/netfilter/nf_nat_sip.c index 78844d9208f1..d0319f96269f 100644 --- a/net/ipv4/netfilter/nf_nat_sip.c +++ b/net/ipv4/netfilter/nf_nat_sip.c | |||
@@ -249,25 +249,25 @@ static void ip_nat_sip_seq_adjust(struct sk_buff *skb, s16 off) | |||
249 | static void ip_nat_sip_expected(struct nf_conn *ct, | 249 | static void ip_nat_sip_expected(struct nf_conn *ct, |
250 | struct nf_conntrack_expect *exp) | 250 | struct nf_conntrack_expect *exp) |
251 | { | 251 | { |
252 | struct nf_nat_range range; | 252 | struct nf_nat_ipv4_range range; |
253 | 253 | ||
254 | /* This must be a fresh one. */ | 254 | /* This must be a fresh one. */ |
255 | BUG_ON(ct->status & IPS_NAT_DONE_MASK); | 255 | BUG_ON(ct->status & IPS_NAT_DONE_MASK); |
256 | 256 | ||
257 | /* For DST manip, map port here to where it's expected. */ | 257 | /* For DST manip, map port here to where it's expected. */ |
258 | range.flags = (IP_NAT_RANGE_MAP_IPS | IP_NAT_RANGE_PROTO_SPECIFIED); | 258 | range.flags = (NF_NAT_RANGE_MAP_IPS | NF_NAT_RANGE_PROTO_SPECIFIED); |
259 | range.min = range.max = exp->saved_proto; | 259 | range.min = range.max = exp->saved_proto; |
260 | range.min_ip = range.max_ip = exp->saved_ip; | 260 | range.min_ip = range.max_ip = exp->saved_ip; |
261 | nf_nat_setup_info(ct, &range, IP_NAT_MANIP_DST); | 261 | nf_nat_setup_info(ct, &range, NF_NAT_MANIP_DST); |
262 | 262 | ||
263 | /* Change src to where master sends to, but only if the connection | 263 | /* Change src to where master sends to, but only if the connection |
264 | * actually came from the same source. */ | 264 | * actually came from the same source. */ |
265 | if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip == | 265 | if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip == |
266 | ct->master->tuplehash[exp->dir].tuple.src.u3.ip) { | 266 | ct->master->tuplehash[exp->dir].tuple.src.u3.ip) { |
267 | range.flags = IP_NAT_RANGE_MAP_IPS; | 267 | range.flags = NF_NAT_RANGE_MAP_IPS; |
268 | range.min_ip = range.max_ip | 268 | range.min_ip = range.max_ip |
269 | = ct->master->tuplehash[!exp->dir].tuple.dst.u3.ip; | 269 | = ct->master->tuplehash[!exp->dir].tuple.dst.u3.ip; |
270 | nf_nat_setup_info(ct, &range, IP_NAT_MANIP_SRC); | 270 | nf_nat_setup_info(ct, &range, NF_NAT_MANIP_SRC); |
271 | } | 271 | } |
272 | } | 272 | } |
273 | 273 | ||
diff --git a/net/ipv4/netfilter/nf_nat_standalone.c b/net/ipv4/netfilter/nf_nat_standalone.c index 92900482edea..3828a4229822 100644 --- a/net/ipv4/netfilter/nf_nat_standalone.c +++ b/net/ipv4/netfilter/nf_nat_standalone.c | |||
@@ -137,7 +137,7 @@ nf_nat_fn(unsigned int hooknum, | |||
137 | return ret; | 137 | return ret; |
138 | } else | 138 | } else |
139 | pr_debug("Already setup manip %s for ct %p\n", | 139 | pr_debug("Already setup manip %s for ct %p\n", |
140 | maniptype == IP_NAT_MANIP_SRC ? "SRC" : "DST", | 140 | maniptype == NF_NAT_MANIP_SRC ? "SRC" : "DST", |
141 | ct); | 141 | ct); |
142 | break; | 142 | break; |
143 | 143 | ||
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index 739548029dc2..4f9c941335c9 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c | |||
@@ -1102,14 +1102,14 @@ ctnetlink_change_nat(struct nf_conn *ct, const struct nlattr * const cda[]) | |||
1102 | 1102 | ||
1103 | if (cda[CTA_NAT_DST]) { | 1103 | if (cda[CTA_NAT_DST]) { |
1104 | ret = ctnetlink_parse_nat_setup(ct, | 1104 | ret = ctnetlink_parse_nat_setup(ct, |
1105 | IP_NAT_MANIP_DST, | 1105 | NF_NAT_MANIP_DST, |
1106 | cda[CTA_NAT_DST]); | 1106 | cda[CTA_NAT_DST]); |
1107 | if (ret < 0) | 1107 | if (ret < 0) |
1108 | return ret; | 1108 | return ret; |
1109 | } | 1109 | } |
1110 | if (cda[CTA_NAT_SRC]) { | 1110 | if (cda[CTA_NAT_SRC]) { |
1111 | ret = ctnetlink_parse_nat_setup(ct, | 1111 | ret = ctnetlink_parse_nat_setup(ct, |
1112 | IP_NAT_MANIP_SRC, | 1112 | NF_NAT_MANIP_SRC, |
1113 | cda[CTA_NAT_SRC]); | 1113 | cda[CTA_NAT_SRC]); |
1114 | if (ret < 0) | 1114 | if (ret < 0) |
1115 | return ret; | 1115 | return ret; |