test suite reviews and discussions
 help / color / mirror / Atom feed
From: "Liu, Yong" <yong.liu@intel.com>
To: Phil Yang <Phil.Yang@arm.com>, "dts@dpdk.org" <dts@dpdk.org>
Cc: nd <nd@arm.com>
Subject: Re: [dts] [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support
Date: Sun, 8 Apr 2018 06:35:56 +0000	[thread overview]
Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E62FF6B96@SHSMSX103.ccr.corp.intel.com> (raw)
In-Reply-To: <AM4PR08MB0913397FF3477B08829F1227E9A40@AM4PR08MB0913.eurprd08.prod.outlook.com>

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 = 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=self.load_tcpdump_sniff_pcap(index)
	return packet.load_pcapfile(file)

You may also need to remove load_sniff_packets function in packet module 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 <yong.liu@intel.com>; dts@dpdk.org
> Cc: nd <nd@arm.com>
> 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 <yong.liu@intel.com>
> > Sent: Wednesday, April 4, 2018 11:28 AM
> > To: Phil Yang <Phil.Yang@arm.com>; dts@dpdk.org
> > Cc: nd <nd@arm.com>
> > 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 <yong.liu@intel.com>; 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 <phil.yang@arm.com>
> > > ---
> > >  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=[]):
> > >          return ""
> > >
> > >
> > > -def sniff_packets(intf, count=0, timeout=5, filters=[]):
> > > +def sniff_packets(intf, count=0, timeout=5, filters=[], target=[]):
> > >      """
> > >      sniff all packets for certain port in certain seconds
> > >      """
> > >      param = ""
> > >      direct_param = r"(\s+)\[ (\S+) in\|out\|inout \]"
> > > -    tcpdump_help = subprocess.check_output("tcpdump -h; echo 0",
> > > -                                           stderr=subprocess.STDOUT,
> > > -                                           shell=True)
> > > +
> > > +    # 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 = subprocess.Popen(["ssh",
> > > +                            "%s@%s" % (target[0], target[1]),
> > > +                            "tcpdump -h"],
> > > +                            stderr=subprocess.PIPE,
> > > +                            stdout=subprocess.PIPE,
> > > +                            shell=False)
> > > +        tcpdump_help = "".join(tuple(tcpdump_help_pipe.communicate()))
> > > +        tcpdump_help_pipe.wait()
> > > +    else:
> > > +        tcpdump_help = subprocess.check_output("tcpdump -h; echo 0",
> > > +                                    stderr=subprocess.STDOUT,
> > > + shell=True)
> > > +
> > >      for line in tcpdump_help.split('\n'):
> > >          m = re.match(direct_param, line)
> > >          if m:
> > > @@ -850,9 +865,16 @@ def sniff_packets(intf, count=0, timeout=5,
> > > filters=[]):
> > >      else:
> > >          cmd = sniff_cmd % options
> > >
> > > -    args = shlex.split(cmd)
> > > +    if target:
> > > +        pipe = subprocess.Popen(["ssh",
> > > +                "%s@%s" % (target[0], target[1]),
> > > +                cmd],
> > > +                stdin=subprocess.PIPE,
> > > +                shell=False)
> > > +    else:
> > > +        args = shlex.split(cmd)
> > > +        pipe = subprocess.Popen(args)
> > >
> > > -    pipe = subprocess.Popen(args)
> > >      index = str(time.time())
> > >      SNIFF_PIDS[index] = (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 = []
> > >          self.bgItf = ''
> > >          self.re_run_time = 0
> > > +	self.sniff_intf = ''
> > >
> > >      def init_ext_gen(self):
> > >          """
> > > @@ -704,6 +705,43 @@ class Tester(Crb):
> > >              self.proc.kill()
> > >              self.proc = None
> > >
> > > +    def tcpdump_sniff_packets(self, intf, count=0, timeout=5,
> filters=[]):
> > > +        """
> > > +        Wrapper for packet module sniff_packets
> > > +        """
> > > +        # load functions in packet module
> > > +        module = __import__("packet")
> > > +        sniff_f = getattr(module, "sniff_packets")
> > > +
> > > +        target=[]
> > > +        target.append(self.get_username())
> > > +        target.append(self.get_ip_address())
> > > +        target.append(self.get_password())
> > > +	self.sniff_intf = 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=''):
> > > +        """
> > > +        Wrapper for packet module load_sniff_pcap
> > > +        """
> > > +        # load functions in packet module
> > > +        module = __import__("packet")
> > > +        load_pcap_f = 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=''):
> > > +        """
> > > +        Wrapper for packet module load_sniff_packets
> > > +        """
> > > +        # load functions in packet module
> > > +        module = __import__("packet")
> > > +        load_f = 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=False):
> > >          """
> > >          Kill all scapy process or DPDK application on tester.
> > > --
> > > 2.7.4

  reply	other threads:[~2018-04-08  6:36 UTC|newest]

Thread overview: 124+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-23  8:03 [dts] [PATCH 01/17] framwork/packet: Add sniff_packet specify running Phil Yang
2018-03-23  8:03 ` [dts] [PATCH 02/17] tests/checksum_offload: Replaced sniff_packet to tester.tcpdump_sniff_packet Phil Yang
2018-03-23  8:03 ` [dts] [PATCH 03/17] tests/etag: " Phil Yang
2018-03-23  8:03 ` [dts] [PATCH 04/17] tests/ipfrag: " Phil Yang
2018-03-23  8:03 ` [dts] [PATCH 05/17] tests/l2fwd_crypto: Replaced sniff_packets to tester.tcpdump_sniff_packets Phil Yang
2018-03-23  8:03 ` [dts] [PATCH 06/17] tests/netmap_compat: Replaced sniff_packet to tester.tcpdump_sniff_packet Phil Yang
2018-03-23  8:03 ` [dts] [PATCH 07/17] tests/queue_start_stop: Replaced sniff_packets to tester.tcpdump_sniff_packets Phil Yang
2018-03-23  8:03 ` [dts] [PATCH 08/17] tests/quota_watermark: " Phil Yang
2018-03-23  8:03 ` [dts] [PATCH 09/17] tests/rxtx_callback: " Phil Yang
2018-03-23  8:03 ` [dts] [PATCH 10/17] tests/scatter: " Phil Yang
2018-03-23  8:04 ` [dts] [PATCH 11/17] tests/keleton: " Phil Yang
2018-03-23  8:04 ` [dts] [PATCH 12/17] tests/userspace_ethtool: " Phil Yang
2018-03-23  8:04 ` [dts] [PATCH 13/17] tests/vf_daemon: " Phil Yang
2018-03-23  8:04 ` [dts] [PATCH 14/17] tests/vf_vlan: " Phil Yang
2018-03-23  8:04 ` [dts] [PATCH 15/17] tests/vlan_ethertype_config: " Phil Yang
2018-03-23  8:04 ` [dts] [PATCH 16/17] tests/vlan: " Phil Yang
2018-03-23  8:04 ` [dts] [PATCH 17/17] tests/ipgre: " Phil Yang
2018-03-28  2:41 ` [dts] [PATCH 01/17] framwork/packet: Add sniff_packet specify running Liu, Yong
2018-03-28  6:34   ` Phil Yang
2018-03-29  2:31     ` Liu, Yong
2018-03-29  2:35       ` Phil Yang
2018-03-30 10:40 ` [dts] [PATCH v2 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
2018-03-30 10:40   ` [dts] [PATCH v2 02/17] tests/checksum_offload: Replace sniff_packet to tester.tcpdump_sniff_packet Phil Yang
2018-03-30 10:40   ` [dts] [PATCH v2 03/17] tests/etag: " Phil Yang
2018-03-30 10:40   ` [dts] [PATCH v2 04/17] tests/ipfrag: " Phil Yang
2018-03-30 10:40   ` [dts] [PATCH v2 05/17] tests/l2fwd_crypto: Replace sniff_packets to tester.tcpdump_sniff_packets Phil Yang
2018-03-30 10:40   ` [dts] [PATCH v2 06/17] tests/netmap_compat: Replace sniff_packet to tester.tcpdump_sniff_packet Phil Yang
2018-03-30 10:40   ` [dts] [PATCH v2 07/17] tests/queue_start_stop: Replace sniff_packets to tester.tcpdump_sniff_packets Phil Yang
2018-03-30 10:41   ` [dts] [PATCH v2 08/17] tests/quota_watermark: " Phil Yang
2018-03-30 10:41   ` [dts] [PATCH v2 09/17] tests/rxtx_callback: " Phil Yang
2018-03-30 10:41   ` [dts] [PATCH v2 10/17] tests/scatter: " Phil Yang
2018-03-30 10:41   ` [dts] [PATCH v2 11/17] tests/skeleton: " Phil Yang
2018-03-30 10:41   ` [dts] [PATCH v2 12/17] tests/userspace_ethtool: " Phil Yang
2018-03-30 10:41   ` [dts] [PATCH v2 13/17] tests/vf_daemon: " Phil Yang
2018-03-30 10:41   ` [dts] [PATCH v2 14/17] tests/vf_vlan: " Phil Yang
2018-03-30 10:41   ` [dts] [PATCH v2 15/17] tests/vlan_ethertype_config: " Phil Yang
2018-03-30 10:41   ` [dts] [PATCH v2 16/17] tests/vlan: " Phil Yang
2018-03-30 10:41   ` [dts] [PATCH v2 17/17] tests/ipgre: " Phil Yang
2018-04-02  3:46   ` [dts] [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
2018-04-02  3:46     ` [dts] [PATCH v3 02/17] tests/checksum_offload: Replace sniff_packet to tester.tcpdump_sniff_packet Phil Yang
2018-04-02  3:46     ` [dts] [PATCH v3 03/17] tests/etag: " Phil Yang
2018-04-02  3:46     ` [dts] [PATCH v3 04/17] tests/ipfrag: " Phil Yang
2018-04-02  3:46     ` [dts] [PATCH v3 05/17] tests/l2fwd_crypto: Replace sniff_packets to tester.tcpdump_sniff_packets Phil Yang
2018-04-02  3:46     ` [dts] [PATCH v3 06/17] tests/netmap_compat: Replace sniff_packet to tester.tcpdump_sniff_packet Phil Yang
2018-04-02  3:46     ` [dts] [PATCH v3 07/17] tests/queue_start_stop: Replace sniff_packets to tester.tcpdump_sniff_packets Phil Yang
2018-04-02  3:46     ` [dts] [PATCH v3 08/17] tests/quota_watermark: " Phil Yang
2018-04-02  3:46     ` [dts] [PATCH v3 09/17] tests/rxtx_callback: " Phil Yang
2018-04-02  3:46     ` [dts] [PATCH v3 10/17] tests/scatter: " Phil Yang
2018-04-02  3:46     ` [dts] [PATCH v3 11/17] tests/skeleton: " Phil Yang
2018-04-02  3:46     ` [dts] [PATCH v3 12/17] tests/userspace_ethtool: " Phil Yang
2018-04-02  3:46     ` [dts] [PATCH v3 13/17] tests/vf_daemon: " Phil Yang
2018-04-02  3:46     ` [dts] [PATCH v3 14/17] tests/vf_vlan: " Phil Yang
2018-04-02  3:46     ` [dts] [PATCH v3 15/17] tests/vlan_ethertype_config: " Phil Yang
2018-04-02  3:46     ` [dts] [PATCH v3 16/17] tests/vlan: " Phil Yang
2018-04-02  3:46     ` [dts] [PATCH v3 17/17] tests/ipgre: " Phil Yang
2018-04-04  3:28     ` [dts] [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support Liu, Yong
2018-04-04  7:27       ` Phil Yang
2018-04-08  6:35         ` Liu, Yong [this message]
2018-04-12  7:38           ` Phil Yang
2018-04-12  7:45             ` Liu, Yong
2018-04-12  9:52     ` [dts] [PATCH v4] " Phil Yang
2018-04-18  6:23       ` Liu, Yong
2018-09-04  8:34         ` Phil Yang (Arm Technology China)
2018-09-04  8:50           ` Liu, Yong
2018-09-04  9:14             ` Phil Yang (Arm Technology China)
2018-09-04  8:26       ` [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine Phil Yang
2018-09-04  8:26         ` [dts] [PATCH v5 02/22] tests/checksum_offload: Replace sniff_packet to tester.tcpdump_sniff_packet Phil Yang
2018-09-04  8:26         ` [dts] [PATCH v5 03/22] tests/etag: " Phil Yang
2018-09-04  8:26         ` [dts] [PATCH v5 04/22] tests/ipfrag: " Phil Yang
2018-09-04  8:26         ` [dts] [PATCH v5 05/22] tests/l2fwd_crypto: replaced sniff_packets to tester.tcpdump_sniff_packets Phil Yang
2018-09-04  8:26         ` [dts] [PATCH v5 06/22] tests/netmap_compat: replaced sniff_packet to tester.tcpdump_sniff_packet Phil Yang
2018-09-04  8:26         ` [dts] [PATCH v5 07/22] tests/queue_start_stop: replaced sniff_packets to tester.tcpdump_sniff_packets Phil Yang
2018-09-04  8:26         ` [dts] [PATCH v5 08/22] tests/quota_watermark: " Phil Yang
2018-09-04  8:26         ` [dts] [PATCH v5 09/22] tests/rxtx_callback: " Phil Yang
2018-09-04  8:26         ` [dts] [PATCH v5 10/22] tests/scatter: " Phil Yang
2018-09-04  8:26         ` [dts] [PATCH v5 11/22] tests/skeleton: " Phil Yang
2018-09-04  8:26         ` [dts] [PATCH v5 12/22] tests/userspace_ethtool: " Phil Yang
2018-09-04  8:26         ` [dts] [PATCH v5 13/22] tests/vf_daemon: " Phil Yang
2018-09-04  8:26         ` [dts] [PATCH v5 14/22] tests/vf_vlan: " Phil Yang
2018-09-04  8:26         ` [dts] [PATCH v5 15/22] tests/vlan_ethertype_config: remove unused sniff_packets Phil Yang
2018-09-04  8:26         ` [dts] [PATCH v5 16/22] tests/vlan: replaced sniff_packets to tester.tcpdump_sniff_packets Phil Yang
2018-09-04  8:26         ` [dts] [PATCH v5 17/22] tests/ipgre: " Phil Yang
2018-09-04  8:26         ` [dts] [PATCH v5 18/22] tests/hotplug: remove unused packet sniff import Phil Yang
2018-09-04  8:26         ` [dts] [PATCH v5 19/22] tests/keep_alive: " Phil Yang
2018-09-04  8:26         ` [dts] [PATCH v5 20/22] tests/link_status_interrupt: " Phil Yang
2018-09-04  8:26         ` [dts] [PATCH v5 21/22] tests/vhost_pmd_xstats: " Phil Yang
2018-09-04  8:26         ` [dts] [PATCH v5 22/22] tests/ddp_mpls: " Phil Yang
2018-09-17  5:12         ` [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine Phil Yang (Arm Technology China)
2018-09-21  3:09         ` Tu, Lijuan
2018-09-21  3:21           ` Phil Yang (Arm Technology China)
2018-09-21  3:41             ` Tu, Lijuan
2018-09-21  6:58               ` Phil Yang (Arm Technology China)
2018-09-21  7:19                 ` Tu, Lijuan
2018-09-21  7:32                   ` Phil Yang (Arm Technology China)
2018-09-21  8:27                     ` Tu, Lijuan
2018-09-21 12:05                       ` Phil Yang (Arm Technology China)
2018-09-26  5:15                         ` Tu, Lijuan
2018-10-16  6:19         ` [dts] [PATCH v6 " Phil Yang
2018-10-16  6:19           ` [dts] [PATCH v6 02/22] tests/checksum_offload: Replace sniff_packet to tester.tcpdump_sniff_packet Phil Yang
2018-10-16  6:19           ` [dts] [PATCH v6 03/22] tests/etag: " Phil Yang
2018-10-16  6:19           ` [dts] [PATCH v6 04/22] tests/ipfrag: " Phil Yang
2018-10-16  6:19           ` [dts] [PATCH v6 05/22] tests/l2fwd_crypto: replaced sniff_packets to tester.tcpdump_sniff_packets Phil Yang
2018-10-16  6:19           ` [dts] [PATCH v6 06/22] tests/netmap_compat: replaced sniff_packet to tester.tcpdump_sniff_packet Phil Yang
2018-10-16  6:19           ` [dts] [PATCH v6 07/22] tests/queue_start_stop: replaced sniff_packets to tester.tcpdump_sniff_packets Phil Yang
2018-10-16  6:19           ` [dts] [PATCH v6 08/22] tests/quota_watermark: " Phil Yang
2018-10-16  6:19           ` [dts] [PATCH v6 09/22] tests/rxtx_callback: " Phil Yang
2018-10-16  6:19           ` [dts] [PATCH v6 10/22] tests/scatter: " Phil Yang
2018-10-16  6:19           ` [dts] [PATCH v6 11/22] tests/skeleton: " Phil Yang
2018-10-16  6:19           ` [dts] [PATCH v6 12/22] tests/userspace_ethtool: " Phil Yang
2018-10-16  6:19           ` [dts] [PATCH v6 13/22] tests/vf_daemon: " Phil Yang
2018-10-16  6:19           ` [dts] [PATCH v6 14/22] tests/vf_vlan: " Phil Yang
2018-10-16  6:19           ` [dts] [PATCH v6 15/22] tests/vlan_ethertype_config: remove unused sniff_packets Phil Yang
2018-10-16  6:19           ` [dts] [PATCH v6 16/22] tests/vlan: replaced sniff_packets to tester.tcpdump_sniff_packets Phil Yang
2018-10-16  6:19           ` [dts] [PATCH v6 17/22] tests/ipgre: " Phil Yang
2018-10-16  6:19           ` [dts] [PATCH v6 18/22] tests/hotplug: remove unused packet sniff import Phil Yang
2018-10-16  6:19           ` [dts] [PATCH v6 19/22] tests/keep_alive: " Phil Yang
2018-10-16  6:20           ` [dts] [PATCH v6 20/22] tests/link_status_interrupt: " Phil Yang
2018-10-16  6:20           ` [dts] [PATCH v6 21/22] tests/vhost_pmd_xstats: " Phil Yang
2018-10-16  6:20           ` [dts] [PATCH v6 22/22] tests/ddp_mpls: " Phil Yang
2018-10-18  9:15           ` [dts] [PATCH v6 01/22] framework/packet: support packet sniffer to specify running machine Tu, Lijuan
2018-10-18 10:00             ` Phil Yang (Arm Technology China)
2018-10-19  9:29               ` Phil Yang (Arm Technology China)
2018-10-19  9:25           ` [dts] [PATCH v7] " Phil Yang
2018-10-23  9:44             ` Tu, Lijuan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86228AFD5BCD8E4EBFD2B90117B5E81E62FF6B96@SHSMSX103.ccr.corp.intel.com \
    --to=yong.liu@intel.com \
    --cc=Phil.Yang@arm.com \
    --cc=dts@dpdk.org \
    --cc=nd@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).