X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Ftest_ip4.py;h=c18ce4caa0a9c700529c0d85a758d6ca2e365478;hb=a6fe463c1cb67a52f06e519a514a47a9b6af8057;hp=9f2c925ec4d3690357f790111f1af856a9c0de12;hpb=6e4c6ad92e59045f0babf5af5093cb8402ec37fb;p=vpp.git diff --git a/test/test_ip4.py b/test/test_ip4.py index 9f2c925ec4d..c18ce4caa0a 100644 --- a/test/test_ip4.py +++ b/test/test_ip4.py @@ -4,17 +4,18 @@ import random import socket import unittest +from scapy.contrib.mpls import MPLS +from scapy.layers.inet import IP, UDP, TCP, ICMP, icmptypes, icmpcodes +from scapy.layers.l2 import Ether, Dot1Q, ARP +from scapy.packet import Raw +from six import moves + from framework import VppTestCase, VppTestRunner -from vpp_sub_interface import VppSubInterface, VppDot1QSubint, VppDot1ADSubint +from util import ppp from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpMRoute, \ VppMRoutePath, MRouteItfFlags, MRouteEntryFlags, VppMplsIpBind, \ - VppMplsTable, VppIpTable - -from scapy.packet import Raw -from scapy.layers.l2 import Ether, Dot1Q, ARP -from scapy.layers.inet import IP, UDP, TCP, ICMP, icmptypes, icmpcodes -from util import ppp -from scapy.contrib.mpls import MPLS + VppMplsTable, VppIpTable, VppIpAddress +from vpp_sub_interface import VppSubInterface, VppDot1QSubint, VppDot1ADSubint class TestIPv4(VppTestCase): @@ -134,11 +135,12 @@ class TestIPv4(VppTestCase): UDP(sport=1234, dport=1234)) pkts = [self.modify_packet(src_if, i, pkt_tmpl) - for i in xrange(self.pg_if_packet_sizes[0], - self.pg_if_packet_sizes[1], 10)] + for i in moves.range(self.pg_if_packet_sizes[0], + self.pg_if_packet_sizes[1], 10)] pkts_b = [self.modify_packet(src_if, i, pkt_tmpl) - for i in xrange(self.pg_if_packet_sizes[1] + hdr_ext, - self.pg_if_packet_sizes[2] + hdr_ext, 50)] + for i in moves.range(self.pg_if_packet_sizes[1] + hdr_ext, + self.pg_if_packet_sizes[2] + hdr_ext, + 50)] pkts.extend(pkts_b) return pkts @@ -1094,7 +1096,7 @@ class TestIPPunt(VppTestCase): def setUp(self): super(TestIPPunt, self).setUp() - self.create_pg_interfaces(range(2)) + self.create_pg_interfaces(range(4)) for i in self.pg_interfaces: i.admin_up() @@ -1121,8 +1123,7 @@ class TestIPPunt(VppTestCase): # # Configure a punt redirect via pg1. # - nh_addr = socket.inet_pton(socket.AF_INET, - self.pg1.remote_ip4) + nh_addr = VppIpAddress(self.pg1.remote_ip4).encode() self.vapi.ip_punt_redirect(self.pg0.sw_if_index, self.pg1.sw_if_index, nh_addr) @@ -1180,6 +1181,40 @@ class TestIPPunt(VppTestCase): nh_addr, is_add=0) + def test_ip_punt_dump(self): + """ IP4 punt redirect dump""" + + # + # Configure a punt redirects + # + nh_address = VppIpAddress(self.pg3.remote_ip4).encode() + self.vapi.ip_punt_redirect(self.pg0.sw_if_index, + self.pg3.sw_if_index, + nh_address) + self.vapi.ip_punt_redirect(self.pg1.sw_if_index, + self.pg3.sw_if_index, + nh_address) + self.vapi.ip_punt_redirect(self.pg2.sw_if_index, + self.pg3.sw_if_index, + VppIpAddress('0.0.0.0').encode()) + + # + # Dump pg0 punt redirects + # + punts = self.vapi.ip_punt_redirect_dump(self.pg0.sw_if_index) + for p in punts: + self.assertEqual(p.punt.rx_sw_if_index, self.pg0.sw_if_index) + + # + # Dump punt redirects for all interfaces + # + punts = self.vapi.ip_punt_redirect_dump(0xffffffff) + self.assertEqual(len(punts), 3) + for p in punts: + self.assertEqual(p.punt.tx_sw_if_index, self.pg3.sw_if_index) + self.assertNotEqual(punts[1].punt.nh.un.ip4, self.pg3.remote_ip4) + self.assertEqual(punts[2].punt.nh.un.ip4.address, '\x00'*4) + class TestIPDeag(VppTestCase): """ IPv4 Deaggregate Routes """