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 290151BC3D for ; Thu, 12 Apr 2018 09:45:24 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Apr 2018 00:45:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,440,1517904000"; d="scan'208";a="42730691" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga003.jf.intel.com with ESMTP; 12 Apr 2018 00:45:23 -0700 Received: from fmsmsx112.amr.corp.intel.com (10.18.116.6) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 12 Apr 2018 00:45:23 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX112.amr.corp.intel.com (10.18.116.6) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 12 Apr 2018 00:45:22 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.151]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.43]) with mapi id 14.03.0319.002; Thu, 12 Apr 2018 15:45:21 +0800 From: "Liu, Yong" To: Phil Yang , "dts@dpdk.org" CC: nd Thread-Topic: [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support Thread-Index: AQHTyjU/g+dc41M4vUGzsGD/VddspqPv85mQ//++iACABrsykIAF2qiAgACHv5A= Date: Thu, 12 Apr 2018 07:45:20 +0000 Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E62FFFA46@SHSMSX103.ccr.corp.intel.com> References: <1522406469-9251-1-git-send-email-phil.yang@arm.com> <1522640786-26646-1-git-send-email-phil.yang@arm.com> <86228AFD5BCD8E4EBFD2B90117B5E81E62FE1D1E@SHSMSX103.ccr.corp.intel.com> <86228AFD5BCD8E4EBFD2B90117B5E81E62FF6B96@SHSMSX103.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: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMWVhZWZhNTctY2JjYy00MzZiLTk4MjgtNTY4M2YyZGMyYzdjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJmQ25DcUZtOXJBMHYzZHhKd2E4eFVjQnYrYzRyXC9hR213blExNGN5SlRFaE02VlRhSmM3RGoyalBKbml5Zjd3WiJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.0.116 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 v3 01/17] 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: Thu, 12 Apr 2018 07:45:25 -0000 You're welcome, Phil. Sure, you can send one single patch for v4. > -----Original Message----- > From: Phil Yang [mailto:Phil.Yang@arm.com] > Sent: Thursday, April 12, 2018 3:39 PM > To: Liu, Yong ; dts@dpdk.org > Cc: nd > Subject: RE: [PATCH v3 01/17] framwork/packet: sniff_packet specify > running target support >=20 > Hi Marvin, >=20 > Great idea! I'll Update it. After test, I'll upstream the patch ASAP. >=20 > BTW, Can I just upstream this single patch as V4? Because other files are > keep unchanged. >=20 > Thanks, > Phil Yang >=20 > > -----Original Message----- > > From: Liu, Yong > > Sent: Sunday, April 8, 2018 2:36 PM > > To: Phil Yang ; dts@dpdk.org > > Cc: nd > > Subject: RE: [PATCH v3 01/17] framwork/packet: sniff_packet specify > running > > target support > > > > Hi Phil, > > I think it will be too complicated for each suite handle the temporary > pcap file. > > Packet module is just designed for this kind of purpose. > > There's only need few changes on your v3 patch for fulfilling the need. > > > > Logic for load_tcpdump_sniff_pcap will be pretty clear: > > > > pcap =3D load_pcap_f(index) # just stop sniff process > > self.session.copy_file_from(pcap) # copy from tester to self CRB > > return pcap.split(os.sep)[-1] # return filename > > > > As to load_tcpdump_sniff_packets, I think this function should be > revised since > > pcap file only available after ssh copy. > > > > file=3Dself.load_tcpdump_sniff_pcap(index) > > return packet.load_pcapfile(file) > > > > You may also need to remove load_sniff_packets function in packet modul= e > as it > > will be useless. > > > > Thanks, > > Marvin > > > > > -----Original Message----- > > > From: Phil Yang [mailto:Phil.Yang@arm.com] > > > Sent: Wednesday, April 04, 2018 3:27 PM > > > To: Liu, Yong ; dts@dpdk.org > > > Cc: nd > > > Subject: RE: [PATCH v3 01/17] framwork/packet: sniff_packet specify > > > running target support > > > > > > Hi Marvin, > > > > > > > Filename will be return after running load_pcap_f function, please > > > > use > > > that > > > > name. > > > > It can be multiple sniffer functions work in the same time. > > > > > > If so, I think it is better to copy sniffer pcap file outside > > > load_tcpdump_sniff_pcap and load_tcpdump_sniff_packets function of > > > tester module. > > > I was planning to do it that way in patch V2, but it is need to add > > > tester.session.copy_file_from() operation in each test case. > > > > > > Can I roll back to patch V2? > > > > > > Thanks, > > > Phil Yang > > > > > > > -----Original Message----- > > > > From: Liu, Yong > > > > Sent: Wednesday, April 4, 2018 11:28 AM > > > > To: Phil Yang ; dts@dpdk.org > > > > Cc: nd > > > > Subject: RE: [PATCH v3 01/17] framwork/packet: sniff_packet specify > > > running > > > > target support > > > > > > > > Phil, > > > > Some comments are inline. > > > > > > > > Thanks, > > > > Marvin > > > > > > > > > -----Original Message----- > > > > > From: Phil Yang [mailto:phil.yang@arm.com] > > > > > Sent: Monday, April 02, 2018 11:46 AM > > > > > To: dts@dpdk.org > > > > > Cc: nd@arm.com; Liu, Yong ; phil.yang@arm.com > > > > > Subject: [PATCH v3 01/17] 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 sur= e > > > > > sniff_packet process running on the machine we expected. > > > > > > > > > > Signed-off-by: Phil Yang > > > > > --- > > > > > framework/packet.py | 34 ++++++++++++++++++++++++++++------ > > > > > framework/tester.py | 38 ++++++++++++++++++++++++++++++++++++++ > > > > > 2 files changed, 66 insertions(+), 6 deletions(-) > > > > > > > > > > diff --git a/framework/packet.py b/framework/packet.py index > > > > > 976b82b..484e511 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.STDOUT, > > > > > - shell=3DTrue) > > > > > + > > > > > + # target[] contain the remote machine info for ssh connectio= n > > > > > + # 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; ec= ho > 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) > > > > > diff --git a/framework/tester.py b/framework/tester.py index > > > > > a775f68..10761a8 100755 > > > > > --- a/framework/tester.py > > > > > +++ b/framework/tester.py > > > > > @@ -70,6 +70,7 @@ class Tester(Crb): > > > > > self.bgCmds =3D [] > > > > > self.bgItf =3D '' > > > > > self.re_run_time =3D 0 > > > > > + self.sniff_intf =3D '' > > > > > > > > > > def init_ext_gen(self): > > > > > """ > > > > > @@ -704,6 +705,43 @@ 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()) > > > > > + self.sniff_intf =3D intf > > > > > > > > Indent not align here, and I think there's no need to save sniffer > > > interface in this > > > > module. > > > > > > > > > + 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") > > > > > + self.session.copy_file_from("/tmp/sniff_%s.pcap" % > > > > > +self.sniff_intf, > > > > > "/tmp/") > > > > > + > > > > > > > > Filename will be return after running load_pcap_f function, please > > > > use > > > that > > > > name. > > > > It can be multiple sniffer functions work in the same time. > > > > > > > > > + return load_pcap_f(index) > > > > > + > > > > > + def load_tcpdump_sniff_packets(self, index=3D''): > > > > > + """ > > > > > + Wrapper for packet module load_sniff_packets > > > > > + """ > > > > > + # load functions in packet module > > > > > + module =3D __import__("packet") > > > > > + load_f =3D getattr(module, "load_sniff_packets") > > > > > + self.session.copy_file_from("/tmp/sniff_%s.pcap" % > > > > > +self.sniff_intf, > > > > > "/tmp/") > > > > > + > > > > > + return load_f(index) > > > > > + > > > > > def kill_all(self, killall=3DFalse): > > > > > """ > > > > > Kill all scapy process or DPDK application on tester. > > > > > -- > > > > > 2.7.4