diff options
author | Neale Ranns <nranns@cisco.com> | 2019-03-20 18:24:43 +0000 |
---|---|---|
committer | Paul Vinciguerra <pvinci@vinciconsulting.com> | 2019-03-21 13:44:31 +0000 |
commit | 2ac885c665309fc670cec96675ec1f510116fc13 (patch) | |
tree | 56cecf4fdd50ea4f2c0885a5d008c33ef5fce9cb /test/test_ipsec_tun_if_esp.py | |
parent | bcee60d570d7ad38f46c5bf0b28693557c567a27 (diff) |
IPSEC: Mutli-tunnel tests
Change-Id: I46f1db6579835c6613fdbb2b726246cc62b135fe
Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'test/test_ipsec_tun_if_esp.py')
-rw-r--r-- | test/test_ipsec_tun_if_esp.py | 127 |
1 files changed, 125 insertions, 2 deletions
diff --git a/test/test_ipsec_tun_if_esp.py b/test/test_ipsec_tun_if_esp.py index 06d2c89ebe9..ac96cfb9cc4 100644 --- a/test/test_ipsec_tun_if_esp.py +++ b/test/test_ipsec_tun_if_esp.py @@ -1,9 +1,10 @@ import unittest import socket +import copy from scapy.layers.ipsec import ESP from framework import VppTestRunner from template_ipsec import TemplateIpsec, IpsecTun4Tests, IpsecTun6Tests, \ - IpsecTcpTests + IpsecTun4, IpsecTun6, IpsecTcpTests, config_tun_params from vpp_ipsec_tun_interface import VppIpsecTunInterface from vpp_ip_route import VppIpRoute, VppRoutePath, DpoProto @@ -69,7 +70,7 @@ class TemplateIpsec6TunIfEsp(TemplateIpsec): tun_if.admin_up() tun_if.config_ip6() - VppIpRoute(self, p.remote_tun_if_host, 32, + VppIpRoute(self, p.remote_tun_if_host, 128, [VppRoutePath(tun_if.remote_ip6, 0xffffffff, proto=DpoProto.DPO_PROTO_IP6)], @@ -87,5 +88,127 @@ class TestIpsec6TunIfEsp1(TemplateIpsec6TunIfEsp, IpsecTun6Tests): tun6_decrypt_node_name = "esp6-decrypt" +class TestIpsec4MultiTunIfEsp(TemplateIpsec, IpsecTun4): + """ IPsec IPv4 Multi Tunnel interface """ + + encryption_type = ESP + tun4_encrypt_node_name = "esp4-encrypt" + tun4_decrypt_node_name = "esp4-decrypt" + + def setUp(self): + super(TestIpsec4MultiTunIfEsp, self).setUp() + + self.tun_if = self.pg0 + + self.multi_params = [] + + for ii in range(10): + p = copy.copy(self.ipv4_params) + + p.remote_tun_if_host = "1.1.1.%d" % (ii + 1) + p.scapy_tun_sa_id = p.scapy_tun_sa_id + ii + p.scapy_tun_spi = p.scapy_tun_spi + ii + p.vpp_tun_sa_id = p.vpp_tun_sa_id + ii + p.vpp_tun_spi = p.vpp_tun_spi + ii + + p.scapy_tra_sa_id = p.scapy_tra_sa_id + ii + p.scapy_tra_spi = p.scapy_tra_spi + ii + p.vpp_tra_sa_id = p.vpp_tra_sa_id + ii + p.vpp_tra_spi = p.vpp_tra_spi + ii + + config_tun_params(p, self.encryption_type, self.tun_if) + self.multi_params.append(p) + + p.tun_if = VppIpsecTunInterface(self, self.pg0, p.vpp_tun_spi, + p.scapy_tun_spi, + p.crypt_algo_vpp_id, + p.crypt_key, p.crypt_key, + p.auth_algo_vpp_id, p.auth_key, + p.auth_key) + p.tun_if.add_vpp_config() + p.tun_if.admin_up() + p.tun_if.config_ip4() + + VppIpRoute(self, p.remote_tun_if_host, 32, + [VppRoutePath(p.tun_if.remote_ip4, + 0xffffffff)]).add_vpp_config() + + def tearDown(self): + if not self.vpp_dead: + self.vapi.cli("show hardware") + super(TestIpsec4MultiTunIfEsp, self).tearDown() + + def test_tun_44(self): + """Multiple IPSEC tunnel interfaces """ + for p in self.multi_params: + self.verify_tun_44(p, count=127) + c = p.tun_if.get_rx_stats() + self.assertEqual(c['packets'], 127) + c = p.tun_if.get_tx_stats() + self.assertEqual(c['packets'], 127) + + +class TestIpsec6MultiTunIfEsp(TemplateIpsec, IpsecTun6): + """ IPsec IPv6 Muitli Tunnel interface """ + + encryption_type = ESP + tun6_encrypt_node_name = "esp6-encrypt" + tun6_decrypt_node_name = "esp6-decrypt" + + def setUp(self): + super(TestIpsec6MultiTunIfEsp, self).setUp() + + self.tun_if = self.pg0 + + self.multi_params = [] + + for ii in range(10): + p = copy.copy(self.ipv6_params) + + p.remote_tun_if_host = "1111::%d" % (ii + 1) + p.scapy_tun_sa_id = p.scapy_tun_sa_id + ii + p.scapy_tun_spi = p.scapy_tun_spi + ii + p.vpp_tun_sa_id = p.vpp_tun_sa_id + ii + p.vpp_tun_spi = p.vpp_tun_spi + ii + + p.scapy_tra_sa_id = p.scapy_tra_sa_id + ii + p.scapy_tra_spi = p.scapy_tra_spi + ii + p.vpp_tra_sa_id = p.vpp_tra_sa_id + ii + p.vpp_tra_spi = p.vpp_tra_spi + ii + + config_tun_params(p, self.encryption_type, self.tun_if) + self.multi_params.append(p) + + p.tun_if = VppIpsecTunInterface(self, self.pg0, p.vpp_tun_spi, + p.scapy_tun_spi, + p.crypt_algo_vpp_id, + p.crypt_key, p.crypt_key, + p.auth_algo_vpp_id, p.auth_key, + p.auth_key, is_ip6=True) + p.tun_if.add_vpp_config() + p.tun_if.admin_up() + p.tun_if.config_ip6() + + VppIpRoute(self, p.remote_tun_if_host, 128, + [VppRoutePath(p.tun_if.remote_ip6, + 0xffffffff, + proto=DpoProto.DPO_PROTO_IP6)], + is_ip6=1).add_vpp_config() + + def tearDown(self): + if not self.vpp_dead: + self.vapi.cli("show hardware") + super(TestIpsec6MultiTunIfEsp, self).tearDown() + + def test_tun_66(self): + """Multiple IPSEC tunnel interfaces """ + for p in self.multi_params: + self.verify_tun_66(p, count=127) + c = p.tun_if.get_rx_stats() + self.assertEqual(c['packets'], 127) + c = p.tun_if.get_tx_stats() + self.assertEqual(c['packets'], 127) + + if __name__ == '__main__': unittest.main(testRunner=VppTestRunner) |