aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2006-05-19 05:16:29 -0400
committerDavid S. Miller <davem@davemloft.net>2006-05-19 05:16:29 -0400
commita467704dcb4fa45da48079486f1b0e6baffb12d2 (patch)
tree5e08a631dfe15e7d90f372eb36a3318cae1f3b32
parent5c170a09d9092e63af1658179f29867d32d56b55 (diff)
[NETFILTER]: GRE conntrack: fix htons/htonl confusion
GRE keys are 16 bit. Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/ipv4/netfilter/ip_nat_proto_gre.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/net/ipv4/netfilter/ip_nat_proto_gre.c b/net/ipv4/netfilter/ip_nat_proto_gre.c
index 6c4899d8046a..96ceabaec402 100644
--- a/net/ipv4/netfilter/ip_nat_proto_gre.c
+++ b/net/ipv4/netfilter/ip_nat_proto_gre.c
@@ -49,15 +49,15 @@ gre_in_range(const struct ip_conntrack_tuple *tuple,
49 const union ip_conntrack_manip_proto *min, 49 const union ip_conntrack_manip_proto *min,
50 const union ip_conntrack_manip_proto *max) 50 const union ip_conntrack_manip_proto *max)
51{ 51{
52 u_int32_t key; 52 __be16 key;
53 53
54 if (maniptype == IP_NAT_MANIP_SRC) 54 if (maniptype == IP_NAT_MANIP_SRC)
55 key = tuple->src.u.gre.key; 55 key = tuple->src.u.gre.key;
56 else 56 else
57 key = tuple->dst.u.gre.key; 57 key = tuple->dst.u.gre.key;
58 58
59 return ntohl(key) >= ntohl(min->gre.key) 59 return ntohs(key) >= ntohs(min->gre.key)
60 && ntohl(key) <= ntohl(max->gre.key); 60 && ntohs(key) <= ntohs(max->gre.key);
61} 61}
62 62
63/* generate unique tuple ... */ 63/* generate unique tuple ... */
@@ -81,14 +81,14 @@ gre_unique_tuple(struct ip_conntrack_tuple *tuple,
81 min = 1; 81 min = 1;
82 range_size = 0xffff; 82 range_size = 0xffff;
83 } else { 83 } else {
84 min = ntohl(range->min.gre.key); 84 min = ntohs(range->min.gre.key);
85 range_size = ntohl(range->max.gre.key) - min + 1; 85 range_size = ntohs(range->max.gre.key) - min + 1;
86 } 86 }
87 87
88 DEBUGP("min = %u, range_size = %u\n", min, range_size); 88 DEBUGP("min = %u, range_size = %u\n", min, range_size);
89 89
90 for (i = 0; i < range_size; i++, key++) { 90 for (i = 0; i < range_size; i++, key++) {
91 *keyptr = htonl(min + key % range_size); 91 *keyptr = htons(min + key % range_size);
92 if (!ip_nat_used_tuple(tuple, conntrack)) 92 if (!ip_nat_used_tuple(tuple, conntrack))
93 return 1; 93 return 1;
94 } 94 }