summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/nat.am1
-rwxr-xr-xsrc/plugins/nat/in2out.c3
-rw-r--r--src/plugins/nat/nat.c49
-rw-r--r--src/plugins/nat/nat.h2
-rw-r--r--src/plugins/nat/nat_api.c3
-rw-r--r--src/plugins/nat/nat_dpo.c79
-rw-r--r--src/plugins/nat/nat_dpo.h36
-rw-r--r--test/test_nat.py241
-rw-r--r--test/vpp_papi_provider.py2
9 files changed, 397 insertions, 19 deletions
diff --git a/src/plugins/nat.am b/src/plugins/nat.am
index b6c369fe324..a0e0568a5a1 100644
--- a/src/plugins/nat.am
+++ b/src/plugins/nat.am
@@ -23,6 +23,7 @@ nat_plugin_la_SOURCES = nat/nat.c \
nat/nat_ipfix_logging.c \
nat/nat_det.c \
nat/nat_reass.c \
+ nat/nat_dpo.c \
nat/nat64.c \
nat/nat64_cli.c \
nat/nat64_in2out.c \
diff --git a/src/plugins/nat/in2out.c b/src/plugins/nat/in2out.c
index 517011eec06..b0dbbc8fa11 100755
--- a/src/plugins/nat/in2out.c
+++ b/src/plugins/nat/in2out.c
@@ -179,6 +179,9 @@ snat_not_translate_fast (snat_main_t * sm, vlib_node_runtime_t *node,
u32 sw_if_index0, ip4_header_t * ip0, u32 proto0,
u32 rx_fib_index0)
{
+ if (sm->out2in_dpo)
+ return 0;
+
fib_node_index_t fei = FIB_NODE_INDEX_INVALID;
fib_prefix_t pfx = {
.fp_proto = FIB_PROTOCOL_IP4,
diff --git a/src/plugins/nat/nat.c b/src/plugins/nat/nat.c
index e9b2c2c07ba..721ad16d3dc 100644
--- a/src/plugins/nat/nat.c
+++ b/src/plugins/nat/nat.c
@@ -20,6 +20,7 @@
#include <vnet/ip/ip4.h>
#include <vnet/plugin/plugin.h>
#include <nat/nat.h>
+#include <nat/nat_dpo.h>
#include <nat/nat_ipfix_logging.h>
#include <nat/nat_det.h>
#include <nat/nat64.h>
@@ -567,7 +568,7 @@ void snat_add_address (snat_main_t *sm, ip4_address_t *addr, u32 vrf_id,
/* Add external address to FIB */
pool_foreach (i, sm->interfaces,
({
- if (nat_interface_is_inside(i))
+ if (nat_interface_is_inside(i) || sm->out2in_dpo)
continue;
snat_add_del_addr_to_fib(addr, 32, i->sw_if_index, 1);
@@ -575,7 +576,7 @@ void snat_add_address (snat_main_t *sm, ip4_address_t *addr, u32 vrf_id,
}));
pool_foreach (i, sm->output_feature_interfaces,
({
- if (nat_interface_is_inside(i))
+ if (nat_interface_is_inside(i) || sm->out2in_dpo)
continue;
snat_add_del_addr_to_fib(addr, 32, i->sw_if_index, 1);
@@ -951,7 +952,7 @@ int snat_add_static_mapping(ip4_address_t l_addr, ip4_address_t e_addr,
/* Add/delete external address to FIB */
pool_foreach (interface, sm->interfaces,
({
- if (nat_interface_is_inside(interface))
+ if (nat_interface_is_inside(interface) || sm->out2in_dpo)
continue;
snat_add_del_addr_to_fib(&e_addr, 32, interface->sw_if_index, is_add);
@@ -959,7 +960,7 @@ int snat_add_static_mapping(ip4_address_t l_addr, ip4_address_t e_addr,
}));
pool_foreach (interface, sm->output_feature_interfaces,
({
- if (nat_interface_is_inside(interface))
+ if (nat_interface_is_inside(interface) || sm->out2in_dpo)
continue;
snat_add_del_addr_to_fib(&e_addr, 32, interface->sw_if_index, is_add);
@@ -1324,7 +1325,7 @@ snat_del_address (snat_main_t *sm, ip4_address_t addr, u8 delete_sm,
/* Delete external address from FIB */
pool_foreach (interface, sm->interfaces,
({
- if (nat_interface_is_inside(interface))
+ if (nat_interface_is_inside(interface) || sm->out2in_dpo)
continue;
snat_add_del_addr_to_fib(&addr, 32, interface->sw_if_index, 0);
@@ -1332,7 +1333,7 @@ snat_del_address (snat_main_t *sm, ip4_address_t addr, u8 delete_sm,
}));
pool_foreach (interface, sm->output_feature_interfaces,
({
- if (nat_interface_is_inside(interface))
+ if (nat_interface_is_inside(interface) || sm->out2in_dpo)
continue;
snat_add_del_addr_to_fib(&addr, 32, interface->sw_if_index, 0);
@@ -1351,6 +1352,9 @@ int snat_interface_add_del (u32 sw_if_index, u8 is_inside, int is_del)
snat_static_mapping_t * m;
snat_det_map_t * dm;
+ if (sm->out2in_dpo && !is_inside)
+ return VNET_API_ERROR_UNSUPPORTED;
+
if (sm->static_mapping_only && !(sm->static_mapping_connection_tracking))
feature_name = is_inside ? "nat44-in2out-fast" : "nat44-out2in-fast";
else
@@ -1452,7 +1456,7 @@ set_flags:
/* Add/delete external addresses to FIB */
fib:
- if (is_inside)
+ if (is_inside && !sm->out2in_dpo)
{
vnet_feature_enable_disable ("ip4-local", "nat44-hairpinning",
sw_if_index, !is_del, 0, 0);
@@ -1680,6 +1684,8 @@ static clib_error_t * snat_init (vlib_main_t * vm)
vec_add1 (im->add_del_interface_address_callbacks, cb4);
+ nat_dpo_module_init ();
+
/* Init IPFIX logging */
snat_ipfix_logging_init(vm);
@@ -1988,6 +1994,29 @@ exhausted:
return 1;
}
+void
+nat44_add_del_address_dpo (ip4_address_t addr, u8 is_add)
+{
+ dpo_id_t dpo_v4 = DPO_INVALID;
+ fib_prefix_t pfx = {
+ .fp_proto = FIB_PROTOCOL_IP4,
+ .fp_len = 32,
+ .fp_addr.ip4.as_u32 = addr.as_u32,
+ };
+
+ if (is_add)
+ {
+ nat_dpo_create (DPO_PROTO_IP4, 0, &dpo_v4);
+ fib_table_entry_special_dpo_add (0, &pfx, FIB_SOURCE_PLUGIN_HI,
+ FIB_ENTRY_FLAG_EXCLUSIVE, &dpo_v4);
+ dpo_reset (&dpo_v4);
+ }
+ else
+ {
+ fib_table_entry_special_remove (0, &pfx, FIB_SOURCE_PLUGIN_HI);
+ }
+}
+
static clib_error_t *
add_address_command_fn (vlib_main_t * vm,
unformat_input_t * input,
@@ -2074,6 +2103,9 @@ add_address_command_fn (vlib_main_t * vm,
break;
}
+ if (sm->out2in_dpo)
+ nat44_add_del_address_dpo (this_addr, is_add);
+
increment_v4_address (&this_addr);
}
@@ -2866,6 +2898,7 @@ snat_config (vlib_main_t * vm, unformat_input_t * input)
snat_main_per_thread_data_t *tsm;
sm->deterministic = 0;
+ sm->out2in_dpo = 0;
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
@@ -2906,6 +2939,8 @@ snat_config (vlib_main_t * vm, unformat_input_t * input)
else if (unformat (input, "nat64 st hash memory %d",
&nat64_st_memory_size))
;
+ else if (unformat (input, "out2in dpo"))
+ sm->out2in_dpo = 1;
else
return clib_error_return (0, "unknown input '%U'",
format_unformat_error, input);
diff --git a/src/plugins/nat/nat.h b/src/plugins/nat/nat.h
index 1e8e3ca0403..614668d8421 100644
--- a/src/plugins/nat/nat.h
+++ b/src/plugins/nat/nat.h
@@ -357,6 +357,7 @@ typedef struct snat_main_s {
u8 static_mapping_only;
u8 static_mapping_connection_tracking;
u8 deterministic;
+ u8 out2in_dpo;
u32 translation_buckets;
u32 translation_memory_size;
u32 max_translations;
@@ -539,6 +540,7 @@ void snat_add_address(snat_main_t *sm, ip4_address_t *addr, u32 vrf_id,
u8 twice_nat);
int snat_del_address(snat_main_t *sm, ip4_address_t addr, u8 delete_sm,
u8 twice_nat);
+void nat44_add_del_address_dpo (ip4_address_t addr, u8 is_add);
int snat_add_static_mapping(ip4_address_t l_addr, ip4_address_t e_addr,
u16 l_port, u16 e_port, u32 vrf_id, int addr_only,
u32 sw_if_index, snat_protocol_t proto, int is_add,
diff --git a/src/plugins/nat/nat_api.c b/src/plugins/nat/nat_api.c
index 2397663270a..d0efb001843 100644
--- a/src/plugins/nat/nat_api.c
+++ b/src/plugins/nat/nat_api.c
@@ -442,6 +442,9 @@ static void
if (rv)
goto send_reply;
+ if (sm->out2in_dpo)
+ nat44_add_del_address_dpo (this_addr, mp->is_add);
+
increment_v4_address (&this_addr);
}
diff --git a/src/plugins/nat/nat_dpo.c b/src/plugins/nat/nat_dpo.c
new file mode 100644
index 00000000000..46ccda8845e
--- /dev/null
+++ b/src/plugins/nat/nat_dpo.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vnet/ip/ip.h>
+#include <nat/nat_dpo.h>
+
+dpo_type_t nat_dpo_type;
+
+void
+nat_dpo_create (dpo_proto_t dproto, u32 aftr_index, dpo_id_t * dpo)
+{
+ dpo_set (dpo, nat_dpo_type, dproto, aftr_index);
+}
+
+u8 *
+format_nat_dpo (u8 * s, va_list * args)
+{
+ index_t index = va_arg (*args, index_t);
+ CLIB_UNUSED (u32 indent) = va_arg (*args, u32);
+
+ return (format (s, "NAT44 out2in: AFTR:%d", index));
+}
+
+static void
+nat_dpo_lock (dpo_id_t * dpo)
+{
+}
+
+static void
+nat_dpo_unlock (dpo_id_t * dpo)
+{
+}
+
+const static dpo_vft_t nat_dpo_vft = {
+ .dv_lock = nat_dpo_lock,
+ .dv_unlock = nat_dpo_unlock,
+ .dv_format = format_nat_dpo,
+};
+
+const static char *const nat_ip4_nodes[] = {
+ "nat44-out2in",
+ NULL,
+};
+
+const static char *const nat_ip6_nodes[] = {
+ NULL,
+};
+
+const static char *const *const nat_nodes[DPO_PROTO_NUM] = {
+ [DPO_PROTO_IP4] = nat_ip4_nodes,
+ [DPO_PROTO_IP6] = nat_ip6_nodes,
+ [DPO_PROTO_MPLS] = NULL,
+};
+
+void
+nat_dpo_module_init (void)
+{
+ nat_dpo_type = dpo_register_new_type (&nat_dpo_vft, nat_nodes);
+}
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/plugins/nat/nat_dpo.h b/src/plugins/nat/nat_dpo.h
new file mode 100644
index 00000000000..e85b3e824f3
--- /dev/null
+++ b/src/plugins/nat/nat_dpo.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __included_nat_dpo_h__
+#define __included_nat_dpo_h__
+
+#include <vnet/vnet.h>
+#include <vnet/dpo/dpo.h>
+
+void nat_dpo_create (dpo_proto_t dproto, u32 aftr_index, dpo_id_t * dpo);
+
+u8 *format_nat_dpo (u8 * s, va_list * args);
+
+void nat_dpo_module_init (void);
+
+#endif /* __included_nat_dpo_h__ */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/test/test_nat.py b/test/test_nat.py
index aeeb5aa2bd5..4ced0af46e0 100644
--- a/test/test_nat.py
+++ b/test/test_nat.py
@@ -134,30 +134,34 @@ class MethodHolder(VppTestCase):
self.assertEqual(new['ICMPv6EchoReply'].cksum,
pkt['ICMPv6EchoReply'].cksum)
- def create_stream_in(self, in_if, out_if, ttl=64):
+ def create_stream_in(self, in_if, out_if, dst_ip=None, ttl=64):
"""
Create packet stream for inside network
:param in_if: Inside interface
:param out_if: Outside interface
+ :param dst_ip: Destination address
:param ttl: TTL of generated packets
"""
+ if dst_ip is None:
+ dst_ip = out_if.remote_ip4
+
pkts = []
# TCP
p = (Ether(dst=in_if.local_mac, src=in_if.remote_mac) /
- IP(src=in_if.remote_ip4, dst=out_if.remote_ip4, ttl=ttl) /
+ IP(src=in_if.remote_ip4, dst=dst_ip, ttl=ttl) /
TCP(sport=self.tcp_port_in, dport=20))
pkts.append(p)
# UDP
p = (Ether(dst=in_if.local_mac, src=in_if.remote_mac) /
- IP(src=in_if.remote_ip4, dst=out_if.remote_ip4, ttl=ttl) /
+ IP(src=in_if.remote_ip4, dst=dst_ip, ttl=ttl) /
UDP(sport=self.udp_port_in, dport=20))
pkts.append(p)
# ICMP
p = (Ether(dst=in_if.local_mac, src=in_if.remote_mac) /
- IP(src=in_if.remote_ip4, dst=out_if.remote_ip4, ttl=ttl) /
+ IP(src=in_if.remote_ip4, dst=dst_ip, ttl=ttl) /
ICMP(id=self.icmp_id_in, type='echo-request'))
pkts.append(p)
@@ -206,6 +210,48 @@ class MethodHolder(VppTestCase):
pref_n[15] = ip4_n[3]
return socket.inet_ntop(socket.AF_INET6, ''.join(pref_n))
+ def extract_ip4(self, ip6, plen):
+ """
+ Extract IPv4 address embedded in IPv6 addresses
+
+ :param ip6: IPv6 address
+ :param plen: IPv6 prefix length
+ :returns: extracted IPv4 address
+ """
+ ip6_n = list(socket.inet_pton(socket.AF_INET6, ip6))
+ ip4_n = [None] * 4
+ if plen == 32:
+ ip4_n[0] = ip6_n[4]
+ ip4_n[1] = ip6_n[5]
+ ip4_n[2] = ip6_n[6]
+ ip4_n[3] = ip6_n[7]
+ elif plen == 40:
+ ip4_n[0] = ip6_n[5]
+ ip4_n[1] = ip6_n[6]
+ ip4_n[2] = ip6_n[7]
+ ip4_n[3] = ip6_n[9]
+ elif plen == 48:
+ ip4_n[0] = ip6_n[6]
+ ip4_n[1] = ip6_n[7]
+ ip4_n[2] = ip6_n[9]
+ ip4_n[3] = ip6_n[10]
+ elif plen == 56:
+ ip4_n[0] = ip6_n[7]
+ ip4_n[1] = ip6_n[9]
+ ip4_n[2] = ip6_n[10]
+ ip4_n[3] = ip6_n[11]
+ elif plen == 64:
+ ip4_n[0] = ip6_n[9]
+ ip4_n[1] = ip6_n[10]
+ ip4_n[2] = ip6_n[11]
+ ip4_n[3] = ip6_n[12]
+ elif plen == 96:
+ ip4_n[0] = ip6_n[12]
+ ip4_n[1] = ip6_n[13]
+ ip4_n[2] = ip6_n[14]
+ ip4_n[3] = ip6_n[15]
+ return socket.inet_ntop(socket.AF_INET, ''.join(ip4_n))
+
def create_stream_in_ip6(self, in_if, out_if, hlim=64, pref=None, plen=0):
"""
Create IPv6 packet stream for inside network
@@ -284,8 +330,37 @@ class MethodHolder(VppTestCase):
return pkts
+ def create_stream_out_ip6(self, out_if, src_ip, dst_ip, hl=64):
+ """
+ Create packet stream for outside network
+
+ :param out_if: Outside interface
+ :param dst_ip: Destination IP address (Default use global NAT address)
+ :param hl: HL of generated packets
+ """
+ pkts = []
+ # TCP
+ p = (Ether(dst=out_if.local_mac, src=out_if.remote_mac) /
+ IPv6(src=src_ip, dst=dst_ip, hlim=hl) /
+ TCP(dport=self.tcp_port_out, sport=20))
+ pkts.append(p)
+
+ # UDP
+ p = (Ether(dst=out_if.local_mac, src=out_if.remote_mac) /
+ IPv6(src=src_ip, dst=dst_ip, hlim=hl) /
+ UDP(dport=self.udp_port_out, sport=20))
+ pkts.append(p)
+
+ # ICMP
+ p = (Ether(dst=out_if.local_mac, src=out_if.remote_mac) /
+ IPv6(src=src_ip, dst=dst_ip, hlim=hl) /
+ ICMPv6EchoReply(id=self.icmp_id_out))
+ pkts.append(p)
+
+ return pkts
+
def verify_capture_out(self, capture, nat_ip=None, same_port=False,
- packet_num=3, dst_ip=None):
+ packet_num=3, dst_ip=None, is_ip6=False):
"""
Verify captured packets on outside network
@@ -294,16 +369,24 @@ class MethodHolder(VppTestCase):
:param same_port: Sorce port number is not translated (Default False)
:param packet_num: Expected number of packets (Default 3)
:param dst_ip: Destination IP address (Default do not verify)
+ :param is_ip6: If L3 protocol is IPv6 (Default False)
"""
+ if is_ip6:
+ IP46 = IPv6
+ ICMP46 = ICMPv6EchoRequest
+ else:
+ IP46 = IP
+ ICMP46 = ICMP
if nat_ip is None:
nat_ip = self.nat_addr
self.assertEqual(packet_num, len(capture))
for packet in capture:
try:
- self.check_ip_checksum(packet)
- self.assertEqual(packet[IP].src, nat_ip)
+ if not is_ip6:
+ self.check_ip_checksum(packet)
+ self.assertEqual(packet[IP46].src, nat_ip)
if dst_ip is not None:
- self.assertEqual(packet[IP].dst, dst_ip)
+ self.assertEqual(packet[IP46].dst, dst_ip)
if packet.haslayer(TCP):
if same_port:
self.assertEqual(packet[TCP].sport, self.tcp_port_in)
@@ -321,16 +404,33 @@ class MethodHolder(VppTestCase):
self.udp_port_out = packet[UDP].sport
else:
if same_port:
- self.assertEqual(packet[ICMP].id, self.icmp_id_in)
+ self.assertEqual(packet[ICMP46].id, self.icmp_id_in)
else:
- self.assertNotEqual(packet[ICMP].id, self.icmp_id_in)
- self.icmp_id_out = packet[ICMP].id
- self.check_icmp_checksum(packet)
+ self.assertNotEqual(packet[ICMP46].id, self.icmp_id_in)
+ self.icmp_id_out = packet[ICMP46].id
+ if is_ip6:
+ self.check_icmpv6_checksum(packet)
+ else:
+ self.check_icmp_checksum(packet)
except:
self.logger.error(ppp("Unexpected or invalid packet "
"(outside network):", packet))
raise
+ def verify_capture_out_ip6(self, capture, nat_ip, same_port=False,
+ packet_num=3, dst_ip=None):
+ """
+ Verify captured packets on outside network
+
+ :param capture: Captured packets
+ :param nat_ip: Translated IP address
+ :param same_port: Sorce port number is not translated (Default False)
+ :param packet_num: Expected number of packets (Default 3)
+ :param dst_ip: Destination IP address (Default do not verify)
+ """
+ return self.verify_capture_out(capture, nat_ip, same_port, packet_num,
+ dst_ip, True)
+
def verify_capture_in(self, capture, in_if, packet_num=3):
"""
Verify captured packets on inside network
@@ -3105,6 +3205,123 @@ class TestNAT44(MethodHolder):
self.clear_nat44()
+class TestNAT44Out2InDPO(MethodHolder):
+ """ NAT44 Test Cases using out2in DPO """
+
+ @classmethod
+ def setUpConstants(cls):
+ super(TestNAT44Out2InDPO, cls).setUpConstants()
+ cls.vpp_cmdline.extend(["nat", "{", "out2in dpo", "}"])
+
+ @classmethod
+ def setUpClass(cls):
+ super(TestNAT44Out2InDPO, cls).setUpClass()
+
+ try:
+ cls.tcp_port_in = 6303
+ cls.tcp_port_out = 6303
+ cls.udp_port_in = 6304
+ cls.udp_port_out = 6304
+ cls.icmp_id_in = 6305
+ cls.icmp_id_out = 6305
+ cls.nat_addr = '10.0.0.3'
+ cls.nat_addr_n = socket.inet_pton(socket.AF_INET, cls.nat_addr)
+ cls.dst_ip4 = '192.168.70.1'
+
+ cls.create_pg_interfaces(range(2))
+
+ cls.pg0.admin_up()
+ cls.pg0.config_ip4()
+ cls.pg0.resolve_arp()
+
+ cls.pg1.admin_up()
+ cls.pg1.config_ip6()
+ cls.pg1.resolve_ndp()
+
+ cls.vapi.ip_add_del_route(is_ipv6=True, dst_address='\x00'*16,
+ dst_address_length=0,
+ next_hop_address=cls.pg1.remote_ip6n,
+ next_hop_sw_if_index=cls.pg1.sw_if_index)
+
+ except Exception:
+ super(TestNAT44Out2InDPO, cls).tearDownClass()
+ raise
+
+ def configure_xlat(self):
+ self.dst_ip6_pfx = '1:2:3::'
+ self.dst_ip6_pfx_n = socket.inet_pton(socket.AF_INET6,
+ self.dst_ip6_pfx)
+ self.dst_ip6_pfx_len = 96
+ self.src_ip6_pfx = '4:5:6::'
+ self.src_ip6_pfx_n = socket.inet_pton(socket.AF_INET6,
+ self.src_ip6_pfx)
+ self.src_ip6_pfx_len = 96
+ self.vapi.map_add_domain(self.dst_ip6_pfx_n, self.dst_ip6_pfx_len,
+ self.src_ip6_pfx_n, self.src_ip6_pfx_len,
+ '\x00\x00\x00\x00', 0, is_translation=1,
+ is_rfc6052=1)
+
+ def test_464xlat_ce(self):
+ """ Test 464XLAT CE with NAT44 """
+
+ self.configure_xlat()
+
+ self.vapi.nat44_interface_add_del_feature(self.pg0.sw_if_index)
+ self.vapi.nat44_add_del_address_range(self.nat_addr_n, self.nat_addr_n)
+
+ out_src_ip6 = self.compose_ip6(self.dst_ip4, self.dst_ip6_pfx,
+ self.dst_ip6_pfx_len)
+ out_dst_ip6 = self.compose_ip6(self.nat_addr, self.src_ip6_pfx,
+ self.src_ip6_pfx_len)
+
+ try:
+ pkts = self.create_stream_in(self.pg0, self.pg1, self.dst_ip4)
+ self.pg0.add_stream(pkts)
+ self.pg_enable_capture(self.pg_interfaces)
+ self.pg_start()
+ capture = self.pg1.get_capture(len(pkts))
+ self.verify_capture_out_ip6(capture, nat_ip=out_dst_ip6,
+ dst_ip=out_src_ip6)
+
+ pkts = self.create_stream_out_ip6(self.pg1, out_src_ip6,
+ out_dst_ip6)
+ self.pg1.add_stream(pkts)
+ self.pg_enable_capture(self.pg_interfaces)
+ self.pg_start()
+ capture = self.pg0.get_capture(len(pkts))
+ self.verify_capture_in(capture, self.pg0)
+ finally:
+ self.vapi.nat44_interface_add_del_feature(self.pg0.sw_if_index,
+ is_add=0)
+ self.vapi.nat44_add_del_address_range(self.nat_addr_n,
+ self.nat_addr_n, is_add=0)
+
+ def test_464xlat_ce_no_nat(self):
+ """ Test 464XLAT CE without NAT44 """
+
+ self.configure_xlat()
+
+ out_src_ip6 = self.compose_ip6(self.dst_ip4, self.dst_ip6_pfx,
+ self.dst_ip6_pfx_len)
+ out_dst_ip6 = self.compose_ip6(self.pg0.remote_ip4, self.src_ip6_pfx,
+ self.src_ip6_pfx_len)
+
+ pkts = self.create_stream_in(self.pg0, self.pg1, self.dst_ip4)
+ self.pg0.add_stream(pkts)
+ self.pg_enable_capture(self.pg_interfaces)
+ self.pg_start()
+ capture = self.pg1.get_capture(len(pkts))
+ self.verify_capture_out_ip6(capture, dst_ip=out_src_ip6,
+ nat_ip=out_dst_ip6, same_port=True)
+
+ pkts = self.create_stream_out_ip6(self.pg1, out_src_ip6, out_dst_ip6)
+ self.pg1.add_stream(pkts)
+ self.pg_enable_capture(self.pg_interfaces)
+ self.pg_start()
+ capture = self.pg0.get_capture(len(pkts))
+ self.verify_capture_in(capture, self.pg0)
+
+
class TestDeterministicNAT(MethodHolder):
""" Deterministic NAT Test Cases """
diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py
index c6157d382d3..16bc44b64b9 100644
--- a/test/vpp_papi_provider.py
+++ b/test/vpp_papi_provider.py
@@ -2315,6 +2315,7 @@ class VppPapiProvider(object):
psid_offset=0,
psid_length=0,
is_translation=0,
+ is_rfc6052=0,
mtu=1280):
return self.api(
self.papi.map_add_domain,
@@ -2329,6 +2330,7 @@ class VppPapiProvider(object):
'psid_offset': psid_offset,
'psid_length': psid_length,
'is_translation': is_translation,
+ 'is_rfc6052': is_rfc6052,
'mtu': mtu
})