def cnat_exclude_subnet(self, exclude_subnet, isAdd=True):
add = 1 if isAdd else 0
self._test.vapi.cnat_add_del_snat_prefix(
- prefix=exclude_subnet, is_add=add)
+ prefix=exclude_subnet, is_add=add)
def query_vpp_config(self):
return False
class TestCNatTranslation(VppTestCase):
""" CNat Translation """
extra_vpp_punt_config = ["cnat", "{",
+ "session-db-buckets", "64",
+ "session-cleanup-timeout", "0.1",
"session-max-age", "1",
- "tcp-max-age", "1", "}"]
+ "tcp-max-age", "1",
+ "scanner", "off", "}"]
@classmethod
def setUpClass(cls):
self.logger.info(self.vapi.cli("sh cnat session verbose"))
#
- # turn the scanner back on and wait untill the sessions
+ # turn the scanner back on and wait until the sessions
# all disapper
#
self.vapi.cli("test cnat scanner on")
i.admin_down()
super(TestCNatSourceNAT, self).tearDown()
- def cnat_create_translation(self, srcNatAddr, interface, isV6=False):
+ def cnat_set_snat_address(self, srcNatAddr, interface, isV6=False):
t1 = VppCNATSourceNat(self, srcNatAddr)
t1.add_vpp_config()
cnat_arc_name = "ip6-unicast" if isV6 else "ip4-unicast"
self.pg1.configure_ipv6_neighbors()
self.vapi.cli("test cnat scanner on")
- t1 = self.cnat_create_translation(srcNatAddr, self.pg0)
+ t1 = self.cnat_set_snat_address(srcNatAddr, self.pg0, isV6)
for nbr, remote_host in enumerate(self.pg1.remote_hosts):
# from pods to outside network
Raw())
rxs = self.send_and_expect(
- self.pg0,
- p1 * N_PKTS,
- self.pg1)
+ self.pg0,
+ p1 * N_PKTS,
+ self.pg1)
for rx in rxs:
self.assert_packet_checksums_valid(rx)
self.assertEqual(
Raw())
rxs = self.send_and_expect(
- self.pg1,
- p2 * N_PKTS,
- self.pg0)
+ self.pg1,
+ p2 * N_PKTS,
+ self.pg0)
for rx in rxs:
self.assert_packet_checksums_valid(rx)
self.vapi.cnat_session_purge()
rxs = self.send_and_expect(
- self.pg0,
- p1 * N_PKTS,
- self.pg1)
+ self.pg0,
+ p1 * N_PKTS,
+ self.pg1)
for rx in rxs:
self.assert_packet_checksums_valid(rx)
self.assertEqual(
self.vapi.cnat_session_purge()
rxs = self.send_and_expect(
- self.pg0,
- p1 * N_PKTS,
- self.pg1)
+ self.pg0,
+ p1 * N_PKTS,
+ self.pg1)
for rx in rxs:
self.assert_packet_checksums_valid(rx)
rx[ip_class].src,
srcNatAddr)
- # def test_cnat6_sourcenat(self):
- # # """ CNat Source Nat ipv6 """
- # self.cnat_test_sourcenat(self.pg2.remote_hosts[0].ip6, TCP, True)
- # self.cnat_test_sourcenat(self.pg2.remote_hosts[0].ip6, UDP, True)
+ def test_cnat6_sourcenat(self):
+ # """ CNat Source Nat ipv6 """
+ self.cnat_test_sourcenat(self.pg2.remote_hosts[0].ip6, TCP, True)
+ self.cnat_test_sourcenat(self.pg2.remote_hosts[0].ip6, UDP, True)
def test_cnat4_sourcenat(self):
# """ CNat Source Nat ipv4 """
self.cnat_test_sourcenat(self.pg2.remote_hosts[0].ip4, TCP)
self.cnat_test_sourcenat(self.pg2.remote_hosts[0].ip4, UDP)
+
if __name__ == '__main__':
unittest.main(testRunner=VppTestRunner)