diff options
author | Artem Glazychev <artem.glazychev@xored.com> | 2022-02-21 17:51:29 +0700 |
---|---|---|
committer | Artem Glazychev <artem.glazychev@xored.com> | 2022-02-22 18:05:04 +0000 |
commit | 8cd5a1a1e088ee6b2ca7e0b7fffa6a4912af2780 (patch) | |
tree | 9cba755bcd9063a84c7d86ea00a92daa5207a190 | |
parent | 83945776cbee381e8eb7ab733348a4878520a9b0 (diff) |
vxlan: add l2 mode test
Type: improvement
Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
Change-Id: I214f6fb5b63d97ca4afe3b10fd2d3e3410b5a6e4
-rw-r--r-- | test/test_vxlan.py | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/test/test_vxlan.py b/test/test_vxlan.py index 028275ccedf..4247a396d24 100644 --- a/test/test_vxlan.py +++ b/test/test_vxlan.py @@ -7,6 +7,7 @@ from framework import VppTestCase, VppTestRunner from template_bd import BridgeDomain from scapy.layers.l2 import Ether +from scapy.layers.l2 import ARP from scapy.packet import Raw, bind_layers from scapy.layers.inet import IP, UDP from scapy.layers.vxlan import VXLAN @@ -15,6 +16,7 @@ import util from vpp_ip_route import VppIpRoute, VppRoutePath from vpp_vxlan_tunnel import VppVxlanTunnel from vpp_ip import INVALID_INDEX +from vpp_neighbor import VppNeighbor class TestVxlan(BridgeDomain, VppTestCase): @@ -417,5 +419,62 @@ class TestVxlan2(VppTestCase): rx = self.send_and_assert_no_replies(self.pg1, [p]) +class TestVxlanL2Mode(VppTestCase): + """ VXLAN Test Case """ + def setUp(self): + super(TestVxlanL2Mode, self).setUp() + + # Create 2 pg interfaces. + self.create_pg_interfaces(range(2)) + for pg in self.pg_interfaces: + pg.admin_up() + + # Configure IPv4 addresses on VPP pg0. + self.pg0.config_ip4() + self.pg0.resolve_arp() + + # Configure IPv4 addresses on VPP pg1. + self.pg1.config_ip4() + + def tearDown(self): + super(TestVxlanL2Mode, self).tearDown() + + def test_l2_mode(self): + """ VXLAN L2 mode """ + t = VppVxlanTunnel(self, + src=self.pg0.local_ip4, + dst=self.pg0.remote_ip4, + vni=1000, is_l3=False) + t.add_vpp_config() + t.config_ip4() + t.admin_up() + + dstIP = t.local_ip4[:-1] + "2" + + # Create a packet to send + p = (Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac) / + IP(src=self.pg1.local_ip4, dst=dstIP) / + UDP(sport=555, dport=556) / + Raw(b'\x00' * 80)) + + # Expect ARP request + rx = self.send_and_expect(self.pg1, [p], self.pg0) + for p in rx: + self.assertEqual(p[Ether].dst, self.pg0.remote_mac) + self.assertEqual(p[Ether].src, self.pg0.local_mac) + self.assertEqual(p[ARP].op, 1) + self.assertEqual(p[ARP].pdst, dstIP) + + # Resolve ARP + VppNeighbor(self, t.sw_if_index, + self.pg1.remote_mac, + dstIP).add_vpp_config() + + # Send packets + NUM_PKTS = 128 + rx = self.send_and_expect(self.pg1, p * NUM_PKTS, self.pg0) + self.assertEqual(NUM_PKTS, len(rx)) + + if __name__ == '__main__': unittest.main(testRunner=VppTestRunner) |