From: Phil Yang <phil.yang@arm.com>
To: dts@dpdk.org
Cc: nd@arm.com, yong.liu@intel.com
Subject: [dts] [PATCH v2 01/17] framwork/packet: sniff_packet specify running target support
Date: Fri, 30 Mar 2018 18:40:53 +0800 [thread overview]
Message-ID: <1522406469-9251-1-git-send-email-phil.yang@arm.com> (raw)
In-Reply-To: <1521792246-4950-1-git-send-email-phil.yang@arm.com>
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 | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 62 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..49749de 100755
--- a/framework/tester.py
+++ b/framework/tester.py
@@ -704,6 +704,40 @@ 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")
+
+ 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")
+
+ return load_f(index)
+
def kill_all(self, killall=False):
"""
Kill all scapy process or DPDK application on tester.
--
2.7.4
next prev parent reply other threads:[~2018-03-30 10:41 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 ` Phil Yang [this message]
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
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=1522406469-9251-1-git-send-email-phil.yang@arm.com \
--to=phil.yang@arm.com \
--cc=dts@dpdk.org \
--cc=nd@arm.com \
--cc=yong.liu@intel.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).