VPP-1506: dump local punts and registered punt sockets
[vpp.git] / test / test_mtu.py
index 1327c4b..57d5600 100644 (file)
@@ -12,7 +12,8 @@ import unittest
 from scapy.layers.inet6 import IPv6, Ether, IP, UDP, ICMPv6PacketTooBig
 from scapy.layers.inet import ICMP
 from framework import VppTestCase, VppTestRunner
 from scapy.layers.inet6 import IPv6, Ether, IP, UDP, ICMPv6PacketTooBig
 from scapy.layers.inet import ICMP
 from framework import VppTestCase, VppTestRunner
-from vpp_ip_route import VppIpRoute, VppRoutePath, DpoProto
+from vpp_ip import DpoProto
+from vpp_ip_route import VppIpRoute, VppRoutePath
 from socket import AF_INET, AF_INET6, inet_pton
 import StringIO
 
 from socket import AF_INET, AF_INET6, inet_pton
 import StringIO
 
@@ -45,9 +46,9 @@ class TestMTU(VppTestCase):
         cls.create_pg_interfaces(range(2))
         cls.interfaces = list(cls.pg_interfaces)
 
         cls.create_pg_interfaces(range(2))
         cls.interfaces = list(cls.pg_interfaces)
 
-    def setUp(cls):
-        super(TestMTU, cls).setUp()
-        for i in cls.interfaces:
+    def setUp(self):
+        super(TestMTU, self).setUp()
+        for i in self.interfaces:
             i.admin_up()
             i.config_ip4()
             i.config_ip6()
             i.admin_up()
             i.config_ip4()
             i.config_ip6()
@@ -119,7 +120,6 @@ class TestMTU(VppTestCase):
             # n.show2()
             self.validate_bytes(str(p[1]), icmp4_reply)
 
             # n.show2()
             self.validate_bytes(str(p[1]), icmp4_reply)
 
-        '''
         # Now with DF off. Expect fragments.
         # First go with 1500 byte packets.
         p_payload = UDP(sport=1234, dport=1234) / self.payload(
         # Now with DF off. Expect fragments.
         # First go with 1500 byte packets.
         p_payload = UDP(sport=1234, dport=1234) / self.payload(
@@ -127,19 +127,18 @@ class TestMTU(VppTestCase):
         p4 = p_ether / p_ip4 / p_payload
         p4.flags = 0
         p4_reply = p_ip4 / p_payload
         p4 = p_ether / p_ip4 / p_payload
         p4.flags = 0
         p4_reply = p_ip4 / p_payload
-        p4_reply.ttl = 62 # check this
+        p4_reply.ttl = 62  # check this
         p4_reply.flags = 0
         p4_reply.id = 256
         self.pg_enable_capture()
         self.pg0.add_stream(p4*1)
         self.pg_start()
         rx = self.pg1.get_capture(3)
         p4_reply.flags = 0
         p4_reply.id = 256
         self.pg_enable_capture()
         self.pg0.add_stream(p4*1)
         self.pg_start()
         rx = self.pg1.get_capture(3)
-        print('RX', len(rx))
         reass_pkt = reassemble(rx)
         self.validate(reass_pkt, p4_reply)
         reass_pkt = reassemble(rx)
         self.validate(reass_pkt, p4_reply)
+
         '''
         # Now what happens with a 9K frame
         '''
         # Now what happens with a 9K frame
-        '''
         p_payload = UDP(sport=1234, dport=1234) / self.payload(
             current_mtu - 20 - 8)
         p4 = p_ether / p_ip4 / p_payload
         p_payload = UDP(sport=1234, dport=1234) / self.payload(
             current_mtu - 20 - 8)
         p4 = p_ether / p_ip4 / p_payload
@@ -158,6 +157,7 @@ class TestMTU(VppTestCase):
         p4_reply.show2()
         self.validate(reass_pkt, p4_reply)
         '''
         p4_reply.show2()
         self.validate(reass_pkt, p4_reply)
         '''
+
         # Reset MTU
         self.vapi.sw_interface_set_mtu(self.pg1.sw_if_index,
                                        [current_mtu, 0, 0, 0])
         # Reset MTU
         self.vapi.sw_interface_set_mtu(self.pg1.sw_if_index,
                                        [current_mtu, 0, 0, 0])
@@ -188,16 +188,16 @@ class TestMTU(VppTestCase):
         p_icmp6 = ICMPv6PacketTooBig(mtu=1280, cksum=0x4c7a)
         icmp6_reply = (IPv6(src=self.pg0.local_ip6,
                             dst=self.pg0.remote_ip6,
         p_icmp6 = ICMPv6PacketTooBig(mtu=1280, cksum=0x4c7a)
         icmp6_reply = (IPv6(src=self.pg0.local_ip6,
                             dst=self.pg0.remote_ip6,
-                            hlim=254, plen=1240) /
+                            hlim=255, plen=1240) /
                        p_icmp6 / p_ip6 / p_payload)
         icmp6_reply[2].hlim -= 1
         n = icmp6_reply.__class__(str(icmp6_reply))
         s = str(icmp6_reply)
                        p_icmp6 / p_ip6 / p_payload)
         icmp6_reply[2].hlim -= 1
         n = icmp6_reply.__class__(str(icmp6_reply))
         s = str(icmp6_reply)
-        icmp6_reply = s[0:1280]
+        icmp6_reply_str = s[0:1280]
 
         rx = self.send_and_expect(self.pg0, p6*9, self.pg0)
         for p in rx:
 
         rx = self.send_and_expect(self.pg0, p6*9, self.pg0)
         for p in rx:
-            self.validate_bytes(str(p[1]), icmp6_reply)
+            self.validate_bytes(str(p[1]), icmp6_reply_str)
 
         # Reset MTU
         self.vapi.sw_interface_set_mtu(self.pg1.sw_if_index,
 
         # Reset MTU
         self.vapi.sw_interface_set_mtu(self.pg1.sw_if_index,