From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0055.outbound.protection.outlook.com [104.47.1.55]) by dpdk.org (Postfix) with ESMTP id 2E7B21B785 for ; Wed, 4 Apr 2018 09:27:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=hElWbzvKdosMA49SdrsyfwQ+gI2rFlIGcwIbZHlkzsw=; b=natJAsQ/Doy7epe1XtxM+csZRFusQpkDZJxIl4HMFcPm30pkAGY3z+0oHjJbs0U2KpHv0FCGCNvv27EENKoB+owcZagFQbLgdnTBewUOLJoZ8PHMmVk+BQIa5fAkORhuIJQuf0xjeAYBhjWLnN7OWKCATusRmGFizXUnyget5S4= Received: from AM4PR08MB0913.eurprd08.prod.outlook.com (10.166.133.135) by AM4PR08MB2756.eurprd08.prod.outlook.com (10.171.190.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.631.10; Wed, 4 Apr 2018 07:27:05 +0000 Received: from AM4PR08MB0913.eurprd08.prod.outlook.com ([fe80::3418:15f6:2cf7:e5ef]) by AM4PR08MB0913.eurprd08.prod.outlook.com ([fe80::3418:15f6:2cf7:e5ef%4]) with mapi id 15.20.0653.012; Wed, 4 Apr 2018 07:27:04 +0000 From: Phil Yang To: "Liu, Yong" , "dts@dpdk.org" CC: nd Thread-Topic: [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support Thread-Index: AQHTyjU1/OS+Q60M60Sohrb6BfABsKPv9YUAgAA0hoA= Date: Wed, 4 Apr 2018 07:27:04 +0000 Message-ID: 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> In-Reply-To: <86228AFD5BCD8E4EBFD2B90117B5E81E62FE1D1E@SHSMSX103.ccr.corp.intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Phil.Yang@arm.com; x-originating-ip: [113.29.88.7] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM4PR08MB2756; 7:gkkhZSUhxA+qDQdVnlNn89gXC2fjN3MweARwT9+/yBKUHAEJU7xI4yA0tRYYpTUzY6AG9Jb3GzTcwgERO95YN+AzK0GpeoQ7LG/duT5UJZS8YZKzU6xjO8mi5hJDAeoYSMRCFfurWfHMlhP+s0GVmXPpLrC37HHRVpd4osQwG0a0UwjIXGjLXdTozc9xXyBX98aViDx21w72N9lWLMslzxKDy58vgvQPNjh49MBLjWutL4q1bIrskRLiymHMHgXZ x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 35d3c0b3-5076-4e35-17f5-08d599fd7741 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:AM4PR08MB2756; x-ms-traffictypediagnostic: AM4PR08MB2756: nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231221)(944501327)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(6072148)(201708071742011); SRVR:AM4PR08MB2756; BCL:0; PCL:0; RULEID:; SRVR:AM4PR08MB2756; x-forefront-prvs: 0632519F33 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39380400002)(396003)(366004)(346002)(376002)(39860400002)(13464003)(199004)(189003)(229853002)(2501003)(68736007)(14454004)(25786009)(5250100002)(2906002)(97736004)(33656002)(4326008)(81156014)(3660700001)(106356001)(551544002)(105586002)(2900100001)(81166006)(3280700002)(8936002)(72206003)(8676002)(53936002)(6246003)(53546011)(6116002)(476003)(66066001)(6436002)(7736002)(74316002)(55016002)(305945005)(186003)(5660300001)(3846002)(446003)(316002)(102836004)(110136005)(7696005)(55236004)(76176011)(6506007)(59450400001)(11346002)(86362001)(9686003)(26005)(99286004)(486006)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR08MB2756; H:AM4PR08MB0913.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: /KOq494q6mUYjf9hQybLzxwr8lCr1Na4PWBvIJGIH2EtXqPoEAKcnQ/8OiXxXZ/uKd5Grphm+a1HgoKkYZmuFJS10F2P+7vWQEmh2Wu9eNCM3tBtjlr3vVcrwUGHiVzO0nfq3FiobzbpSTxgFlWpPvkPhmzZuPkznLvMyO0u3vS+95LpMBnormV7xV4bIO3GRc3VEPeJDsh3b/03mfylKILnbHEeUsXMvqgE+Y7CKh/Q2ldnhm9/+79rPz/tDMjzakqAa9HT7Sm4BY/KiwLdn0BE5UCOR1NWd+38EvZZ97mwJoXehtpF1AWjAtrMSYxPwPrmrVY2SXWSWWpLj1aqypCSeUKuDuEDxgH38aXDAnqBDswngoGvnIELklqtmueA107wukwMX3vD4/JAWyWmTzAs7MG4j7fiRNK/e70ZeHc= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 35d3c0b3-5076-4e35-17f5-08d599fd7741 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Apr 2018 07:27:04.8222 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR08MB2756 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: Wed, 04 Apr 2018 07:27:06 -0000 Hi Marvin, > Filename will be return after running load_pcap_f function, please use th= at > 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 runni= ng > target support >=20 > Phil, > Some comments are inline. >=20 > Thanks, > Marvin >=20 > > -----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 sure > > 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 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) > > 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, filt= ers=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 >=20 > Indent not align here, and I think there's no need to save sniffer interf= ace in this > module. >=20 > > + 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/") > > + >=20 > Filename will be return after running load_pcap_f function, please use th= at > name. > It can be multiple sniffer functions work in the same time. >=20 > > + 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