+class TestIpsecItf6MPLS(TemplateIpsec,
+ TemplateIpsecItf6,
+ IpsecTun6):
+ """ IPsec Interface MPLSoIPv6 """
+
+ tun6_encrypt_node_name = "esp-mpls-encrypt-tun"
+
+ def setUp(self):
+ super(TestIpsecItf6MPLS, self).setUp()
+
+ self.tun_if = self.pg0
+
+ def tearDown(self):
+ super(TestIpsecItf6MPLS, self).tearDown()
+
+ def gen_encrypt_pkts6(self, p, sa, sw_intf, src, dst, count=1,
+ payload_size=100):
+ return [Ether(src=sw_intf.remote_mac, dst=sw_intf.local_mac) /
+ sa.encrypt(MPLS(label=66, ttl=3) /
+ IPv6(src=src, dst=dst) /
+ UDP(sport=1166, dport=2233) /
+ Raw(b'X' * payload_size))
+ for i in range(count)]
+
+ def verify_encrypted6(self, p, sa, rxs):
+ for rx in rxs:
+ try:
+ pkt = sa.decrypt(rx[IPv6])
+ if not pkt.haslayer(IPv6):
+ pkt = IP(pkt[Raw].load)
+ self.assert_packet_checksums_valid(pkt)
+ self.assert_equal(pkt[MPLS].label, 66)
+ self.assert_equal(pkt[IPv6].dst, p.remote_tun_if_host)
+ except (IndexError, AssertionError):
+ self.logger.debug(ppp("Unexpected packet:", rx))
+ try:
+ self.logger.debug(ppp("Decrypted packet:", pkt))
+ except:
+ pass
+ raise
+
+ def test_tun_mpls_o_ip6(self):
+ """IPSEC interface MPLS over IPv6"""
+
+ n_pkts = 127
+ p = self.ipv6_params
+ f = FibPathProto
+
+ tbl = VppMplsTable(self, 0)
+ tbl.add_vpp_config()
+
+ self.config_network(p)
+ # deag MPLS routes from the tunnel
+ r6 = VppMplsRoute(self, 66, 1,
+ [VppRoutePath(
+ self.pg1.remote_ip6,
+ self.pg1.sw_if_index)],
+ eos_proto=f.FIB_PATH_NH_PROTO_IP6).add_vpp_config()
+ p.route.modify([VppRoutePath(p.tun_if.remote_ip6,
+ p.tun_if.sw_if_index,
+ labels=[VppMplsLabel(66)])])
+ p.tun_if.enable_mpls()
+
+ self.config_sa_tun(p,
+ self.pg0.local_ip6,
+ self.pg0.remote_ip6)
+ self.config_protect(p)
+
+ self.verify_tun_66(p, count=n_pkts)
+
+ # cleanup
+ p.tun_if.disable_mpls()
+ self.unconfig_protect(p)
+ self.unconfig_sa(p)
+ self.unconfig_network(p)
+
+