nat: pick outside addr based on local addr 51/31451/5
authorKlement Sekera <ksekera@cisco.com>
Thu, 25 Feb 2021 15:47:23 +0000 (16:47 +0100)
committerKlement Sekera <ksekera@cisco.com>
Mon, 1 Mar 2021 12:03:20 +0000 (13:03 +0100)
commitdc243ee2bcc4926ec23e71a687bb62b5c52c2fbb
treeeb4a57e84f45b5bbdfd4385976ce20974b797c5a
parentf1af21c9d7c2d4f4e138b5dd0dd40e7f881b46ae
nat: pick outside addr based on local addr

Use outside addresses more evenly by using local address to pick from
pool of addresses. This ensures stability from POV of remote host -
an internal host always gets translated using the same outside address,
so it doesn't appear to be "hopping". Also, this avoids all hosts
being translated using the first address, which helps avoid needless
recaptchas and the like.

Exact assignment depends on internal ordering of addresses - local address
is used to pick an offset into internal vector. If that address cannot be
used, a linear search is performed as a fallback mechanism to find a possible
translation.

Type: improvement
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: I7ccb1da1dda5537f5d30d2f4cb48024f4b51c1a4
src/plugins/nat/nat44-ed/nat44_ed_in2out.c
src/plugins/nat/nat44-ei/nat44_ei.c
src/plugins/nat/nat44-ei/nat44_ei.h
src/plugins/nat/nat44-ei/nat44_ei_in2out.c
src/plugins/nat/test/test_nat44_ed.py
src/plugins/nat/test/test_nat44_ei.py