diff options
author | Alexander Chernavin <achernavin@netgate.com> | 2021-07-06 06:08:26 -0400 |
---|---|---|
committer | Matthew Smith <mgsmith@netgate.com> | 2021-08-17 21:32:14 +0000 |
commit | 4de12b9c62757f7297c6ac5c7eedff17082f4ee8 (patch) | |
tree | 9435894aa5f601220efde2d9a414586cd9a79cad /test | |
parent | b93782b36643714a8dcb53e2e396da642b1b0053 (diff) |
nat: fix counters increment for output feature
Type: fix
The NAT plugin stores packet counters and a counter represents a vector
indexed by interface index. When an interface is assigned a NAT role,
the counters are validated to be long enough for the given interface
index.
When a packet traverses NAT in2out and output feature is disabled, the
appropriate counters are updated by the RX interface index. In this
case, translation happens on the inside interface and its index was
ensured to be valid in all of the counters during NAT role assignment.
When a packet traverses NAT in2out and output feature is enabled, the
appropriate counters are updated by the RX interface index too. In this
case, translation happens on the outside interface and the packet could
be received on any interface, even with no NAT role assigned. If that's
the case and its index is greater than the greatest index validated in
the counters, a new counter value will be written to memory that does
not belong to the counter. As a result, a crash will occur at some
point.
With this change, use TX interface index to update the counters when
output feature is enabled. TX interface is an actual interface where
translation happens and its index is always valid in the counters.
Signed-off-by: Alexander Chernavin <achernavin@netgate.com>
Change-Id: I53a52af949fe96419e1b5fef4134ab4062198f51
Diffstat (limited to 'test')
-rw-r--r-- | test/test_nat44_ed.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/test/test_nat44_ed.py b/test/test_nat44_ed.py index b11e3c03cde..258bee3a1f6 100644 --- a/test/test_nat44_ed.py +++ b/test/test_nat44_ed.py @@ -3681,7 +3681,7 @@ class TestNAT44EDMW(TestNAT44ED): capture = self.pg8.get_capture(len(pkts)) self.verify_capture_out(capture, ignore_port=True) - if_idx = self.pg7.sw_if_index + if_idx = self.pg8.sw_if_index cnt = self.statistics['/nat44-ed/in2out/slowpath/tcp'] self.assertEqual(cnt[:, if_idx].sum() - tcpn[:, if_idx].sum(), 2) cnt = self.statistics['/nat44-ed/in2out/slowpath/udp'] |