OSDN Git Service

netfilter: nat: remove l4 protocol port rovers
authorFlorian Westphal <fw@strlen.de>
Thu, 15 Nov 2018 09:22:59 +0000 (10:22 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Sat, 1 Dec 2018 11:38:42 +0000 (12:38 +0100)
commit6ed5943f8735e2b778d92ea4d9805c0a1d89bc2b
treead0b549420d6aeb8380dcc7ac6d1bbc7015b39f6
parentc3e9305983597a61083482581e83f0bd77ba306a
netfilter: nat: remove l4 protocol port rovers

This is a leftover from days where single-cpu systems were common:
Store last port used to resolve a clash to use it as a starting point when
the next conflict needs to be resolved.

When we have parallel attempt to connect to same address:port pair,
its likely that both cores end up computing the same "available" port,
as both use same starting port, and newly used ports won't become
visible to other cores until the conntrack gets confirmed later.

One of the cores then has to drop the packet at insertion time because
the chosen new tuple turns out to be in use after all.

Lets simplify this: remove port rover and use a pseudo-random starting
point.

Note that this doesn't make netfilter default to 'fully random' mode;
the 'rover' was only used if NAT could not reuse source port as-is.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/net/netfilter/nf_nat_l4proto.h
net/netfilter/nf_nat_proto_common.c
net/netfilter/nf_nat_proto_dccp.c
net/netfilter/nf_nat_proto_sctp.c
net/netfilter/nf_nat_proto_tcp.c
net/netfilter/nf_nat_proto_udp.c