From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 47A851BE0 for ; Tue, 4 Sep 2018 10:50:58 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Sep 2018 01:50:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,328,1531810800"; d="scan'208";a="68213722" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga008.fm.intel.com with ESMTP; 04 Sep 2018 01:50:52 -0700 Received: from fmsmsx120.amr.corp.intel.com (10.18.124.208) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 4 Sep 2018 01:50:52 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by fmsmsx120.amr.corp.intel.com (10.18.124.208) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 4 Sep 2018 01:50:51 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.240]) by shsmsx102.ccr.corp.intel.com ([169.254.2.226]) with mapi id 14.03.0319.002; Tue, 4 Sep 2018 16:50:49 +0800 From: "Liu, Yong" To: "Phil Yang (Arm Technology China)" , "dts@dpdk.org" CC: nd Thread-Topic: [PATCH v4] framwork/packet: sniff_packet specify running target support Thread-Index: AQHT0kQfr6Wb/Ztdo0uAHUGdHzgDpKQGFJHwgNoVAoCAAIlnUA== Date: Tue, 4 Sep 2018 08:50:49 +0000 Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E6313275D@SHSMSX103.ccr.corp.intel.com> References: <1522640786-26646-1-git-send-email-phil.yang@arm.com> <1523526771-7437-1-git-send-email-phil.yang@arm.com> <86228AFD5BCD8E4EBFD2B90117B5E81E63011A25@SHSMSX101.ccr.corp.intel.com> In-Reply-To: Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYWUyNmM4NTctZGNiOS00OWRiLWE2ZTMtNmJmMzhhYzA5ZDQ1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiZUQ3ckRUYWdHc3NLYmxyUDJBN0Z3Z0I0aEhZMnkzR2czbEdUQjAwUzhmN1hXcm05Rnk1K2JXc1lcL2JIQUZlZ0IifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action 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] [PATCH v4] framwork/packet: sniff_packet specify running target support 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: Tue, 04 Sep 2018 08:50:59 -0000 Phil, thanks for your great contribution in DTS project. Always can see gre= at ideas from you:) Regards, Marvin > -----Original Message----- > From: Phil Yang (Arm Technology China) [mailto:Phil.Yang@arm.com] > Sent: Tuesday, September 04, 2018 4:35 PM > To: Liu, Yong ; dts@dpdk.org > Cc: nd > Subject: RE: [PATCH v4] framwork/packet: sniff_packet specify running tar= get > support >=20 > Hi Marvin, >=20 > Apologize for hung up this thread such a long time. >=20 > I have upstreamed the patch set version 5th, which solved the two issues = you > had pointed out. >=20 > Please review it. >=20 > Thanks, > Phil Yang >=20 > > -----Original Message----- > > From: Liu, Yong > > Sent: Wednesday, April 18, 2018 2:23 PM > > To: Phil Yang ; dts@dpdk.org > > Cc: nd > > Subject: RE: [PATCH v4] framwork/packet: sniff_packet specify running > target > > support > > > > Hi Phil, > > I tried your patch set and met such issues. > > > > 1. load_sniff_packet function will send signal to child process to stop > sniff. But > > this method will not work with remote ssh. After received signal only s= sh > process > > is exited and meanwhile tcpdump process is still alive. > > > > 2. In v3 patch set, code for import packet module has been remove. That > will > > cause some suites can't run. > > > > Thanks, > > Marvin > > > > > -----Original Message----- > > > From: Phil Yang [mailto:phil.yang@arm.com] > > > Sent: Thursday, April 12, 2018 5:53 PM > > > To: dts@dpdk.org > > > Cc: nd@arm.com; Liu, Yong > > > Subject: [PATCH v4] framwork/packet: sniff_packet specify running > > > target support > > > > > > If tester in crb file was not the machine which running dts, the > > > sniff_packet process will not running on tester. > > > > > > Create a ssh connection to the tester and run tcpdump to make sure > > > sniff_packet process running on the machine we expected. > > > > > > Removed load_sniff_packets function in packet module as it will be > > > useless. > > > > > > Signed-off-by: Phil Yang > > > Suggested-by: Marvin Liu > > > --- > > > framework/packet.py | 70 > > > +++++++++++++++++++++--------------------------- > > > ----- > > > framework/tester.py | 37 ++++++++++++++++++++++++++++ > > > 2 files changed, 65 insertions(+), 42 deletions(-) > > > > > > diff --git a/framework/packet.py b/framework/packet.py index > > > 976b82b..f99ead8 100755 > > > --- a/framework/packet.py > > > +++ b/framework/packet.py > > > @@ -812,15 +812,30 @@ def get_filter_cmd(filters=3D[]): > > > return "" > > > > > > > > > -def sniff_packets(intf, count=3D0, timeout=3D5, filters=3D[]): > > > +def sniff_packets(intf, count=3D0, timeout=3D5, filters=3D[], target= =3D[]): > > > """ > > > sniff all packets for certain port in certain seconds > > > """ > > > param =3D "" > > > direct_param =3D r"(\s+)\[ (\S+) in\|out\|inout \]" > > > - tcpdump_help =3D subprocess.check_output("tcpdump -h; echo 0", > > > - stderr=3Dsubprocess.STDOU= T, > > > - shell=3DTrue) > > > + > > > + # target[] contain the remote machine info for ssh connection > > > + # target[0]: username > > > + # target[1]: ip address > > > + # target[2]: pass word > > > + if target: > > > + tcpdump_help_pipe =3D subprocess.Popen(["ssh", > > > + "%s@%s" % (target[0], target[1]), > > > + "tcpdump -h"], > > > + stderr=3Dsubprocess.PIPE, > > > + stdout=3Dsubprocess.PIPE, > > > + shell=3DFalse) > > > + tcpdump_help =3D "".join(tuple(tcpdump_help_pipe.communicate= ())) > > > + tcpdump_help_pipe.wait() > > > + else: > > > + tcpdump_help =3D subprocess.check_output("tcpdump -h; echo 0= ", > > > + stderr=3Dsubprocess.STDOUT, > > > + shell=3DTrue) > > > + > > > for line in tcpdump_help.split('\n'): > > > m =3D re.match(direct_param, line) > > > if m: > > > @@ -850,9 +865,16 @@ def sniff_packets(intf, count=3D0, timeout=3D5, > > > filters=3D[]): > > > else: > > > cmd =3D sniff_cmd % options > > > > > > - args =3D shlex.split(cmd) > > > + if target: > > > + pipe =3D subprocess.Popen(["ssh", > > > + "%s@%s" % (target[0], target[1]), > > > + cmd], > > > + stdin=3Dsubprocess.PIPE, > > > + shell=3DFalse) > > > + else: > > > + args =3D shlex.split(cmd) > > > + pipe =3D subprocess.Popen(args) > > > > > > - pipe =3D subprocess.Popen(args) > > > index =3D str(time.time()) > > > SNIFF_PIDS[index] =3D (pipe, intf, timeout) > > > time.sleep(1) > > > @@ -886,42 +908,6 @@ def load_sniff_pcap(index=3D''): > > > return "" > > > > > > > > > -def load_sniff_packets(index=3D''): > > > - """ > > > - Stop sniffer and return packet objects > > > - """ > > > - pkts =3D [] > > > - child_exit =3D False > > > - if index in SNIFF_PIDS.keys(): > > > - pipe, intf, timeout =3D SNIFF_PIDS[index] > > > - time_elapse =3D int(time.time() - float(index)) > > > - while time_elapse < timeout: > > > - if pipe.poll() is not None: > > > - child_exit =3D True > > > - break > > > - > > > - time.sleep(1) > > > - time_elapse +=3D 1 > > > - > > > - if not child_exit: > > > - pipe.send_signal(signal.SIGINT) > > > - pipe.wait() > > > - > > > - # wait pcap file ready > > > - time.sleep(1) > > > - try: > > > - cap_pkts =3D rdpcap("/tmp/sniff_%s.pcap" % intf) > > > - for pkt in cap_pkts: > > > - # packet gen should be scapy > > > - packet =3D Packet(tx_port=3Dintf) > > > - packet.pktgen.assign_pkt(pkt) > > > - pkts.append(packet) > > > - except: > > > - pass > > > - > > > - return pkts > > > - > > > - > > > def load_pcapfile(filename=3D""): > > > pkts =3D [] > > > try: > > > diff --git a/framework/tester.py b/framework/tester.py index > > > a775f68..c787b89 100755 > > > --- a/framework/tester.py > > > +++ b/framework/tester.py > > > @@ -35,6 +35,7 @@ Interface for bulk traffic generators. > > > > > > import re > > > import subprocess > > > +import os > > > from time import sleep > > > from settings import NICS, load_global_setting, PERF_SETTING from > > > crb import Crb @@ -704,6 +705,42 @@ class Tester(Crb): > > > self.proc.kill() > > > self.proc =3D None > > > > > > + def tcpdump_sniff_packets(self, intf, count=3D0, timeout=3D5, > filters=3D[]): > > > + """ > > > + Wrapper for packet module sniff_packets > > > + """ > > > + # load functions in packet module > > > + module =3D __import__("packet") > > > + sniff_f =3D getattr(module, "sniff_packets") > > > + > > > + target=3D[] > > > + target.append(self.get_username()) > > > + target.append(self.get_ip_address()) > > > + target.append(self.get_password()) > > > + return sniff_f(intf, count, timeout, filters, target) > > > + > > > + def load_tcpdump_sniff_pcap(self, index=3D''): > > > + """ > > > + Wrapper for packet module load_sniff_pcap > > > + """ > > > + # load functions in packet module > > > + module =3D __import__("packet") > > > + load_pcap_f =3D getattr(module, "load_sniff_pcap") > > > + pcap =3D load_pcap_f(index) > > > + self.session.copy_file_from(pcap) > > > + > > > + return pcap.split(os.sep)[-1] > > > + > > > + def load_tcpdump_sniff_packets(self, index=3D''): > > > + """ > > > + Wrapper for packet module load_sniff_packets > > > + """ > > > + # load functions in packet module > > > + packet =3D __import__("packet") > > > + file =3D self.load_tcpdump_sniff_pcap(index) > > > + > > > + return packet.load_pcapfile(file) > > > + > > > def kill_all(self, killall=3DFalse): > > > """ > > > Kill all scapy process or DPDK application on tester. > > > -- > > > 2.7.4