summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2019-03-15 02:16:20 -0700
committerJohn Lo <loj@cisco.com>2019-03-21 20:33:30 +0000
commit192b13f96d6b4d1b4cbbb64a3d447329bf2ba900 (patch)
tree44681e508ad2dc06af4518e6f4d0ead6ff35ab77 /test
parent1ea74b5df5acfc827ee53fd5cb6bdb40140da0f0 (diff)
BVI Interface
a new dedicated BVI interface as opposed to [re]using a loopback. benefits: - removes ambiguity over the purpose of a loopback interface - TX node dedicated to BVI only functions. Change-Id: I749d6b38440d450ac5b909a28053c75ec9df946a Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'test')
-rw-r--r--test/framework.py15
-rw-r--r--test/test_ip4_irb.py50
-rw-r--r--test/test_l2_flood.py14
-rw-r--r--test/vpp_bvi_interface.py22
4 files changed, 69 insertions, 32 deletions
diff --git a/test/framework.py b/test/framework.py
index ea989eb242d..dce477d16d2 100644
--- a/test/framework.py
+++ b/test/framework.py
@@ -25,6 +25,7 @@ from hook import StepHook, PollHook, VppDiedError
from vpp_pg_interface import VppPGInterface
from vpp_sub_interface import VppSubInterface
from vpp_lo_interface import VppLoInterface
+from vpp_bvi_interface import VppBviInterface
from vpp_papi_provider import VppPapiProvider
from vpp_papi.vpp_stats import VPPStats
from log import RED, GREEN, YELLOW, double_line_delim, single_line_delim, \
@@ -690,6 +691,20 @@ class VppTestCase(unittest.TestCase):
cls.lo_interfaces = result
return result
+ @classmethod
+ def create_bvi_interfaces(cls, count):
+ """
+ Create BVI interfaces.
+
+ :param count: number of interfaces created.
+ :returns: List of created interfaces.
+ """
+ result = [VppBviInterface(cls) for i in range(count)]
+ for intf in result:
+ setattr(cls, intf.name, intf)
+ cls.bvi_interfaces = result
+ return result
+
@staticmethod
def extend_packet(packet, size, padding=' '):
"""
diff --git a/test/test_ip4_irb.py b/test/test_ip4_irb.py
index 1d55cef5d90..ef3dc1caf2b 100644
--- a/test/test_ip4_irb.py
+++ b/test/test_ip4_irb.py
@@ -42,10 +42,10 @@ class TestIpIrb(VppTestCase):
def setUpClass(cls):
"""
#. Create BD with MAC learning enabled and put interfaces to this BD.
- #. Configure IPv4 addresses on loopback interface and routed interface.
- #. Configure MAC address binding to IPv4 neighbors on loop0.
+ #. Configure IPv4 addresses on BVI interface and routed interface.
+ #. Configure MAC address binding to IPv4 neighbors on bvi0.
#. Configure MAC address on pg2.
- #. Loopback BVI interface has remote hosts, one half of hosts are
+ #. BVI interface has remote hosts, one half of hosts are
behind pg0 second behind pg1.
"""
super(TestIpIrb, cls).setUpClass()
@@ -54,40 +54,40 @@ class TestIpIrb(VppTestCase):
cls.bd_id = 10
cls.remote_hosts_count = 250
- # create 3 pg interfaces, 1 loopback interface
+ # create 3 pg interfaces, 1 BVI interface
cls.create_pg_interfaces(range(3))
- cls.create_loopback_interfaces(1)
+ cls.create_bvi_interfaces(1)
cls.interfaces = list(cls.pg_interfaces)
- cls.interfaces.extend(cls.lo_interfaces)
+ cls.interfaces.extend(cls.bvi_interfaces)
for i in cls.interfaces:
i.admin_up()
# Create BD with MAC learning enabled and put interfaces to this BD
cls.vapi.sw_interface_set_l2_bridge(
- rx_sw_if_index=cls.loop0.sw_if_index, bd_id=cls.bd_id,
+ rx_sw_if_index=cls.bvi0.sw_if_index, bd_id=cls.bd_id,
port_type=L2_PORT_TYPE.BVI)
cls.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=cls.pg0.sw_if_index,
bd_id=cls.bd_id)
cls.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=cls.pg1.sw_if_index,
bd_id=cls.bd_id)
- # Configure IPv4 addresses on loopback interface and routed interface
- cls.loop0.config_ip4()
+ # Configure IPv4 addresses on BVI interface and routed interface
+ cls.bvi0.config_ip4()
cls.pg2.config_ip4()
- # Configure MAC address binding to IPv4 neighbors on loop0
- cls.loop0.generate_remote_hosts(cls.remote_hosts_count)
- cls.loop0.configure_ipv4_neighbors()
+ # Configure MAC address binding to IPv4 neighbors on bvi0
+ cls.bvi0.generate_remote_hosts(cls.remote_hosts_count)
+ cls.bvi0.configure_ipv4_neighbors()
# configure MAC address on pg2
cls.pg2.resolve_arp()
- # Loopback BVI interface has remote hosts, one half of hosts are behind
+ # BVI interface has remote hosts, one half of hosts are behind
# pg0 second behind pg1
half = cls.remote_hosts_count // 2
- cls.pg0.remote_hosts = cls.loop0.remote_hosts[:half]
- cls.pg1.remote_hosts = cls.loop0.remote_hosts[half:]
+ cls.pg0.remote_hosts = cls.bvi0.remote_hosts[:half]
+ cls.pg1.remote_hosts = cls.bvi0.remote_hosts[half:]
def tearDown(self):
"""Run standard test teardown and log ``show l2patch``,
@@ -220,32 +220,32 @@ class TestIpIrb(VppTestCase):
Test scenario:
- ip traffic from pg2 interface must ends in both pg0 and pg1
- - arp entry present in loop0 interface for destination IP
- - no l2 entree configured, pg0 and pg1 are same
+ - arp entry present in bvi0 interface for destination IP
+ - no l2 entry configured, pg0 and pg1 are same
"""
stream = self.create_stream(
- self.pg2, self.loop0, self.pg_if_packet_sizes)
+ self.pg2, self.bvi0, self.pg_if_packet_sizes)
self.pg2.add_stream(stream)
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
- packet_count = self.get_packet_count_for_if_idx(self.loop0.sw_if_index)
+ packet_count = self.get_packet_count_for_if_idx(self.bvi0.sw_if_index)
rcvd1 = self.pg0.get_capture(packet_count)
rcvd2 = self.pg1.get_capture(packet_count)
- self.verify_capture(self.loop0, self.pg2, rcvd1)
- self.verify_capture(self.loop0, self.pg2, rcvd2)
+ self.verify_capture(self.bvi0, self.pg2, rcvd1)
+ self.verify_capture(self.bvi0, self.pg2, rcvd2)
self.assertListEqual(rcvd1.res, rcvd2.res)
def send_and_verify_l2_to_ip(self):
stream1 = self.create_stream_l2_to_ip(
- self.pg0, self.loop0, self.pg2, self.pg_if_packet_sizes)
+ self.pg0, self.bvi0, self.pg2, self.pg_if_packet_sizes)
stream2 = self.create_stream_l2_to_ip(
- self.pg1, self.loop0, self.pg2, self.pg_if_packet_sizes)
+ self.pg1, self.bvi0, self.pg2, self.pg_if_packet_sizes)
self.vapi.cli("clear trace")
self.pg0.add_stream(stream1)
self.pg1.add_stream(stream2)
@@ -254,7 +254,7 @@ class TestIpIrb(VppTestCase):
self.pg_start()
rcvd = self.pg2.get_capture(514)
- self.verify_capture_l2_to_ip(self.pg2, self.loop0, rcvd)
+ self.verify_capture_l2_to_ip(self.pg2, self.bvi0, rcvd)
def test_ip4_irb_2(self):
""" IPv4 IRB test 2
@@ -265,7 +265,7 @@ class TestIpIrb(VppTestCase):
self.send_and_verify_l2_to_ip()
# change the BVI's mac and resed traffic
- self.loop0.set_mac(MACAddress("00:00:00:11:11:33"))
+ self.bvi0.set_mac(MACAddress("00:00:00:11:11:33"))
self.send_and_verify_l2_to_ip()
# check it wasn't flooded
diff --git a/test/test_l2_flood.py b/test/test_l2_flood.py
index 7fe5214dcde..e81daf99235 100644
--- a/test/test_l2_flood.py
+++ b/test/test_l2_flood.py
@@ -20,24 +20,24 @@ class TestL2Flood(VppTestCase):
# 12 l2 interface and one l3
self.create_pg_interfaces(range(13))
- self.create_loopback_interfaces(1)
+ self.create_bvi_interfaces(1)
for i in self.pg_interfaces:
i.admin_up()
- for i in self.lo_interfaces:
+ for i in self.bvi_interfaces:
i.admin_up()
self.pg12.config_ip4()
self.pg12.resolve_arp()
- self.loop0.config_ip4()
+ self.bvi0.config_ip4()
def tearDown(self):
self.pg12.unconfig_ip4()
- self.loop0.unconfig_ip4()
+ self.bvi0.unconfig_ip4()
for i in self.pg_interfaces:
i.admin_down()
- for i in self.lo_interfaces:
+ for i in self.bvi_interfaces:
i.admin_down()
super(TestL2Flood, self).tearDown()
@@ -61,7 +61,7 @@ class TestL2Flood(VppTestCase):
for i in self.pg_interfaces[8:12]:
self.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=i.sw_if_index,
bd_id=1, shg=2)
- for i in self.lo_interfaces:
+ for i in self.bvi_interfaces:
self.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=i.sw_if_index,
bd_id=1, shg=2,
port_type=L2_PORT_TYPE.BVI)
@@ -142,7 +142,7 @@ class TestL2Flood(VppTestCase):
for i in self.pg_interfaces[:12]:
self.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=i.sw_if_index,
bd_id=1, enable=0)
- for i in self.lo_interfaces:
+ for i in self.bvi_interfaces:
self.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=i.sw_if_index,
bd_id=1, shg=2,
port_type=L2_PORT_TYPE.BVI,
diff --git a/test/vpp_bvi_interface.py b/test/vpp_bvi_interface.py
new file mode 100644
index 00000000000..7039f29ca8d
--- /dev/null
+++ b/test/vpp_bvi_interface.py
@@ -0,0 +1,22 @@
+from vpp_object import VppObject
+from vpp_interface import VppInterface
+
+
+class VppBviInterface(VppInterface, VppObject):
+ """VPP bvi interface."""
+
+ def __init__(self, test):
+ """ Create VPP BVI interface """
+ super(VppBviInterface, self).__init__(test)
+ self.add_vpp_config()
+
+ def add_vpp_config(self):
+ r = self.test.vapi.bvi_create(user_instance=0xffffffff,
+ mac="00:00:00:00:00:00")
+ self.set_sw_if_index(r.sw_if_index)
+
+ def remove_vpp_config(self):
+ self.test.vapi.bvi_delete(sw_if_index=self.sw_if_index)
+
+ def object_id(self):
+ return "bvi-%d" % self._sw_if_index