ethernet: check destination mac for L3 in ethernet-input node
[vpp.git] / test / test_reassembly.py
index cef94f3..98c50f9 100644 (file)
@@ -1,11 +1,11 @@
 #!/usr/bin/env python3
 
 import unittest
-from random import shuffle, choice, randrange
+from random import shuffle, randrange
 
-from framework import VppTestCase, VppTestRunner
+from framework import VppTestCase
+from asfframework import VppTestRunner
 
-import scapy.compat
 from scapy.packet import Raw
 from scapy.layers.l2 import Ether, GRE
 from scapy.layers.inet import IP, UDP, ICMP, icmptypes
@@ -21,11 +21,9 @@ from scapy.layers.inet6 import (
     ICMPv6EchoRequest,
     ICMPv6EchoReply,
 )
-from framework import VppTestCase, VppTestRunner
-from util import ppp, ppc, fragment_rfc791, fragment_rfc8200
+from util import ppp, fragment_rfc791, fragment_rfc8200
 from vpp_gre_interface import VppGreInterface
-from vpp_ip import DpoProto
-from vpp_ip_route import VppIpRoute, VppRoutePath, FibPathProto
+from vpp_ip_route import VppIpRoute, VppRoutePath
 from vpp_papi import VppEnum
 
 # 35 is enough to have >257 400-byte fragments
@@ -1098,7 +1096,7 @@ class TestIPv4MWReassembly(VppTestCase):
         first_packets = [[] for n in range(self.vpp_worker_count)]
         second_packets = [[] for n in range(self.vpp_worker_count)]
         rest_of_packets = [[] for n in range(self.vpp_worker_count)]
-        for (_, p) in self.pkt_infos:
+        for _, p in self.pkt_infos:
             wi = randrange(self.vpp_worker_count)
             second_packets[wi].append(p[0])
             if len(p) <= 1:
@@ -1606,16 +1604,6 @@ class TestIPv6Reassembly(VppTestCase):
         self.assertIn(ICMPv6ParamProblem, icmp)
         self.assert_equal(icmp[ICMPv6ParamProblem].code, 3, "ICMP code")
 
-    def test_truncated_fragment(self):
-        """truncated fragment"""
-        pkt = (
-            Ether(src=self.pg0.local_mac, dst=self.pg0.remote_mac)
-            / IPv6(src=self.pg0.remote_ip6, dst=self.pg0.local_ip6, nh=44, plen=2)
-            / IPv6ExtHdrFragment(nh=6)
-        )
-
-        self.send_and_assert_no_replies(self.pg0, [pkt], self.pg0)
-
     def test_invalid_frag_size(self):
         """fragment size not a multiple of 8"""
         p = (
@@ -1659,7 +1647,7 @@ class TestIPv6Reassembly(VppTestCase):
     def test_atomic_fragment(self):
         """IPv6 atomic fragment"""
         pkt = (
-            Ether(src=self.pg0.local_mac, dst=self.pg0.remote_mac)
+            Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
             / IPv6(src=self.pg0.remote_ip6, dst=self.pg0.local_ip6, nh=44, plen=65535)
             / IPv6ExtHdrFragment(
                 offset=8191, m=1, res1=0xFF, res2=0xFF, nh=255, id=0xFFFF
@@ -1681,7 +1669,7 @@ class TestIPv6Reassembly(VppTestCase):
         self.send_and_assert_no_replies(self.pg0, [pkt])
 
         pkt = (
-            Ether(src=self.pg0.local_mac, dst=self.pg0.remote_mac)
+            Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
             / IPv6(src=self.pg0.remote_ip6, dst=self.pg0.remote_ip6)
             / ICMPv6EchoRequest()
         )
@@ -1690,7 +1678,7 @@ class TestIPv6Reassembly(VppTestCase):
     def test_one_fragment(self):
         """whole packet in one fragment processed independently"""
         pkt = (
-            Ether(src=self.pg0.local_mac, dst=self.pg0.remote_mac)
+            Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
             / IPv6(src=self.pg0.remote_ip6, dst=self.pg0.local_ip6)
             / ICMPv6EchoRequest()
             / Raw("X" * 1600)
@@ -1702,7 +1690,7 @@ class TestIPv6Reassembly(VppTestCase):
 
         # send an atomic fragment with same id - should be reassembled
         pkt = (
-            Ether(src=self.pg0.local_mac, dst=self.pg0.remote_mac)
+            Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
             / IPv6(src=self.pg0.remote_ip6, dst=self.pg0.local_ip6)
             / IPv6ExtHdrFragment(id=1)
             / ICMPv6EchoRequest()
@@ -1717,7 +1705,7 @@ class TestIPv6Reassembly(VppTestCase):
     def test_bunch_of_fragments(self):
         """valid fragments followed by rogue fragments and atomic fragment"""
         pkt = (
-            Ether(src=self.pg0.local_mac, dst=self.pg0.remote_mac)
+            Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
             / IPv6(src=self.pg0.remote_ip6, dst=self.pg0.local_ip6)
             / ICMPv6EchoRequest()
             / Raw("X" * 1600)
@@ -1735,7 +1723,7 @@ class TestIPv6Reassembly(VppTestCase):
         self.send_and_assert_no_replies(self.pg0, inc_frag * 604)
 
         pkt = (
-            Ether(src=self.pg0.local_mac, dst=self.pg0.remote_mac)
+            Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
             / IPv6(src=self.pg0.remote_ip6, dst=self.pg0.local_ip6)
             / IPv6ExtHdrFragment(id=1)
             / ICMPv6EchoRequest()
@@ -1750,7 +1738,7 @@ class TestIPv6Reassembly(VppTestCase):
         )
         self.vapi.ip_local_reass_enable_disable(enable_ip6=True)
         pkt = (
-            Ether(src=self.src_if.local_mac, dst=self.src_if.remote_mac)
+            Ether(src=self.src_if.remote_mac, dst=self.src_if.local_mac)
             / IPv6(src=self.src_if.remote_ip6, dst=self.src_if.local_ip6)
             / ICMPv6EchoRequest(id=1234)
             / Raw("X" * 1600)
@@ -1930,7 +1918,7 @@ class TestIPv6MWReassembly(VppTestCase):
         first_packets = [[] for n in range(self.vpp_worker_count)]
         second_packets = [[] for n in range(self.vpp_worker_count)]
         rest_of_packets = [[] for n in range(self.vpp_worker_count)]
-        for (_, p) in self.pkt_infos:
+        for _, p in self.pkt_infos:
             wi = randrange(self.vpp_worker_count)
             second_packets[wi].append(p[0])
             if len(p) <= 1:
@@ -2196,7 +2184,7 @@ class TestIPv6SVReassembly(VppTestCase):
     def test_one_fragment(self):
         """whole packet in one fragment processed independently"""
         pkt = (
-            Ether(src=self.src_if.local_mac, dst=self.src_if.remote_mac)
+            Ether(src=self.src_if.remote_mac, dst=self.src_if.local_mac)
             / IPv6(src=self.src_if.remote_ip6, dst=self.dst_if.remote_ip6)
             / ICMPv6EchoRequest()
             / Raw("X" * 1600)
@@ -2208,7 +2196,7 @@ class TestIPv6SVReassembly(VppTestCase):
 
         # send an atomic fragment with same id - should be reassembled
         pkt = (
-            Ether(src=self.src_if.local_mac, dst=self.src_if.remote_mac)
+            Ether(src=self.src_if.remote_mac, dst=self.src_if.local_mac)
             / IPv6(src=self.src_if.remote_ip6, dst=self.dst_if.remote_ip6)
             / IPv6ExtHdrFragment(id=1)
             / ICMPv6EchoRequest()
@@ -2221,7 +2209,7 @@ class TestIPv6SVReassembly(VppTestCase):
     def test_bunch_of_fragments(self):
         """valid fragments followed by rogue fragments and atomic fragment"""
         pkt = (
-            Ether(src=self.src_if.local_mac, dst=self.src_if.remote_mac)
+            Ether(src=self.src_if.remote_mac, dst=self.src_if.local_mac)
             / IPv6(src=self.src_if.remote_ip6, dst=self.dst_if.remote_ip6)
             / ICMPv6EchoRequest()
             / Raw("X" * 1600)
@@ -2230,7 +2218,7 @@ class TestIPv6SVReassembly(VppTestCase):
         rx = self.send_and_expect(self.src_if, frags, self.dst_if)
 
         rogue = (
-            Ether(src=self.src_if.local_mac, dst=self.src_if.remote_mac)
+            Ether(src=self.src_if.remote_mac, dst=self.src_if.local_mac)
             / IPv6(src=self.src_if.remote_ip6, dst=self.dst_if.remote_ip6)
             / IPv6ExtHdrFragment(id=1, nh=58, offset=608)
             / Raw("X" * 308)
@@ -2239,7 +2227,7 @@ class TestIPv6SVReassembly(VppTestCase):
         self.send_and_expect(self.src_if, rogue * 604, self.dst_if)
 
         pkt = (
-            Ether(src=self.src_if.local_mac, dst=self.src_if.remote_mac)
+            Ether(src=self.src_if.remote_mac, dst=self.src_if.local_mac)
             / IPv6(src=self.src_if.remote_ip6, dst=self.dst_if.remote_ip6)
             / IPv6ExtHdrFragment(id=1)
             / ICMPv6EchoRequest()