return result
@classmethod
- def create_loopback_interfaces(cls, count):
+ def create_loopback_interfaces(cls, interfaces):
"""
Create loopback interfaces.
- :param count: number of interfaces created.
+ :param interfaces: iterable indexes of the interfaces.
:returns: List of created interfaces.
"""
- result = [VppLoInterface(cls) for i in range(count)]
- for intf in result:
+ result = []
+ for i in interfaces:
+ intf = VppLoInterface(cls, i)
setattr(cls, intf.name, intf)
+ result.append(intf)
cls.lo_interfaces = result
return result
# create 3 pg interfaces, 1 loopback interface
cls.create_pg_interfaces(range(3))
- cls.create_loopback_interfaces(1)
+ cls.create_loopback_interfaces(range(1))
cls.interfaces = list(cls.pg_interfaces)
cls.interfaces.extend(cls.lo_interfaces)
try:
# create 4 pg interfaces, 1 loopback interface
cls.create_pg_interfaces(range(4))
- cls.create_loopback_interfaces(1)
+ cls.create_loopback_interfaces(range(1))
# create 2 subinterfaces
cls.subifs = [
cls.vapi.cli("set log class bfd level debug")
try:
cls.create_pg_interfaces([0])
- cls.create_loopback_interfaces(1)
+ cls.create_loopback_interfaces([0])
cls.loopback0 = cls.lo_interfaces[0]
cls.loopback0.config_ip4()
cls.loopback0.admin_up()
cls.pg0.configure_ipv6_neighbors()
cls.pg0.admin_up()
cls.pg0.resolve_ndp()
- cls.create_loopback_interfaces(1)
+ cls.create_loopback_interfaces([0])
cls.loopback0 = cls.lo_interfaces[0]
cls.loopback0.config_ip6()
cls.loopback0.admin_up()
def test_set_del_udp_echo_source(self):
""" set/del udp echo source """
- self.create_loopback_interfaces(1)
+ self.create_loopback_interfaces([0])
self.loopback0 = self.lo_interfaces[0]
self.loopback0.admin_up()
self.cli_verify_response("show bfd echo-source",
def test_0050_loopback_prepare_test(self):
""" Create loopbacks overlapping with remote addresses """
- self.create_loopback_interfaces(2)
+ self.create_loopback_interfaces(range(2))
for i in range(2):
intf = self.lo_interfaces[i]
intf.admin_up()
#!/usr/bin/env python
+import random
+import socket
import unittest
from framework import VppTestCase, VppTestRunner
-from vpp_sub_interface import VppDot1QSubint
-from vpp_ip_route import VppIpRoute, VppRoutePath
+from vpp_sub_interface import VppSubInterface, VppDot1QSubint
+from vpp_ip_route import VppIpRoute, VppRoutePath, DpoProto, VppIpMRoute, \
+ VppMRoutePath, MRouteEntryFlags, MRouteItfFlags
from vpp_papi_provider import L2_VTR_OP
from scapy.packet import Raw
-from scapy.layers.l2 import Ether, Dot1Q
+from scapy.layers.l2 import Ether, Dot1Q, ARP
from scapy.layers.inet import IP, UDP
+from util import ppp
from socket import AF_INET, inet_pton
super(TestDVR, self).setUp()
self.create_pg_interfaces(range(4))
- self.create_loopback_interfaces(1)
+ self.create_loopback_interfaces(range(1))
for i in self.pg_interfaces:
i.admin_up()
#!/usr/bin/env python
import unittest
+import socket
+import struct
from framework import VppTestCase, VppTestRunner
from vpp_object import VppObject
from scapy.layers.l2 import Ether, ARP
from scapy.layers.inet import IP, UDP
from scapy.layers.inet6 import IPv6, ICMPv6ND_NS, ICMPv6NDOptSrcLLAddr, \
- ICMPv6ND_NA
+ ICMPv6NDOptDstLLAddr, ICMPv6ND_NA
from scapy.utils6 import in6_getnsma, in6_getnsmac
from socket import AF_INET, AF_INET6
from scapy.utils import inet_pton, inet_ntop
-from util import mactobinary
+from util import Host, mactobinary
class VppGbpEndpoint(VppObject):
super(TestGBP, self).setUp()
self.create_pg_interfaces(range(9))
- self.create_loopback_interfaces(9)
+ self.create_loopback_interfaces(range(9))
self.router_mac = "00:11:22:33:44:55"
def test_crud(self):
# create
- loopbacks = self.create_loopback_interfaces(20)
+ loopbacks = self.create_loopback_interfaces(range(20))
for i in loopbacks:
i.local_ip4_prefix_len = 32
i.config_ip4()
def test_down(self):
# create
- loopbacks = self.create_loopback_interfaces(20)
+ loopbacks = self.create_loopback_interfaces(range(20))
for i in loopbacks:
i.local_ip4_prefix_len = 32
i.config_ip4()
# create 3 pg interfaces, 1 loopback interface
cls.create_pg_interfaces(range(3))
- cls.create_loopback_interfaces(1)
+ cls.create_loopback_interfaces(range(1))
cls.interfaces = list(cls.pg_interfaces)
cls.interfaces.extend(cls.lo_interfaces)
import unittest
from framework import VppTestCase, VppTestRunner
+from vpp_sub_interface import VppSubInterface, VppDot1QSubint, VppDot1ADSubint
from vpp_ip_route import VppIpMRoute, VppMRoutePath, VppMFibSignal, \
MRouteItfFlags, MRouteEntryFlags, VppIpTable, DpoProto
from scapy.packet import Raw
from scapy.layers.l2 import Ether
-from scapy.layers.inet import IP, UDP, getmacbyip
+from scapy.layers.inet import IP, UDP, getmacbyip, ICMP
from scapy.layers.inet6 import IPv6, getmacbyip6
+from util import ppp
#
# The number of packets sent is set to 91 so that when we replicate more than 3
#!/usr/bin/env python
import unittest
+import socket
+import struct
from framework import VppTestCase, VppTestRunner
+from vpp_object import VppObject
from vpp_papi_provider import QOS_SOURCE
-from vpp_ip_route import VppIpRoute, VppRoutePath
+from vpp_ip_route import VppIpRoute, VppRoutePath, VppMplsRoute
+from vpp_sub_interface import VppSubInterface, VppDot1QSubint
from scapy.packet import Raw
-from scapy.layers.l2 import Ether
+from scapy.layers.l2 import Ether, Dot1Q
from scapy.layers.inet import IP, UDP
from scapy.layers.inet6 import IPv6
from scapy.contrib.mpls import MPLS
def setUp(self):
super(TestSCTP, self).setUp()
self.vapi.session_enable_disable(is_enabled=1)
- self.create_loopback_interfaces(2)
+ self.create_loopback_interfaces(range(2))
table_id = 0
super(TestSession, self).setUp()
self.vapi.session_enable_disable(is_enabled=1)
- self.create_loopback_interfaces(2)
+ self.create_loopback_interfaces(range(2))
table_id = 0
def setUp(self):
super(TestTCP, self).setUp()
self.vapi.session_enable_disable(is_enabled=1)
- self.create_loopback_interfaces(2)
+ self.create_loopback_interfaces(range(2))
table_id = 0
#!/usr/bin/env python
-import unittest
+
from framework import VppTestCase, VppTestRunner
-from vpp_udp_encap import VppUdpEncap
+from vpp_udp_encap import *
from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable, VppMplsLabel
from scapy.packet import Raw
-from scapy.layers.l2 import Ether
+from scapy.layers.l2 import Ether, ARP
from scapy.layers.inet import IP, UDP
from scapy.layers.inet6 import IPv6
from scapy.contrib.mpls import MPLS
def setUp(self):
super(TestUDP, self).setUp()
self.vapi.session_enable_disable(is_enabled=1)
- self.create_loopback_interfaces(2)
+ self.create_loopback_interfaces(range(2))
table_id = 0
worker_client.join(self.timeout)
try:
self.validateResults(worker_client, worker_server, self.timeout)
- except Exception as error:
+ except Exception, error:
self.fail("Failed with %s" % error)
def thru_host_stack_setup(self):
self.vapi.session_enable_disable(is_enabled=1)
- self.create_loopback_interfaces(2)
+ self.create_loopback_interfaces(range(2))
table_id = 1
def thru_host_stack_ipv6_setup(self):
self.vapi.session_enable_disable(is_enabled=1)
- self.create_loopback_interfaces(2)
+ self.create_loopback_interfaces(range(2))
table_id = 1
try:
self.validateResults(worker_client, worker_server, self.timeout)
- except Exception as error:
+ except Exception, error:
self.fail("Failed with %s" % error)
def validateResults(self, worker_client, worker_server, timeout):
use_custom_mac=0, mac_address=''):
""" Create VPP Bond interface """
- super(VppBondInterface, self).__init__(test)
+ self._test = test
self.mode = mode
self.lb = lb
self.use_custom_mac = use_custom_mac
self.lb,
self.use_custom_mac,
self.mac_address)
- self.set_sw_if_index(r.sw_if_index)
+ self._sw_if_index = r.sw_if_index
+ super(VppBondInterface, self).__init__(self._test)
def remove_vpp_config(self):
self.test.vapi.bond_delete(self.sw_if_index)
def __init__(self, test, src_ip, dst_ip, outer_fib_id=0, type=0,
session=0):
""" Create VPP GRE interface """
- super(VppGreInterface, self).__init__(test)
+ self._test = test
self.t_src = src_ip
self.t_dst = dst_ip
self.t_outer_fib = outer_fib_id
outer_fib_id=self.t_outer_fib,
tunnel_type=self.t_type,
session_id=self.t_session)
- self.set_sw_if_index(r.sw_if_index)
+ self._sw_if_index = r.sw_if_index
self.generate_remote_hosts()
self.test.registry.register(self, self.test.logger)
+ super(VppGreInterface, self).__init__(self.test)
def remove_vpp_config(self):
s = socket.inet_pton(socket.AF_INET, self.t_src)
def __init__(self, test, src_ip, dst_ip, outer_fib_id=0, type=0,
session=0):
""" Create VPP GRE interface """
- super(VppGre6Interface, self).__init__(test)
+ self._test = test
self.t_src = src_ip
self.t_dst = dst_ip
self.t_outer_fib = outer_fib_id
tunnel_type=self.t_type,
session_id=self.t_session,
is_ip6=1)
- self.set_sw_if_index(r.sw_if_index)
+ self._sw_if_index = r.sw_if_index
self.generate_remote_hosts()
self.test.registry.register(self, self.test.logger)
+ super(VppGre6Interface, self).__init__(self.test)
def remove_vpp_config(self):
s = socket.inet_pton(socket.AF_INET6, self.t_src)
class VppLoInterface(VppInterface, VppObject):
"""VPP loopback interface."""
- def __init__(self, test):
+ def __init__(self, test, lo_index):
""" Create VPP loopback interface """
- super(VppLoInterface, self).__init__(test)
+ self._test = test
self.add_vpp_config()
+ super(VppLoInterface, self).__init__(test)
+ self._lo_index = lo_index
def add_vpp_config(self):
r = self.test.vapi.create_loopback()
- self.set_sw_if_index(r.sw_if_index)
+ self._sw_if_index = r.sw_if_index
def remove_vpp_config(self):
self.test.vapi.delete_loopback(self.sw_if_index)
def __init__(self, test, paths, is_multicast=0, is_l2=0):
""" Create MPLS Tunnel interface """
- super(VppMPLSTunnelInterface, self).__init__(test)
+ self._test = test
self.t_paths = paths
self.is_multicast = is_multicast
self.is_l2 = is_l2
is_multicast=self.is_multicast,
l2_only=self.is_l2)
sw_if_index = reply.sw_if_index
- self.set_sw_if_index(sw_if_index)
+ self._sw_if_index = sw_if_index
+ super(VppMPLSTunnelInterface, self).__init__(self.test)
def remove_vpp_config(self):
for path in self.t_paths:
def __init__(self, test, client_ip, client_mac,
session_id, decap_vrf_id=0):
""" Create VPP PPPoE4 interface """
- super(VppPppoeInterface, self).__init__(test)
+ self._test = test
self.client_ip = client_ip
self.client_mac = client_mac
self.session_id = session_id
cip, cmac,
session_id=self.session_id,
decap_vrf_id=self.decap_vrf_id)
- self.set_sw_if_index(r.sw_if_index)
+ self._sw_if_index = r.sw_if_index
+ super(VppPppoeInterface, self).__init__(self._test)
self.generate_remote_hosts()
def remove_vpp_config(self):
cip = socket.inet_pton(socket.AF_INET, self.client_ip)
cmac = mactobinary(self.client_mac)
self.unconfig()
- self.test.vapi.pppoe_add_del_session(
+ r = self.test.vapi.pppoe_add_del_session(
cip, cmac,
session_id=self.session_id,
decap_vrf_id=self.decap_vrf_id,
self._parent = parent
self._parent.add_sub_if(self)
self._sub_id = sub_id
+ self.set_vtr(L2_VTR_OP.L2_DISABLED)
self.DOT1AD_TYPE = 0x88A8
self.DOT1Q_TYPE = 0x8100
- def set_sw_if_index(self, sw_if_index):
- super(VppSubInterface, self).set_sw_if_index(sw_if_index)
- self.set_vtr(L2_VTR_OP.L2_DISABLED)
-
@abstractmethod
def create_arp_req(self):
pass
def create_ndp_req(self):
pass
+ def resolve_arp(self):
+ super(VppSubInterface, self).resolve_arp(self.parent)
+
+ def resolve_ndp(self):
+ super(VppSubInterface, self).resolve_ndp(self.parent)
+
@abstractmethod
def add_dot1_layer(self, pkt):
pass
def remove_vpp_config(self):
- self.test.vapi.delete_subif(self.sw_if_index)
+ self.test.vapi.delete_subif(self._sw_if_index)
def _add_tag(self, packet, vlan, tag_type):
payload = packet.payload
return self._vlan
def __init__(self, test, parent, sub_id, vlan=None):
- super(VppDot1QSubint, self).__init__(test, parent, sub_id)
if vlan is None:
vlan = sub_id
self._vlan = vlan
r = test.vapi.create_vlan_subif(parent.sw_if_index, vlan)
- self.set_sw_if_index(r.sw_if_index)
+ self._sw_if_index = r.sw_if_index
+ super(VppDot1QSubint, self).__init__(test, parent, sub_id)
def create_arp_req(self):
packet = VppPGInterface.create_arp_req(self)
return self._inner_vlan
def __init__(self, test, parent, sub_id, outer_vlan, inner_vlan):
- super(VppDot1ADSubint, self).__init__(test, parent, sub_id)
r = test.vapi.create_subif(parent.sw_if_index, sub_id, outer_vlan,
inner_vlan, dot1ad=1, two_tags=1,
exact_match=1)
- self.set_sw_if_index(r.sw_if_index)
+ self._sw_if_index = r.sw_if_index
self._outer_vlan = outer_vlan
self._inner_vlan = inner_vlan
+ super(VppDot1ADSubint, self).__init__(test, parent, sub_id)
def create_arp_req(self):
packet = VppPGInterface.create_arp_req(self)
class VppP2PSubint(VppSubInterface):
def __init__(self, test, parent, sub_id, remote_mac):
- super(VppP2PSubint, self).__init__(test, parent, sub_id)
r = test.vapi.create_p2pethernet_subif(parent.sw_if_index,
remote_mac, sub_id)
- self.set_sw_if_index(r.sw_if_index)
+ self._sw_if_index = r.sw_if_index
self.parent_sw_if_index = parent.sw_if_index
self.p2p_remote_mac = remote_mac
+ super(VppP2PSubint, self).__init__(test, parent, sub_id)
def add_dot1_layer(self, packet):
return packet
tag=''):
""" Create VPP Vhost interface """
- super(VppVhostInterface, self).__init__(test)
+ self._test = test
self.is_server = is_server
self.sock_filename = sock_filename
self.renumber = renumber
self.use_custom_mac,
self.mac_address,
self.tag)
- self.set_sw_if_index(r.sw_if_index)
+ self._sw_if_index = r.sw_if_index
+ super(VppVhostInterface, self).__init__(self._test)
def remove_vpp_config(self):
self.test.vapi.delete_vhost_user_if(self.sw_if_index)