From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id A599CB511 for ; Sun, 15 Feb 2015 02:34:43 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 14 Feb 2015 17:34:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,578,1418112000"; d="scan'208";a="666526383" Received: from pgsmsx108.gar.corp.intel.com ([10.221.44.103]) by fmsmga001.fm.intel.com with ESMTP; 14 Feb 2015 17:34:41 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by PGSMSX108.gar.corp.intel.com (10.221.44.103) with Microsoft SMTP Server (TLS) id 14.3.195.1; Sun, 15 Feb 2015 09:34:15 +0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.197]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.161]) with mapi id 14.03.0195.001; Sun, 15 Feb 2015 09:34:14 +0800 From: "Liu, Yong" To: "Xu, HuilongX" , "dts@dpdk.org" Thread-Topic: [dts] used tcpdum get package replace scapy get package Thread-Index: AQHQSLrU2NKPkfRmf06xQoPo2tiaTZzw5PeA Date: Sun, 15 Feb 2015 01:34:13 +0000 Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E10D7C9D6@SHSMSX103.ccr.corp.intel.com> References: <1423962024-12768-1-git-send-email-huilongx.xu@intel.com> In-Reply-To: <1423962024-12768-1-git-send-email-huilongx.xu@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] used tcpdum get package replace scapy get package X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Feb 2015 01:34:44 -0000 Huilong, please see my comments below. > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of huilongx.xu > Sent: Sunday, February 15, 2015 9:00 AM > To: dts@dpdk.org > Subject: [dts] used tcpdum get package replace scapy get package >=20 > scapy default get package will remove vlan id in package head, > so used linux kernel tcpdum get package form tester port. >=20 > update some variable name >=20 > Signed-off-by: huilongx.xu > --- > tests/TestSuite_vlan.py | 70 ++++++++++++++++++++++++++++++++---------= - > ----- > 1 files changed, 48 insertions(+), 22 deletions(-) >=20 > diff --git a/tests/TestSuite_vlan.py b/tests/TestSuite_vlan.py > index e9813f3..08d03f8 100644 > --- a/tests/TestSuite_vlan.py > +++ b/tests/TestSuite_vlan.py > @@ -51,6 +51,8 @@ class TestVlan(TestCase): >=20 > Vlan Prerequistites > """ > + global dutRxPortId > + global dutTxPortId >=20 > # Based on h/w type, choose how many ports to use > ports =3D self.dut.get_ports(self.nic) > @@ -61,7 +63,8 @@ class TestVlan(TestCase): > ports =3D self.dut.get_ports(self.nic) > global valports > valports =3D [_ for _ in ports if self.tester.get_local_port(_) = !=3D > -1] > - > + dutRxPortId =3D valports[0] > + dutTxPortId =3D valports[1] > portMask =3D dts.create_mask(valports[:2]) >=20 > self.pmdout =3D PmdOutput(self.dut) > @@ -69,21 +72,32 @@ class TestVlan(TestCase): >=20 > self.dut.send_expect("set verbose 1", "testpmd> ") > out =3D self.dut.send_expect("set fwd mac", "testpmd> ") > - self.dut.send_expect("vlan set strip off %s" % valports[0], > "testpmd> ") Please add some comments about why FVL need set promisc off and vlan filter= on. And why FVL has different behavior from other NICs. > + if self.nic in ["fortville_eagle", "fortville_spirit", > "fortville_spirit_single"]: > + self.dut.send_expect("set promisc all off", "testpmd> ") > + self.dut.send_expect("vlan set filter on %s"%dutRxPortId, > "testpmd> ") Please follow python Pep8 code format, you can use pep8 do such check.=20 > + self.dut.send_expect("vlan set strip off %s" % dutRxPortId, > "testpmd> ") > self.verify('Set mac packet forwarding mode' in out, "set fwd > rxonly error") > + def start_tcpdump(self): > + port =3D self.tester.get_local_port(dutTxPortId) > + rxItf =3D self.tester.get_interface(port) >=20 > + self.tester.send_expect("rm -rf ./vlan_test.cap","#") > + self.tester.send_expect("tcpdump -i %s -w ./vlan_test.cap 2> > /dev/null& "%rxItf,"#" ) Better save pcap file in tmp folder. After system reboot, these file will b= e removed automatically. > + def get_tcpdump_package(self): > + self.tester.send_expect("killall tcpdump","#") > + return self.tester.send_expect("tcpdump -nn -e -v - > r ./vlan_test.cap","#") Can we make these two functions into more generic API? Like sniff_packets(self, intf=3D"", count=3D-1, timeout=3D5, filter=3D"") a= nd dump_packets(self, pcap=3D"", filter=3D""). > def vlan_send_packet(self, vid, num=3D1): > """ > Send $num of packet to portid > """ >=20 > - port =3D self.tester.get_local_port(valports[0]) > + port =3D self.tester.get_local_port(dutRxPortId) > txItf =3D self.tester.get_interface(port) >=20 > - port =3D self.tester.get_local_port(valports[1]) > + port =3D self.tester.get_local_port(dutTxPortId) > rxItf =3D self.tester.get_interface(port) >=20 > - mac =3D self.dut.get_mac_address(valports[0]) > + mac =3D self.dut.get_mac_address(dutRxPortId) >=20 > # FIXME send a burst with only num packet > self.tester.scapy_background() > @@ -106,12 +120,16 @@ class TestVlan(TestCase): > Enable receipt of VLAN packets > """ > self.dut.send_expect("set promisc all off", "testpmd> ") > - self.dut.send_expect("rx_vlan add 1 %s" % valports[0], "testpmd> > ") > + self.dut.send_expect("rx_vlan add 1 %s" % dutRxPortId, "testpmd> > ") > + self.dut.send_expect("vlan set strip off %s" % dutRxPortId, > "testpmd> ") > self.dut.send_expect("start", "testpmd> ", 120) > + out =3D self.dut.send_expect("show port info %s" % dutRxPortId, > "testpmd> ", 20) >=20 > + self.start_tcpdump() > self.vlan_send_packet(1) > - out =3D self.tester.scapy_get_result() > - self.verify("vlan=3D1L" in out, "Wrong vlan:" + out) > + > + out =3D self.get_tcpdump_package() > + self.verify("vlan 1" in out, "Wrong vlan:" + out) >=20 > self.dut.send_expect("stop", "testpmd> ") >=20 > @@ -120,13 +138,13 @@ class TestVlan(TestCase): > Disable receipt of VLAN packets > """ >=20 > - self.dut.send_expect("rx_vlan rm 1 %s" % valports[0], "testpmd> = ") > + self.dut.send_expect("rx_vlan rm 1 %s" % dutRxPortId, "testpmd> = ") > self.dut.send_expect("start", "testpmd> ", 120) > - > + self.start_tcpdump() > self.vlan_send_packet(1) >=20 > - out =3D self.tester.scapy_get_result() > - self.verify("vlan=3D1L" not in out, "Wrong vlan:" + out) > + out =3D self.get_tcpdump_package() > + self.verify("vlan 1" not in out, "Wrong vlan:" + out) >=20 > out =3D self.dut.send_expect("stop", "testpmd> ") >=20 > @@ -134,15 +152,17 @@ class TestVlan(TestCase): > """ > Set vlan strip on > """ > - self.dut.send_expect("vlan set strip on %s" % valports[0], > "testpmd> ", 20) > - self.dut.send_expect("set promisc all off", "testpmd> ", 20) > - out =3D self.dut.send_expect("vlan set strip on %s" % valports[0= ], > "testpmd> ", 20) > + self.dut.send_expect("vlan set strip on %s" % dutRxPortId, > "testpmd> ", 20) > + if self.nic in ["fortville_eagle", "fortville_spirit", > "fortville_spirit_single"]: > + self.dut.send_expect("rx_vlan add 1 %s" % dutRxPortId, > "testpmd> ", 20) > + out =3D self.dut.send_expect("show port info %s" % dutRxPortId, > "testpmd> ", 20) > self.verify("strip on" in out, "Wrong strip:" + out) >=20 > self.dut.send_expect("start", "testpmd> ", 120) > + self.start_tcpdump() > self.vlan_send_packet(1) > - out =3D self.tester.scapy_get_result() > - self.verify("vlan=3D1L" not in out, "Wrong vlan:" + out) > + out =3D self.get_tcpdump_package() > + self.verify("vlan 1" not in out, "Wrong vlan:" + out) > out =3D self.dut.send_expect("quit", "#", 120) >=20 > def test_vlan_strip_config_off(self): > @@ -150,14 +170,17 @@ class TestVlan(TestCase): > Set vlan strip off > """ >=20 > - self.dut.send_expect("vlan set strip off %s" % valports[0], > "testpmd> ", 20) > - out =3D self.dut.send_expect("show port info %s" % valports[0], > "testpmd> ", 20) > + self.dut.send_expect("vlan set strip off %s" % dutRxPortId, > "testpmd> ", 20) > + if self.nic in ["fortville_eagle", "fortville_spirit", > "fortville_spirit_single"]: > + self.dut.send_expect("rx_vlan add 1 %s" % dutRxPortId, > "testpmd> ", 20) > + out =3D self.dut.send_expect("show port info %s" % dutRxPortId, > "testpmd> ", 20) Please add some comments about when FVL need add rx vlan here. > self.verify("strip off" in out, "Wrong strip:" + out) > self.dut.send_expect("set nbport 2", "testpmd> ") > self.dut.send_expect("start", "testpmd> ", 120) > + self.start_tcpdump() > self.vlan_send_packet(1) > - out =3D self.tester.scapy_get_result() > - self.verify("vlan=3D1L" in out, "Wrong strip vlan:" + out) > + out =3D self.get_tcpdump_package() > + self.verify("vlan 1" in out, "Wrong strip vlan:" + out) > out =3D self.dut.send_expect("stop", "testpmd> ", 120) >=20 > def FAILING_test_vlan_enable_vlan_insertion(self): > @@ -187,7 +210,10 @@ class TestVlan(TestCase): >=20 > out =3D self.tester.scapy_get_result() > self.verify("vlan=3D1L" in out, "Wrong vlan: " + out) > - self.dut.send_expect("quit", "# ", 30) > + if self.nic in ["fortville_eagle", "fortville_spirit", > "fortville_spirit_single"]: > + self.dut.send_expect("stop", "testpmd> ", 30) > + else: > + self.dut.send_expect("quit", "# ", 30) >=20 > def tear_down(self): > """ > -- > 1.7.4.4