From 5854b43de4c04a7c52b0cf03cd548c9cac86c325 Mon Sep 17 00:00:00 2001 From: Filip Varga Date: Tue, 5 Nov 2019 14:14:08 +0100 Subject: nat: NAT udp counter & unit test fixes Ticket: VPP-1798 Type: fix Change-Id: I42f02d5824575720e95b9fc99cfa864252221a82 Signed-off-by: Filip Varga --- src/plugins/nat/in2out.c | 2 +- src/plugins/nat/in2out_ed.c | 2 +- src/plugins/nat/nat64_in2out.c | 2 +- src/plugins/nat/nat64_out2in.c | 2 +- src/plugins/nat/test/test_nat.py | 32 ++++++++++++++++---------------- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/plugins/nat/in2out.c b/src/plugins/nat/in2out.c index 802202d7939..5cfe058c099 100755 --- a/src/plugins/nat/in2out.c +++ b/src/plugins/nat/in2out.c @@ -1573,7 +1573,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm, vlib_node_increment_counter (vm, stats_node_index, SNAT_IN2OUT_ERROR_TCP_PACKETS, tcp_packets); vlib_node_increment_counter (vm, stats_node_index, - SNAT_IN2OUT_ERROR_UDP_PACKETS, tcp_packets); + SNAT_IN2OUT_ERROR_UDP_PACKETS, udp_packets); vlib_node_increment_counter (vm, stats_node_index, SNAT_IN2OUT_ERROR_ICMP_PACKETS, icmp_packets); vlib_node_increment_counter (vm, stats_node_index, diff --git a/src/plugins/nat/in2out_ed.c b/src/plugins/nat/in2out_ed.c index c878dddd13e..77d620f11cb 100644 --- a/src/plugins/nat/in2out_ed.c +++ b/src/plugins/nat/in2out_ed.c @@ -1629,7 +1629,7 @@ nat44_ed_in2out_node_fn_inline (vlib_main_t * vm, vlib_node_increment_counter (vm, stats_node_index, NAT_IN2OUT_ED_ERROR_TCP_PACKETS, tcp_packets); vlib_node_increment_counter (vm, stats_node_index, - NAT_IN2OUT_ED_ERROR_UDP_PACKETS, tcp_packets); + NAT_IN2OUT_ED_ERROR_UDP_PACKETS, udp_packets); vlib_node_increment_counter (vm, stats_node_index, NAT_IN2OUT_ED_ERROR_ICMP_PACKETS, icmp_packets); diff --git a/src/plugins/nat/nat64_in2out.c b/src/plugins/nat/nat64_in2out.c index 11551f45741..225683cd028 100644 --- a/src/plugins/nat/nat64_in2out.c +++ b/src/plugins/nat/nat64_in2out.c @@ -1157,7 +1157,7 @@ nat64_in2out_node_fn_inline (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_node_increment_counter (vm, stats_node_index, NAT64_IN2OUT_ERROR_TCP_PACKETS, tcp_packets); vlib_node_increment_counter (vm, stats_node_index, - NAT64_IN2OUT_ERROR_UDP_PACKETS, tcp_packets); + NAT64_IN2OUT_ERROR_UDP_PACKETS, udp_packets); vlib_node_increment_counter (vm, stats_node_index, NAT64_IN2OUT_ERROR_ICMP_PACKETS, icmp_packets); vlib_node_increment_counter (vm, stats_node_index, diff --git a/src/plugins/nat/nat64_out2in.c b/src/plugins/nat/nat64_out2in.c index b62bbee6f49..e0dd407e0cf 100644 --- a/src/plugins/nat/nat64_out2in.c +++ b/src/plugins/nat/nat64_out2in.c @@ -561,7 +561,7 @@ VLIB_NODE_FN (nat64_out2in_node) (vlib_main_t * vm, vlib_node_increment_counter (vm, nm->out2in_node_index, NAT64_OUT2IN_ERROR_TCP_PACKETS, tcp_packets); vlib_node_increment_counter (vm, nm->out2in_node_index, - NAT64_OUT2IN_ERROR_UDP_PACKETS, tcp_packets); + NAT64_OUT2IN_ERROR_UDP_PACKETS, udp_packets); vlib_node_increment_counter (vm, nm->out2in_node_index, NAT64_OUT2IN_ERROR_ICMP_PACKETS, icmp_packets); vlib_node_increment_counter (vm, nm->out2in_node_index, diff --git a/src/plugins/nat/test/test_nat.py b/src/plugins/nat/test/test_nat.py index 08642045958..448a7fcf14c 100644 --- a/src/plugins/nat/test/test_nat.py +++ b/src/plugins/nat/test/test_nat.py @@ -244,7 +244,7 @@ class MethodHolder(VppTestCase): p = (Ether(dst=in_if.local_mac, src=in_if.remote_mac) / IP(src=in_if.remote_ip4, dst=dst_ip, ttl=ttl) / TCP(sport=self.tcp_port_in, dport=20)) - pkts.append(p) + pkts.extend([p, p]) # UDP p = (Ether(dst=in_if.local_mac, src=in_if.remote_mac) / @@ -408,7 +408,7 @@ class MethodHolder(VppTestCase): p = (Ether(dst=out_if.local_mac, src=out_if.remote_mac) / IP(src=out_if.remote_ip4, dst=dst_ip, ttl=ttl) / TCP(dport=tcp_port, sport=20)) - pkts.append(p) + pkts.extend([p, p]) # UDP p = (Ether(dst=out_if.local_mac, src=out_if.remote_mac) / @@ -1575,7 +1575,7 @@ class TestNAT44(MethodHolder): err = self.statistics.get_err_counter( '/err/nat44-in2out-slowpath/TCP packets') - self.assertEqual(err - tcpn, 1) + self.assertEqual(err - tcpn, 2) err = self.statistics.get_err_counter( '/err/nat44-in2out-slowpath/UDP packets') self.assertEqual(err - udpn, 1) @@ -1584,7 +1584,7 @@ class TestNAT44(MethodHolder): self.assertEqual(err - icmpn, 1) err = self.statistics.get_err_counter( '/err/nat44-in2out-slowpath/good in2out packets processed') - self.assertEqual(err - totaln, 3) + self.assertEqual(err - totaln, 4) # out2in tcpn = self.statistics.get_err_counter('/err/nat44-out2in/TCP packets') @@ -1602,14 +1602,14 @@ class TestNAT44(MethodHolder): self.verify_capture_in(capture, self.pg0) err = self.statistics.get_err_counter('/err/nat44-out2in/TCP packets') - self.assertEqual(err - tcpn, 1) + self.assertEqual(err - tcpn, 2) err = self.statistics.get_err_counter('/err/nat44-out2in/UDP packets') self.assertEqual(err - udpn, 1) err = self.statistics.get_err_counter('/err/nat44-out2in/ICMP packets') self.assertEqual(err - icmpn, 1) err = self.statistics.get_err_counter( '/err/nat44-out2in/good out2in packets processed') - self.assertEqual(err - totaln, 3) + self.assertEqual(err - totaln, 4) users = self.statistics.get_counter('/nat44/total-users') self.assertEqual(users[0][0], 1) @@ -4727,7 +4727,7 @@ class TestNAT44EndpointDependent(MethodHolder): err = self.statistics.get_err_counter( '/err/nat44-ed-in2out-slowpath/TCP packets') - self.assertEqual(err - tcpn, 1) + self.assertEqual(err - tcpn, 2) err = self.statistics.get_err_counter( '/err/nat44-ed-in2out-slowpath/UDP packets') self.assertEqual(err - udpn, 1) @@ -4736,7 +4736,7 @@ class TestNAT44EndpointDependent(MethodHolder): self.assertEqual(err - icmpn, 1) err = self.statistics.get_err_counter( '/err/nat44-ed-in2out-slowpath/good in2out packets processed') - self.assertEqual(err - totaln, 3) + self.assertEqual(err - totaln, 4) # out2in tcpn = self.statistics.get_err_counter( @@ -4757,7 +4757,7 @@ class TestNAT44EndpointDependent(MethodHolder): err = self.statistics.get_err_counter( '/err/nat44-ed-out2in/TCP packets') - self.assertEqual(err - tcpn, 1) + self.assertEqual(err - tcpn, 2) err = self.statistics.get_err_counter( '/err/nat44-ed-out2in/UDP packets') self.assertEqual(err - udpn, 1) @@ -4766,7 +4766,7 @@ class TestNAT44EndpointDependent(MethodHolder): self.assertEqual(err - icmpn, 1) err = self.statistics.get_err_counter( '/err/nat44-ed-out2in/good out2in packets processed') - self.assertEqual(err - totaln, 2) + self.assertEqual(err - totaln, 3) users = self.statistics.get_counter('/nat44/total-users') self.assertEqual(users[0][0], 1) @@ -4823,7 +4823,7 @@ class TestNAT44EndpointDependent(MethodHolder): err = self.statistics.get_err_counter( '/err/nat44-ed-in2out-slowpath/TCP packets') - self.assertEqual(err - tcpn, 1) + self.assertEqual(err - tcpn, 2) err = self.statistics.get_err_counter( '/err/nat44-ed-in2out-slowpath/UDP packets') self.assertEqual(err - udpn, 1) @@ -4832,7 +4832,7 @@ class TestNAT44EndpointDependent(MethodHolder): self.assertEqual(err - icmpn, 1) err = self.statistics.get_err_counter( '/err/nat44-ed-in2out-slowpath/good in2out packets processed') - self.assertEqual(err - totaln, 3) + self.assertEqual(err - totaln, 4) # out2in tcpn = self.statistics.get_err_counter( @@ -4853,7 +4853,7 @@ class TestNAT44EndpointDependent(MethodHolder): err = self.statistics.get_err_counter( '/err/nat44-ed-out2in/TCP packets') - self.assertEqual(err - tcpn, 1) + self.assertEqual(err - tcpn, 2) err = self.statistics.get_err_counter( '/err/nat44-ed-out2in/UDP packets') self.assertEqual(err - udpn, 1) @@ -4862,7 +4862,7 @@ class TestNAT44EndpointDependent(MethodHolder): self.assertEqual(err - icmpn, 1) err = self.statistics.get_err_counter( '/err/nat44-ed-out2in/good out2in packets processed') - self.assertEqual(err - totaln, 2) + self.assertEqual(err - totaln, 3) users = self.statistics.get_counter('/nat44/total-users') self.assertEqual(users[0][0], 1) @@ -8034,14 +8034,14 @@ class TestNAT64(MethodHolder): self.verify_capture_in_ip6(capture, ip[IPv6].src, self.pg0.remote_ip6) err = self.statistics.get_err_counter('/err/nat64-out2in/TCP packets') - self.assertEqual(err - tcpn, 1) + self.assertEqual(err - tcpn, 2) err = self.statistics.get_err_counter('/err/nat64-out2in/UDP packets') self.assertEqual(err - udpn, 1) err = self.statistics.get_err_counter('/err/nat64-out2in/ICMP packets') self.assertEqual(err - icmpn, 1) err = self.statistics.get_err_counter( '/err/nat64-out2in/good out2in packets processed') - self.assertEqual(err - totaln, 3) + self.assertEqual(err - totaln, 4) bibs = self.statistics.get_counter('/nat64/total-bibs') self.assertEqual(bibs[0][0], 3) -- cgit 1.2.3-korg