[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>
This commit is contained in:
parent
5c170a09d9
commit
a467704dcb
|
@ -49,15 +49,15 @@ gre_in_range(const struct ip_conntrack_tuple *tuple,
|
||||||
const union ip_conntrack_manip_proto *min,
|
const union ip_conntrack_manip_proto *min,
|
||||||
const union ip_conntrack_manip_proto *max)
|
const union ip_conntrack_manip_proto *max)
|
||||||
{
|
{
|
||||||
u_int32_t key;
|
__be16 key;
|
||||||
|
|
||||||
if (maniptype == IP_NAT_MANIP_SRC)
|
if (maniptype == IP_NAT_MANIP_SRC)
|
||||||
key = tuple->src.u.gre.key;
|
key = tuple->src.u.gre.key;
|
||||||
else
|
else
|
||||||
key = tuple->dst.u.gre.key;
|
key = tuple->dst.u.gre.key;
|
||||||
|
|
||||||
return ntohl(key) >= ntohl(min->gre.key)
|
return ntohs(key) >= ntohs(min->gre.key)
|
||||||
&& ntohl(key) <= ntohl(max->gre.key);
|
&& ntohs(key) <= ntohs(max->gre.key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* generate unique tuple ... */
|
/* generate unique tuple ... */
|
||||||
|
@ -81,14 +81,14 @@ gre_unique_tuple(struct ip_conntrack_tuple *tuple,
|
||||||
min = 1;
|
min = 1;
|
||||||
range_size = 0xffff;
|
range_size = 0xffff;
|
||||||
} else {
|
} else {
|
||||||
min = ntohl(range->min.gre.key);
|
min = ntohs(range->min.gre.key);
|
||||||
range_size = ntohl(range->max.gre.key) - min + 1;
|
range_size = ntohs(range->max.gre.key) - min + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGP("min = %u, range_size = %u\n", min, range_size);
|
DEBUGP("min = %u, range_size = %u\n", min, range_size);
|
||||||
|
|
||||||
for (i = 0; i < range_size; i++, key++) {
|
for (i = 0; i < range_size; i++, key++) {
|
||||||
*keyptr = htonl(min + key % range_size);
|
*keyptr = htons(min + key % range_size);
|
||||||
if (!ip_nat_used_tuple(tuple, conntrack))
|
if (!ip_nat_used_tuple(tuple, conntrack))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue