From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0046.outbound.protection.outlook.com [104.47.1.46]) by dpdk.org (Postfix) with ESMTP id 1066FF11 for ; Tue, 4 Sep 2018 10:34:38 +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:X-MS-Exchange-SenderADCheck; bh=j250FbZPG/JgCaoRk+Yuzqm+2hIVOAyBOS5p6D0f2V8=; b=pbcUNKPgrRaatAp5wlQ6FAy5c0lgObrqHm7GtVcHnPrnBtyO5G9kdFk9awJ+/J9tFXjFBloDOqht4VkdlaavdCUOo5kDOjP5bUx2gQ40JeDWf8uF3T0AVOJiHc3TWCxniNimKCfNeQB3rNuO3ictZ4oqJkUAYj+PdvRI0nQpjWo= Received: from DB7PR08MB3385.eurprd08.prod.outlook.com (20.176.238.90) by DB7PR08MB3193.eurprd08.prod.outlook.com (52.134.110.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1101.17; Tue, 4 Sep 2018 08:34:36 +0000 Received: from DB7PR08MB3385.eurprd08.prod.outlook.com ([fe80::f0e6:1c3d:9285:472f]) by DB7PR08MB3385.eurprd08.prod.outlook.com ([fe80::f0e6:1c3d:9285:472f%2]) with mapi id 15.20.1101.016; Tue, 4 Sep 2018 08:34:36 +0000 From: "Phil Yang (Arm Technology China)" To: "Liu, Yong" , "dts@dpdk.org" CC: nd Thread-Topic: [PATCH v4] framwork/packet: sniff_packet specify running target support Thread-Index: AQHT1t2+WHPGponvIEiHM4wZ53zBKaTgpU1A Date: Tue, 4 Sep 2018 08:34:35 +0000 Message-ID: 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: <86228AFD5BCD8E4EBFD2B90117B5E81E63011A25@SHSMSX101.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; DB7PR08MB3193; 6:BUYQwoIowaHEvmeIrhs3Yh4Xz3k4DB2usBX/hzaavSnPRA03wB4yy3ghEC3opsAOmS2eyJZbAtEQSxrzwEtaML/apoayr3glBFnvACc34uCq3Yk2SDGN4NmNyU5LEj6qD9j3N7h+LKjF+SiPwuaKKsLh7iW0/DIA22jA1DnxnYtkVYljBtxgTkXDv3vEnaSGVKI0/t4o3n9NEwQ1ZtQfEBiNdJaYNvlwYQTzXZAM8xgePeuZ9AMG5YIrOTWfrTeV4JzFmz8HzEZUnMvnnYVhUxV+xqGyDOFO5lDYbVoK03uJO9NvbRz/8aslNfRqm3MATebcH7ORsSMueQx/O4Si30hPhXFmNYK6p42CXzc8vlqt17nsmm7kyQQ+x4Yo0KWl40AOKxVltK/xEf67MdbadaYvC/+eR9KULFdDXn+/vv4mhhp3oocTBJx1IWKE1Z8DqE2leUzCA4SeUlteuiE26g==; 5:PelV9wvuwefCRDmgyhzC41H4gFiq0DNZs8mds9k7RFlf1tUUABVcSFpsAS724ccybMNw2nbvRkrkHJaGzFJdC9F87R+MVCxR0nCJnjO3tP71DlYY2PULIaS4LFuqNIaUhgszAPl7sGLHnkkSVk/dr9LIZJ+IAhJj9iY8okR+Rcc=; 7:ZIaOxgbmBzuS8i2PLROQ6T6w6XcguvpXGUH6qHekALWEIjjZYkX+pfE4AltO5xbrUcXxfbdZkbz+6iPTtQr4d2WxF3Vc5ZgLm9h34C6Wdhx89ow0c8eQknV8yBn/r5AJ/bxtBo/LLz61yu3vrXWvWe/bb25ySPWH3m9mHBgU6Qv/77kxmFa7RubXJXpfp1xQbiv8AgePLOeHPmKP7U7GkQrNnEw7X7riytRasJ/jxwWcWxPVVyPyTqp49881YpXX x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 4699643c-6875-42ea-8bee-08d612413f3a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB7PR08MB3193; x-ms-traffictypediagnostic: DB7PR08MB3193: nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917)(228905959029699); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(823301075)(93006095)(93001095)(3002001)(3231311)(944501410)(52105095)(10201501046)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699016); SRVR:DB7PR08MB3193; BCL:0; PCL:0; RULEID:; SRVR:DB7PR08MB3193; x-forefront-prvs: 0785459C39 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(39860400002)(376002)(136003)(346002)(366004)(13464003)(199004)(189003)(6116002)(9686003)(2900100001)(55016002)(72206003)(26005)(97736004)(66066001)(551544002)(476003)(305945005)(86362001)(486006)(3846002)(5250100002)(7736002)(74316002)(11346002)(2501003)(446003)(8676002)(14454004)(55236004)(53936002)(8936002)(25786009)(316002)(68736007)(6246003)(81156014)(81166006)(6436002)(110136005)(106356001)(105586002)(4326008)(102836004)(229853002)(14444005)(256004)(99286004)(7696005)(53546011)(478600001)(5660300001)(76176011)(186003)(33656002)(6506007)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR08MB3193; H:DB7PR08MB3385.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: sWbxNONRHZBA07HoSdq00B35P4riCyqLxDffsVk/lbvjiMLoXilpnDOk0thDr2YIXO4DwU3vj/uh2MC4fpsVUk6EhXfb98dCUhKKz+UwT2RsH9g+o3UOLoNzI9aCAnZV6WTGTuhfy3wWpDxclRodMrjrfPhFst5IiFIjPJqJ2E0vVmfDED8FbHW0n1GvJVVh+PG8791JSNSpcatXIsDq2D9pSINJ4dq2S3Xyye/LKDqTMStGFa0ja6U5gRzurW++2HbocpR+cvKm/nd3Lmx3di6HmaN5HT7RfCmcDTA5rAhevqeDmqzOc5OI6Atu5xaj6GjKbsWEi+sVgfmwv9uIAP/uIPpka2rBo5kJHTKWCPE= 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: 4699643c-6875-42ea-8bee-08d612413f3a X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Sep 2018 08:34:36.1229 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3193 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:34:38 -0000 Hi Marvin, Apologize for hung up this thread such a long time.=20 I have upstreamed the patch set version 5th, which solved the two issues yo= u had pointed out. Please review it. Thanks, Phil Yang > -----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 tar= get > support >=20 > Hi Phil, > I tried your patch set and met such issues. >=20 > 1. load_sniff_packet function will send signal to child process to stop s= niff. But > this method will not work with remote ssh. After received signal only ssh= process > is exited and meanwhile tcpdump process is still alive. >=20 > 2. In v3 patch set, code for import packet module has been remove. That w= ill > cause some suites can't run. >=20 > Thanks, > Marvin >=20 > > -----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.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) > > @@ -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, 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()) > > + 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