diff options
-rw-r--r-- | src/plugins/flowprobe/test/test_flowprobe.py | 4 | ||||
-rw-r--r-- | src/plugins/nat/test/test_nat.py | 156 | ||||
-rw-r--r-- | src/vat/api_format.c | 5 | ||||
-rw-r--r-- | src/vnet/ipfix-export/flow_api.c | 34 | ||||
-rw-r--r-- | src/vnet/ipfix-export/ipfix_export.api | 26 | ||||
-rw-r--r-- | src/vpp/api/custom_dump.c | 4 |
6 files changed, 121 insertions, 108 deletions
diff --git a/src/plugins/flowprobe/test/test_flowprobe.py b/src/plugins/flowprobe/test/test_flowprobe.py index 307d836e9ed..8c9c54b78b5 100644 --- a/src/plugins/flowprobe/test/test_flowprobe.py +++ b/src/plugins/flowprobe/test/test_flowprobe.py @@ -59,8 +59,8 @@ class VppCFLOW(VppObject): def enable_exporter(self): self._test.vapi.set_ipfix_exporter( - collector_address=self._test.pg0.remote_ip4n, - src_address=self._test.pg0.local_ip4n, + collector_address=self._test.pg0.remote_ip4, + src_address=self._test.pg0.local_ip4, path_mtu=self._mtu, template_interval=self._timeout) diff --git a/src/plugins/nat/test/test_nat.py b/src/plugins/nat/test/test_nat.py index aa2a6c80e92..08642045958 100644 --- a/src/plugins/nat/test/test_nat.py +++ b/src/plugins/nat/test/test_nat.py @@ -1065,7 +1065,7 @@ class MethodHolder(VppTestCase): # maxEntriesPerUser self.assertEqual(struct.pack("I", limit), record[473]) # sourceIPv4Address - self.assertEqual(src_addr, record[8]) + self.assertEqual(socket.inet_pton(socket.AF_INET, src_addr), record[8]) def verify_syslog_apmap(self, data, is_add=True): message = data.decode('utf-8') @@ -1816,7 +1816,7 @@ class TestNAT44(MethodHolder): is_add=1) self.vapi.nat44_forwarding_enable_disable(enable=1) - real_ip = self.pg0.remote_ip4n + real_ip = self.pg0.remote_ip4 alias_ip = self.nat_addr flags = self.config_flags.NAT_IS_ADDR_ONLY self.vapi.nat44_add_del_static_mapping(is_add=1, @@ -2100,7 +2100,7 @@ class TestNAT44(MethodHolder): # 1:1NAT self.nat44_add_static_mapping(self.pg0.remote_ip4, nat_ip) - sessions = self.vapi.nat44_user_session_dump(self.pg0.remote_ip4n, 0) + sessions = self.vapi.nat44_user_session_dump(self.pg0.remote_ip4, 0) self.assertEqual(len(sessions), 0) pkts = self.create_stream_in(self.pg0, self.pg1) self.pg0.add_stream(pkts) @@ -2113,7 +2113,7 @@ class TestNAT44(MethodHolder): """ Identity NAT """ flags = self.config_flags.NAT_IS_ADDR_ONLY self.vapi.nat44_add_del_identity_mapping( - ip_address=self.pg0.remote_ip4n, sw_if_index=0xFFFFFFFF, + ip_address=self.pg0.remote_ip4, sw_if_index=0xFFFFFFFF, flags=flags, is_add=1) flags = self.config_flags.NAT_IS_INSIDE self.vapi.nat44_interface_add_del_feature( @@ -2143,11 +2143,11 @@ class TestNAT44(MethodHolder): self.logger.error(ppp("Unexpected or invalid packet:", p)) raise - sessions = self.vapi.nat44_user_session_dump(self.pg0.remote_ip4n, 0) + sessions = self.vapi.nat44_user_session_dump(self.pg0.remote_ip4, 0) self.assertEqual(len(sessions), 0) flags = self.config_flags.NAT_IS_ADDR_ONLY self.vapi.nat44_add_del_identity_mapping( - ip_address=self.pg0.remote_ip4n, sw_if_index=0xFFFFFFFF, + ip_address=self.pg0.remote_ip4, sw_if_index=0xFFFFFFFF, flags=flags, vrf_id=1, is_add=1) identity_mappings = self.vapi.nat44_identity_mapping_dump() self.assertEqual(len(identity_mappings), 2) @@ -2299,7 +2299,7 @@ class TestNAT44(MethodHolder): # pg5 session dump addresses = self.vapi.nat44_address_dump() self.assertEqual(len(addresses), 1) - sessions = self.vapi.nat44_user_session_dump(self.pg5.remote_ip4n, 10) + sessions = self.vapi.nat44_user_session_dump(self.pg5.remote_ip4, 10) self.assertEqual(len(sessions), 3) for session in sessions: self.assertFalse(session.flags & self.config_flags.NAT_IS_STATIC) @@ -2351,7 +2351,7 @@ class TestNAT44(MethodHolder): self.config_flags.NAT_IS_EXT_HOST_VALID) # pg4 session dump - sessions = self.vapi.nat44_user_session_dump(self.pg4.remote_ip4n, 10) + sessions = self.vapi.nat44_user_session_dump(self.pg4.remote_ip4, 10) self.assertGreaterEqual(len(sessions), 4) for session in sessions: self.assertFalse(session.flags & self.config_flags.NAT_IS_STATIC) @@ -2361,7 +2361,7 @@ class TestNAT44(MethodHolder): addresses[0].ip_address) # pg6 session dump - sessions = self.vapi.nat44_user_session_dump(self.pg6.remote_ip4n, 20) + sessions = self.vapi.nat44_user_session_dump(self.pg6.remote_ip4, 20) self.assertGreaterEqual(len(sessions), 3) for session in sessions: self.assertTrue(session.flags & self.config_flags.NAT_IS_STATIC) @@ -2642,7 +2642,7 @@ class TestNAT44(MethodHolder): users = self.vapi.nat44_user_dump() for user in users: - if user.ip_address == self.pg0.remote_ip4n: + if user.ip_address == self.pg0.remote_ip4: self.assertEqual(user.nsessions, nat44_config.max_translations_per_user) self.assertEqual(user.nstaticsessions, 0) @@ -2660,7 +2660,7 @@ class TestNAT44(MethodHolder): self.pg1.get_capture(1) users = self.vapi.nat44_user_dump() for user in users: - if user.ip_address == self.pg0.remote_ip4n: + if user.ip_address == self.pg0.remote_ip4: self.assertEqual(user.nsessions, nat44_config.max_translations_per_user - 1) self.assertEqual(user.nstaticsessions, 1) @@ -2803,8 +2803,8 @@ class TestNAT44(MethodHolder): self.vapi.nat44_interface_add_del_feature( sw_if_index=self.pg1.sw_if_index, is_add=1) - self.vapi.set_ipfix_exporter(collector_address=self.pg3.remote_ip4n, - src_address=self.pg3.local_ip4n, + self.vapi.set_ipfix_exporter(collector_address=self.pg3.remote_ip4, + src_address=self.pg3.local_ip4, path_mtu=512, template_interval=10, collector_port=collector_port) @@ -2848,8 +2848,8 @@ class TestNAT44(MethodHolder): self.vapi.nat44_interface_add_del_feature( sw_if_index=self.pg1.sw_if_index, is_add=1) - self.vapi.set_ipfix_exporter(collector_address=self.pg3.remote_ip4n, - src_address=self.pg3.local_ip4n, + self.vapi.set_ipfix_exporter(collector_address=self.pg3.remote_ip4, + src_address=self.pg3.local_ip4, path_mtu=512, template_interval=10) self.vapi.nat_ipfix_enable_disable(domain_id=self.ipfix_domain_id, @@ -2911,8 +2911,8 @@ class TestNAT44(MethodHolder): self.pg_start() self.pg1.get_capture(max_sessions) - self.vapi.set_ipfix_exporter(collector_address=self.pg3.remote_ip4n, - src_address=self.pg3.local_ip4n, + self.vapi.set_ipfix_exporter(collector_address=self.pg3.remote_ip4, + src_address=self.pg3.local_ip4, path_mtu=512, template_interval=10) self.vapi.nat_ipfix_enable_disable(domain_id=self.ipfix_domain_id, @@ -2951,7 +2951,7 @@ class TestNAT44(MethodHolder): """ Test syslog address and port mapping creation and deletion """ self.vapi.syslog_set_filter( self.SYSLOG_SEVERITY.SYSLOG_API_SEVERITY_INFO) - self.vapi.syslog_set_sender(self.pg3.local_ip4n, self.pg3.remote_ip4n) + self.vapi.syslog_set_sender(self.pg3.local_ip4, self.pg3.remote_ip4) self.nat44_add_address(self.nat_addr) flags = self.config_flags.NAT_IS_INSIDE self.vapi.nat44_interface_add_del_feature( @@ -3619,7 +3619,7 @@ class TestNAT44(MethodHolder): self.pg_start() self.pg1.get_capture(len(pkts)) - sessions = self.vapi.nat44_user_session_dump(self.pg0.remote_ip4n, 0) + sessions = self.vapi.nat44_user_session_dump(self.pg0.remote_ip4, 0) nsessions = len(sessions) self.vapi.nat44_del_session(address=sessions[0].inside_ip_address, @@ -3630,7 +3630,7 @@ class TestNAT44(MethodHolder): port=sessions[1].outside_port, protocol=sessions[1].protocol) - sessions = self.vapi.nat44_user_session_dump(self.pg0.remote_ip4n, 0) + sessions = self.vapi.nat44_user_session_dump(self.pg0.remote_ip4, 0) self.assertEqual(nsessions - len(sessions), 2) self.vapi.nat44_del_session(address=sessions[0].inside_ip_address, @@ -3843,8 +3843,8 @@ class TestNAT44(MethodHolder): is_add=1) self.vapi.nat_set_reass(timeout=2, max_reass=1024, max_frag=1, drop_frag=0) - self.vapi.set_ipfix_exporter(collector_address=self.pg3.remote_ip4n, - src_address=self.pg3.local_ip4n, + self.vapi.set_ipfix_exporter(collector_address=self.pg3.remote_ip4, + src_address=self.pg3.local_ip4, path_mtu=512, template_interval=10) self.vapi.nat_ipfix_enable_disable(domain_id=self.ipfix_domain_id, @@ -4112,7 +4112,7 @@ class TestNAT44(MethodHolder): # delete one session self.pg_enable_capture(self.pg_interfaces) - self.vapi.nat44_del_session(address=self.pg0.remote_ip4n, + self.vapi.nat44_del_session(address=self.pg0.remote_ip4, port=self.tcp_port_in, protocol=IP_PROTOS.tcp, flags=self.config_flags.NAT_IS_INSIDE) @@ -4438,14 +4438,12 @@ class TestNAT44EndpointDependent(MethodHolder): cls.pg4._remote_hosts[1]._ip4 = cls.pg4._remote_hosts[0]._ip4 cls.pg4.resolve_arp() - zero_ip4n = socket.inet_pton(socket.AF_INET, "0.0.0.0") + zero_ip4 = socket.inet_pton(socket.AF_INET, "0.0.0.0") cls.vapi.ip_table_add_del(is_add=1, table_id=1) cls.pg5._local_ip4 = VppIpPrefix("10.1.1.1", cls.pg5.local_ip4_prefix.len) cls.pg5._remote_hosts[0]._ip4 = "10.1.1.2" - cls.pg5._remote_hosts[0]._ip4n = socket.inet_pton( - socket.AF_INET, cls.pg5.remote_ip4) cls.pg5.set_table_ip4(1) cls.pg5.config_ip4() cls.pg5.admin_up() @@ -4459,8 +4457,6 @@ class TestNAT44EndpointDependent(MethodHolder): cls.pg6._local_ip4 = VppIpPrefix("10.1.2.1", cls.pg6.local_ip4_prefix.len) cls.pg6._remote_hosts[0]._ip4 = "10.1.2.2" - cls.pg6._remote_hosts[0]._ip4n = socket.inet_pton( - socket.AF_INET, cls.pg6.remote_ip4) cls.pg6.set_table_ip4(1) cls.pg6.config_ip4() cls.pg6.admin_up() @@ -4949,7 +4945,7 @@ class TestNAT44EndpointDependent(MethodHolder): self.pg0.remote_hosts[0] = host0 user = self.pg0.remote_hosts[1] - sessions = self.vapi.nat44_user_session_dump(user.ip4n, 0) + sessions = self.vapi.nat44_user_session_dump(user.ip4, 0) self.assertEqual(len(sessions), 3) self.assertTrue(sessions[0].flags & self.config_flags.NAT_IS_EXT_HOST_VALID) @@ -4961,7 +4957,7 @@ class TestNAT44EndpointDependent(MethodHolder): self.config_flags.NAT_IS_EXT_HOST_VALID), ext_host_address=sessions[0].ext_host_address, ext_host_port=sessions[0].ext_host_port) - sessions = self.vapi.nat44_user_session_dump(user.ip4n, 0) + sessions = self.vapi.nat44_user_session_dump(user.ip4, 0) self.assertEqual(len(sessions), 2) finally: @@ -4982,11 +4978,11 @@ class TestNAT44EndpointDependent(MethodHolder): server1 = self.pg0.remote_hosts[0] server2 = self.pg0.remote_hosts[1] - locals = [{'addr': server1.ip4n, + locals = [{'addr': server1.ip4, 'port': local_port, 'probability': 70, 'vrf_id': 0}, - {'addr': server2.ip4n, + {'addr': server2.ip4, 'port': local_port, 'probability': 30, 'vrf_id': 0}] @@ -5050,7 +5046,7 @@ class TestNAT44EndpointDependent(MethodHolder): self.logger.error(ppp("Unexpected or invalid packet:", p)) raise - sessions = self.vapi.nat44_user_session_dump(server.ip4n, 0) + sessions = self.vapi.nat44_user_session_dump(server.ip4, 0) self.assertEqual(len(sessions), 1) self.assertTrue(sessions[0].flags & self.config_flags.NAT_IS_EXT_HOST_VALID) @@ -5062,7 +5058,7 @@ class TestNAT44EndpointDependent(MethodHolder): self.config_flags.NAT_IS_EXT_HOST_VALID), ext_host_address=sessions[0].ext_host_address, ext_host_port=sessions[0].ext_host_port) - sessions = self.vapi.nat44_user_session_dump(server.ip4n, 0) + sessions = self.vapi.nat44_user_session_dump(server.ip4, 0) self.assertEqual(len(sessions), 0) @unittest.skipUnless(running_extended_tests, "part of extended tests") @@ -5076,11 +5072,11 @@ class TestNAT44EndpointDependent(MethodHolder): server2 = self.pg0.remote_hosts[1] server3 = self.pg0.remote_hosts[2] - locals = [{'addr': server1.ip4n, + locals = [{'addr': server1.ip4, 'port': local_port, 'probability': 90, 'vrf_id': 0}, - {'addr': server2.ip4n, + {'addr': server2.ip4, 'port': local_port, 'probability': 10, 'vrf_id': 0}] @@ -5121,7 +5117,7 @@ class TestNAT44EndpointDependent(MethodHolder): self.assertGreater(server1_n, server2_n) local = { - 'addr': server3.ip4n, + 'addr': server3.ip4, 'port': local_port, 'probability': 20, 'vrf_id': 0 @@ -5161,7 +5157,7 @@ class TestNAT44EndpointDependent(MethodHolder): self.assertGreater(server3_n, 0) local = { - 'addr': server2.ip4n, + 'addr': server2.ip4, 'port': local_port, 'probability': 10, 'vrf_id': 0 @@ -5200,11 +5196,11 @@ class TestNAT44EndpointDependent(MethodHolder): server1 = self.pg0.remote_hosts[0] server2 = self.pg0.remote_hosts[1] - locals = [{'addr': server1.ip4n, + locals = [{'addr': server1.ip4, 'port': local_port, 'probability': 70, 'vrf_id': 0}, - {'addr': server2.ip4n, + {'addr': server2.ip4, 'port': local_port, 'probability': 30, 'vrf_id': 0}] @@ -5315,11 +5311,11 @@ class TestNAT44EndpointDependent(MethodHolder): server1 = self.pg0.remote_hosts[0] server2 = self.pg0.remote_hosts[1] - locals = [{'addr': server1.ip4n, + locals = [{'addr': server1.ip4, 'port': local_port, 'probability': 50, 'vrf_id': 0}, - {'addr': server2.ip4n, + {'addr': server2.ip4, 'port': local_port, 'probability': 50, 'vrf_id': 0}] @@ -5512,7 +5508,7 @@ class TestNAT44EndpointDependent(MethodHolder): self.nat44_add_address(self.nat_addr) flags = self.config_flags.NAT_IS_ADDR_ONLY self.vapi.nat44_add_del_identity_mapping( - ip_address=self.pg1.remote_ip4n, sw_if_index=0xFFFFFFFF, + ip_address=self.pg1.remote_ip4, sw_if_index=0xFFFFFFFF, flags=flags, is_add=1) flags = self.config_flags.NAT_IS_OUT2IN_ONLY self.nat44_add_static_mapping(self.pg0.remote_ip4, external_addr, @@ -5803,11 +5799,11 @@ class TestNAT44EndpointDependent(MethodHolder): proto=IP_PROTOS.tcp, flags=flags) else: - locals = [{'addr': server1.ip4n, + locals = [{'addr': server1.ip4, 'port': port_in1, 'probability': 50, 'vrf_id': 0}, - {'addr': server2.ip4n, + {'addr': server2.ip4, 'port': port_in2, 'probability': 50, 'vrf_id': 0}] @@ -5896,7 +5892,7 @@ class TestNAT44EndpointDependent(MethodHolder): raise if eh_translate: - sessions = self.vapi.nat44_user_session_dump(server.ip4n, 0) + sessions = self.vapi.nat44_user_session_dump(server.ip4, 0) self.assertEqual(len(sessions), 1) self.assertTrue(sessions[0].flags & self.config_flags.NAT_IS_EXT_HOST_VALID) @@ -5911,7 +5907,7 @@ class TestNAT44EndpointDependent(MethodHolder): self.config_flags.NAT_IS_EXT_HOST_VALID), ext_host_address=sessions[0].ext_host_nat_address, ext_host_port=sessions[0].ext_host_nat_port) - sessions = self.vapi.nat44_user_session_dump(server.ip4n, 0) + sessions = self.vapi.nat44_user_session_dump(server.ip4, 0) self.assertEqual(len(sessions), 0) def test_twice_nat(self): @@ -5990,7 +5986,7 @@ class TestNAT44EndpointDependent(MethodHolder): 80, proto=IP_PROTOS.tcp, flags=flags) - sessions = self.vapi.nat44_user_session_dump(self.pg0.remote_ip4n, 0) + sessions = self.vapi.nat44_user_session_dump(self.pg0.remote_ip4, 0) start_sessnum = len(sessions) # SYN packet out->in @@ -6049,7 +6045,7 @@ class TestNAT44EndpointDependent(MethodHolder): self.pg_start() self.pg1.get_capture(1) - sessions = self.vapi.nat44_user_session_dump(self.pg0.remote_ip4n, + sessions = self.vapi.nat44_user_session_dump(self.pg0.remote_ip4, 0) self.assertEqual(len(sessions) - start_sessnum, 0) @@ -6072,7 +6068,7 @@ class TestNAT44EndpointDependent(MethodHolder): sw_if_index=self.pg1.sw_if_index, is_add=1) - sessions = self.vapi.nat44_user_session_dump(self.pg0.remote_ip4n, 0) + sessions = self.vapi.nat44_user_session_dump(self.pg0.remote_ip4, 0) start_sessnum = len(sessions) self.initiate_tcp_session(self.pg0, self.pg1) @@ -6118,7 +6114,7 @@ class TestNAT44EndpointDependent(MethodHolder): self.pg_start() self.pg1.get_capture(1) - sessions = self.vapi.nat44_user_session_dump(self.pg0.remote_ip4n, + sessions = self.vapi.nat44_user_session_dump(self.pg0.remote_ip4, 0) self.assertEqual(len(sessions) - start_sessnum, 0) @@ -6141,7 +6137,7 @@ class TestNAT44EndpointDependent(MethodHolder): sw_if_index=self.pg1.sw_if_index, is_add=1) - sessions = self.vapi.nat44_user_session_dump(self.pg0.remote_ip4n, 0) + sessions = self.vapi.nat44_user_session_dump(self.pg0.remote_ip4, 0) start_sessnum = len(sessions) self.initiate_tcp_session(self.pg0, self.pg1) @@ -6177,7 +6173,7 @@ class TestNAT44EndpointDependent(MethodHolder): self.pg_start() self.pg0.get_capture(1) - sessions = self.vapi.nat44_user_session_dump(self.pg0.remote_ip4n, + sessions = self.vapi.nat44_user_session_dump(self.pg0.remote_ip4, 0) self.assertEqual(len(sessions) - start_sessnum, 0) @@ -6200,7 +6196,7 @@ class TestNAT44EndpointDependent(MethodHolder): sw_if_index=self.pg1.sw_if_index, is_add=1) - sessions = self.vapi.nat44_user_session_dump(self.pg0.remote_ip4n, 0) + sessions = self.vapi.nat44_user_session_dump(self.pg0.remote_ip4, 0) start_sessnum = len(sessions) self.initiate_tcp_session(self.pg0, self.pg1) @@ -6245,7 +6241,7 @@ class TestNAT44EndpointDependent(MethodHolder): self.pg_start() self.pg0.get_capture(1) - sessions = self.vapi.nat44_user_session_dump(self.pg0.remote_ip4n, + sessions = self.vapi.nat44_user_session_dump(self.pg0.remote_ip4, 0) self.assertEqual(len(sessions) - start_sessnum, 0) @@ -6881,8 +6877,8 @@ class TestNAT44EndpointDependent(MethodHolder): self.vapi.nat44_interface_add_del_feature( sw_if_index=self.pg1.sw_if_index, is_add=1) - self.vapi.set_ipfix_exporter(collector_address=self.pg2.remote_ip4n, - src_address=self.pg2.local_ip4n, + self.vapi.set_ipfix_exporter(collector_address=self.pg2.remote_ip4, + src_address=self.pg2.local_ip4, path_mtu=512, template_interval=10) self.vapi.nat_set_timeouts(udp=5, tcp_established=7440, @@ -6932,7 +6928,7 @@ class TestNAT44EndpointDependent(MethodHolder): self.verify_ipfix_max_entries_per_user( data, nat44_config.max_translations_per_user, - self.pg0.remote_ip4n) + self.pg0.remote_ip4) sleep(6) p = (Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) / @@ -6947,7 +6943,7 @@ class TestNAT44EndpointDependent(MethodHolder): """ Test syslog session creation and deletion """ self.vapi.syslog_set_filter( self.SYSLOG_SEVERITY.SYSLOG_API_SEVERITY_INFO) - self.vapi.syslog_set_sender(self.pg2.local_ip4n, self.pg2.remote_ip4n) + self.vapi.syslog_set_sender(self.pg2.local_ip4, self.pg2.remote_ip4) self.nat44_add_address(self.nat_addr) flags = self.config_flags.NAT_IS_INSIDE self.vapi.nat44_interface_add_del_feature( @@ -7305,7 +7301,7 @@ class TestDeterministicNAT(MethodHolder): nat_ip = "10.0.0.10" - self.vapi.nat_det_add_del_map(is_add=1, in_addr=self.pg0.remote_ip4n, + self.vapi.nat_det_add_del_map(is_add=1, in_addr=self.pg0.remote_ip4, in_plen=32, out_addr=socket.inet_aton(nat_ip), out_plen=32) @@ -7335,7 +7331,7 @@ class TestDeterministicNAT(MethodHolder): self.verify_capture_in(capture, self.pg0) # session dump test - sessions = self.vapi.nat_det_session_dump(self.pg0.remote_ip4n) + sessions = self.vapi.nat_det_session_dump(self.pg0.remote_ip4) self.assertEqual(len(sessions), 3) # TCP session @@ -7368,7 +7364,7 @@ class TestDeterministicNAT(MethodHolder): host0 = self.pg0.remote_hosts[0] host1 = self.pg0.remote_hosts[1] - self.vapi.nat_det_add_del_map(is_add=1, in_addr=host0.ip4n, in_plen=24, + self.vapi.nat_det_add_del_map(is_add=1, in_addr=host0.ip4, in_plen=24, out_addr=socket.inet_aton(nat_ip), out_plen=32) flags = self.config_flags.NAT_IS_INSIDE @@ -7466,21 +7462,21 @@ class TestDeterministicNAT(MethodHolder): # session close api test self.vapi.nat_det_close_session_out(socket.inet_aton(nat_ip), port_out1, - self.pg1.remote_ip4n, + self.pg1.remote_ip4, external_port) dms = self.vapi.nat_det_map_dump() self.assertEqual(dms[0].ses_num, 1) - self.vapi.nat_det_close_session_in(host0.ip4n, + self.vapi.nat_det_close_session_in(host0.ip4, port_in, - self.pg1.remote_ip4n, + self.pg1.remote_ip4, external_port) dms = self.vapi.nat_det_map_dump() self.assertEqual(dms[0].ses_num, 0) def test_tcp_session_close_detection_in(self): """ Deterministic NAT TCP session close from inside network """ - self.vapi.nat_det_add_del_map(is_add=1, in_addr=self.pg0.remote_ip4n, + self.vapi.nat_det_add_del_map(is_add=1, in_addr=self.pg0.remote_ip4, in_plen=32, out_addr=socket.inet_aton(self.nat_addr), out_plen=32) @@ -7546,7 +7542,7 @@ class TestDeterministicNAT(MethodHolder): def test_tcp_session_close_detection_out(self): """ Deterministic NAT TCP session close from outside network """ - self.vapi.nat_det_add_del_map(is_add=1, in_addr=self.pg0.remote_ip4n, + self.vapi.nat_det_add_del_map(is_add=1, in_addr=self.pg0.remote_ip4, in_plen=32, out_addr=socket.inet_aton(self.nat_addr), out_plen=32) @@ -7613,7 +7609,7 @@ class TestDeterministicNAT(MethodHolder): @unittest.skipUnless(running_extended_tests, "part of extended tests") def test_session_timeout(self): """ Deterministic NAT session timeouts """ - self.vapi.nat_det_add_del_map(is_add=1, in_addr=self.pg0.remote_ip4n, + self.vapi.nat_det_add_del_map(is_add=1, in_addr=self.pg0.remote_ip4, in_plen=32, out_addr=socket.inet_aton(self.nat_addr), out_plen=32) @@ -7641,7 +7637,7 @@ class TestDeterministicNAT(MethodHolder): @unittest.skipUnless(running_extended_tests, "part of extended tests") def test_session_limit_per_user(self): """ Deterministic NAT maximum sessions per user limit """ - self.vapi.nat_det_add_del_map(is_add=1, in_addr=self.pg0.remote_ip4n, + self.vapi.nat_det_add_del_map(is_add=1, in_addr=self.pg0.remote_ip4, in_plen=32, out_addr=socket.inet_aton(self.nat_addr), out_plen=32) @@ -7652,8 +7648,8 @@ class TestDeterministicNAT(MethodHolder): self.vapi.nat44_interface_add_del_feature( sw_if_index=self.pg1.sw_if_index, is_add=1) - self.vapi.set_ipfix_exporter(collector_address=self.pg2.remote_ip4n, - src_address=self.pg2.local_ip4n, + self.vapi.set_ipfix_exporter(collector_address=self.pg2.remote_ip4, + src_address=self.pg2.local_ip4, path_mtu=512, template_interval=10) self.vapi.nat_ipfix_enable_disable(domain_id=1, src_port=4739, @@ -7711,7 +7707,7 @@ class TestDeterministicNAT(MethodHolder): data = ipfix.decode_data_set(p.getlayer(Set)) self.verify_ipfix_max_entries_per_user(data, 1000, - self.pg0.remote_ip4n) + self.pg0.remote_ip4) def clear_nat_det(self): """ @@ -8915,8 +8911,8 @@ class TestNAT64(MethodHolder): self.pg_start() self.pg1.get_capture(max_sessions) - self.vapi.set_ipfix_exporter(collector_address=self.pg3.remote_ip4n, - src_address=self.pg3.local_ip4n, + self.vapi.set_ipfix_exporter(collector_address=self.pg3.remote_ip4, + src_address=self.pg3.local_ip4, path_mtu=512, template_interval=10) self.vapi.nat_ipfix_enable_disable(domain_id=self.ipfix_domain_id, @@ -8987,8 +8983,8 @@ class TestNAT64(MethodHolder): sw_if_index=self.pg1.sw_if_index) self.vapi.nat_set_reass(timeout=2, max_reass=1024, max_frag=1, drop_frag=0, is_ip6=1) - self.vapi.set_ipfix_exporter(collector_address=self.pg3.remote_ip4n, - src_address=self.pg3.local_ip4n, + self.vapi.set_ipfix_exporter(collector_address=self.pg3.remote_ip4, + src_address=self.pg3.local_ip4, path_mtu=512, template_interval=10) self.vapi.nat_ipfix_enable_disable(domain_id=self.ipfix_domain_id, @@ -9041,8 +9037,8 @@ class TestNAT64(MethodHolder): sw_if_index=self.pg0.sw_if_index) self.vapi.nat64_add_del_interface(is_add=1, flags=0, sw_if_index=self.pg1.sw_if_index) - self.vapi.set_ipfix_exporter(collector_address=self.pg3.remote_ip4n, - src_address=self.pg3.local_ip4n, + self.vapi.set_ipfix_exporter(collector_address=self.pg3.remote_ip4, + src_address=self.pg3.local_ip4, path_mtu=512, template_interval=10) self.vapi.nat_ipfix_enable_disable(domain_id=self.ipfix_domain_id, @@ -9135,7 +9131,7 @@ class TestNAT64(MethodHolder): sw_if_index=self.pg1.sw_if_index) self.vapi.syslog_set_filter( self.SYSLOG_SEVERITY.SYSLOG_API_SEVERITY_INFO) - self.vapi.syslog_set_sender(self.pg3.local_ip4n, self.pg3.remote_ip4n) + self.vapi.syslog_set_sender(self.pg3.local_ip4, self.pg3.remote_ip4) p = (Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) / IPv6(src=self.pg0.remote_ip6, dst=remote_host_ip6) / @@ -9291,7 +9287,7 @@ class TestDSlite(MethodHolder): aftr_ip4 = '192.0.0.1' aftr_ip6 = '2001:db8:85a3::8a2e:370:1' self.vapi.dslite_set_aftr_addr(ip4_addr=aftr_ip4, ip6_addr=aftr_ip6) - self.vapi.syslog_set_sender(self.pg2.local_ip4n, self.pg2.remote_ip4n) + self.vapi.syslog_set_sender(self.pg2.local_ip4, self.pg2.remote_ip4) # UDP p = (Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac) / diff --git a/src/vat/api_format.c b/src/vat/api_format.c index cbd7f901f98..3ad4ec6e2cd 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -11281,10 +11281,11 @@ api_set_ipfix_exporter (vat_main_t * vam) M (SET_IPFIX_EXPORTER, mp); - memcpy (mp->collector_address, collector_address.data, + memcpy (mp->collector_address.un.ip4, collector_address.data, sizeof (collector_address.data)); mp->collector_port = htons ((u16) collector_port); - memcpy (mp->src_address, src_address.data, sizeof (src_address.data)); + memcpy (mp->src_address.un.ip4, src_address.data, + sizeof (src_address.data)); mp->vrf_id = htonl (vrf_id); mp->path_mtu = htonl (path_mtu); mp->template_interval = htonl (template_interval); diff --git a/src/vnet/ipfix-export/flow_api.c b/src/vnet/ipfix-export/flow_api.c index 959671d3751..ead602499da 100644 --- a/src/vnet/ipfix-export/flow_api.c +++ b/src/vnet/ipfix-export/flow_api.c @@ -19,6 +19,7 @@ #include <vnet/vnet.h> #include <vlibmemory/api.h> +#include <vnet/ip/ip_types_api.h> #include <vnet/interface.h> #include <vnet/api_errno.h> @@ -74,11 +75,18 @@ vl_api_set_ipfix_exporter_t_handler (vl_api_set_ipfix_exporter_t * mp) if (!reg) return; - memcpy (collector.data, mp->collector_address, sizeof (collector.data)); + if (mp->src_address.af == ADDRESS_IP6 + || mp->collector_address.af == ADDRESS_IP6) + { + rv = VNET_API_ERROR_UNIMPLEMENTED; + goto out; + } + + ip4_address_decode (mp->collector_address.un.ip4, &collector); collector_port = ntohs (mp->collector_port); if (collector_port == (u16) ~ 0) collector_port = UDP_DST_PORT_ipfix; - memcpy (src.data, mp->src_address, sizeof (src.data)); + ip4_address_decode (mp->src_address.un.ip4, &src); fib_id = ntohl (mp->vrf_id); ip4_main_t *im = &ip4_main; @@ -157,6 +165,8 @@ vl_api_ipfix_exporter_dump_t_handler (vl_api_ipfix_exporter_dump_t * mp) vl_api_registration_t *reg; vl_api_ipfix_exporter_details_t *rmp; ip4_main_t *im = &ip4_main; + ip46_address_t collector = {.as_u64[0] = 0,.as_u64[1] = 0 }; + ip46_address_t src = {.as_u64[0] = 0,.as_u64[1] = 0 }; u32 vrf_id; reg = vl_api_client_index_to_registration (mp->client_index); @@ -167,11 +177,15 @@ vl_api_ipfix_exporter_dump_t_handler (vl_api_ipfix_exporter_dump_t * mp) clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_IPFIX_EXPORTER_DETAILS); rmp->context = mp->context; - memcpy (rmp->collector_address, frm->ipfix_collector.data, - sizeof (frm->ipfix_collector.data)); + + memcpy (&collector.ip4, &frm->ipfix_collector, sizeof (ip4_address_t)); + ip_address_encode (&collector, IP46_TYPE_IP4, &rmp->collector_address); + rmp->collector_port = htons (frm->collector_port); - memcpy (rmp->src_address, frm->src_address.data, - sizeof (frm->src_address.data)); + + memcpy (&src.ip4, &frm->src_address, sizeof (ip4_address_t)); + ip_address_encode (&src, IP46_TYPE_IP4, &rmp->src_address); + if (frm->fib_index == ~0) vrf_id = ~0; else @@ -255,8 +269,8 @@ static void return; classify_table_index = ntohl (mp->table_id); - ip_version = mp->ip_version; - transport_protocol = mp->transport_protocol; + ip_version = ntohl (mp->ip_version); + transport_protocol = ntohl (mp->transport_protocol); is_add = mp->is_add; if (fcm->src_port == 0) @@ -331,8 +345,8 @@ send_ipfix_classify_table_details (u32 table_index, mp->_vl_msg_id = ntohs (VL_API_IPFIX_CLASSIFY_TABLE_DETAILS); mp->context = context; mp->table_id = htonl (table->classify_table_index); - mp->ip_version = table->ip_version; - mp->transport_protocol = table->transport_protocol; + mp->ip_version = htonl (table->ip_version); + mp->transport_protocol = htonl (table->transport_protocol); vl_api_send_msg (reg, (u8 *) mp); } diff --git a/src/vnet/ipfix-export/ipfix_export.api b/src/vnet/ipfix-export/ipfix_export.api index 8b13c3bd720..efd967d1844 100644 --- a/src/vnet/ipfix-export/ipfix_export.api +++ b/src/vnet/ipfix-export/ipfix_export.api @@ -13,7 +13,9 @@ * limitations under the License. */ -option version = "1.0.1"; +option version = "2.0.1"; + +import "vnet/ip/ip_types.api"; /** \brief Configure IPFIX exporter process request @param client_index - opaque cookie to identify the sender @@ -30,13 +32,13 @@ autoreply define set_ipfix_exporter { u32 client_index; u32 context; - u8 collector_address[16]; + vl_api_address_t collector_address; u16 collector_port; - u8 src_address[16]; + vl_api_address_t src_address; u32 vrf_id; u32 path_mtu; u32 template_interval; - u8 udp_checksum; + bool udp_checksum; }; /** \brief IPFIX exporter dump request @@ -62,13 +64,13 @@ define ipfix_exporter_dump define ipfix_exporter_details { u32 context; - u8 collector_address[16]; + vl_api_address_t collector_address; u16 collector_port; - u8 src_address[16]; + vl_api_address_t src_address; u32 vrf_id; u32 path_mtu; u32 template_interval; - u8 udp_checksum; + bool udp_checksum; }; /** \brief IPFIX classify stream configure request @@ -115,9 +117,9 @@ autoreply define ipfix_classify_table_add_del { u32 client_index; u32 context; u32 table_id; - u8 ip_version; - u8 transport_protocol; - u8 is_add; + vl_api_address_family_t ip_version; + vl_api_ip_proto_t transport_protocol; + bool is_add; }; /** \brief IPFIX classify tables dump request @@ -138,8 +140,8 @@ define ipfix_classify_table_dump { define ipfix_classify_table_details { u32 context; u32 table_id; - u8 ip_version; - u8 transport_protocol; + vl_api_address_family_t ip_version; + vl_api_ip_proto_t transport_protocol; }; autoreply define ipfix_flush { diff --git a/src/vpp/api/custom_dump.c b/src/vpp/api/custom_dump.c index 66a17b27cb1..7b37862fd40 100644 --- a/src/vpp/api/custom_dump.c +++ b/src/vpp/api/custom_dump.c @@ -2556,10 +2556,10 @@ static void *vl_api_set_ipfix_exporter_t_print s = format (0, "SCRIPT: set_ipfix_exporter "); s = format (s, "collector-address %U ", format_ip4_address, - (ip4_address_t *) mp->collector_address); + (ip4_address_t *) mp->collector_address.un.ip4); s = format (s, "collector-port %d ", (mp->collector_port)); s = format (s, "src-address %U ", format_ip4_address, - (ip4_address_t *) mp->src_address); + (ip4_address_t *) mp->src_address.un.ip4); s = format (s, "vrf-id %d ", (mp->vrf_id)); s = format (s, "path-mtu %d ", (mp->path_mtu)); s = format (s, "template-interval %d ", (mp->template_interval)); |