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@arm.com" <nd@arm.com>
Subject: Re: [dts] [PATCH v4] framwork/packet: sniff_packet specify running target support
Date: Wed, 18 Apr 2018 06:23:10 +0000	[thread overview]
Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E63011A25@SHSMSX101.ccr.corp.intel.com> (raw)
In-Reply-To: <1523526771-7437-1-git-send-email-phil.yang@arm.com>

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 ssh 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 <yong.liu@intel.com>
> 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 <phil.yang@arm.com>
> Suggested-by: Marvin Liu <yong.liu@intel.com>
> ---
>  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=[]):
>          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)
> @@ -886,42 +908,6 @@ def load_sniff_pcap(index=''):
>      return ""
> 
> 
> -def load_sniff_packets(index=''):
> -    """
> -    Stop sniffer and return packet objects
> -    """
> -    pkts = []
> -    child_exit = False
> -    if index in SNIFF_PIDS.keys():
> -        pipe, intf, timeout = SNIFF_PIDS[index]
> -        time_elapse = int(time.time() - float(index))
> -        while time_elapse < timeout:
> -            if pipe.poll() is not None:
> -                child_exit = True
> -                break
> -
> -            time.sleep(1)
> -            time_elapse += 1
> -
> -        if not child_exit:
> -            pipe.send_signal(signal.SIGINT)
> -            pipe.wait()
> -
> -        # wait pcap file ready
> -        time.sleep(1)
> -        try:
> -            cap_pkts = rdpcap("/tmp/sniff_%s.pcap" % intf)
> -            for pkt in cap_pkts:
> -                # packet gen should be scapy
> -                packet = Packet(tx_port=intf)
> -                packet.pktgen.assign_pkt(pkt)
> -                pkts.append(packet)
> -        except:
> -            pass
> -
> -    return pkts
> -
> -
>  def load_pcapfile(filename=""):
>      pkts = []
>      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 = 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())
> +        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")
> +        pcap = load_pcap_f(index)
> +        self.session.copy_file_from(pcap)
> +
> +        return pcap.split(os.sep)[-1]
> +
> +    def load_tcpdump_sniff_packets(self, index=''):
> +        """
> +        Wrapper for packet module load_sniff_packets
> +        """
> +        # load functions in packet module
> +        packet = __import__("packet")
> +        file = self.load_tcpdump_sniff_pcap(index)
> +
> +        return packet.load_pcapfile(file)
> +
>      def kill_all(self, killall=False):
>          """
>          Kill all scapy process or DPDK application on tester.
> --
> 2.7.4

  reply	other threads:[~2018-04-18  6:23 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
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 [this message]
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=86228AFD5BCD8E4EBFD2B90117B5E81E63011A25@SHSMSX101.ccr.corp.intel.com \
    --to=yong.liu@intel.com \
    --cc=dts@dpdk.org \
    --cc=nd@arm.com \
    --cc=phil.yang@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).