summaryrefslogtreecommitdiffstats
path: root/test/test_vxlan.py
AgeCommit message (Collapse)AuthorFilesLines
2020-06-08vxlan: Fixed checksum caclculation offsetVladimir Isaev1-1/+2
VXLAN uses csum_offload for IPv6 packets. But without gso node we have csum calculated only for inner packet. This patch adds support for outer header csum calculation. Checksum for inner packet should be calculated before interface-output node (for example in vxlan node). Type: fix Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com> Signed-off-by: Vladimir Isaev <visaev@netgate.com> Change-Id: Ica68429ede4426293769207cd83c791ebe72fe56
2020-05-03tests: vpp_interface remove deprecated packed propertiesPaul Vinciguerra1-10/+6
The api no longer requires packed ip addresses. Type: test Change-Id: If67365d86b7c3189f871a58234e99f9c8f875371 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2020-04-10geneve: Fix the byte swapping for the VNINeale Ranns1-2/+4
Type: fix - swipe away the vomit indent left last time. - add tests for VNIs > 16bit Change-Id: I2d1f591bfb9d7a18996c38969365a509168d4193 Signed-off-by: Neale Ranns <nranns@cisco.com>
2020-03-16vxlan: vxlan/vxlan.api API cleanupJakub Grajciar1-52/+66
Use consistent API types. Type: fix Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com> Change-Id: I7f6f37ec6eed780322e2488d6eb0f5681945ba09 Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
2019-12-14tests: changes for scapy 2.4.3 migrationsnaramre1-1/+2
Type: fix Change-Id: I7e041b666dabd90df23a920a1f1d99db4c10ddfe Signed-off-by: snaramre <snaramre@cisco.com>
2019-11-08tests: python3 use byte strings in raw()Ole Troan1-1/+1
Raw('\xaf) and Raw(b'\xaf) are two quite different things in python 2 versus 3. In most cases this didn't make a difference, apart from those cases where length of payload actually mattered. Type: fix Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: I3cba5c1486e436a3ca8aa10a7b393da75aa9f6b9
2019-11-05misc: Fix python scripts shebang lineRenato Botelho do Couto1-1/+1
Type: fix Since CentOS 8, RPM build script doesn't accept '#!/usr/bin/env python' as a valid shebang line. It requires scripts to explicitly chose between python2 or python3. Change all to use python3 as suggested by Paul Vinciguerra. Depends-On: https://gerrit.fd.io/r/23170 Signed-off-by: Renato Botelho do Couto <renato@netgate.com> Change-Id: Ie72af9f60fd0609e07f05b70f8d96e738b2754d1
2019-06-18fib: fib api updatesNeale Ranns1-8/+13
Enhance the route add/del APIs to take a set of paths rather than just one. Most unicast routing protocols calcualte all the available paths in one run of the algorithm so updating all the paths at once is beneficial for the client. two knobs control the behaviour: is_multipath - if set the the set of paths passed will be added to those that already exist, otherwise the set will replace them. is_add - add or remove the set is_add=0, is_multipath=1 and an empty set, results in deleting the route. It is also considerably faster to add multiple paths at once, than one at a time: vat# ip_add_del_route 1.1.1.1/32 count 100000 multipath via 10.10.10.11 100000 routes in .572240 secs, 174751.80 routes/sec vat# ip_add_del_route 1.1.1.1/32 count 100000 multipath via 10.10.10.12 100000 routes in .528383 secs, 189256.54 routes/sec vat# ip_add_del_route 1.1.1.1/32 count 100000 multipath via 10.10.10.13 100000 routes in .757131 secs, 132077.52 routes/sec vat# ip_add_del_route 1.1.1.1/32 count 100000 multipath via 10.10.10.14 100000 routes in .878317 secs, 113854.12 routes/sec vat# ip_route_add_del 1.1.1.1/32 count 100000 multipath via 10.10.10.11 via 10.10.10.12 via 10.10.10.13 via 10.10.10.14 100000 routes in .900212 secs, 111084.93 routes/sec Change-Id: I416b93f7684745099c1adb0b33edac58c9339c1a Signed-off-by: Neale Ranns <neale.ranns@cisco.com> Signed-off-by: Ole Troan <ot@cisco.com> Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-04-11Tests: Refactor tearDown show command logging, add lifecycle markers.Paul Vinciguerra1-5/+6
This change adds a consistent interface for adding test-specific show commands to log.txt. It also adds log markers for the execution of setUp[Class], tearDown[Class] in the logs. Change-Id: I7d42e396e594a59e866a7d55dac0af25548e657a Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-04-10Tests Cleanup: Fix missing calls to setUpClass/tearDownClass.Paul Vinciguerra1-0/+4
Continuation/Part 2 of https://gerrit.fd.io/r/#/c/17092/ Change-Id: Id0122d84eaf2c05d29e5be63a594d5e528ee7c9a Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-03-12Tests: Raise exception, don't raise string.Paul Vinciguerra1-1/+1
This was deprecated ~ python 2.4, and causes a TypeError as sideEffect. >>> raise "foo" Traceback (most recent call last): File "<input>", line 1, in <module> TypeError: exceptions must derive from BaseException Change-Id: I4117b6d60ae896eaa1ef2a73a323d8d241f8c3a7 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-03-11vpp_papi_provider: Remove more wrapper functions.Ole Troan1-35/+30
Split this work up into pieces. Please don't add new wrappers to vpp_papi_provider.py. Change-Id: I0f8f2afc4cd2bba07ea70ddecea2d7319f7b2e10 Signed-off-by: Ole Troan <ot@cisco.com>
2018-12-10Test framework: StringIO fixes for Python3Ole Troan1-18/+2
Add 2/3 support to binarytomac and mactobinary and move to vpp_mac.py Change-Id: I3dc7e4a24486aee22140c781aae7e44e58935877 Signed-off-by: Ole Troan <ot@cisco.com>
2018-08-17VPP-1392: VXLAN fails with IP fragmentationOle Troan1-1/+46
Not only is it wasteful to send all fragments back through ip4-lookup, but it doesn't work with tunnel mechanisms that don't have IP enabled on their payload side. Change-Id: Ic92d95982dddaa70969a2a6ea2f98edec7614425 Signed-off-by: Ole Troan <ot@cisco.com>
2018-06-21test:vxlan over ipv6 testsEyal Bari1-1/+5
Change-Id: Id910db0e3a07ecc6f469e2f0d1e97f39ba48cc60 Signed-off-by: Eyal Bari <ebari@cisco.com>
2017-12-13make "test-all" target pass againGabriel Ganne1-1/+1
The "test-all" target is still never called as part of any continuous test (as it probably should) but at least it can now be expected to succeed. VXLAN-GPE: * decapsulate Ethernet to "l2-input" instead of "ethernet-input" otherwise the inner mac address get checked against the interface one (external) and packet gets dropped (mac mismatch) * set packet input sw_if_index to unicast vxlan tunnel for learning TEST: * VXLAN: * reduce the number of share tunnels: => reduce test duration by half => no functional change * VXLAN-GPE: * fix test TearDown() cli: command is "show vxlan-gpe" only * remove vxlan-gpe specific tests as the were a duplicated of the BridgeDomain one and already inherited. * disable test_mcast_rcv() and test_mcast_flood() tests * P2PEthernetAPI: * remove test: "create 100k of p2p subifs" there already is a "create 1k p2p subifs" so this one is a load test and not a unit test. See: lists.fd.io/pipermail/vpp-dev/2017-November/007280.html Change-Id: Icafb83769eb560cbdeb3dc6d1f1d3c23c0901cd9 Signed-off-by: Gabriel Ganne <gabriel.ganne@enea.com>
2017-04-07VXLAN/TEST:validate vxlan del reply has valid sw_if_indexEyal Bari1-1/+3
Change-Id: Icf7420b7ee212e9341f63f005dc287d019fd8e4c Signed-off-by: Eyal Bari <ebari@cisco.com>
2017-03-29VXLAN:validate mcast encapsulation ip/macEyal Bari1-3/+9
Change-Id: I399257e372f83f4d12dc7873617980af6e46a9bc Signed-off-by: Eyal Bari <ebari@cisco.com>
2017-01-25test adding and removing shared mcast dst tunnelsEyal Bari1-8/+39
Adds and delete 2000 multicast vxlan tunnels sharing group address to test mcast tunnel ref count code as part of the stability stage (before starting traffic tests) Change-Id: Ic50cedf80471e14431feb493104eff5ea7d5d429 Signed-off-by: Eyal Bari <ebari@cisco.com>
2017-01-11vxlan unit test - minor fixesEyal Bari1-20/+19
moved ip4_range and ip4n_range to util added n_ucast_tunnels Change-Id: I9140c4e54a0636d90a97db03da842f5183319af5 Signed-off-by: Eyal Bari <ebari@cisco.com>
2017-01-06Added basic tests for multicast vxlan tunnelsEyal Bari1-14/+107
unicast flood test - test headend replication multicast flood test - test flooding when a multicast vxlan tunnel is present in BD multicast receive test - verify that multicast packet are received on their corresponding unicast tunnels and that unmatched packets are dropped all tests run after adding and removing 200 mcast tunnels to test stability Change-Id: Ia05108c39ac35096a5b633cf52480a9ba87c14df Signed-off-by: Eyal Bari <ebari@cisco.com>
2016-12-13make test: Use VXLAN built in scapy 2.3.3Matej Klotton1-2/+6
- fix documentation issues. - fix mpls test. Change-Id: Ieef6b4b5e4aca99e89bd03e45a991be89d42adba Signed-off-by: Matej Klotton <mklotton@cisco.com>
2016-12-05make test: fix missing log/packet messagesKlement Sekera1-2/+1
Change-Id: Idb3119792943664748c4abc3829ad723f4156dfe Signed-off-by: Klement Sekera <ksekera@cisco.com>
2016-10-26refactor test frameworkKlement Sekera1-54/+52
Change-Id: I31da3b1857b6399f9899276a2d99cdd19436296c Signed-off-by: Klement Sekera <ksekera@cisco.com> Signed-off-by: Matej Klotton <mklotton@cisco.com> Signed-off-by: Jan Gelety <jgelety@cisco.com> Signed-off-by: Juraj Sloboda <jsloboda@cisco.com>
2016-10-03test: new test infrastructureDamjan Marion1-0/+102
Change-Id: I73ca19c431743f6b39669c583d9222a6559346ef Signed-off-by: Jan Gelety <jgelety@cisco.com> Signed-off-by: Juraj Sloboda <jsloboda@cisco.com> Signed-off-by: Stefan Kobza <skobza@cisco.com> Signed-off-by: Matej Klotton <mklotton@cisco.com> Signed-off-by: Maciek Konstantynowicz <mkonstan@cisco.com> Signed-off-by: Damjan Marion <damarion@cisco.com>
span> self._local_addr_n @property def remote_addr_n(self): return self._remote_addr_n @property def local_ip4(self): """Local IPv4 address on VPP interface (string).""" return self._local_ip4 @property def local_ip4n(self): """Local IPv4 address - raw, suitable as API parameter.""" return socket.inet_pton(socket.AF_INET, self._local_ip4) @property def remote_ip4(self): """IPv4 address of remote peer "connected" to this interface.""" return self._remote_hosts[0].ip4 @property def remote_ip4n(self): """IPv4 address of remote peer - raw, suitable as API parameter.""" return socket.inet_pton(socket.AF_INET, self.remote_ip4) @property def local_ip6(self): """Local IPv6 address on VPP interface (string).""" return self._local_ip6 @property def local_ip6n(self): """Local IPv6 address - raw, suitable as API parameter.""" return socket.inet_pton(socket.AF_INET6, self.local_ip6) @property def remote_ip6(self): """IPv6 address of remote peer "connected" to this interface.""" return self._remote_hosts[0].ip6 @property def remote_ip6n(self): """IPv6 address of remote peer - raw, suitable as API parameter""" return socket.inet_pton(socket.AF_INET6, self.remote_ip6) @property def local_ip6_ll(self): """Local IPv6 link-local address on VPP interface (string).""" return self._local_ip6_ll @property def local_ip6n_ll(self): """Local IPv6 link-local address - raw, suitable as API parameter.""" return self._local_ip6n_ll @property def remote_ip6_ll(self): """Link-local IPv6 address of remote peer "connected" to this interface.""" return self._remote_ip6_ll @property def remote_ip6n_ll(self): """Link-local IPv6 address of remote peer - raw, suitable as API parameter""" return self._remote_ip6n_ll @property def name(self): """Name of the interface.""" return self._name @property def dump(self): """RAW result of sw_interface_dump for this interface.""" return self._dump @property def test(self): """Test case creating this interface.""" return self._test @property def remote_hosts(self): """Remote hosts list""" return self._remote_hosts @remote_hosts.setter def remote_hosts(self, value): """ :param list value: List of remote hosts. """ self._remote_hosts = value self._hosts_by_mac = {} self._hosts_by_ip4 = {} self._hosts_by_ip6 = {} for host in self._remote_hosts: self._hosts_by_mac[host.mac] = host self._hosts_by_ip4[host.ip4] = host self._hosts_by_ip6[host.ip6] = host def host_by_mac(self, mac): """ :param mac: MAC address to find host by. :return: Host object assigned to interface. """ return self._hosts_by_mac[mac] def host_by_ip4(self, ip): """ :param ip: IPv4 address to find host by. :return: Host object assigned to interface. """ return self._hosts_by_ip4[ip] def host_by_ip6(self, ip): """ :param ip: IPv6 address to find host by. :return: Host object assigned to interface. """ return self._hosts_by_ip6[ip] def generate_remote_hosts(self, count=1): """Generate and add remote hosts for the interface. :param int count: Number of generated remote hosts. """ self._remote_hosts = [] self._hosts_by_mac = {} self._hosts_by_ip4 = {} self._hosts_by_ip6 = {} for i in range( 2, count + 2): # 0: network address, 1: local vpp address mac = "02:%02x:00:00:ff:%02x" % (self.sw_if_index, i) ip4 = "172.16.%u.%u" % (self.sw_if_index, i) ip6 = "fd01:%x::%x" % (self.sw_if_index, i) ip6_ll = mk_ll_addr(mac) host = Host(mac, ip4, ip6, ip6_ll) self._remote_hosts.append(host) self._hosts_by_mac[mac] = host self._hosts_by_ip4[ip4] = host self._hosts_by_ip6[ip6] = host @abstractmethod def __init__(self, test): self._test = test self._remote_hosts = [] self._hosts_by_mac = {} self._hosts_by_ip4 = {} self._hosts_by_ip6 = {} def set_mac(self, mac): self._local_mac = str(mac) self._local_ip6_ll = mk_ll_addr(self._local_mac) self.test.vapi.sw_interface_set_mac_address( self.sw_if_index, mac.packed) def set_sw_if_index(self, sw_if_index): self._sw_if_index = sw_if_index self.generate_remote_hosts() self._local_ip4 = "172.16.%u.1" % self.sw_if_index self._local_ip4n = socket.inet_pton(socket.AF_INET, self.local_ip4) self._local_ip4_subnet = "172.16.%u.0" % self.sw_if_index self._local_ip4n_subnet = socket.inet_pton(socket.AF_INET, self._local_ip4_subnet) self._local_ip4_bcast = "172.16.%u.255" % self.sw_if_index self._local_ip4n_bcast = socket.inet_pton(socket.AF_INET, self._local_ip4_bcast) self.local_ip4_prefix_len = 24 self.has_ip4_config = False self.ip4_table_id = 0 self._local_ip6 = "fd01:%x::1" % self.sw_if_index self._local_ip6n = socket.inet_pton(socket.AF_INET6, self.local_ip6) self.local_ip6_prefix_len = 64 self.has_ip6_config = False self.ip6_table_id = 0 self._local_addr = {socket.AF_INET: self.local_ip4, socket.AF_INET6: self.local_ip6} self._local_addr_n = {socket.AF_INET: self.local_ip4n, socket.AF_INET6: self.local_ip6n} self._remote_addr = {socket.AF_INET: self.remote_ip4, socket.AF_INET6: self.remote_ip6} self._remote_addr_n = {socket.AF_INET: self.remote_ip4n, socket.AF_INET6: self.remote_ip6n} r = self.test.vapi.sw_interface_dump() for intf in r: if intf.sw_if_index == self.sw_if_index: self._name = intf.interface_name.split(b'\0', 1)[0].decode('utf8') self._local_mac = mac_ntop(intf.l2_address) self._dump = intf break else: raise Exception( "Could not find interface with sw_if_index %d " "in interface dump %s" % (self.sw_if_index, moves.reprlib.repr(r))) self._local_ip6_ll = mk_ll_addr(self.local_mac) self._local_ip6n_ll = socket.inet_pton(socket.AF_INET6, self.local_ip6_ll) self._remote_ip6_ll = mk_ll_addr(self.remote_mac) self._remote_ip6n_ll = socket.inet_pton(socket.AF_INET6, self.remote_ip6_ll) def config_ip4(self): """Configure IPv4 address on the VPP interface.""" self.test.vapi.sw_interface_add_del_address( self.sw_if_index, self.local_ip4n, self.local_ip4_prefix_len) self.has_ip4_config = True def unconfig_ip4(self): """Remove IPv4 address on the VPP interface.""" try: if self.has_ip4_config: self.test.vapi.sw_interface_add_del_address( self.sw_if_index, self.local_ip4n, self.local_ip4_prefix_len, is_add=0) except AttributeError: self.has_ip4_config = False self.has_ip4_config = False def configure_ipv4_neighbors(self): """For every remote host assign neighbor's MAC to IPv4 addresses. :param vrf_id: The FIB table / VRF ID. (Default value = 0) """ for host in self._remote_hosts: macn = mac_pton(host.mac) ipn = host.ip4n self.test.vapi.ip_neighbor_add_del( self.sw_if_index, macn, ipn) def config_ip6(self): """Configure IPv6 address on the VPP interface.""" self.test.vapi.sw_interface_add_del_address( self.sw_if_index, self._local_ip6n, self.local_ip6_prefix_len, is_ipv6=1) self.has_ip6_config = True def unconfig_ip6(self): """Remove IPv6 address on the VPP interface.""" try: if self.has_ip6_config: self.test.vapi.sw_interface_add_del_address( self.sw_if_index, self.local_ip6n, self.local_ip6_prefix_len, is_ipv6=1, is_add=0) except AttributeError: self.has_ip6_config = False self.has_ip6_config = False def configure_ipv6_neighbors(self): """For every remote host assign neighbor's MAC to IPv6 addresses. :param vrf_id: The FIB table / VRF ID. (Default value = 0) """ for host in self._remote_hosts: macn = mac_pton(host.mac) ipn = host.ip6n self.test.vapi.ip_neighbor_add_del( self.sw_if_index, macn, ipn, is_ipv6=1) def unconfig(self): """Unconfigure IPv6 and IPv4 address on the VPP interface.""" self.unconfig_ip4() self.unconfig_ip6() def set_table_ip4(self, table_id): """Set the interface in a IPv4 Table. .. note:: Must be called before configuring IP4 addresses. """ self.ip4_table_id = table_id self.test.vapi.sw_interface_set_table( self.sw_if_index, 0, self.ip4_table_id) def set_table_ip6(self, table_id): """Set the interface in a IPv6 Table. .. note:: Must be called before configuring IP6 addresses. """ self.ip6_table_id = table_id self.test.vapi.sw_interface_set_table( self.sw_if_index, 1, self.ip6_table_id) def disable_ipv6_ra(self): """Configure IPv6 RA suppress on the VPP interface.""" self.test.vapi.sw_interface_ra_suppress(self.sw_if_index) def ip6_ra_config(self, no=0, suppress=0, send_unicast=0): """Configure IPv6 RA suppress on the VPP interface.""" self.test.vapi.ip6_sw_interface_ra_config(self.sw_if_index, no, suppress, send_unicast) def ip6_ra_prefix(self, address, address_length, is_no=0, off_link=0, no_autoconfig=0, use_default=0): """Configure IPv6 RA suppress on the VPP interface.""" self.test.vapi.ip6_sw_interface_ra_prefix(self.sw_if_index, address, address_length, is_no=is_no, off_link=off_link, no_autoconfig=no_autoconfig, use_default=use_default) def admin_up(self): """Put interface ADMIN-UP.""" self.test.vapi.sw_interface_set_flags(self.sw_if_index, admin_up_down=1) def admin_down(self): """Put interface ADMIN-down.""" self.test.vapi.sw_interface_set_flags(self.sw_if_index, admin_up_down=0) def ip6_enable(self): """IPv6 Enable interface""" self.test.vapi.ip6_sw_interface_enable_disable(self.sw_if_index, enable=1) def ip6_disable(self): """Put interface ADMIN-DOWN.""" self.test.vapi.ip6_sw_interface_enable_disable(self.sw_if_index, enable=0) def add_sub_if(self, sub_if): """Register a sub-interface with this interface. :param sub_if: sub-interface """ if not hasattr(self, 'sub_if'): self.sub_if = sub_if else: if isinstance(self.sub_if, list): self.sub_if.append(sub_if) else: self.sub_if = sub_if def enable_mpls(self): """Enable MPLS on the VPP interface.""" self.test.vapi.sw_interface_enable_disable_mpls( self.sw_if_index) def disable_mpls(self): """Enable MPLS on the VPP interface.""" self.test.vapi.sw_interface_enable_disable_mpls( self.sw_if_index, 0) def is_ip4_entry_in_fib_dump(self, dump): for i in dump: if i.address == self.local_ip4n and \ i.address_length == self.local_ip4_prefix_len and \ i.table_id == self.ip4_table_id: return True return False def set_unnumbered(self, ip_sw_if_index): """ Set the interface to unnumbered via ip_sw_if_index """ self.test.vapi.sw_interface_set_unnumbered( self.sw_if_index, ip_sw_if_index) def unset_unnumbered(self, ip_sw_if_index): """ Unset the interface to unnumbered via ip_sw_if_index """ self.test.vapi.sw_interface_set_unnumbered( self.sw_if_index, ip_sw_if_index, is_add=0) def set_proxy_arp(self, enable=1): """ Set the interface to enable/disable Proxy ARP """ self.test.vapi.proxy_arp_intfc_enable_disable( self.sw_if_index, enable) def query_vpp_config(self): dump = self.test.vapi.sw_interface_dump() return self.is_interface_config_in_dump(dump) def get_interface_config_from_dump(self, dump): for i in dump: if i.interface_name.rstrip(' \t\r\n\0') == self.name and \ i.sw_if_index == self.sw_if_index: return i else: return None def is_interface_config_in_dump(self, dump): return self.get_interface_config_from_dump(dump) is not None def assert_interface_state(self, admin_up_down, link_up_down, expect_event=False): if expect_event: event = self.test.vapi.wait_for_event(timeout=1, name='sw_interface_event') self.test.assert_equal(event.sw_if_index, self.sw_if_index, "sw_if_index") self.test.assert_equal(event.admin_up_down, admin_up_down, "admin state") self.test.assert_equal(event.link_up_down, link_up_down, "link state") dump = self.test.vapi.sw_interface_dump() if_state = self.get_interface_config_from_dump(dump) self.test.assert_equal(if_state.admin_up_down, admin_up_down, "admin state") self.test.assert_equal(if_state.link_up_down, link_up_down, "link state") def __str__(self): return self.name