From 23e5f0923b843f11d79e57b456a4073d4be3e6f9 Mon Sep 17 00:00:00 2001 From: Artem Glazychev Date: Mon, 21 Feb 2022 17:51:29 +0700 Subject: vxlan: add l2 mode test The same test for v22.02 was already merged: https://gerrit.fd.io/r/c/vpp/+/35390 Type: improvement Signed-off-by: Artem Glazychev Change-Id: I214f6fb5b63d97ca4afe3b10fd2d3e3410b5a6e4 --- test/test_vxlan.py | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) 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) -- cgit 1.2.3-korg