Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 90695
b: refs/heads/master
c: 5abd363
h: refs/heads/master
i:
  90693: 7a017cd
  90691: ace67e9
  90687: a56d56a
v: v3
  • Loading branch information
Patrick McHardy committed Apr 14, 2008
1 parent 5de4a9c commit eb5856a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 937e0dfd87a8b7946a17161664500fba93eb13fd
refs/heads/master: 5abd363f738dcd048ee790fb9b84d0768a8a407f
15 changes: 10 additions & 5 deletions trunk/net/ipv4/netfilter/nf_nat_proto_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ int nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple,
{
unsigned int range_size, min, i;
__be16 *portptr;
u_int16_t off;

if (maniptype == IP_NAT_MANIP_SRC)
portptr = &tuple->src.u.all;
Expand Down Expand Up @@ -72,13 +73,17 @@ int nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple,
range_size = ntohs(range->max.all) - min + 1;
}

off = *rover;
if (range->flags & IP_NAT_RANGE_PROTO_RANDOM)
*rover = net_random();
off = net_random();

for (i = 0; i < range_size; i++, (*rover)++) {
*portptr = htons(min + *rover % range_size);
if (!nf_nat_used_tuple(tuple, ct))
return 1;
for (i = 0; i < range_size; i++, off++) {
*portptr = htons(min + off % range_size);
if (nf_nat_used_tuple(tuple, ct))
continue;
if (!(range->flags & IP_NAT_RANGE_PROTO_RANDOM))
*rover = off;
return 1;
}
return 0;
}
Expand Down

0 comments on commit eb5856a

Please sign in to comment.