test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH 01/17] framwork/packet: Add sniff_packet specify running
@ 2018-03-23  8:03 Phil Yang
  2018-03-23  8:03 ` [dts] [PATCH 02/17] tests/checksum_offload: Replaced sniff_packet to tester.tcpdump_sniff_packet Phil Yang
                   ` (17 more replies)
  0 siblings, 18 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-23  8:03 UTC (permalink / raw)
  To: dts; +Cc: nd, phil.yang, yong.liu, herbert.guan

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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH 02/17] tests/checksum_offload: Replaced sniff_packet to tester.tcpdump_sniff_packet
  2018-03-23  8:03 [dts] [PATCH 01/17] framwork/packet: Add sniff_packet specify running Phil Yang
@ 2018-03-23  8:03 ` Phil Yang
  2018-03-23  8:03 ` [dts] [PATCH 03/17] tests/etag: " Phil Yang
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-23  8:03 UTC (permalink / raw)
  To: dts; +Cc: nd, phil.yang, yong.liu, herbert.guan

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_checksum_offload.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_checksum_offload.py b/tests/TestSuite_checksum_offload.py
index 2ff5c2f..6541ba5 100644
--- a/tests/TestSuite_checksum_offload.py
+++ b/tests/TestSuite_checksum_offload.py
@@ -43,7 +43,6 @@ import utils
 
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets, strip_pktload
 from test_capabilities import DRIVER_TEST_LACK_CAPA
 
 class TestChecksumOffload(TestCase):
@@ -175,13 +174,14 @@ class TestChecksumOffload(TestCase):
 
         self.tester.send_expect("exit()", "#")
 
-        inst = sniff_packets(intf=rx_interface, count=len(packets_sent), filters=[{'layer':'ether', 'config':{'src': sniff_src}}])
+        inst = self.tester.tcpdump_sniff_packets(intf=rx_interface, count=len(packets_sent),
+                filters=[{'layer':'ether', 'config':{'src': sniff_src}}])
 
         for packet_type in packets_sent.keys():
             self.tester.scapy_append('sendp([%s], iface="%s")' % (packets_sent[packet_type], tx_interface))
 
         self.tester.scapy_execute()
-	p = load_sniff_packets(inst)
+	p = self.tester.load_tcpdump_sniff_packets(inst)
 	nr_packets=len(p)
 	reslist = [p[i].pktgen.pkt.sprintf("%IP.chksum%;%TCP.chksum%;%UDP.chksum%;%SCTP.chksum%") for i in range(nr_packets)]
 	out = string.join(reslist, ",")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH 03/17] tests/etag: Replaced sniff_packet to tester.tcpdump_sniff_packet
  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 ` Phil Yang
  2018-03-23  8:03 ` [dts] [PATCH 04/17] tests/ipfrag: " Phil Yang
                   ` (15 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-23  8:03 UTC (permalink / raw)
  To: dts; +Cc: nd, phil.yang, yong.liu, herbert.guan

Make sniff_packet running on the tester. Create a ssh connection to
the tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_etag.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_etag.py b/tests/TestSuite_etag.py
index 642fb2b..a2fb699 100644
--- a/tests/TestSuite_etag.py
+++ b/tests/TestSuite_etag.py
@@ -46,7 +46,6 @@ from exception import VerifyFailure
 
 from scapy.utils import rdpcap
 
-from packet import Packet, sniff_packets, load_sniff_packets
 
 VM_CORES_MASK = 'all'
 
@@ -325,11 +324,11 @@ class TestEtag(TestCase):
         pkt_types = {'IP_RAW': {'layer_configs': config_layers}}
 
         intf = self.src_intf
-        inst = sniff_packets(intf)
+        inst = self.tester.tcpdump_sniff_packets(intf)
 
         self.check_packet_transmission(pkt_types)
         time.sleep(1)
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         self.host_testpmd.execute_cmd('E-tag set insertion off port-tag-id 1000 port 0 vf 0')
 
         # load sniff pcap file, check received packet's content
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH 04/17] tests/ipfrag: Replaced sniff_packet to tester.tcpdump_sniff_packet
  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 ` Phil Yang
  2018-03-23  8:03 ` [dts] [PATCH 05/17] tests/l2fwd_crypto: Replaced sniff_packets to tester.tcpdump_sniff_packets Phil Yang
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-23  8:03 UTC (permalink / raw)
  To: dts; +Cc: nd, phil.yang, yong.liu, herbert.guan

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_ipfrag.py | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/tests/TestSuite_ipfrag.py b/tests/TestSuite_ipfrag.py
index f23dbe1..9ebda1f 100644
--- a/tests/TestSuite_ipfrag.py
+++ b/tests/TestSuite_ipfrag.py
@@ -39,7 +39,6 @@ import string
 import re
 import time
 from settings import HEADER_SIZE
-from packet import Packet, sniff_packets, load_sniff_packets
 
 lpm_table_ipv4 = [
     "{IPv4(100,10,0,0), 16, P1}",
@@ -159,7 +158,7 @@ l3fwd_ipv4_route_array[] = {\\\n"
                 expPkts = 1
                 val = 2
 
-            inst = sniff_packets(intf=self.rxItf, timeout=5)
+            inst = self.tester.tcpdump_sniff_packets(intf=self.rxItf, timeout=5)
             # send packet
             for times in range(burst):
                 pkt_size = pkt_sizes[pkt_sizes.index(size) + times]
@@ -169,7 +168,7 @@ l3fwd_ipv4_route_array[] = {\\\n"
                 pkt.send_pkt(tx_port=self.txItf)
 
             # verify normal packet just by number, verify fragment packet by all elements
-            pkts = load_sniff_packets(inst)
+            pkts = self.tester.load_tcpdump_sniff_packets(inst)
             self.verify(len(pkts) == expPkts, "Failed on forward packet size " + str(size))
             if flag == 'frag':
                 idx = 1
@@ -209,7 +208,7 @@ l3fwd_ipv4_route_array[] = {\\\n"
                 expPkts = 1
                 val = 2
 
-            inst = sniff_packets(intf=self.rxItf, timeout=5)
+            inst = self.tester.tcpdump_sniff_packets(intf=self.rxItf, timeout=5)
             # send packet
             for times in range(burst):
                 pkt_size = pkt_sizes[pkt_sizes.index(size) + times]
@@ -219,7 +218,7 @@ l3fwd_ipv4_route_array[] = {\\\n"
                 pkt.send_pkt(tx_port=self.txItf)
 
             # verify normal packet just by number, verify fragment packet by all elements
-            pkts = load_sniff_packets(inst)
+            pkts = self.tester.load_tcpdump_sniff_packets(inst)
             self.verify(len(pkts) == expPkts, "Failed on forward packet size " + str(size))
             if flag == 'frag':
                 idx = 1
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH 05/17] tests/l2fwd_crypto: Replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-03-23  8:03 [dts] [PATCH 01/17] framwork/packet: Add sniff_packet specify running Phil Yang
                   ` (2 preceding siblings ...)
  2018-03-23  8:03 ` [dts] [PATCH 04/17] tests/ipfrag: " Phil Yang
@ 2018-03-23  8:03 ` Phil Yang
  2018-03-23  8:03 ` [dts] [PATCH 06/17] tests/netmap_compat: Replaced sniff_packet to tester.tcpdump_sniff_packet Phil Yang
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-23  8:03 UTC (permalink / raw)
  To: dts; +Cc: nd, phil.yang, yong.liu, herbert.guan

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_l2fwd_crypto.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_l2fwd_crypto.py b/tests/TestSuite_l2fwd_crypto.py
index d559909..ea35a29 100644
--- a/tests/TestSuite_l2fwd_crypto.py
+++ b/tests/TestSuite_l2fwd_crypto.py
@@ -38,7 +38,7 @@ import sys
 import utils
 import commands
 from test_case import TestCase
-from packet import Packet, sniff_packets, load_sniff_packets, save_packets
+from packet import Packet, save_packets
 
 from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
 from cryptography.hazmat.backends import default_backend
@@ -501,7 +501,7 @@ class TestL2fwdCrypto(TestCase):
 
             payload = self.__format_hex_to_list(test_vector["input"])
 
-            inst = sniff_packets(self.rx_interface, timeout=5)
+            inst = self.tester.tcpdump_sniff_packets(self.rx_interface, timeout=5)
 
             PACKET_COUNT = 65
             pkt = Packet()
@@ -512,7 +512,7 @@ class TestL2fwdCrypto(TestCase):
             pkt.send_pkt(tx_port=self.tx_interface, count=PACKET_COUNT)
             pkt.pktgen.pkt.show()
 
-            pkt_rec = load_sniff_packets(inst)
+            pkt_rec = self.tester.load_tcpdump_sniff_packets(inst)
 
             for pkt_r in pkt_rec:
                 packet_hex = pkt_r.strip_element_layer4("load")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH 06/17] tests/netmap_compat: Replaced sniff_packet to tester.tcpdump_sniff_packet
  2018-03-23  8:03 [dts] [PATCH 01/17] framwork/packet: Add sniff_packet specify running Phil Yang
                   ` (3 preceding siblings ...)
  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 ` 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
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-23  8:03 UTC (permalink / raw)
  To: dts; +Cc: nd, phil.yang, yong.liu, herbert.guan

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_netmap_compat.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/tests/TestSuite_netmap_compat.py b/tests/TestSuite_netmap_compat.py
index 5225a27..84136c7 100644
--- a/tests/TestSuite_netmap_compat.py
+++ b/tests/TestSuite_netmap_compat.py
@@ -43,7 +43,6 @@ from test_case import TestCase
 from plotting import Plotting 
 from settings import HEADER_SIZE   
 from etgen import IxiaPacketGenerator
-from packet import Packet, sniff_packets, load_sniff_packets
 
 class TestNetmapCompat(TestCase):
 
@@ -80,7 +79,7 @@ class TestNetmapCompat(TestCase):
 
         self.rxItf = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0]))
 
-        self.inst = sniff_packets(self.rxItf)
+        self.inst = self.tester.tcpdump_sniff_packets(self.rxItf)
 
         self.scapy_send_packet()
 
@@ -98,7 +97,7 @@ class TestNetmapCompat(TestCase):
         self.dut.send_expect(cmd,"Port %s now in Netmap mode" % self.dut_ports[0], 60)
        
         self.rxItf = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[1]))
-        self.inst = sniff_packets(self.rxItf)
+        self.inst = self.tester.tcpdump_sniff_packets(self.rxItf)
 
         self.scapy_send_packet()
 
@@ -117,7 +116,7 @@ class TestNetmapCompat(TestCase):
 
 
     def get_tcpdump_package(self):  
-        pkts = load_sniff_packets(self.inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(self.inst)
         dsts = []  
         for packet in pkts:  
             dst = packet.strip_element_layer2("dst")  
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH 07/17] tests/queue_start_stop: Replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-03-23  8:03 [dts] [PATCH 01/17] framwork/packet: Add sniff_packet specify running Phil Yang
                   ` (4 preceding siblings ...)
  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 ` Phil Yang
  2018-03-23  8:03 ` [dts] [PATCH 08/17] tests/quota_watermark: " Phil Yang
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-23  8:03 UTC (permalink / raw)
  To: dts; +Cc: nd, phil.yang, yong.liu, herbert.guan

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_queue_start_stop.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_queue_start_stop.py b/tests/TestSuite_queue_start_stop.py
index cc031f5..bf69666 100644
--- a/tests/TestSuite_queue_start_stop.py
+++ b/tests/TestSuite_queue_start_stop.py
@@ -44,7 +44,7 @@ import os
 from test_case import TestCase
 from pmd_output import PmdOutput
 from settings import FOLDERS
-from packet import Packet, sniff_packets, load_sniff_packets, strip_pktload
+from packet import Packet, strip_pktload
 
 #
 #
@@ -99,10 +99,10 @@ class TestQueueStartStop(TestCase):
         dmac = self.dut.get_mac_address(txPort)
 
         pkt = Packet(pkt_type="UDP", pkt_len=pktSize)
-        inst = sniff_packets(rxitf)
+        inst = self.tester.tcpdump_sniff_packets(rxitf)
         pkt.config_layer('ether', {'dst': dmac})
         pkt.send_pkt(tx_port=txitf)
-        sniff_pkts = load_sniff_packets(inst)
+        sniff_pkts = self.tester.load_tcpdump_sniff_packets(inst)
 
         if received:
             res = strip_pktload(sniff_pkts[0], layer="L4")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH 08/17] tests/quota_watermark: Replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-03-23  8:03 [dts] [PATCH 01/17] framwork/packet: Add sniff_packet specify running Phil Yang
                   ` (5 preceding siblings ...)
  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 ` Phil Yang
  2018-03-23  8:03 ` [dts] [PATCH 09/17] tests/rxtx_callback: " Phil Yang
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-23  8:03 UTC (permalink / raw)
  To: dts; +Cc: nd, phil.yang, yong.liu, herbert.guan

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_quota_watermark.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_quota_watermark.py b/tests/TestSuite_quota_watermark.py
index ecacf38..845b27f 100644
--- a/tests/TestSuite_quota_watermark.py
+++ b/tests/TestSuite_quota_watermark.py
@@ -39,7 +39,6 @@ import time
 import utils
 from test_case import TestCase
 from etgen import IxiaPacketGenerator
-from packet import Packet, sniff_packets, load_sniff_packets
 
 test_config = {
     'frames_to_sent': 15 * 10 ** 6,
@@ -311,9 +310,9 @@ class TestQuotaWatermark(TestCase, IxiaPacketGenerator):
         rx_intf = self.tester.get_interface(rev_port)
         tx_intf = self.tester.get_interface(send_port)
         # send and sniff packet
-        rx_inst = sniff_packets(rx_intf, timeout=5)
+        rx_inst = self.tester.tcpdump_sniff_packets(rx_intf, timeout=5)
         self.send_pcap_pkt_by_scapy(self.tester, tgen_input[0][2], tx_intf)
-        pkts = load_sniff_packets(rx_inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(rx_inst)
         self.verify(len(pkts) == pkt_cnt, "Packet not forwarded as expected")
 
         return
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH 09/17] tests/rxtx_callback: Replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-03-23  8:03 [dts] [PATCH 01/17] framwork/packet: Add sniff_packet specify running Phil Yang
                   ` (6 preceding siblings ...)
  2018-03-23  8:03 ` [dts] [PATCH 08/17] tests/quota_watermark: " Phil Yang
@ 2018-03-23  8:03 ` Phil Yang
  2018-03-23  8:03 ` [dts] [PATCH 10/17] tests/scatter: " Phil Yang
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-23  8:03 UTC (permalink / raw)
  To: dts; +Cc: nd, phil.yang, yong.liu, herbert.guan

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_rxtx_callbacks.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_rxtx_callbacks.py b/tests/TestSuite_rxtx_callbacks.py
index dd968a4..a654480 100644
--- a/tests/TestSuite_rxtx_callbacks.py
+++ b/tests/TestSuite_rxtx_callbacks.py
@@ -41,7 +41,6 @@ from test_case import TestCase
 from plotting import Plotting
 from settings import HEADER_SIZE
 from etgen import IxiaPacketGenerator
-from packet import Packet, sniff_packets, load_sniff_packets
 
 
 class TestRxtxCallbacks(TestCase):
@@ -77,7 +76,7 @@ class TestRxtxCallbacks(TestCase):
         self.iface_port0 = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0]))
         self.iface_port1 = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[1]))
 
-        self.inst_port1 = sniff_packets(self.iface_port1)
+        self.inst_port1 = self.tester.tcpdump_sniff_packets(self.iface_port1)
         self.scapy_send_packet(self.iface_port0)
 
         out_port1 = self.get_tcpdump_package(self.inst_port1)
@@ -92,7 +91,7 @@ class TestRxtxCallbacks(TestCase):
         self.tester.scapy_execute()
 
     def get_tcpdump_package(self,inst):
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         dsts = []
         for packet in pkts:
             dst = packet.strip_element_layer2("dst")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH 10/17] tests/scatter: Replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-03-23  8:03 [dts] [PATCH 01/17] framwork/packet: Add sniff_packet specify running Phil Yang
                   ` (7 preceding siblings ...)
  2018-03-23  8:03 ` [dts] [PATCH 09/17] tests/rxtx_callback: " Phil Yang
@ 2018-03-23  8:03 ` Phil Yang
  2018-03-23  8:04 ` [dts] [PATCH 11/17] tests/keleton: " Phil Yang
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-23  8:03 UTC (permalink / raw)
  To: dts; +Cc: nd, phil.yang, yong.liu, herbert.guan

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_scatter.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_scatter.py b/tests/TestSuite_scatter.py
index 74fc08f..4db0bb0 100644
--- a/tests/TestSuite_scatter.py
+++ b/tests/TestSuite_scatter.py
@@ -35,7 +35,7 @@ Test Scattered Packets.
 """
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets, strip_pktload
+from packet import Packet, strip_pktload
 import time
 #
 #
@@ -82,11 +82,11 @@ class TestScatter(TestCase):
         """
         dmac = self.dut.get_mac_address(self.port)
 
-        inst = sniff_packets(self.intf)
+        inst = self.tester.tcpdump_sniff_packets(self.intf)
         pkt = Packet(pkt_type="IP_RAW", pkt_len=pktsize)
         pkt.config_layer('ether', {'dst': dmac})
         pkt.send_pkt(tx_port=self.intf)
-        sniff_pkts = load_sniff_packets(inst)
+        sniff_pkts = self.tester.load_tcpdump_sniff_packets(inst)
 
         res = ""
         if len(sniff_pkts):
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH 11/17] tests/keleton: Replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-03-23  8:03 [dts] [PATCH 01/17] framwork/packet: Add sniff_packet specify running Phil Yang
                   ` (8 preceding siblings ...)
  2018-03-23  8:03 ` [dts] [PATCH 10/17] tests/scatter: " Phil Yang
@ 2018-03-23  8:04 ` Phil Yang
  2018-03-23  8:04 ` [dts] [PATCH 12/17] tests/userspace_ethtool: " Phil Yang
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-23  8:04 UTC (permalink / raw)
  To: dts; +Cc: nd, phil.yang, yong.liu, herbert.guan

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_skeleton.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_skeleton.py b/tests/TestSuite_skeleton.py
index 77f95e1..b56d955 100644
--- a/tests/TestSuite_skeleton.py
+++ b/tests/TestSuite_skeleton.py
@@ -42,7 +42,6 @@ from plotting import Plotting
 from settings import HEADER_SIZE
 from etgen import IxiaPacketGenerator
 
-from packet import Packet, sniff_packets, load_sniff_packets
 
 
 class TestSkeleton(TestCase):
@@ -80,7 +79,7 @@ class TestSkeleton(TestCase):
         self.iface_port0 = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0]))
         self.iface_port1 = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[1]))
 
-        self.inst_port1 = sniff_packets(self.iface_port1)
+        self.inst_port1 = self.tester.tcpdump_sniff_packets(self.iface_port1)
         self.scapy_send_packet(self.iface_port0)
 
         out_port1 = self.get_tcpdump_package(self.inst_port1)
@@ -95,7 +94,7 @@ class TestSkeleton(TestCase):
         self.tester.scapy_execute()
 
     def get_tcpdump_package(self,inst):
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         dsts = []
         for packet in pkts:
             dst = packet.strip_element_layer2("dst")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH 12/17] tests/userspace_ethtool: Replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-03-23  8:03 [dts] [PATCH 01/17] framwork/packet: Add sniff_packet specify running Phil Yang
                   ` (9 preceding siblings ...)
  2018-03-23  8:04 ` [dts] [PATCH 11/17] tests/keleton: " Phil Yang
@ 2018-03-23  8:04 ` Phil Yang
  2018-03-23  8:04 ` [dts] [PATCH 13/17] tests/vf_daemon: " Phil Yang
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-23  8:04 UTC (permalink / raw)
  To: dts; +Cc: nd, phil.yang, yong.liu, herbert.guan

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_userspace_ethtool.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_userspace_ethtool.py b/tests/TestSuite_userspace_ethtool.py
index 84b1f1e..edcfc88 100644
--- a/tests/TestSuite_userspace_ethtool.py
+++ b/tests/TestSuite_userspace_ethtool.py
@@ -39,7 +39,6 @@ import utils
 import time
 import re
 from test_case import TestCase
-from packet import Packet, sniff_packets, load_sniff_packets
 import random
 from etgen import IxiaPacketGenerator
 from settings import HEADER_SIZE
@@ -478,9 +477,9 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator):
             tester_port = self.tester.get_local_port(port)
             intf = self.tester.get_interface(tester_port)
             # send and sniff packet
-            inst = sniff_packets(intf, timeout=5)
+            inst = self.tester.tcpdump_sniff_packets(intf, timeout=5)
             pkt.send_pkt(tx_port=intf)
-            pkts = load_sniff_packets(inst)
+            pkts = self.tester.load_tcpdump_sniff_packets(inst)
             self.verify(len(pkts) == 1, "Packet not forwarded as expected")
             src_mac = pkts[0].strip_layer_element("layer2", "src")
             self.verify(src_mac == valid_mac, "Forwarded packet not match default mac")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH 13/17] tests/vf_daemon: Replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-03-23  8:03 [dts] [PATCH 01/17] framwork/packet: Add sniff_packet specify running Phil Yang
                   ` (10 preceding siblings ...)
  2018-03-23  8:04 ` [dts] [PATCH 12/17] tests/userspace_ethtool: " Phil Yang
@ 2018-03-23  8:04 ` Phil Yang
  2018-03-23  8:04 ` [dts] [PATCH 14/17] tests/vf_vlan: " Phil Yang
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-23  8:04 UTC (permalink / raw)
  To: dts; +Cc: nd, phil.yang, yong.liu, herbert.guan

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_vf_daemon.py | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/tests/TestSuite_vf_daemon.py b/tests/TestSuite_vf_daemon.py
index b1ad522..e256825 100644
--- a/tests/TestSuite_vf_daemon.py
+++ b/tests/TestSuite_vf_daemon.py
@@ -8,7 +8,6 @@ from scapy.utils import rdpcap
 from qemu_kvm import QEMUKvm
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets
 from settings import get_nic_name
 import random
 
@@ -154,7 +153,7 @@ class Testvf_daemon(TestCase):
             pkt.config_layer('vlan', {'vlan': vlan_id})
         pkt.config_layer('ether', {'dst': dst_mac})
 
-        inst = sniff_packets(self.tester_intf, timeout=30)
+        inst = self.tester.tcpdump_sniff_packets(self.tester_intf, timeout=30)
         pkt.send_pkt(tx_port=self.tester_intf, count=num)
         return inst
 
@@ -162,7 +161,7 @@ class Testvf_daemon(TestCase):
         """
         Load sniff packets, strip and return mac address from dump message
         """
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         macs = []
         for pkt in pkts:
             mac = pkt.strip_element_layer2(element)
@@ -173,7 +172,7 @@ class Testvf_daemon(TestCase):
         """
         Load sniff packets, strip and return vlan id from dump message
         """
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         vlans = []
         for pkt in pkts:
             vlan = pkt.strip_element_vlan("vlan")
@@ -422,7 +421,7 @@ class Testvf_daemon(TestCase):
         self.dut_testpmd.execute_cmd('set tx loopback 0 off')
         time.sleep(5)
 
-        inst = sniff_packets(self.tester_intf, timeout=10)
+        inst = self.tester.tcpdump_sniff_packets(self.tester_intf, timeout=10)
 
         self.vm1_testpmd.execute_cmd('set burst 5')
         self.vm1_testpmd.execute_cmd('start tx_first')
@@ -438,7 +437,7 @@ class Testvf_daemon(TestCase):
         self.dut_testpmd.execute_cmd('set tx loopback 0 on')
         time.sleep(3)
 
-        inst = sniff_packets(self.tester_intf, timeout=10)
+        inst = self.tester.tcpdump_sniff_packets(self.tester_intf, timeout=10)
 
         self.vm1_testpmd.execute_cmd('stop')
         self.vm1_testpmd.execute_cmd('start tx_first')
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH 14/17] tests/vf_vlan: Replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-03-23  8:03 [dts] [PATCH 01/17] framwork/packet: Add sniff_packet specify running Phil Yang
                   ` (11 preceding siblings ...)
  2018-03-23  8:04 ` [dts] [PATCH 13/17] tests/vf_daemon: " Phil Yang
@ 2018-03-23  8:04 ` Phil Yang
  2018-03-23  8:04 ` [dts] [PATCH 15/17] tests/vlan_ethertype_config: " Phil Yang
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-23  8:04 UTC (permalink / raw)
  To: dts; +Cc: nd, phil.yang, yong.liu, herbert.guan

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_vf_vlan.py | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/tests/TestSuite_vf_vlan.py b/tests/TestSuite_vf_vlan.py
index da9330d..8af7e5a 100644
--- a/tests/TestSuite_vf_vlan.py
+++ b/tests/TestSuite_vf_vlan.py
@@ -6,7 +6,6 @@ import time
 from virt_common import VM
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets
 from settings import get_nic_name
 import random
 
@@ -173,9 +172,9 @@ class TestVfVlan(TestCase):
 
         pkt = Packet(pkt_type='UDP')
         pkt.config_layer('ether', {'dst': self.vf1_mac})
-        inst = sniff_packets(self.tester_intf0, timeout=5)
+        inst = self.tester.tcpdump_sniff_packets(self.tester_intf0, timeout=5)
         pkt.send_pkt(tx_port=self.tester_intf1)
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
 
         self.verify(len(pkts), "Not receive expected packet")
         self.vm0_testpmd.quit()
@@ -258,13 +257,13 @@ class TestVfVlan(TestCase):
             "ip link set %s vf 0 vlan 0" % (self.host_intf0), "# ")
 
     def tx_and_check(self, tx_vlan=1):
-        inst = sniff_packets(self.tester_intf0, timeout=5)
+        inst = self.tester.tcpdump_sniff_packets(self.tester_intf0, timeout=5)
         self.vm0_testpmd.execute_cmd('set burst 1')
         self.vm0_testpmd.execute_cmd('start tx_first')
         self.vm0_testpmd.execute_cmd('stop')
 
         # strip sniffered vlans
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         vlans = []
         for pkt in pkts:
             vlan = pkt.strip_element_vlan("vlan")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH 15/17] tests/vlan_ethertype_config: Replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-03-23  8:03 [dts] [PATCH 01/17] framwork/packet: Add sniff_packet specify running Phil Yang
                   ` (12 preceding siblings ...)
  2018-03-23  8:04 ` [dts] [PATCH 14/17] tests/vf_vlan: " Phil Yang
@ 2018-03-23  8:04 ` Phil Yang
  2018-03-23  8:04 ` [dts] [PATCH 16/17] tests/vlan: " Phil Yang
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-23  8:04 UTC (permalink / raw)
  To: dts; +Cc: nd, phil.yang, yong.liu, herbert.guan

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_vlan_ethertype_config.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tests/TestSuite_vlan_ethertype_config.py b/tests/TestSuite_vlan_ethertype_config.py
index 1fb30fb..413ec89 100644
--- a/tests/TestSuite_vlan_ethertype_config.py
+++ b/tests/TestSuite_vlan_ethertype_config.py
@@ -43,7 +43,6 @@ import utils
 
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets
 from scapy.utils import struct, socket, wrpcap, rdpcap
 from scapy.layers.inet import Ether, IP, TCP, UDP, ICMP
 from scapy.layers.l2 import Dot1Q, ARP, GRE
@@ -125,7 +124,7 @@ class TestVlanEthertypeConfig(TestCase):
         # off
         self.dmac = self.dut.get_mac_address(dutRxPortId)
 
-        self.inst = sniff_packets(self.rxItf)
+        self.inst = self.tester.tcpdump_sniff_packets(self.rxItf)
         pkt = []
         if outer_vid < 0 or outer_tpid <= 0:
             pkt = [
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH 16/17] tests/vlan: Replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-03-23  8:03 [dts] [PATCH 01/17] framwork/packet: Add sniff_packet specify running Phil Yang
                   ` (13 preceding siblings ...)
  2018-03-23  8:04 ` [dts] [PATCH 15/17] tests/vlan_ethertype_config: " Phil Yang
@ 2018-03-23  8:04 ` Phil Yang
  2018-03-23  8:04 ` [dts] [PATCH 17/17] tests/ipgre: " Phil Yang
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-23  8:04 UTC (permalink / raw)
  To: dts; +Cc: nd, phil.yang, yong.liu, herbert.guan

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_vlan.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_vlan.py b/tests/TestSuite_vlan.py
index 0f1833b..2b70ffa 100644
--- a/tests/TestSuite_vlan.py
+++ b/tests/TestSuite_vlan.py
@@ -43,7 +43,6 @@ import time
 
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets
 
 
 class TestVlan(TestCase):
@@ -88,7 +87,7 @@ class TestVlan(TestCase):
             netobj.add_vlan(vlan_id = self.vlan)
 
     def get_tcpdump_package(self):
-        pkts = load_sniff_packets(self.inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(self.inst)
         vlans = []
         for packet in pkts:
             vlan = packet.strip_element_vlan("vlan")
@@ -110,7 +109,7 @@ class TestVlan(TestCase):
         # the package dect mac must is dut tx port id when the port promisc is off
         self.dmac = self.dut.get_mac_address(dutRxPortId)
 
-        self.inst = sniff_packets(self.rxItf)
+        self.inst = self.tester.tcpdump_sniff_packets(self.rxItf)
         # FIXME  send a burst with only num packet
         if vid == -1:
             pkt = Packet(pkt_type='UDP')
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH 17/17] tests/ipgre: Replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-03-23  8:03 [dts] [PATCH 01/17] framwork/packet: Add sniff_packet specify running Phil Yang
                   ` (14 preceding siblings ...)
  2018-03-23  8:04 ` [dts] [PATCH 16/17] tests/vlan: " Phil Yang
@ 2018-03-23  8:04 ` Phil Yang
  2018-03-28  2:41 ` [dts] [PATCH 01/17] framwork/packet: Add sniff_packet specify running Liu, Yong
  2018-03-30 10:40 ` [dts] [PATCH v2 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-23  8:04 UTC (permalink / raw)
  To: dts; +Cc: nd, phil.yang, yong.liu, herbert.guan

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_ipgre.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_ipgre.py b/tests/TestSuite_ipgre.py
index 2dccb9c..e400161 100644
--- a/tests/TestSuite_ipgre.py
+++ b/tests/TestSuite_ipgre.py
@@ -44,7 +44,7 @@ import re
 import time
 import os
 
-from packet import Packet, sniff_packets, load_sniff_packets, NVGRE, IPPROTO_NVGRE
+from packet import Packet, NVGRE, IPPROTO_NVGRE
 
 from scapy.utils import wrpcap, rdpcap
 from scapy.packet import split_layers,bind_layers
@@ -98,11 +98,11 @@ class TestIpgre(TestCase):
             if layer_configs:
                 for layer in layer_configs.keys():
                     pkt.config_layer(layer, layer_configs[layer])
-            inst = sniff_packets(self.tester_iface, count=1, timeout=8)
+            inst = self.tester.tcpdump_sniff_packets(self.tester_iface, count=1, timeout=8)
             pkt.send_pkt(tx_port=self.tester_iface)
             out = self.dut.get_session_output(timeout=2)
             time.sleep(1)
-            load_sniff_packets(inst)
+            self.tester.load_tcpdump_sniff_packets(inst)
             if self.printFlag: # debug output
                 print out
             for pkt_layer_name in pkt_names:
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* Re: [dts] [PATCH 01/17] framwork/packet: Add sniff_packet specify running
  2018-03-23  8:03 [dts] [PATCH 01/17] framwork/packet: Add sniff_packet specify running Phil Yang
                   ` (15 preceding siblings ...)
  2018-03-23  8:04 ` [dts] [PATCH 17/17] tests/ipgre: " Phil Yang
@ 2018-03-28  2:41 ` Liu, Yong
  2018-03-28  6:34   ` Phil Yang
  2018-03-30 10:40 ` [dts] [PATCH v2 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
  17 siblings, 1 reply; 124+ messages in thread
From: Liu, Yong @ 2018-03-28  2:41 UTC (permalink / raw)
  To: Phil Yang, dts; +Cc: nd, herbert.guan

Hi Phil,
In previous design, DTS will be run on tester for simple design and stability. 
In our site, I can't see the benefit of change the design. Could you please explain why you change it?
Anyway we can change the design, but I think it will need some kind of diagnosis about the impact. 
There may be some other staff depend on the assumption that DTS is on the tester machine.

Just for this patch. In load function, DTS machine should transmit tester's pcap file first and then analyze packets.

Regards,
Marvin 

> -----Original Message-----
> From: Phil Yang [mailto:phil.yang@arm.com]
> Sent: Friday, March 23, 2018 4:04 PM
> To: dts@dpdk.org
> Cc: nd@arm.com; phil.yang@arm.com; Liu, Yong <yong.liu@intel.com>;
> herbert.guan@arm.com
> Subject: [PATCH 01/17] framwork/packet: Add sniff_packet specify running
> 
> 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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* Re: [dts] [PATCH 01/17] framwork/packet: Add sniff_packet specify running
  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
  0 siblings, 1 reply; 124+ messages in thread
From: Phil Yang @ 2018-03-28  6:34 UTC (permalink / raw)
  To: Liu, Yong, dts; +Cc: nd, Herbert Guan

Hi Marvin,

> -----Original Message-----
> From: Liu, Yong <yong.liu@intel.com>
> Sent: Wednesday, March 28, 2018 10:41 AM
> To: Phil Yang <Phil.Yang@arm.com>; dts@dpdk.org
> Cc: nd <nd@arm.com>; Herbert Guan <Herbert.Guan@arm.com>
> Subject: RE: [PATCH 01/17] framwork/packet: Add sniff_packet specify running
> 
> Hi Phil,
> In previous design, DTS will be run on tester for simple design and stability.
> In our site, I can't see the benefit of change the design. Could you please explain
> why you change it?
> Anyway we can change the design, but I think it will need some kind of diagnosis
> about the impact.
> There may be some other staff depend on the assumption that DTS is on the
> tester machine.


We are trying to use one machine as the controller to run DTS. The controller communicate with testers which listed in the crbs.cfg by SSH connection.
So the DTS will not running on tester. 

Since testers are connected with DUTs port by port, so I think introduce controller into the DTS is more flexible to manager machines. If other staff depend on the assumption that DTS is no the tester machine, sniff_packet process will also connect to the tester by SSH connection. Just one more SSH connection.
However, we cannot make sure the DTS is always running on the tester. 


> 
> Just for this patch. In load function, DTS machine should transmit tester's pcap
> file first and then analyze packets.

You are correct. Thanks to point out.

If my proposal is acceptable, I will resend the version 2 to add the transmit process.

Thanks.

> 
> Regards,
> Marvin
> 
> > -----Original Message-----
> > From: Phil Yang [mailto:phil.yang@arm.com]
> > Sent: Friday, March 23, 2018 4:04 PM
> > To: dts@dpdk.org
> > Cc: nd@arm.com; phil.yang@arm.com; Liu, Yong <yong.liu@intel.com>;
> > herbert.guan@arm.com
> > Subject: [PATCH 01/17] framwork/packet: Add sniff_packet specify
> > running
> >
> > 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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* Re: [dts] [PATCH 01/17] framwork/packet: Add sniff_packet specify running
  2018-03-28  6:34   ` Phil Yang
@ 2018-03-29  2:31     ` Liu, Yong
  2018-03-29  2:35       ` Phil Yang
  0 siblings, 1 reply; 124+ messages in thread
From: Liu, Yong @ 2018-03-29  2:31 UTC (permalink / raw)
  To: Phil Yang, dts; +Cc: nd, Herbert Guan

Phil,
Please go on, I think this change won't affect most of suites.  
Please also keep packet module still workable with directly call. Some of our internal tools are using it for sniffing packets.

Regards,
Marvin

> -----Original Message-----
> From: Phil Yang [mailto:Phil.Yang@arm.com]
> Sent: Wednesday, March 28, 2018 2:34 PM
> To: Liu, Yong <yong.liu@intel.com>; dts@dpdk.org
> Cc: nd <nd@arm.com>; Herbert Guan <Herbert.Guan@arm.com>
> Subject: RE: [PATCH 01/17] framwork/packet: Add sniff_packet specify
> running
> 
> Hi Marvin,
> 
> > -----Original Message-----
> > From: Liu, Yong <yong.liu@intel.com>
> > Sent: Wednesday, March 28, 2018 10:41 AM
> > To: Phil Yang <Phil.Yang@arm.com>; dts@dpdk.org
> > Cc: nd <nd@arm.com>; Herbert Guan <Herbert.Guan@arm.com>
> > Subject: RE: [PATCH 01/17] framwork/packet: Add sniff_packet specify
> running
> >
> > Hi Phil,
> > In previous design, DTS will be run on tester for simple design and
> stability.
> > In our site, I can't see the benefit of change the design. Could you
> please explain
> > why you change it?
> > Anyway we can change the design, but I think it will need some kind of
> diagnosis
> > about the impact.
> > There may be some other staff depend on the assumption that DTS is on
> the
> > tester machine.
> 
> 
> We are trying to use one machine as the controller to run DTS. The
> controller communicate with testers which listed in the crbs.cfg by SSH
> connection.
> So the DTS will not running on tester.
> 
> Since testers are connected with DUTs port by port, so I think introduce
> controller into the DTS is more flexible to manager machines. If other
> staff depend on the assumption that DTS is no the tester machine,
> sniff_packet process will also connect to the tester by SSH connection.
> Just one more SSH connection.
> However, we cannot make sure the DTS is always running on the tester.
> 
> 
> >
> > Just for this patch. In load function, DTS machine should transmit
> tester's pcap
> > file first and then analyze packets.
> 
> You are correct. Thanks to point out.
> 
> If my proposal is acceptable, I will resend the version 2 to add the
> transmit process.
> 
> Thanks.
> 
> >
> > Regards,
> > Marvin
> >
> > > -----Original Message-----
> > > From: Phil Yang [mailto:phil.yang@arm.com]
> > > Sent: Friday, March 23, 2018 4:04 PM
> > > To: dts@dpdk.org
> > > Cc: nd@arm.com; phil.yang@arm.com; Liu, Yong <yong.liu@intel.com>;
> > > herbert.guan@arm.com
> > > Subject: [PATCH 01/17] framwork/packet: Add sniff_packet specify
> > > running
> > >
> > > 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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* Re: [dts] [PATCH 01/17] framwork/packet: Add sniff_packet specify running
  2018-03-29  2:31     ` Liu, Yong
@ 2018-03-29  2:35       ` Phil Yang
  0 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-29  2:35 UTC (permalink / raw)
  To: Liu, Yong, dts; +Cc: nd, Herbert Guan

Ok, Thanks.

Thanks,
Phil Yang

> -----Original Message-----
> From: Liu, Yong <yong.liu@intel.com>
> Sent: Thursday, March 29, 2018 10:31 AM
> To: Phil Yang <Phil.Yang@arm.com>; dts@dpdk.org
> Cc: nd <nd@arm.com>; Herbert Guan <Herbert.Guan@arm.com>
> Subject: RE: [PATCH 01/17] framwork/packet: Add sniff_packet specify running
> 
> Phil,
> Please go on, I think this change won't affect most of suites.
> Please also keep packet module still workable with directly call. Some of our
> internal tools are using it for sniffing packets.
> 
> Regards,
> Marvin
> 
> > -----Original Message-----
> > From: Phil Yang [mailto:Phil.Yang@arm.com]
> > Sent: Wednesday, March 28, 2018 2:34 PM
> > To: Liu, Yong <yong.liu@intel.com>; dts@dpdk.org
> > Cc: nd <nd@arm.com>; Herbert Guan <Herbert.Guan@arm.com>
> > Subject: RE: [PATCH 01/17] framwork/packet: Add sniff_packet specify
> > running
> >
> > Hi Marvin,
> >
> > > -----Original Message-----
> > > From: Liu, Yong <yong.liu@intel.com>
> > > Sent: Wednesday, March 28, 2018 10:41 AM
> > > To: Phil Yang <Phil.Yang@arm.com>; dts@dpdk.org
> > > Cc: nd <nd@arm.com>; Herbert Guan <Herbert.Guan@arm.com>
> > > Subject: RE: [PATCH 01/17] framwork/packet: Add sniff_packet specify
> > running
> > >
> > > Hi Phil,
> > > In previous design, DTS will be run on tester for simple design and
> > stability.
> > > In our site, I can't see the benefit of change the design. Could you
> > please explain
> > > why you change it?
> > > Anyway we can change the design, but I think it will need some kind
> > > of
> > diagnosis
> > > about the impact.
> > > There may be some other staff depend on the assumption that DTS is
> > > on
> > the
> > > tester machine.
> >
> >
> > We are trying to use one machine as the controller to run DTS. The
> > controller communicate with testers which listed in the crbs.cfg by
> > SSH connection.
> > So the DTS will not running on tester.
> >
> > Since testers are connected with DUTs port by port, so I think
> > introduce controller into the DTS is more flexible to manager
> > machines. If other staff depend on the assumption that DTS is no the
> > tester machine, sniff_packet process will also connect to the tester by SSH
> connection.
> > Just one more SSH connection.
> > However, we cannot make sure the DTS is always running on the tester.
> >
> >
> > >
> > > Just for this patch. In load function, DTS machine should transmit
> > tester's pcap
> > > file first and then analyze packets.
> >
> > You are correct. Thanks to point out.
> >
> > If my proposal is acceptable, I will resend the version 2 to add the
> > transmit process.
> >
> > Thanks.
> >
> > >
> > > Regards,
> > > Marvin
> > >
> > > > -----Original Message-----
> > > > From: Phil Yang [mailto:phil.yang@arm.com]
> > > > Sent: Friday, March 23, 2018 4:04 PM
> > > > To: dts@dpdk.org
> > > > Cc: nd@arm.com; phil.yang@arm.com; Liu, Yong <yong.liu@intel.com>;
> > > > herbert.guan@arm.com
> > > > Subject: [PATCH 01/17] framwork/packet: Add sniff_packet specify
> > > > running
> > > >
> > > > 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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v2 01/17] framwork/packet: sniff_packet specify running target support
  2018-03-23  8:03 [dts] [PATCH 01/17] framwork/packet: Add sniff_packet specify running Phil Yang
                   ` (16 preceding siblings ...)
  2018-03-28  2:41 ` [dts] [PATCH 01/17] framwork/packet: Add sniff_packet specify running Liu, Yong
@ 2018-03-30 10:40 ` 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
                     ` (16 more replies)
  17 siblings, 17 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-30 10:40 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu

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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v2 02/17] tests/checksum_offload: Replace sniff_packet to tester.tcpdump_sniff_packet
  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   ` Phil Yang
  2018-03-30 10:40   ` [dts] [PATCH v2 03/17] tests/etag: " Phil Yang
                     ` (15 subsequent siblings)
  16 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-30 10:40 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_checksum_offload.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_checksum_offload.py b/tests/TestSuite_checksum_offload.py
index 2ff5c2f..aa43263 100644
--- a/tests/TestSuite_checksum_offload.py
+++ b/tests/TestSuite_checksum_offload.py
@@ -43,7 +43,6 @@ import utils
 
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets, strip_pktload
 from test_capabilities import DRIVER_TEST_LACK_CAPA
 
 class TestChecksumOffload(TestCase):
@@ -175,13 +174,15 @@ class TestChecksumOffload(TestCase):
 
         self.tester.send_expect("exit()", "#")
 
-        inst = sniff_packets(intf=rx_interface, count=len(packets_sent), filters=[{'layer':'ether', 'config':{'src': sniff_src}}])
+        inst = self.tester.tcpdump_sniff_packets(intf=rx_interface, count=len(packets_sent),
+                filters=[{'layer':'ether', 'config':{'src': sniff_src}}])
 
         for packet_type in packets_sent.keys():
             self.tester.scapy_append('sendp([%s], iface="%s")' % (packets_sent[packet_type], tx_interface))
 
         self.tester.scapy_execute()
-	p = load_sniff_packets(inst)
+        self.tester.session.copy_file_from("/tmp/sniff_%s.pcap" % self.rx_interface, "/tmp/")
+	p = self.tester.load_tcpdump_sniff_packets(inst)
 	nr_packets=len(p)
 	reslist = [p[i].pktgen.pkt.sprintf("%IP.chksum%;%TCP.chksum%;%UDP.chksum%;%SCTP.chksum%") for i in range(nr_packets)]
 	out = string.join(reslist, ",")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v2 03/17] tests/etag: Replace sniff_packet to tester.tcpdump_sniff_packet
  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   ` Phil Yang
  2018-03-30 10:40   ` [dts] [PATCH v2 04/17] tests/ipfrag: " Phil Yang
                     ` (14 subsequent siblings)
  16 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-30 10:40 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu

Make sniff_packet running on the tester. Create a ssh connection to
the tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_etag.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_etag.py b/tests/TestSuite_etag.py
index 642fb2b..a325a9e 100644
--- a/tests/TestSuite_etag.py
+++ b/tests/TestSuite_etag.py
@@ -46,7 +46,6 @@ from exception import VerifyFailure
 
 from scapy.utils import rdpcap
 
-from packet import Packet, sniff_packets, load_sniff_packets
 
 VM_CORES_MASK = 'all'
 
@@ -325,11 +324,12 @@ class TestEtag(TestCase):
         pkt_types = {'IP_RAW': {'layer_configs': config_layers}}
 
         intf = self.src_intf
-        inst = sniff_packets(intf)
+        inst = self.tester.tcpdump_sniff_packets(intf)
 
         self.check_packet_transmission(pkt_types)
         time.sleep(1)
-        pkts = load_sniff_packets(inst)
+        self.tester.session.copy_file_from("/tmp/sniff_%s.pcap" % intf, "/tmp/")
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         self.host_testpmd.execute_cmd('E-tag set insertion off port-tag-id 1000 port 0 vf 0')
 
         # load sniff pcap file, check received packet's content
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v2 04/17] tests/ipfrag: Replace sniff_packet to tester.tcpdump_sniff_packet
  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   ` 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
                     ` (13 subsequent siblings)
  16 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-30 10:40 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_ipfrag.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/tests/TestSuite_ipfrag.py b/tests/TestSuite_ipfrag.py
index f23dbe1..d5e8e5f 100644
--- a/tests/TestSuite_ipfrag.py
+++ b/tests/TestSuite_ipfrag.py
@@ -39,7 +39,6 @@ import string
 import re
 import time
 from settings import HEADER_SIZE
-from packet import Packet, sniff_packets, load_sniff_packets
 
 lpm_table_ipv4 = [
     "{IPv4(100,10,0,0), 16, P1}",
@@ -159,7 +158,7 @@ l3fwd_ipv4_route_array[] = {\\\n"
                 expPkts = 1
                 val = 2
 
-            inst = sniff_packets(intf=self.rxItf, timeout=5)
+            inst = self.tester.tcpdump_sniff_packets(intf=self.rxItf, timeout=5)
             # send packet
             for times in range(burst):
                 pkt_size = pkt_sizes[pkt_sizes.index(size) + times]
@@ -169,7 +168,8 @@ l3fwd_ipv4_route_array[] = {\\\n"
                 pkt.send_pkt(tx_port=self.txItf)
 
             # verify normal packet just by number, verify fragment packet by all elements
-            pkts = load_sniff_packets(inst)
+            self.tester.session.copy_file_from("/tmp/sniff_%s.pcap" % self.rxItf, "/tmp/")
+            pkts = self.tester.load_tcpdump_sniff_packets(inst)
             self.verify(len(pkts) == expPkts, "Failed on forward packet size " + str(size))
             if flag == 'frag':
                 idx = 1
@@ -209,7 +209,7 @@ l3fwd_ipv4_route_array[] = {\\\n"
                 expPkts = 1
                 val = 2
 
-            inst = sniff_packets(intf=self.rxItf, timeout=5)
+            inst = self.tester.tcpdump_sniff_packets(intf=self.rxItf, timeout=5)
             # send packet
             for times in range(burst):
                 pkt_size = pkt_sizes[pkt_sizes.index(size) + times]
@@ -219,7 +219,8 @@ l3fwd_ipv4_route_array[] = {\\\n"
                 pkt.send_pkt(tx_port=self.txItf)
 
             # verify normal packet just by number, verify fragment packet by all elements
-            pkts = load_sniff_packets(inst)
+            self.tester.session.copy_file_from("/tmp/sniff_%s.pcap" % self.rxItf, "/tmp/")
+            pkts = self.tester.load_tcpdump_sniff_packets(inst)
             self.verify(len(pkts) == expPkts, "Failed on forward packet size " + str(size))
             if flag == 'frag':
                 idx = 1
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v2 05/17] tests/l2fwd_crypto: Replace sniff_packets to tester.tcpdump_sniff_packets
  2018-03-30 10:40 ` [dts] [PATCH v2 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                     ` (2 preceding siblings ...)
  2018-03-30 10:40   ` [dts] [PATCH v2 04/17] tests/ipfrag: " Phil Yang
@ 2018-03-30 10:40   ` 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
                     ` (12 subsequent siblings)
  16 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-30 10:40 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_l2fwd_crypto.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_l2fwd_crypto.py b/tests/TestSuite_l2fwd_crypto.py
index d559909..1b2431e 100644
--- a/tests/TestSuite_l2fwd_crypto.py
+++ b/tests/TestSuite_l2fwd_crypto.py
@@ -38,7 +38,7 @@ import sys
 import utils
 import commands
 from test_case import TestCase
-from packet import Packet, sniff_packets, load_sniff_packets, save_packets
+from packet import Packet, save_packets
 
 from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
 from cryptography.hazmat.backends import default_backend
@@ -501,7 +501,7 @@ class TestL2fwdCrypto(TestCase):
 
             payload = self.__format_hex_to_list(test_vector["input"])
 
-            inst = sniff_packets(self.rx_interface, timeout=5)
+            inst = self.tester.tcpdump_sniff_packets(self.rx_interface, timeout=5)
 
             PACKET_COUNT = 65
             pkt = Packet()
@@ -512,7 +512,8 @@ class TestL2fwdCrypto(TestCase):
             pkt.send_pkt(tx_port=self.tx_interface, count=PACKET_COUNT)
             pkt.pktgen.pkt.show()
 
-            pkt_rec = load_sniff_packets(inst)
+            self.tester.session.copy_file_from("/tmp/sniff_%s.pcap" % self.rx_interface, "/tmp/")
+            pkt_rec = self.tester.load_tcpdump_sniff_packets(inst)
 
             for pkt_r in pkt_rec:
                 packet_hex = pkt_r.strip_element_layer4("load")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v2 06/17] tests/netmap_compat: Replace sniff_packet to tester.tcpdump_sniff_packet
  2018-03-30 10:40 ` [dts] [PATCH v2 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                     ` (3 preceding siblings ...)
  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   ` 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
                     ` (11 subsequent siblings)
  16 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-30 10:40 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_netmap_compat.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/TestSuite_netmap_compat.py b/tests/TestSuite_netmap_compat.py
index 5225a27..73c9fa3 100644
--- a/tests/TestSuite_netmap_compat.py
+++ b/tests/TestSuite_netmap_compat.py
@@ -43,7 +43,6 @@ from test_case import TestCase
 from plotting import Plotting 
 from settings import HEADER_SIZE   
 from etgen import IxiaPacketGenerator
-from packet import Packet, sniff_packets, load_sniff_packets
 
 class TestNetmapCompat(TestCase):
 
@@ -80,7 +79,7 @@ class TestNetmapCompat(TestCase):
 
         self.rxItf = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0]))
 
-        self.inst = sniff_packets(self.rxItf)
+        self.inst = self.tester.tcpdump_sniff_packets(self.rxItf)
 
         self.scapy_send_packet()
 
@@ -98,7 +97,7 @@ class TestNetmapCompat(TestCase):
         self.dut.send_expect(cmd,"Port %s now in Netmap mode" % self.dut_ports[0], 60)
        
         self.rxItf = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[1]))
-        self.inst = sniff_packets(self.rxItf)
+        self.inst = self.tester.tcpdump_sniff_packets(self.rxItf)
 
         self.scapy_send_packet()
 
@@ -117,7 +116,8 @@ class TestNetmapCompat(TestCase):
 
 
     def get_tcpdump_package(self):  
-        pkts = load_sniff_packets(self.inst)
+        self.tester.session.copy_file_from("/tmp/sniff_%s.pcap" % self.rxItf, "/tmp/")
+        pkts = self.tester.load_tcpdump_sniff_packets(self.inst)
         dsts = []  
         for packet in pkts:  
             dst = packet.strip_element_layer2("dst")  
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v2 07/17] tests/queue_start_stop: Replace sniff_packets to tester.tcpdump_sniff_packets
  2018-03-30 10:40 ` [dts] [PATCH v2 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                     ` (4 preceding siblings ...)
  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   ` Phil Yang
  2018-03-30 10:41   ` [dts] [PATCH v2 08/17] tests/quota_watermark: " Phil Yang
                     ` (10 subsequent siblings)
  16 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-30 10:40 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_queue_start_stop.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_queue_start_stop.py b/tests/TestSuite_queue_start_stop.py
index cc031f5..0f363c8 100644
--- a/tests/TestSuite_queue_start_stop.py
+++ b/tests/TestSuite_queue_start_stop.py
@@ -44,7 +44,7 @@ import os
 from test_case import TestCase
 from pmd_output import PmdOutput
 from settings import FOLDERS
-from packet import Packet, sniff_packets, load_sniff_packets, strip_pktload
+from packet import Packet, strip_pktload
 
 #
 #
@@ -99,10 +99,11 @@ class TestQueueStartStop(TestCase):
         dmac = self.dut.get_mac_address(txPort)
 
         pkt = Packet(pkt_type="UDP", pkt_len=pktSize)
-        inst = sniff_packets(rxitf)
+        inst = self.tester.tcpdump_sniff_packets(rxitf)
         pkt.config_layer('ether', {'dst': dmac})
         pkt.send_pkt(tx_port=txitf)
-        sniff_pkts = load_sniff_packets(inst)
+        self.tester.session.copy_file_from("/tmp/sniff_%s.pcap" % rxitf, "/tmp/")
+        sniff_pkts = self.tester.load_tcpdump_sniff_packets(inst)
 
         if received:
             res = strip_pktload(sniff_pkts[0], layer="L4")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v2 08/17] tests/quota_watermark: Replace sniff_packets to tester.tcpdump_sniff_packets
  2018-03-30 10:40 ` [dts] [PATCH v2 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                     ` (5 preceding siblings ...)
  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   ` Phil Yang
  2018-03-30 10:41   ` [dts] [PATCH v2 09/17] tests/rxtx_callback: " Phil Yang
                     ` (9 subsequent siblings)
  16 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-30 10:41 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_quota_watermark.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_quota_watermark.py b/tests/TestSuite_quota_watermark.py
index ecacf38..e36e539 100644
--- a/tests/TestSuite_quota_watermark.py
+++ b/tests/TestSuite_quota_watermark.py
@@ -39,7 +39,6 @@ import time
 import utils
 from test_case import TestCase
 from etgen import IxiaPacketGenerator
-from packet import Packet, sniff_packets, load_sniff_packets
 
 test_config = {
     'frames_to_sent': 15 * 10 ** 6,
@@ -311,9 +310,10 @@ class TestQuotaWatermark(TestCase, IxiaPacketGenerator):
         rx_intf = self.tester.get_interface(rev_port)
         tx_intf = self.tester.get_interface(send_port)
         # send and sniff packet
-        rx_inst = sniff_packets(rx_intf, timeout=5)
+        rx_inst = self.tester.tcpdump_sniff_packets(rx_intf, timeout=5)
         self.send_pcap_pkt_by_scapy(self.tester, tgen_input[0][2], tx_intf)
-        pkts = load_sniff_packets(rx_inst)
+        self.tester.session.copy_file_from("/tmp/sniff_%s.pcap" % rx_intf, "/tmp/")
+        pkts = self.tester.load_tcpdump_sniff_packets(rx_inst)
         self.verify(len(pkts) == pkt_cnt, "Packet not forwarded as expected")
 
         return
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v2 09/17] tests/rxtx_callback: Replace sniff_packets to tester.tcpdump_sniff_packets
  2018-03-30 10:40 ` [dts] [PATCH v2 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                     ` (6 preceding siblings ...)
  2018-03-30 10:41   ` [dts] [PATCH v2 08/17] tests/quota_watermark: " Phil Yang
@ 2018-03-30 10:41   ` Phil Yang
  2018-03-30 10:41   ` [dts] [PATCH v2 10/17] tests/scatter: " Phil Yang
                     ` (8 subsequent siblings)
  16 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-30 10:41 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_rxtx_callbacks.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_rxtx_callbacks.py b/tests/TestSuite_rxtx_callbacks.py
index dd968a4..aeddf59 100644
--- a/tests/TestSuite_rxtx_callbacks.py
+++ b/tests/TestSuite_rxtx_callbacks.py
@@ -41,7 +41,6 @@ from test_case import TestCase
 from plotting import Plotting
 from settings import HEADER_SIZE
 from etgen import IxiaPacketGenerator
-from packet import Packet, sniff_packets, load_sniff_packets
 
 
 class TestRxtxCallbacks(TestCase):
@@ -77,7 +76,7 @@ class TestRxtxCallbacks(TestCase):
         self.iface_port0 = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0]))
         self.iface_port1 = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[1]))
 
-        self.inst_port1 = sniff_packets(self.iface_port1)
+        self.inst_port1 = self.tester.tcpdump_sniff_packets(self.iface_port1)
         self.scapy_send_packet(self.iface_port0)
 
         out_port1 = self.get_tcpdump_package(self.inst_port1)
@@ -92,7 +91,8 @@ class TestRxtxCallbacks(TestCase):
         self.tester.scapy_execute()
 
     def get_tcpdump_package(self,inst):
-        pkts = load_sniff_packets(inst)
+        self.tester.session.copy_file_from("/tmp/sniff_%s.pcap" % self.iface_port1, "/tmp/")
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         dsts = []
         for packet in pkts:
             dst = packet.strip_element_layer2("dst")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v2 10/17] tests/scatter: Replace sniff_packets to tester.tcpdump_sniff_packets
  2018-03-30 10:40 ` [dts] [PATCH v2 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                     ` (7 preceding siblings ...)
  2018-03-30 10:41   ` [dts] [PATCH v2 09/17] tests/rxtx_callback: " Phil Yang
@ 2018-03-30 10:41   ` Phil Yang
  2018-03-30 10:41   ` [dts] [PATCH v2 11/17] tests/skeleton: " Phil Yang
                     ` (7 subsequent siblings)
  16 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-30 10:41 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_scatter.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_scatter.py b/tests/TestSuite_scatter.py
index 74fc08f..4169774 100644
--- a/tests/TestSuite_scatter.py
+++ b/tests/TestSuite_scatter.py
@@ -35,7 +35,7 @@ Test Scattered Packets.
 """
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets, strip_pktload
+from packet import Packet, strip_pktload
 import time
 #
 #
@@ -82,11 +82,12 @@ class TestScatter(TestCase):
         """
         dmac = self.dut.get_mac_address(self.port)
 
-        inst = sniff_packets(self.intf)
+        inst = self.tester.tcpdump_sniff_packets(self.intf)
         pkt = Packet(pkt_type="IP_RAW", pkt_len=pktsize)
         pkt.config_layer('ether', {'dst': dmac})
         pkt.send_pkt(tx_port=self.intf)
-        sniff_pkts = load_sniff_packets(inst)
+        self.tester.session.copy_file_from("/tmp/sniff_%s.pcap" % self.intf, "/tmp/")
+        sniff_pkts = self.tester.load_tcpdump_sniff_packets(inst)
 
         res = ""
         if len(sniff_pkts):
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v2 11/17] tests/skeleton: Replace sniff_packets to tester.tcpdump_sniff_packets
  2018-03-30 10:40 ` [dts] [PATCH v2 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                     ` (8 preceding siblings ...)
  2018-03-30 10:41   ` [dts] [PATCH v2 10/17] tests/scatter: " Phil Yang
@ 2018-03-30 10:41   ` Phil Yang
  2018-03-30 10:41   ` [dts] [PATCH v2 12/17] tests/userspace_ethtool: " Phil Yang
                     ` (6 subsequent siblings)
  16 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-30 10:41 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_skeleton.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_skeleton.py b/tests/TestSuite_skeleton.py
index 77f95e1..8f429f3 100644
--- a/tests/TestSuite_skeleton.py
+++ b/tests/TestSuite_skeleton.py
@@ -42,7 +42,6 @@ from plotting import Plotting
 from settings import HEADER_SIZE
 from etgen import IxiaPacketGenerator
 
-from packet import Packet, sniff_packets, load_sniff_packets
 
 
 class TestSkeleton(TestCase):
@@ -80,7 +79,7 @@ class TestSkeleton(TestCase):
         self.iface_port0 = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0]))
         self.iface_port1 = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[1]))
 
-        self.inst_port1 = sniff_packets(self.iface_port1)
+        self.inst_port1 = self.tester.tcpdump_sniff_packets(self.iface_port1)
         self.scapy_send_packet(self.iface_port0)
 
         out_port1 = self.get_tcpdump_package(self.inst_port1)
@@ -95,7 +94,8 @@ class TestSkeleton(TestCase):
         self.tester.scapy_execute()
 
     def get_tcpdump_package(self,inst):
-        pkts = load_sniff_packets(inst)
+        self.tester.session.copy_file_from("/tmp/sniff_%s.pcap" % self.iface_port1, "/tmp/")
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         dsts = []
         for packet in pkts:
             dst = packet.strip_element_layer2("dst")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v2 12/17] tests/userspace_ethtool: Replace sniff_packets to tester.tcpdump_sniff_packets
  2018-03-30 10:40 ` [dts] [PATCH v2 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                     ` (9 preceding siblings ...)
  2018-03-30 10:41   ` [dts] [PATCH v2 11/17] tests/skeleton: " Phil Yang
@ 2018-03-30 10:41   ` Phil Yang
  2018-03-30 10:41   ` [dts] [PATCH v2 13/17] tests/vf_daemon: " Phil Yang
                     ` (5 subsequent siblings)
  16 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-30 10:41 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_userspace_ethtool.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_userspace_ethtool.py b/tests/TestSuite_userspace_ethtool.py
index 84b1f1e..4a37a0b 100644
--- a/tests/TestSuite_userspace_ethtool.py
+++ b/tests/TestSuite_userspace_ethtool.py
@@ -39,7 +39,6 @@ import utils
 import time
 import re
 from test_case import TestCase
-from packet import Packet, sniff_packets, load_sniff_packets
 import random
 from etgen import IxiaPacketGenerator
 from settings import HEADER_SIZE
@@ -478,9 +477,10 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator):
             tester_port = self.tester.get_local_port(port)
             intf = self.tester.get_interface(tester_port)
             # send and sniff packet
-            inst = sniff_packets(intf, timeout=5)
+            inst = self.tester.tcpdump_sniff_packets(intf, timeout=5)
             pkt.send_pkt(tx_port=intf)
-            pkts = load_sniff_packets(inst)
+            self.tester.session.copy_file_from("/tmp/sniff_%s.pcap" % intf, "/tmp/")
+            pkts = self.tester.load_tcpdump_sniff_packets(inst)
             self.verify(len(pkts) == 1, "Packet not forwarded as expected")
             src_mac = pkts[0].strip_layer_element("layer2", "src")
             self.verify(src_mac == valid_mac, "Forwarded packet not match default mac")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v2 13/17] tests/vf_daemon: Replace sniff_packets to tester.tcpdump_sniff_packets
  2018-03-30 10:40 ` [dts] [PATCH v2 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                     ` (10 preceding siblings ...)
  2018-03-30 10:41   ` [dts] [PATCH v2 12/17] tests/userspace_ethtool: " Phil Yang
@ 2018-03-30 10:41   ` Phil Yang
  2018-03-30 10:41   ` [dts] [PATCH v2 14/17] tests/vf_vlan: " Phil Yang
                     ` (4 subsequent siblings)
  16 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-30 10:41 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_vf_daemon.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/tests/TestSuite_vf_daemon.py b/tests/TestSuite_vf_daemon.py
index b1ad522..15a95d7 100644
--- a/tests/TestSuite_vf_daemon.py
+++ b/tests/TestSuite_vf_daemon.py
@@ -8,7 +8,6 @@ from scapy.utils import rdpcap
 from qemu_kvm import QEMUKvm
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets
 from settings import get_nic_name
 import random
 
@@ -154,7 +153,7 @@ class Testvf_daemon(TestCase):
             pkt.config_layer('vlan', {'vlan': vlan_id})
         pkt.config_layer('ether', {'dst': dst_mac})
 
-        inst = sniff_packets(self.tester_intf, timeout=30)
+        inst = self.tester.tcpdump_sniff_packets(self.tester_intf, timeout=30)
         pkt.send_pkt(tx_port=self.tester_intf, count=num)
         return inst
 
@@ -162,7 +161,8 @@ class Testvf_daemon(TestCase):
         """
         Load sniff packets, strip and return mac address from dump message
         """
-        pkts = load_sniff_packets(inst)
+        self.tester.session.copy_file_from("/tmp/sniff_%s.pcap" % self.tester_intf, "/tmp/")
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         macs = []
         for pkt in pkts:
             mac = pkt.strip_element_layer2(element)
@@ -173,7 +173,8 @@ class Testvf_daemon(TestCase):
         """
         Load sniff packets, strip and return vlan id from dump message
         """
-        pkts = load_sniff_packets(inst)
+        self.tester.session.copy_file_from("/tmp/sniff_%s.pcap" % self.tester_intf, "/tmp/")
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         vlans = []
         for pkt in pkts:
             vlan = pkt.strip_element_vlan("vlan")
@@ -422,7 +423,7 @@ class Testvf_daemon(TestCase):
         self.dut_testpmd.execute_cmd('set tx loopback 0 off')
         time.sleep(5)
 
-        inst = sniff_packets(self.tester_intf, timeout=10)
+        inst = self.tester.tcpdump_sniff_packets(self.tester_intf, timeout=10)
 
         self.vm1_testpmd.execute_cmd('set burst 5')
         self.vm1_testpmd.execute_cmd('start tx_first')
@@ -438,7 +439,7 @@ class Testvf_daemon(TestCase):
         self.dut_testpmd.execute_cmd('set tx loopback 0 on')
         time.sleep(3)
 
-        inst = sniff_packets(self.tester_intf, timeout=10)
+        inst = self.tester.tcpdump_sniff_packets(self.tester_intf, timeout=10)
 
         self.vm1_testpmd.execute_cmd('stop')
         self.vm1_testpmd.execute_cmd('start tx_first')
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v2 14/17] tests/vf_vlan: Replace sniff_packets to tester.tcpdump_sniff_packets
  2018-03-30 10:40 ` [dts] [PATCH v2 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                     ` (11 preceding siblings ...)
  2018-03-30 10:41   ` [dts] [PATCH v2 13/17] tests/vf_daemon: " Phil Yang
@ 2018-03-30 10:41   ` Phil Yang
  2018-03-30 10:41   ` [dts] [PATCH v2 15/17] tests/vlan_ethertype_config: " Phil Yang
                     ` (3 subsequent siblings)
  16 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-30 10:41 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_vf_vlan.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/tests/TestSuite_vf_vlan.py b/tests/TestSuite_vf_vlan.py
index da9330d..b8fdef8 100644
--- a/tests/TestSuite_vf_vlan.py
+++ b/tests/TestSuite_vf_vlan.py
@@ -6,7 +6,6 @@ import time
 from virt_common import VM
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets
 from settings import get_nic_name
 import random
 
@@ -173,9 +172,10 @@ class TestVfVlan(TestCase):
 
         pkt = Packet(pkt_type='UDP')
         pkt.config_layer('ether', {'dst': self.vf1_mac})
-        inst = sniff_packets(self.tester_intf0, timeout=5)
+        inst = self.tester.tcpdump_sniff_packets(self.tester_intf0, timeout=5)
         pkt.send_pkt(tx_port=self.tester_intf1)
-        pkts = load_sniff_packets(inst)
+        self.tester.session.copy_file_from("/tmp/sniff_%s.pcap" % self.tester_intf0, "/tmp/")
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
 
         self.verify(len(pkts), "Not receive expected packet")
         self.vm0_testpmd.quit()
@@ -258,13 +258,14 @@ class TestVfVlan(TestCase):
             "ip link set %s vf 0 vlan 0" % (self.host_intf0), "# ")
 
     def tx_and_check(self, tx_vlan=1):
-        inst = sniff_packets(self.tester_intf0, timeout=5)
+        inst = self.tester.tcpdump_sniff_packets(self.tester_intf0, timeout=5)
         self.vm0_testpmd.execute_cmd('set burst 1')
         self.vm0_testpmd.execute_cmd('start tx_first')
         self.vm0_testpmd.execute_cmd('stop')
 
         # strip sniffered vlans
-        pkts = load_sniff_packets(inst)
+        self.tester.session.copy_file_from("/tmp/sniff_%s.pcap" % self.tester_intf0, "/tmp/")
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         vlans = []
         for pkt in pkts:
             vlan = pkt.strip_element_vlan("vlan")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v2 15/17] tests/vlan_ethertype_config: Replace sniff_packets to tester.tcpdump_sniff_packets
  2018-03-30 10:40 ` [dts] [PATCH v2 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                     ` (12 preceding siblings ...)
  2018-03-30 10:41   ` [dts] [PATCH v2 14/17] tests/vf_vlan: " Phil Yang
@ 2018-03-30 10:41   ` Phil Yang
  2018-03-30 10:41   ` [dts] [PATCH v2 16/17] tests/vlan: " Phil Yang
                     ` (2 subsequent siblings)
  16 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-30 10:41 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_vlan_ethertype_config.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tests/TestSuite_vlan_ethertype_config.py b/tests/TestSuite_vlan_ethertype_config.py
index 1fb30fb..413ec89 100644
--- a/tests/TestSuite_vlan_ethertype_config.py
+++ b/tests/TestSuite_vlan_ethertype_config.py
@@ -43,7 +43,6 @@ import utils
 
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets
 from scapy.utils import struct, socket, wrpcap, rdpcap
 from scapy.layers.inet import Ether, IP, TCP, UDP, ICMP
 from scapy.layers.l2 import Dot1Q, ARP, GRE
@@ -125,7 +124,7 @@ class TestVlanEthertypeConfig(TestCase):
         # off
         self.dmac = self.dut.get_mac_address(dutRxPortId)
 
-        self.inst = sniff_packets(self.rxItf)
+        self.inst = self.tester.tcpdump_sniff_packets(self.rxItf)
         pkt = []
         if outer_vid < 0 or outer_tpid <= 0:
             pkt = [
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v2 16/17] tests/vlan: Replace sniff_packets to tester.tcpdump_sniff_packets
  2018-03-30 10:40 ` [dts] [PATCH v2 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                     ` (13 preceding siblings ...)
  2018-03-30 10:41   ` [dts] [PATCH v2 15/17] tests/vlan_ethertype_config: " Phil Yang
@ 2018-03-30 10:41   ` 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
  16 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-30 10:41 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_vlan.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_vlan.py b/tests/TestSuite_vlan.py
index 0f1833b..16841dc 100644
--- a/tests/TestSuite_vlan.py
+++ b/tests/TestSuite_vlan.py
@@ -43,7 +43,6 @@ import time
 
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets
 
 
 class TestVlan(TestCase):
@@ -88,7 +87,8 @@ class TestVlan(TestCase):
             netobj.add_vlan(vlan_id = self.vlan)
 
     def get_tcpdump_package(self):
-        pkts = load_sniff_packets(self.inst)
+        self.tester.session.copy_file_from("/tmp/sniff_%s.pcap" % self.rxItf, "/tmp/")
+        pkts = self.tester.load_tcpdump_sniff_packets(self.inst)
         vlans = []
         for packet in pkts:
             vlan = packet.strip_element_vlan("vlan")
@@ -110,7 +110,7 @@ class TestVlan(TestCase):
         # the package dect mac must is dut tx port id when the port promisc is off
         self.dmac = self.dut.get_mac_address(dutRxPortId)
 
-        self.inst = sniff_packets(self.rxItf)
+        self.inst = self.tester.tcpdump_sniff_packets(self.rxItf)
         # FIXME  send a burst with only num packet
         if vid == -1:
             pkt = Packet(pkt_type='UDP')
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v2 17/17] tests/ipgre: Replace sniff_packets to tester.tcpdump_sniff_packets
  2018-03-30 10:40 ` [dts] [PATCH v2 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                     ` (14 preceding siblings ...)
  2018-03-30 10:41   ` [dts] [PATCH v2 16/17] tests/vlan: " Phil Yang
@ 2018-03-30 10:41   ` Phil Yang
  2018-04-02  3:46   ` [dts] [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
  16 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-03-30 10:41 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_ipgre.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_ipgre.py b/tests/TestSuite_ipgre.py
index 2dccb9c..24afce0 100644
--- a/tests/TestSuite_ipgre.py
+++ b/tests/TestSuite_ipgre.py
@@ -44,7 +44,7 @@ import re
 import time
 import os
 
-from packet import Packet, sniff_packets, load_sniff_packets, NVGRE, IPPROTO_NVGRE
+from packet import Packet, NVGRE, IPPROTO_NVGRE
 
 from scapy.utils import wrpcap, rdpcap
 from scapy.packet import split_layers,bind_layers
@@ -98,11 +98,12 @@ class TestIpgre(TestCase):
             if layer_configs:
                 for layer in layer_configs.keys():
                     pkt.config_layer(layer, layer_configs[layer])
-            inst = sniff_packets(self.tester_iface, count=1, timeout=8)
+            inst = self.tester.tcpdump_sniff_packets(self.tester_iface, count=1, timeout=8)
             pkt.send_pkt(tx_port=self.tester_iface)
             out = self.dut.get_session_output(timeout=2)
             time.sleep(1)
-            load_sniff_packets(inst)
+            self.tester.session.copy_file_from("/tmp/sniff_%s.pcap" % self.tester_iface, "/tmp/")
+            self.tester.load_tcpdump_sniff_packets(inst)
             if self.printFlag: # debug output
                 print out
             for pkt_layer_name in pkt_names:
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support
  2018-03-30 10:40 ` [dts] [PATCH v2 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                     ` (15 preceding siblings ...)
  2018-03-30 10:41   ` [dts] [PATCH v2 17/17] tests/ipgre: " Phil Yang
@ 2018-04-02  3:46   ` 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
                       ` (17 more replies)
  16 siblings, 18 replies; 124+ messages in thread
From: Phil Yang @ 2018-04-02  3:46 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, phil.yang

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
+        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/")
+
+        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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v3 02/17] tests/checksum_offload: Replace sniff_packet to tester.tcpdump_sniff_packet
  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     ` Phil Yang
  2018-04-02  3:46     ` [dts] [PATCH v3 03/17] tests/etag: " Phil Yang
                       ` (16 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-04-02  3:46 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, phil.yang

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_checksum_offload.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_checksum_offload.py b/tests/TestSuite_checksum_offload.py
index 2ff5c2f..6541ba5 100644
--- a/tests/TestSuite_checksum_offload.py
+++ b/tests/TestSuite_checksum_offload.py
@@ -43,7 +43,6 @@ import utils
 
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets, strip_pktload
 from test_capabilities import DRIVER_TEST_LACK_CAPA
 
 class TestChecksumOffload(TestCase):
@@ -175,13 +174,14 @@ class TestChecksumOffload(TestCase):
 
         self.tester.send_expect("exit()", "#")
 
-        inst = sniff_packets(intf=rx_interface, count=len(packets_sent), filters=[{'layer':'ether', 'config':{'src': sniff_src}}])
+        inst = self.tester.tcpdump_sniff_packets(intf=rx_interface, count=len(packets_sent),
+                filters=[{'layer':'ether', 'config':{'src': sniff_src}}])
 
         for packet_type in packets_sent.keys():
             self.tester.scapy_append('sendp([%s], iface="%s")' % (packets_sent[packet_type], tx_interface))
 
         self.tester.scapy_execute()
-	p = load_sniff_packets(inst)
+	p = self.tester.load_tcpdump_sniff_packets(inst)
 	nr_packets=len(p)
 	reslist = [p[i].pktgen.pkt.sprintf("%IP.chksum%;%TCP.chksum%;%UDP.chksum%;%SCTP.chksum%") for i in range(nr_packets)]
 	out = string.join(reslist, ",")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v3 03/17] tests/etag: Replace sniff_packet to tester.tcpdump_sniff_packet
  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     ` Phil Yang
  2018-04-02  3:46     ` [dts] [PATCH v3 04/17] tests/ipfrag: " Phil Yang
                       ` (15 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-04-02  3:46 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, phil.yang

Make sniff_packet running on the tester. Create a ssh connection to
the tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_etag.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_etag.py b/tests/TestSuite_etag.py
index 642fb2b..a2fb699 100644
--- a/tests/TestSuite_etag.py
+++ b/tests/TestSuite_etag.py
@@ -46,7 +46,6 @@ from exception import VerifyFailure
 
 from scapy.utils import rdpcap
 
-from packet import Packet, sniff_packets, load_sniff_packets
 
 VM_CORES_MASK = 'all'
 
@@ -325,11 +324,11 @@ class TestEtag(TestCase):
         pkt_types = {'IP_RAW': {'layer_configs': config_layers}}
 
         intf = self.src_intf
-        inst = sniff_packets(intf)
+        inst = self.tester.tcpdump_sniff_packets(intf)
 
         self.check_packet_transmission(pkt_types)
         time.sleep(1)
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         self.host_testpmd.execute_cmd('E-tag set insertion off port-tag-id 1000 port 0 vf 0')
 
         # load sniff pcap file, check received packet's content
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v3 04/17] tests/ipfrag: Replace sniff_packet to tester.tcpdump_sniff_packet
  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     ` 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
                       ` (14 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-04-02  3:46 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, phil.yang

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_ipfrag.py | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/tests/TestSuite_ipfrag.py b/tests/TestSuite_ipfrag.py
index f23dbe1..9ebda1f 100644
--- a/tests/TestSuite_ipfrag.py
+++ b/tests/TestSuite_ipfrag.py
@@ -39,7 +39,6 @@ import string
 import re
 import time
 from settings import HEADER_SIZE
-from packet import Packet, sniff_packets, load_sniff_packets
 
 lpm_table_ipv4 = [
     "{IPv4(100,10,0,0), 16, P1}",
@@ -159,7 +158,7 @@ l3fwd_ipv4_route_array[] = {\\\n"
                 expPkts = 1
                 val = 2
 
-            inst = sniff_packets(intf=self.rxItf, timeout=5)
+            inst = self.tester.tcpdump_sniff_packets(intf=self.rxItf, timeout=5)
             # send packet
             for times in range(burst):
                 pkt_size = pkt_sizes[pkt_sizes.index(size) + times]
@@ -169,7 +168,7 @@ l3fwd_ipv4_route_array[] = {\\\n"
                 pkt.send_pkt(tx_port=self.txItf)
 
             # verify normal packet just by number, verify fragment packet by all elements
-            pkts = load_sniff_packets(inst)
+            pkts = self.tester.load_tcpdump_sniff_packets(inst)
             self.verify(len(pkts) == expPkts, "Failed on forward packet size " + str(size))
             if flag == 'frag':
                 idx = 1
@@ -209,7 +208,7 @@ l3fwd_ipv4_route_array[] = {\\\n"
                 expPkts = 1
                 val = 2
 
-            inst = sniff_packets(intf=self.rxItf, timeout=5)
+            inst = self.tester.tcpdump_sniff_packets(intf=self.rxItf, timeout=5)
             # send packet
             for times in range(burst):
                 pkt_size = pkt_sizes[pkt_sizes.index(size) + times]
@@ -219,7 +218,7 @@ l3fwd_ipv4_route_array[] = {\\\n"
                 pkt.send_pkt(tx_port=self.txItf)
 
             # verify normal packet just by number, verify fragment packet by all elements
-            pkts = load_sniff_packets(inst)
+            pkts = self.tester.load_tcpdump_sniff_packets(inst)
             self.verify(len(pkts) == expPkts, "Failed on forward packet size " + str(size))
             if flag == 'frag':
                 idx = 1
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v3 05/17] tests/l2fwd_crypto: Replace sniff_packets to tester.tcpdump_sniff_packets
  2018-04-02  3:46   ` [dts] [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                       ` (2 preceding siblings ...)
  2018-04-02  3:46     ` [dts] [PATCH v3 04/17] tests/ipfrag: " Phil Yang
@ 2018-04-02  3:46     ` 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
                       ` (13 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-04-02  3:46 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, phil.yang

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_l2fwd_crypto.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_l2fwd_crypto.py b/tests/TestSuite_l2fwd_crypto.py
index d559909..ea35a29 100644
--- a/tests/TestSuite_l2fwd_crypto.py
+++ b/tests/TestSuite_l2fwd_crypto.py
@@ -38,7 +38,7 @@ import sys
 import utils
 import commands
 from test_case import TestCase
-from packet import Packet, sniff_packets, load_sniff_packets, save_packets
+from packet import Packet, save_packets
 
 from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
 from cryptography.hazmat.backends import default_backend
@@ -501,7 +501,7 @@ class TestL2fwdCrypto(TestCase):
 
             payload = self.__format_hex_to_list(test_vector["input"])
 
-            inst = sniff_packets(self.rx_interface, timeout=5)
+            inst = self.tester.tcpdump_sniff_packets(self.rx_interface, timeout=5)
 
             PACKET_COUNT = 65
             pkt = Packet()
@@ -512,7 +512,7 @@ class TestL2fwdCrypto(TestCase):
             pkt.send_pkt(tx_port=self.tx_interface, count=PACKET_COUNT)
             pkt.pktgen.pkt.show()
 
-            pkt_rec = load_sniff_packets(inst)
+            pkt_rec = self.tester.load_tcpdump_sniff_packets(inst)
 
             for pkt_r in pkt_rec:
                 packet_hex = pkt_r.strip_element_layer4("load")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v3 06/17] tests/netmap_compat: Replace sniff_packet to tester.tcpdump_sniff_packet
  2018-04-02  3:46   ` [dts] [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                       ` (3 preceding siblings ...)
  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     ` 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
                       ` (12 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-04-02  3:46 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, phil.yang

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_netmap_compat.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/tests/TestSuite_netmap_compat.py b/tests/TestSuite_netmap_compat.py
index 5225a27..84136c7 100644
--- a/tests/TestSuite_netmap_compat.py
+++ b/tests/TestSuite_netmap_compat.py
@@ -43,7 +43,6 @@ from test_case import TestCase
 from plotting import Plotting 
 from settings import HEADER_SIZE   
 from etgen import IxiaPacketGenerator
-from packet import Packet, sniff_packets, load_sniff_packets
 
 class TestNetmapCompat(TestCase):
 
@@ -80,7 +79,7 @@ class TestNetmapCompat(TestCase):
 
         self.rxItf = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0]))
 
-        self.inst = sniff_packets(self.rxItf)
+        self.inst = self.tester.tcpdump_sniff_packets(self.rxItf)
 
         self.scapy_send_packet()
 
@@ -98,7 +97,7 @@ class TestNetmapCompat(TestCase):
         self.dut.send_expect(cmd,"Port %s now in Netmap mode" % self.dut_ports[0], 60)
        
         self.rxItf = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[1]))
-        self.inst = sniff_packets(self.rxItf)
+        self.inst = self.tester.tcpdump_sniff_packets(self.rxItf)
 
         self.scapy_send_packet()
 
@@ -117,7 +116,7 @@ class TestNetmapCompat(TestCase):
 
 
     def get_tcpdump_package(self):  
-        pkts = load_sniff_packets(self.inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(self.inst)
         dsts = []  
         for packet in pkts:  
             dst = packet.strip_element_layer2("dst")  
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v3 07/17] tests/queue_start_stop: Replace sniff_packets to tester.tcpdump_sniff_packets
  2018-04-02  3:46   ` [dts] [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                       ` (4 preceding siblings ...)
  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     ` Phil Yang
  2018-04-02  3:46     ` [dts] [PATCH v3 08/17] tests/quota_watermark: " Phil Yang
                       ` (11 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-04-02  3:46 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, phil.yang

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_queue_start_stop.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_queue_start_stop.py b/tests/TestSuite_queue_start_stop.py
index cc031f5..bf69666 100644
--- a/tests/TestSuite_queue_start_stop.py
+++ b/tests/TestSuite_queue_start_stop.py
@@ -44,7 +44,7 @@ import os
 from test_case import TestCase
 from pmd_output import PmdOutput
 from settings import FOLDERS
-from packet import Packet, sniff_packets, load_sniff_packets, strip_pktload
+from packet import Packet, strip_pktload
 
 #
 #
@@ -99,10 +99,10 @@ class TestQueueStartStop(TestCase):
         dmac = self.dut.get_mac_address(txPort)
 
         pkt = Packet(pkt_type="UDP", pkt_len=pktSize)
-        inst = sniff_packets(rxitf)
+        inst = self.tester.tcpdump_sniff_packets(rxitf)
         pkt.config_layer('ether', {'dst': dmac})
         pkt.send_pkt(tx_port=txitf)
-        sniff_pkts = load_sniff_packets(inst)
+        sniff_pkts = self.tester.load_tcpdump_sniff_packets(inst)
 
         if received:
             res = strip_pktload(sniff_pkts[0], layer="L4")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v3 08/17] tests/quota_watermark: Replace sniff_packets to tester.tcpdump_sniff_packets
  2018-04-02  3:46   ` [dts] [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                       ` (5 preceding siblings ...)
  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     ` Phil Yang
  2018-04-02  3:46     ` [dts] [PATCH v3 09/17] tests/rxtx_callback: " Phil Yang
                       ` (10 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-04-02  3:46 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, phil.yang

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_quota_watermark.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_quota_watermark.py b/tests/TestSuite_quota_watermark.py
index ecacf38..845b27f 100644
--- a/tests/TestSuite_quota_watermark.py
+++ b/tests/TestSuite_quota_watermark.py
@@ -39,7 +39,6 @@ import time
 import utils
 from test_case import TestCase
 from etgen import IxiaPacketGenerator
-from packet import Packet, sniff_packets, load_sniff_packets
 
 test_config = {
     'frames_to_sent': 15 * 10 ** 6,
@@ -311,9 +310,9 @@ class TestQuotaWatermark(TestCase, IxiaPacketGenerator):
         rx_intf = self.tester.get_interface(rev_port)
         tx_intf = self.tester.get_interface(send_port)
         # send and sniff packet
-        rx_inst = sniff_packets(rx_intf, timeout=5)
+        rx_inst = self.tester.tcpdump_sniff_packets(rx_intf, timeout=5)
         self.send_pcap_pkt_by_scapy(self.tester, tgen_input[0][2], tx_intf)
-        pkts = load_sniff_packets(rx_inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(rx_inst)
         self.verify(len(pkts) == pkt_cnt, "Packet not forwarded as expected")
 
         return
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v3 09/17] tests/rxtx_callback: Replace sniff_packets to tester.tcpdump_sniff_packets
  2018-04-02  3:46   ` [dts] [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                       ` (6 preceding siblings ...)
  2018-04-02  3:46     ` [dts] [PATCH v3 08/17] tests/quota_watermark: " Phil Yang
@ 2018-04-02  3:46     ` Phil Yang
  2018-04-02  3:46     ` [dts] [PATCH v3 10/17] tests/scatter: " Phil Yang
                       ` (9 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-04-02  3:46 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, phil.yang

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_rxtx_callbacks.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_rxtx_callbacks.py b/tests/TestSuite_rxtx_callbacks.py
index dd968a4..a654480 100644
--- a/tests/TestSuite_rxtx_callbacks.py
+++ b/tests/TestSuite_rxtx_callbacks.py
@@ -41,7 +41,6 @@ from test_case import TestCase
 from plotting import Plotting
 from settings import HEADER_SIZE
 from etgen import IxiaPacketGenerator
-from packet import Packet, sniff_packets, load_sniff_packets
 
 
 class TestRxtxCallbacks(TestCase):
@@ -77,7 +76,7 @@ class TestRxtxCallbacks(TestCase):
         self.iface_port0 = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0]))
         self.iface_port1 = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[1]))
 
-        self.inst_port1 = sniff_packets(self.iface_port1)
+        self.inst_port1 = self.tester.tcpdump_sniff_packets(self.iface_port1)
         self.scapy_send_packet(self.iface_port0)
 
         out_port1 = self.get_tcpdump_package(self.inst_port1)
@@ -92,7 +91,7 @@ class TestRxtxCallbacks(TestCase):
         self.tester.scapy_execute()
 
     def get_tcpdump_package(self,inst):
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         dsts = []
         for packet in pkts:
             dst = packet.strip_element_layer2("dst")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v3 10/17] tests/scatter: Replace sniff_packets to tester.tcpdump_sniff_packets
  2018-04-02  3:46   ` [dts] [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                       ` (7 preceding siblings ...)
  2018-04-02  3:46     ` [dts] [PATCH v3 09/17] tests/rxtx_callback: " Phil Yang
@ 2018-04-02  3:46     ` Phil Yang
  2018-04-02  3:46     ` [dts] [PATCH v3 11/17] tests/skeleton: " Phil Yang
                       ` (8 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-04-02  3:46 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, phil.yang

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_scatter.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_scatter.py b/tests/TestSuite_scatter.py
index 74fc08f..4db0bb0 100644
--- a/tests/TestSuite_scatter.py
+++ b/tests/TestSuite_scatter.py
@@ -35,7 +35,7 @@ Test Scattered Packets.
 """
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets, strip_pktload
+from packet import Packet, strip_pktload
 import time
 #
 #
@@ -82,11 +82,11 @@ class TestScatter(TestCase):
         """
         dmac = self.dut.get_mac_address(self.port)
 
-        inst = sniff_packets(self.intf)
+        inst = self.tester.tcpdump_sniff_packets(self.intf)
         pkt = Packet(pkt_type="IP_RAW", pkt_len=pktsize)
         pkt.config_layer('ether', {'dst': dmac})
         pkt.send_pkt(tx_port=self.intf)
-        sniff_pkts = load_sniff_packets(inst)
+        sniff_pkts = self.tester.load_tcpdump_sniff_packets(inst)
 
         res = ""
         if len(sniff_pkts):
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v3 11/17] tests/skeleton: Replace sniff_packets to tester.tcpdump_sniff_packets
  2018-04-02  3:46   ` [dts] [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                       ` (8 preceding siblings ...)
  2018-04-02  3:46     ` [dts] [PATCH v3 10/17] tests/scatter: " Phil Yang
@ 2018-04-02  3:46     ` Phil Yang
  2018-04-02  3:46     ` [dts] [PATCH v3 12/17] tests/userspace_ethtool: " Phil Yang
                       ` (7 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-04-02  3:46 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, phil.yang

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_skeleton.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_skeleton.py b/tests/TestSuite_skeleton.py
index 77f95e1..b56d955 100644
--- a/tests/TestSuite_skeleton.py
+++ b/tests/TestSuite_skeleton.py
@@ -42,7 +42,6 @@ from plotting import Plotting
 from settings import HEADER_SIZE
 from etgen import IxiaPacketGenerator
 
-from packet import Packet, sniff_packets, load_sniff_packets
 
 
 class TestSkeleton(TestCase):
@@ -80,7 +79,7 @@ class TestSkeleton(TestCase):
         self.iface_port0 = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0]))
         self.iface_port1 = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[1]))
 
-        self.inst_port1 = sniff_packets(self.iface_port1)
+        self.inst_port1 = self.tester.tcpdump_sniff_packets(self.iface_port1)
         self.scapy_send_packet(self.iface_port0)
 
         out_port1 = self.get_tcpdump_package(self.inst_port1)
@@ -95,7 +94,7 @@ class TestSkeleton(TestCase):
         self.tester.scapy_execute()
 
     def get_tcpdump_package(self,inst):
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         dsts = []
         for packet in pkts:
             dst = packet.strip_element_layer2("dst")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v3 12/17] tests/userspace_ethtool: Replace sniff_packets to tester.tcpdump_sniff_packets
  2018-04-02  3:46   ` [dts] [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                       ` (9 preceding siblings ...)
  2018-04-02  3:46     ` [dts] [PATCH v3 11/17] tests/skeleton: " Phil Yang
@ 2018-04-02  3:46     ` Phil Yang
  2018-04-02  3:46     ` [dts] [PATCH v3 13/17] tests/vf_daemon: " Phil Yang
                       ` (6 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-04-02  3:46 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, phil.yang

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_userspace_ethtool.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_userspace_ethtool.py b/tests/TestSuite_userspace_ethtool.py
index 84b1f1e..edcfc88 100644
--- a/tests/TestSuite_userspace_ethtool.py
+++ b/tests/TestSuite_userspace_ethtool.py
@@ -39,7 +39,6 @@ import utils
 import time
 import re
 from test_case import TestCase
-from packet import Packet, sniff_packets, load_sniff_packets
 import random
 from etgen import IxiaPacketGenerator
 from settings import HEADER_SIZE
@@ -478,9 +477,9 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator):
             tester_port = self.tester.get_local_port(port)
             intf = self.tester.get_interface(tester_port)
             # send and sniff packet
-            inst = sniff_packets(intf, timeout=5)
+            inst = self.tester.tcpdump_sniff_packets(intf, timeout=5)
             pkt.send_pkt(tx_port=intf)
-            pkts = load_sniff_packets(inst)
+            pkts = self.tester.load_tcpdump_sniff_packets(inst)
             self.verify(len(pkts) == 1, "Packet not forwarded as expected")
             src_mac = pkts[0].strip_layer_element("layer2", "src")
             self.verify(src_mac == valid_mac, "Forwarded packet not match default mac")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v3 13/17] tests/vf_daemon: Replace sniff_packets to tester.tcpdump_sniff_packets
  2018-04-02  3:46   ` [dts] [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                       ` (10 preceding siblings ...)
  2018-04-02  3:46     ` [dts] [PATCH v3 12/17] tests/userspace_ethtool: " Phil Yang
@ 2018-04-02  3:46     ` Phil Yang
  2018-04-02  3:46     ` [dts] [PATCH v3 14/17] tests/vf_vlan: " Phil Yang
                       ` (5 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-04-02  3:46 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, phil.yang

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_vf_daemon.py | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/tests/TestSuite_vf_daemon.py b/tests/TestSuite_vf_daemon.py
index b1ad522..e256825 100644
--- a/tests/TestSuite_vf_daemon.py
+++ b/tests/TestSuite_vf_daemon.py
@@ -8,7 +8,6 @@ from scapy.utils import rdpcap
 from qemu_kvm import QEMUKvm
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets
 from settings import get_nic_name
 import random
 
@@ -154,7 +153,7 @@ class Testvf_daemon(TestCase):
             pkt.config_layer('vlan', {'vlan': vlan_id})
         pkt.config_layer('ether', {'dst': dst_mac})
 
-        inst = sniff_packets(self.tester_intf, timeout=30)
+        inst = self.tester.tcpdump_sniff_packets(self.tester_intf, timeout=30)
         pkt.send_pkt(tx_port=self.tester_intf, count=num)
         return inst
 
@@ -162,7 +161,7 @@ class Testvf_daemon(TestCase):
         """
         Load sniff packets, strip and return mac address from dump message
         """
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         macs = []
         for pkt in pkts:
             mac = pkt.strip_element_layer2(element)
@@ -173,7 +172,7 @@ class Testvf_daemon(TestCase):
         """
         Load sniff packets, strip and return vlan id from dump message
         """
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         vlans = []
         for pkt in pkts:
             vlan = pkt.strip_element_vlan("vlan")
@@ -422,7 +421,7 @@ class Testvf_daemon(TestCase):
         self.dut_testpmd.execute_cmd('set tx loopback 0 off')
         time.sleep(5)
 
-        inst = sniff_packets(self.tester_intf, timeout=10)
+        inst = self.tester.tcpdump_sniff_packets(self.tester_intf, timeout=10)
 
         self.vm1_testpmd.execute_cmd('set burst 5')
         self.vm1_testpmd.execute_cmd('start tx_first')
@@ -438,7 +437,7 @@ class Testvf_daemon(TestCase):
         self.dut_testpmd.execute_cmd('set tx loopback 0 on')
         time.sleep(3)
 
-        inst = sniff_packets(self.tester_intf, timeout=10)
+        inst = self.tester.tcpdump_sniff_packets(self.tester_intf, timeout=10)
 
         self.vm1_testpmd.execute_cmd('stop')
         self.vm1_testpmd.execute_cmd('start tx_first')
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v3 14/17] tests/vf_vlan: Replace sniff_packets to tester.tcpdump_sniff_packets
  2018-04-02  3:46   ` [dts] [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                       ` (11 preceding siblings ...)
  2018-04-02  3:46     ` [dts] [PATCH v3 13/17] tests/vf_daemon: " Phil Yang
@ 2018-04-02  3:46     ` Phil Yang
  2018-04-02  3:46     ` [dts] [PATCH v3 15/17] tests/vlan_ethertype_config: " Phil Yang
                       ` (4 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-04-02  3:46 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, phil.yang

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_vf_vlan.py | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/tests/TestSuite_vf_vlan.py b/tests/TestSuite_vf_vlan.py
index da9330d..8af7e5a 100644
--- a/tests/TestSuite_vf_vlan.py
+++ b/tests/TestSuite_vf_vlan.py
@@ -6,7 +6,6 @@ import time
 from virt_common import VM
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets
 from settings import get_nic_name
 import random
 
@@ -173,9 +172,9 @@ class TestVfVlan(TestCase):
 
         pkt = Packet(pkt_type='UDP')
         pkt.config_layer('ether', {'dst': self.vf1_mac})
-        inst = sniff_packets(self.tester_intf0, timeout=5)
+        inst = self.tester.tcpdump_sniff_packets(self.tester_intf0, timeout=5)
         pkt.send_pkt(tx_port=self.tester_intf1)
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
 
         self.verify(len(pkts), "Not receive expected packet")
         self.vm0_testpmd.quit()
@@ -258,13 +257,13 @@ class TestVfVlan(TestCase):
             "ip link set %s vf 0 vlan 0" % (self.host_intf0), "# ")
 
     def tx_and_check(self, tx_vlan=1):
-        inst = sniff_packets(self.tester_intf0, timeout=5)
+        inst = self.tester.tcpdump_sniff_packets(self.tester_intf0, timeout=5)
         self.vm0_testpmd.execute_cmd('set burst 1')
         self.vm0_testpmd.execute_cmd('start tx_first')
         self.vm0_testpmd.execute_cmd('stop')
 
         # strip sniffered vlans
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         vlans = []
         for pkt in pkts:
             vlan = pkt.strip_element_vlan("vlan")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v3 15/17] tests/vlan_ethertype_config: Replace sniff_packets to tester.tcpdump_sniff_packets
  2018-04-02  3:46   ` [dts] [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                       ` (12 preceding siblings ...)
  2018-04-02  3:46     ` [dts] [PATCH v3 14/17] tests/vf_vlan: " Phil Yang
@ 2018-04-02  3:46     ` Phil Yang
  2018-04-02  3:46     ` [dts] [PATCH v3 16/17] tests/vlan: " Phil Yang
                       ` (3 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-04-02  3:46 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, phil.yang

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_vlan_ethertype_config.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tests/TestSuite_vlan_ethertype_config.py b/tests/TestSuite_vlan_ethertype_config.py
index 1fb30fb..413ec89 100644
--- a/tests/TestSuite_vlan_ethertype_config.py
+++ b/tests/TestSuite_vlan_ethertype_config.py
@@ -43,7 +43,6 @@ import utils
 
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets
 from scapy.utils import struct, socket, wrpcap, rdpcap
 from scapy.layers.inet import Ether, IP, TCP, UDP, ICMP
 from scapy.layers.l2 import Dot1Q, ARP, GRE
@@ -125,7 +124,7 @@ class TestVlanEthertypeConfig(TestCase):
         # off
         self.dmac = self.dut.get_mac_address(dutRxPortId)
 
-        self.inst = sniff_packets(self.rxItf)
+        self.inst = self.tester.tcpdump_sniff_packets(self.rxItf)
         pkt = []
         if outer_vid < 0 or outer_tpid <= 0:
             pkt = [
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v3 16/17] tests/vlan: Replace sniff_packets to tester.tcpdump_sniff_packets
  2018-04-02  3:46   ` [dts] [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                       ` (13 preceding siblings ...)
  2018-04-02  3:46     ` [dts] [PATCH v3 15/17] tests/vlan_ethertype_config: " Phil Yang
@ 2018-04-02  3:46     ` Phil Yang
  2018-04-02  3:46     ` [dts] [PATCH v3 17/17] tests/ipgre: " Phil Yang
                       ` (2 subsequent siblings)
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-04-02  3:46 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, phil.yang

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_vlan.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_vlan.py b/tests/TestSuite_vlan.py
index 0f1833b..2b70ffa 100644
--- a/tests/TestSuite_vlan.py
+++ b/tests/TestSuite_vlan.py
@@ -43,7 +43,6 @@ import time
 
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets
 
 
 class TestVlan(TestCase):
@@ -88,7 +87,7 @@ class TestVlan(TestCase):
             netobj.add_vlan(vlan_id = self.vlan)
 
     def get_tcpdump_package(self):
-        pkts = load_sniff_packets(self.inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(self.inst)
         vlans = []
         for packet in pkts:
             vlan = packet.strip_element_vlan("vlan")
@@ -110,7 +109,7 @@ class TestVlan(TestCase):
         # the package dect mac must is dut tx port id when the port promisc is off
         self.dmac = self.dut.get_mac_address(dutRxPortId)
 
-        self.inst = sniff_packets(self.rxItf)
+        self.inst = self.tester.tcpdump_sniff_packets(self.rxItf)
         # FIXME  send a burst with only num packet
         if vid == -1:
             pkt = Packet(pkt_type='UDP')
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v3 17/17] tests/ipgre: Replace sniff_packets to tester.tcpdump_sniff_packets
  2018-04-02  3:46   ` [dts] [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                       ` (14 preceding siblings ...)
  2018-04-02  3:46     ` [dts] [PATCH v3 16/17] tests/vlan: " Phil Yang
@ 2018-04-02  3:46     ` Phil Yang
  2018-04-04  3:28     ` [dts] [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support Liu, Yong
  2018-04-12  9:52     ` [dts] [PATCH v4] " Phil Yang
  17 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-04-02  3:46 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, phil.yang

Make sniff_packet running on the tester. Create a ssh connection to the
tester then call tcpdump.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 tests/TestSuite_ipgre.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_ipgre.py b/tests/TestSuite_ipgre.py
index 2dccb9c..e400161 100644
--- a/tests/TestSuite_ipgre.py
+++ b/tests/TestSuite_ipgre.py
@@ -44,7 +44,7 @@ import re
 import time
 import os
 
-from packet import Packet, sniff_packets, load_sniff_packets, NVGRE, IPPROTO_NVGRE
+from packet import Packet, NVGRE, IPPROTO_NVGRE
 
 from scapy.utils import wrpcap, rdpcap
 from scapy.packet import split_layers,bind_layers
@@ -98,11 +98,11 @@ class TestIpgre(TestCase):
             if layer_configs:
                 for layer in layer_configs.keys():
                     pkt.config_layer(layer, layer_configs[layer])
-            inst = sniff_packets(self.tester_iface, count=1, timeout=8)
+            inst = self.tester.tcpdump_sniff_packets(self.tester_iface, count=1, timeout=8)
             pkt.send_pkt(tx_port=self.tester_iface)
             out = self.dut.get_session_output(timeout=2)
             time.sleep(1)
-            load_sniff_packets(inst)
+            self.tester.load_tcpdump_sniff_packets(inst)
             if self.printFlag: # debug output
                 print out
             for pkt_layer_name in pkt_names:
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* Re: [dts] [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support
  2018-04-02  3:46   ` [dts] [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                       ` (15 preceding siblings ...)
  2018-04-02  3:46     ` [dts] [PATCH v3 17/17] tests/ipgre: " Phil Yang
@ 2018-04-04  3:28     ` Liu, Yong
  2018-04-04  7:27       ` Phil Yang
  2018-04-12  9:52     ` [dts] [PATCH v4] " Phil Yang
  17 siblings, 1 reply; 124+ messages in thread
From: Liu, Yong @ 2018-04-04  3:28 UTC (permalink / raw)
  To: Phil Yang, dts; +Cc: nd

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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* Re: [dts] [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support
  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
  0 siblings, 1 reply; 124+ messages in thread
From: Phil Yang @ 2018-04-04  7:27 UTC (permalink / raw)
  To: Liu, Yong, dts; +Cc: nd

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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* Re: [dts] [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support
  2018-04-04  7:27       ` Phil Yang
@ 2018-04-08  6:35         ` Liu, Yong
  2018-04-12  7:38           ` Phil Yang
  0 siblings, 1 reply; 124+ messages in thread
From: Liu, Yong @ 2018-04-08  6:35 UTC (permalink / raw)
  To: Phil Yang, dts; +Cc: nd

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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* Re: [dts] [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support
  2018-04-08  6:35         ` Liu, Yong
@ 2018-04-12  7:38           ` Phil Yang
  2018-04-12  7:45             ` Liu, Yong
  0 siblings, 1 reply; 124+ messages in thread
From: Phil Yang @ 2018-04-12  7:38 UTC (permalink / raw)
  To: Liu, Yong, dts; +Cc: nd

Hi Marvin,

Great idea! I'll Update it. After test, I'll upstream the patch ASAP.

BTW, Can I just upstream this single patch as V4? Because other files are keep unchanged. 

Thanks,
Phil Yang

> -----Original Message-----
> From: Liu, Yong <yong.liu@intel.com>
> Sent: Sunday, April 8, 2018 2:36 PM
> 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
> 
> 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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* Re: [dts] [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support
  2018-04-12  7:38           ` Phil Yang
@ 2018-04-12  7:45             ` Liu, Yong
  0 siblings, 0 replies; 124+ messages in thread
From: Liu, Yong @ 2018-04-12  7:45 UTC (permalink / raw)
  To: Phil Yang, dts; +Cc: nd

You're welcome, Phil. Sure, you can send one single patch for v4.

> -----Original Message-----
> From: Phil Yang [mailto:Phil.Yang@arm.com]
> Sent: Thursday, April 12, 2018 3:39 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,
> 
> Great idea! I'll Update it. After test, I'll upstream the patch ASAP.
> 
> BTW, Can I just upstream this single patch as V4? Because other files are
> keep unchanged.
> 
> Thanks,
> Phil Yang
> 
> > -----Original Message-----
> > From: Liu, Yong <yong.liu@intel.com>
> > Sent: Sunday, April 8, 2018 2:36 PM
> > 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
> >
> > 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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v4] framwork/packet: sniff_packet specify running target support
  2018-04-02  3:46   ` [dts] [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support Phil Yang
                       ` (16 preceding siblings ...)
  2018-04-04  3:28     ` [dts] [PATCH v3 01/17] framwork/packet: sniff_packet specify running target support Liu, Yong
@ 2018-04-12  9:52     ` Phil Yang
  2018-04-18  6:23       ` Liu, Yong
  2018-09-04  8:26       ` [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine Phil Yang
  17 siblings, 2 replies; 124+ messages in thread
From: Phil Yang @ 2018-04-12  9:52 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu

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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* Re: [dts] [PATCH v4] framwork/packet: sniff_packet specify running target support
  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:26       ` [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine Phil Yang
  1 sibling, 1 reply; 124+ messages in thread
From: Liu, Yong @ 2018-04-18  6:23 UTC (permalink / raw)
  To: Phil Yang, dts; +Cc: nd

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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine
  2018-04-12  9:52     ` [dts] [PATCH v4] " Phil Yang
  2018-04-18  6:23       ` Liu, Yong
@ 2018-09-04  8:26       ` 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
                           ` (23 more replies)
  1 sibling, 24 replies; 124+ messages in thread
From: Phil Yang @ 2018-09-04  8:26 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, Phil Yang

From: Phil Yang <phil.yang@arm.com>

By default, the Tester is supposed to be the server which running DTS
and the packet sniff methods are running on it.
However, if DTS was not running on the Tester and the Tester is another
remote server, so packet sniff methods cannot sniff Tester's packets
correctly.

This patch adds support for packet sniff methods to specify running
machine and implements sniff packet methods in class tester.

1. Add parameter to sniff_packet and load_sniff_pcap methods to specify
the running machine.
2. Remove load_sniff_packets method in packet.py.
3. Add tcpdump_sniff_packets, load_tcpdump_sniff_pcap and
load_tcpdump_sniff_packets for class tester with the new sniff_packet
API.
4. Update tester.check_random_pkts method with
tester.tcpdump_sniff_packets and tester.load_tcpdump_sniff_packets to
make it execution on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
---
 framework/packet.py | 86 +++++++++++++++++++++++++----------------------------
 framework/tester.py | 48 +++++++++++++++++++++++++++---
 2 files changed, 84 insertions(+), 50 deletions(-)

diff --git a/framework/packet.py b/framework/packet.py
index 976b82b..1f3f07d 100755
--- a/framework/packet.py
+++ b/framework/packet.py
@@ -812,15 +812,31 @@ 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)
+    remote_terminate = 0
+
+    # 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,22 +866,29 @@ 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)
+        remote_terminate = 1
+    else:
+        args = shlex.split(cmd)
+        pipe = subprocess.Popen(args)
 
-    pipe = subprocess.Popen(args)
     index = str(time.time())
-    SNIFF_PIDS[index] = (pipe, intf, timeout)
+    SNIFF_PIDS[index] = (pipe, intf, timeout, remote_terminate)
     time.sleep(1)
     return index
 
 
-def load_sniff_pcap(index=''):
+def load_sniff_pcap(index='', target=[]):
     """
     Stop sniffer and return pcap file
     """
     child_exit = False
     if index in SNIFF_PIDS.keys():
-        pipe, intf, timeout = SNIFF_PIDS[index]
+        pipe, intf, timeout, remote_terminate = SNIFF_PIDS[index]
         time_elapse = int(time.time() - float(index))
         while time_elapse < timeout:
             if pipe.poll() is not None:
@@ -876,6 +899,14 @@ def load_sniff_pcap(index=''):
             time_elapse += 1
 
         if not child_exit:
+            if remote_terminate == 1:
+                stop_tcpdump_pipe = subprocess.Popen(['ssh',
+                                    '%s@%s' % (target[0], target[1]),
+                                    'kill -2 $(pidof tcpdump)'],
+                                    stderr=subprocess.PIPE,
+                                    shell=False)
+                stop_tcpdump_pipe.wait()
+
             pipe.send_signal(signal.SIGINT)
             pipe.wait()
 
@@ -886,42 +917,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:
@@ -983,7 +978,6 @@ if __name__ == "__main__":
     inst = sniff_packets("lo", timeout=5)
     pkt = Packet(pkt_type='UDP')
     pkt.send_pkt(tx_port='lo')
-    pkts = load_sniff_packets(inst)
 
     pkt = Packet(pkt_type='UDP', pkt_len=1500, ran_payload=True)
     pkt.send_pkt(tx_port='lo')
diff --git a/framework/tester.py b/framework/tester.py
index a775f68..c5b705d 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
@@ -560,8 +561,6 @@ class Tester(Crb):
         module = __import__("packet")
         pkt_c = getattr(module, "Packet")
         send_f = getattr(module, "send_packets")
-        sniff_f = getattr(module, "sniff_packets")
-        load_f = getattr(module, "load_sniff_packets")
         compare_f = getattr(module, "compare_pktload")
         strip_f = getattr(module, "strip_pktload")
         save_f = getattr(module, "save_packets")
@@ -606,7 +605,7 @@ class Tester(Crb):
 
             # send and sniff packets
             save_f(pkts=pkts, filename="/tmp/%s_tx.pcap" % txIntf)
-            inst = sniff_f(intf=rxIntf, count=pktnum, timeout=timeout, filters=
+            inst = self.tcpdump_sniff_packets(intf=rxIntf, count=pktnum, timeout=timeout, filters=
                 [{'layer': 'network', 'config': {'srcport': '65535'}},
                  {'layer': 'network', 'config': {'dstport': '65535'}}])
             rx_inst[rxport] = inst
@@ -627,7 +626,7 @@ class Tester(Crb):
         # Verify all packets
         prev_id = -1
         for txport, rxport in portList:
-            recv_pkts = load_f(rx_inst[rxport])
+            recv_pkts = self.load_tcpdump_sniff_packets(rx_inst[rxport])
 
             # only report when recevied number not matched
             if len(tx_pkts[txport]) > len(recv_pkts):
@@ -704,6 +703,47 @@ 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")
+
+        target=[]
+        target.append(self.get_username())
+        target.append(self.get_ip_address())
+        target.append(self.get_password())
+        pcap = load_pcap_f(index, target)
+        self.session.copy_file_from(pcap)
+
+        return pcap.split(os.sep)[-1]
+
+    def load_tcpdump_sniff_packets(self, index=''):
+        """
+        Wrapper for packet module load_pcapfile
+        """
+        # 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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v5 02/22] tests/checksum_offload: Replace sniff_packet to tester.tcpdump_sniff_packet
  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         ` Phil Yang
  2018-09-04  8:26         ` [dts] [PATCH v5 03/22] tests/etag: " Phil Yang
                           ` (22 subsequent siblings)
  23 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-09-04  8:26 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, Phil Yang

From: Phil Yang <phil.yang@arm.com>

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
---
 tests/TestSuite_checksum_offload.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_checksum_offload.py b/tests/TestSuite_checksum_offload.py
index 2ff5c2f..6541ba5 100644
--- a/tests/TestSuite_checksum_offload.py
+++ b/tests/TestSuite_checksum_offload.py
@@ -43,7 +43,6 @@ import utils
 
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets, strip_pktload
 from test_capabilities import DRIVER_TEST_LACK_CAPA
 
 class TestChecksumOffload(TestCase):
@@ -175,13 +174,14 @@ class TestChecksumOffload(TestCase):
 
         self.tester.send_expect("exit()", "#")
 
-        inst = sniff_packets(intf=rx_interface, count=len(packets_sent), filters=[{'layer':'ether', 'config':{'src': sniff_src}}])
+        inst = self.tester.tcpdump_sniff_packets(intf=rx_interface, count=len(packets_sent),
+                filters=[{'layer':'ether', 'config':{'src': sniff_src}}])
 
         for packet_type in packets_sent.keys():
             self.tester.scapy_append('sendp([%s], iface="%s")' % (packets_sent[packet_type], tx_interface))
 
         self.tester.scapy_execute()
-	p = load_sniff_packets(inst)
+	p = self.tester.load_tcpdump_sniff_packets(inst)
 	nr_packets=len(p)
 	reslist = [p[i].pktgen.pkt.sprintf("%IP.chksum%;%TCP.chksum%;%UDP.chksum%;%SCTP.chksum%") for i in range(nr_packets)]
 	out = string.join(reslist, ",")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v5 03/22] tests/etag: Replace sniff_packet to tester.tcpdump_sniff_packet
  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         ` Phil Yang
  2018-09-04  8:26         ` [dts] [PATCH v5 04/22] tests/ipfrag: " Phil Yang
                           ` (21 subsequent siblings)
  23 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-09-04  8:26 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, Phil Yang

From: Phil Yang <phil.yang@arm.com>

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
---
 tests/TestSuite_etag.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_etag.py b/tests/TestSuite_etag.py
index 642fb2b..68cca44 100644
--- a/tests/TestSuite_etag.py
+++ b/tests/TestSuite_etag.py
@@ -46,7 +46,7 @@ from exception import VerifyFailure
 
 from scapy.utils import rdpcap
 
-from packet import Packet, sniff_packets, load_sniff_packets
+from packet import Packet
 
 VM_CORES_MASK = 'all'
 
@@ -325,11 +325,11 @@ class TestEtag(TestCase):
         pkt_types = {'IP_RAW': {'layer_configs': config_layers}}
 
         intf = self.src_intf
-        inst = sniff_packets(intf)
+        inst = self.tester.tcpdump_sniff_packets(intf)
 
         self.check_packet_transmission(pkt_types)
         time.sleep(1)
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         self.host_testpmd.execute_cmd('E-tag set insertion off port-tag-id 1000 port 0 vf 0')
 
         # load sniff pcap file, check received packet's content
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v5 04/22] tests/ipfrag: Replace sniff_packet to tester.tcpdump_sniff_packet
  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         ` 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
                           ` (20 subsequent siblings)
  23 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-09-04  8:26 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, Phil Yang

From: Phil Yang <phil.yang@arm.com>

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
---
 tests/TestSuite_ipfrag.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/TestSuite_ipfrag.py b/tests/TestSuite_ipfrag.py
index f23dbe1..38e00d7 100644
--- a/tests/TestSuite_ipfrag.py
+++ b/tests/TestSuite_ipfrag.py
@@ -39,7 +39,7 @@ import string
 import re
 import time
 from settings import HEADER_SIZE
-from packet import Packet, sniff_packets, load_sniff_packets
+from packet import Packet
 
 lpm_table_ipv4 = [
     "{IPv4(100,10,0,0), 16, P1}",
@@ -159,7 +159,7 @@ l3fwd_ipv4_route_array[] = {\\\n"
                 expPkts = 1
                 val = 2
 
-            inst = sniff_packets(intf=self.rxItf, timeout=5)
+            inst = self.tester.tcpdump_sniff_packets(intf=self.rxItf, timeout=5)
             # send packet
             for times in range(burst):
                 pkt_size = pkt_sizes[pkt_sizes.index(size) + times]
@@ -169,7 +169,7 @@ l3fwd_ipv4_route_array[] = {\\\n"
                 pkt.send_pkt(tx_port=self.txItf)
 
             # verify normal packet just by number, verify fragment packet by all elements
-            pkts = load_sniff_packets(inst)
+            pkts = self.tester.load_tcpdump_sniff_packets(inst)
             self.verify(len(pkts) == expPkts, "Failed on forward packet size " + str(size))
             if flag == 'frag':
                 idx = 1
@@ -209,7 +209,7 @@ l3fwd_ipv4_route_array[] = {\\\n"
                 expPkts = 1
                 val = 2
 
-            inst = sniff_packets(intf=self.rxItf, timeout=5)
+            inst = self.tester.tcpdump_sniff_packets(intf=self.rxItf, timeout=5)
             # send packet
             for times in range(burst):
                 pkt_size = pkt_sizes[pkt_sizes.index(size) + times]
@@ -219,7 +219,7 @@ l3fwd_ipv4_route_array[] = {\\\n"
                 pkt.send_pkt(tx_port=self.txItf)
 
             # verify normal packet just by number, verify fragment packet by all elements
-            pkts = load_sniff_packets(inst)
+            pkts = self.tester.load_tcpdump_sniff_packets(inst)
             self.verify(len(pkts) == expPkts, "Failed on forward packet size " + str(size))
             if flag == 'frag':
                 idx = 1
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v5 05/22] tests/l2fwd_crypto: replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-09-04  8:26       ` [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine Phil Yang
                           ` (2 preceding siblings ...)
  2018-09-04  8:26         ` [dts] [PATCH v5 04/22] tests/ipfrag: " Phil Yang
@ 2018-09-04  8:26         ` 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
                           ` (19 subsequent siblings)
  23 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-09-04  8:26 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, Phil Yang

From: Phil Yang <phil.yang@arm.com>

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
---
 tests/TestSuite_l2fwd_crypto.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_l2fwd_crypto.py b/tests/TestSuite_l2fwd_crypto.py
index d559909..ea35a29 100644
--- a/tests/TestSuite_l2fwd_crypto.py
+++ b/tests/TestSuite_l2fwd_crypto.py
@@ -38,7 +38,7 @@ import sys
 import utils
 import commands
 from test_case import TestCase
-from packet import Packet, sniff_packets, load_sniff_packets, save_packets
+from packet import Packet, save_packets
 
 from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
 from cryptography.hazmat.backends import default_backend
@@ -501,7 +501,7 @@ class TestL2fwdCrypto(TestCase):
 
             payload = self.__format_hex_to_list(test_vector["input"])
 
-            inst = sniff_packets(self.rx_interface, timeout=5)
+            inst = self.tester.tcpdump_sniff_packets(self.rx_interface, timeout=5)
 
             PACKET_COUNT = 65
             pkt = Packet()
@@ -512,7 +512,7 @@ class TestL2fwdCrypto(TestCase):
             pkt.send_pkt(tx_port=self.tx_interface, count=PACKET_COUNT)
             pkt.pktgen.pkt.show()
 
-            pkt_rec = load_sniff_packets(inst)
+            pkt_rec = self.tester.load_tcpdump_sniff_packets(inst)
 
             for pkt_r in pkt_rec:
                 packet_hex = pkt_r.strip_element_layer4("load")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v5 06/22] tests/netmap_compat: replaced sniff_packet to tester.tcpdump_sniff_packet
  2018-09-04  8:26       ` [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine Phil Yang
                           ` (3 preceding siblings ...)
  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         ` 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
                           ` (18 subsequent siblings)
  23 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-09-04  8:26 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, Phil Yang

From: Phil Yang <phil.yang@arm.com>

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
---
 tests/TestSuite_netmap_compat.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/tests/TestSuite_netmap_compat.py b/tests/TestSuite_netmap_compat.py
index 5225a27..84136c7 100644
--- a/tests/TestSuite_netmap_compat.py
+++ b/tests/TestSuite_netmap_compat.py
@@ -43,7 +43,6 @@ from test_case import TestCase
 from plotting import Plotting 
 from settings import HEADER_SIZE   
 from etgen import IxiaPacketGenerator
-from packet import Packet, sniff_packets, load_sniff_packets
 
 class TestNetmapCompat(TestCase):
 
@@ -80,7 +79,7 @@ class TestNetmapCompat(TestCase):
 
         self.rxItf = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0]))
 
-        self.inst = sniff_packets(self.rxItf)
+        self.inst = self.tester.tcpdump_sniff_packets(self.rxItf)
 
         self.scapy_send_packet()
 
@@ -98,7 +97,7 @@ class TestNetmapCompat(TestCase):
         self.dut.send_expect(cmd,"Port %s now in Netmap mode" % self.dut_ports[0], 60)
        
         self.rxItf = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[1]))
-        self.inst = sniff_packets(self.rxItf)
+        self.inst = self.tester.tcpdump_sniff_packets(self.rxItf)
 
         self.scapy_send_packet()
 
@@ -117,7 +116,7 @@ class TestNetmapCompat(TestCase):
 
 
     def get_tcpdump_package(self):  
-        pkts = load_sniff_packets(self.inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(self.inst)
         dsts = []  
         for packet in pkts:  
             dst = packet.strip_element_layer2("dst")  
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v5 07/22] tests/queue_start_stop: replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-09-04  8:26       ` [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine Phil Yang
                           ` (4 preceding siblings ...)
  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         ` Phil Yang
  2018-09-04  8:26         ` [dts] [PATCH v5 08/22] tests/quota_watermark: " Phil Yang
                           ` (17 subsequent siblings)
  23 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-09-04  8:26 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, Phil Yang

From: Phil Yang <phil.yang@arm.com>

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
---
 tests/TestSuite_queue_start_stop.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_queue_start_stop.py b/tests/TestSuite_queue_start_stop.py
index 3dd37b3..6cd6831 100644
--- a/tests/TestSuite_queue_start_stop.py
+++ b/tests/TestSuite_queue_start_stop.py
@@ -44,7 +44,7 @@ import os
 from test_case import TestCase
 from pmd_output import PmdOutput
 from settings import FOLDERS
-from packet import Packet, sniff_packets, load_sniff_packets, strip_pktload
+from packet import Packet, strip_pktload
 
 #
 #
@@ -99,10 +99,10 @@ class TestQueueStartStop(TestCase):
         dmac = self.dut.get_mac_address(txPort)
 
         pkt = Packet(pkt_type="UDP", pkt_len=pktSize)
-        inst = sniff_packets(rxitf)
+        inst = self.tester.tcpdump_sniff_packets(rxitf)
         pkt.config_layer('ether', {'dst': dmac})
         pkt.send_pkt(tx_port=txitf)
-        sniff_pkts = load_sniff_packets(inst)
+        sniff_pkts = self.tester.load_tcpdump_sniff_packets(inst)
 
         if received:
             res = strip_pktload(sniff_pkts[0], layer="L4")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v5 08/22] tests/quota_watermark: replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-09-04  8:26       ` [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine Phil Yang
                           ` (5 preceding siblings ...)
  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         ` Phil Yang
  2018-09-04  8:26         ` [dts] [PATCH v5 09/22] tests/rxtx_callback: " Phil Yang
                           ` (16 subsequent siblings)
  23 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-09-04  8:26 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, Phil Yang

From: Phil Yang <phil.yang@arm.com>

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
---
 tests/TestSuite_quota_watermark.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_quota_watermark.py b/tests/TestSuite_quota_watermark.py
index ecacf38..845b27f 100644
--- a/tests/TestSuite_quota_watermark.py
+++ b/tests/TestSuite_quota_watermark.py
@@ -39,7 +39,6 @@ import time
 import utils
 from test_case import TestCase
 from etgen import IxiaPacketGenerator
-from packet import Packet, sniff_packets, load_sniff_packets
 
 test_config = {
     'frames_to_sent': 15 * 10 ** 6,
@@ -311,9 +310,9 @@ class TestQuotaWatermark(TestCase, IxiaPacketGenerator):
         rx_intf = self.tester.get_interface(rev_port)
         tx_intf = self.tester.get_interface(send_port)
         # send and sniff packet
-        rx_inst = sniff_packets(rx_intf, timeout=5)
+        rx_inst = self.tester.tcpdump_sniff_packets(rx_intf, timeout=5)
         self.send_pcap_pkt_by_scapy(self.tester, tgen_input[0][2], tx_intf)
-        pkts = load_sniff_packets(rx_inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(rx_inst)
         self.verify(len(pkts) == pkt_cnt, "Packet not forwarded as expected")
 
         return
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v5 09/22] tests/rxtx_callback: replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-09-04  8:26       ` [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine Phil Yang
                           ` (6 preceding siblings ...)
  2018-09-04  8:26         ` [dts] [PATCH v5 08/22] tests/quota_watermark: " Phil Yang
@ 2018-09-04  8:26         ` Phil Yang
  2018-09-04  8:26         ` [dts] [PATCH v5 10/22] tests/scatter: " Phil Yang
                           ` (15 subsequent siblings)
  23 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-09-04  8:26 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, Phil Yang

From: Phil Yang <phil.yang@arm.com>

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
---
 tests/TestSuite_rxtx_callbacks.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_rxtx_callbacks.py b/tests/TestSuite_rxtx_callbacks.py
index dd968a4..a654480 100644
--- a/tests/TestSuite_rxtx_callbacks.py
+++ b/tests/TestSuite_rxtx_callbacks.py
@@ -41,7 +41,6 @@ from test_case import TestCase
 from plotting import Plotting
 from settings import HEADER_SIZE
 from etgen import IxiaPacketGenerator
-from packet import Packet, sniff_packets, load_sniff_packets
 
 
 class TestRxtxCallbacks(TestCase):
@@ -77,7 +76,7 @@ class TestRxtxCallbacks(TestCase):
         self.iface_port0 = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0]))
         self.iface_port1 = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[1]))
 
-        self.inst_port1 = sniff_packets(self.iface_port1)
+        self.inst_port1 = self.tester.tcpdump_sniff_packets(self.iface_port1)
         self.scapy_send_packet(self.iface_port0)
 
         out_port1 = self.get_tcpdump_package(self.inst_port1)
@@ -92,7 +91,7 @@ class TestRxtxCallbacks(TestCase):
         self.tester.scapy_execute()
 
     def get_tcpdump_package(self,inst):
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         dsts = []
         for packet in pkts:
             dst = packet.strip_element_layer2("dst")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v5 10/22] tests/scatter: replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-09-04  8:26       ` [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine Phil Yang
                           ` (7 preceding siblings ...)
  2018-09-04  8:26         ` [dts] [PATCH v5 09/22] tests/rxtx_callback: " Phil Yang
@ 2018-09-04  8:26         ` Phil Yang
  2018-09-04  8:26         ` [dts] [PATCH v5 11/22] tests/skeleton: " Phil Yang
                           ` (14 subsequent siblings)
  23 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-09-04  8:26 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, Phil Yang

From: Phil Yang <phil.yang@arm.com>

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
---
 tests/TestSuite_scatter.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_scatter.py b/tests/TestSuite_scatter.py
index d6aef49..0d38513 100644
--- a/tests/TestSuite_scatter.py
+++ b/tests/TestSuite_scatter.py
@@ -35,7 +35,7 @@ Test Scattered Packets.
 """
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets, strip_pktload
+from packet import Packet, strip_pktload
 import time
 #
 #
@@ -82,11 +82,11 @@ class TestScatter(TestCase):
         """
         dmac = self.dut.get_mac_address(self.port)
 
-        inst = sniff_packets(self.intf)
+        inst = self.tester.tcpdump_sniff_packets(self.intf)
         pkt = Packet(pkt_type="IP_RAW", pkt_len=pktsize)
         pkt.config_layer('ether', {'dst': dmac})
         pkt.send_pkt(tx_port=self.intf)
-        sniff_pkts = load_sniff_packets(inst)
+        sniff_pkts = self.tester.load_tcpdump_sniff_packets(inst)
 
         res = ""
         if len(sniff_pkts):
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v5 11/22] tests/skeleton: replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-09-04  8:26       ` [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine Phil Yang
                           ` (8 preceding siblings ...)
  2018-09-04  8:26         ` [dts] [PATCH v5 10/22] tests/scatter: " Phil Yang
@ 2018-09-04  8:26         ` Phil Yang
  2018-09-04  8:26         ` [dts] [PATCH v5 12/22] tests/userspace_ethtool: " Phil Yang
                           ` (13 subsequent siblings)
  23 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-09-04  8:26 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, Phil Yang

From: Phil Yang <phil.yang@arm.com>

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
---
 tests/TestSuite_skeleton.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_skeleton.py b/tests/TestSuite_skeleton.py
index 77f95e1..b56d955 100644
--- a/tests/TestSuite_skeleton.py
+++ b/tests/TestSuite_skeleton.py
@@ -42,7 +42,6 @@ from plotting import Plotting
 from settings import HEADER_SIZE
 from etgen import IxiaPacketGenerator
 
-from packet import Packet, sniff_packets, load_sniff_packets
 
 
 class TestSkeleton(TestCase):
@@ -80,7 +79,7 @@ class TestSkeleton(TestCase):
         self.iface_port0 = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0]))
         self.iface_port1 = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[1]))
 
-        self.inst_port1 = sniff_packets(self.iface_port1)
+        self.inst_port1 = self.tester.tcpdump_sniff_packets(self.iface_port1)
         self.scapy_send_packet(self.iface_port0)
 
         out_port1 = self.get_tcpdump_package(self.inst_port1)
@@ -95,7 +94,7 @@ class TestSkeleton(TestCase):
         self.tester.scapy_execute()
 
     def get_tcpdump_package(self,inst):
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         dsts = []
         for packet in pkts:
             dst = packet.strip_element_layer2("dst")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v5 12/22] tests/userspace_ethtool: replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-09-04  8:26       ` [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine Phil Yang
                           ` (9 preceding siblings ...)
  2018-09-04  8:26         ` [dts] [PATCH v5 11/22] tests/skeleton: " Phil Yang
@ 2018-09-04  8:26         ` Phil Yang
  2018-09-04  8:26         ` [dts] [PATCH v5 13/22] tests/vf_daemon: " Phil Yang
                           ` (12 subsequent siblings)
  23 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-09-04  8:26 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, Phil Yang

From: Phil Yang <phil.yang@arm.com>

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
---
 tests/TestSuite_userspace_ethtool.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_userspace_ethtool.py b/tests/TestSuite_userspace_ethtool.py
index eccc77b..8ade421 100644
--- a/tests/TestSuite_userspace_ethtool.py
+++ b/tests/TestSuite_userspace_ethtool.py
@@ -39,7 +39,7 @@ import utils
 import time
 import re
 from test_case import TestCase
-from packet import Packet, sniff_packets, load_sniff_packets
+from packet import Packet
 import random
 from etgen import IxiaPacketGenerator
 from settings import HEADER_SIZE
@@ -490,9 +490,9 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator):
             tester_port = self.tester.get_local_port(port)
             intf = self.tester.get_interface(tester_port)
             # send and sniff packet
-            inst = sniff_packets(intf, timeout=5)
+            inst = self.tester.tcpdump_sniff_packets(intf, timeout=5)
             pkt.send_pkt(tx_port=intf)
-            pkts = load_sniff_packets(inst)
+            pkts = self.tester.load_tcpdump_sniff_packets(inst)
             self.verify(len(pkts) == 1, "Packet not forwarded as expected")
             src_mac = pkts[0].strip_layer_element("layer2", "src")
             self.verify(src_mac == valid_mac, "Forwarded packet not match default mac")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v5 13/22] tests/vf_daemon: replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-09-04  8:26       ` [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine Phil Yang
                           ` (10 preceding siblings ...)
  2018-09-04  8:26         ` [dts] [PATCH v5 12/22] tests/userspace_ethtool: " Phil Yang
@ 2018-09-04  8:26         ` Phil Yang
  2018-09-04  8:26         ` [dts] [PATCH v5 14/22] tests/vf_vlan: " Phil Yang
                           ` (11 subsequent siblings)
  23 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-09-04  8:26 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, Phil Yang

From: Phil Yang <phil.yang@arm.com>

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
---
 tests/TestSuite_vf_daemon.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tests/TestSuite_vf_daemon.py b/tests/TestSuite_vf_daemon.py
index c264911..42a14e5 100644
--- a/tests/TestSuite_vf_daemon.py
+++ b/tests/TestSuite_vf_daemon.py
@@ -8,7 +8,7 @@ from scapy.utils import rdpcap
 from qemu_kvm import QEMUKvm
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets
+from packet import Packet
 from settings import get_nic_name
 import random
 
@@ -154,7 +154,7 @@ class Testvf_daemon(TestCase):
             pkt.config_layer('vlan', {'vlan': vlan_id})
         pkt.config_layer('ether', {'dst': dst_mac})
 
-        inst = sniff_packets(self.tester_intf, timeout=30)
+        inst = self.tester.tcpdump_sniff_packets(self.tester_intf, timeout=30)
         pkt.send_pkt(tx_port=self.tester_intf, count=num)
         return inst
 
@@ -162,7 +162,7 @@ class Testvf_daemon(TestCase):
         """
         Load sniff packets, strip and return mac address from dump message
         """
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         macs = []
         for pkt in pkts:
             mac = pkt.strip_element_layer2(element)
@@ -173,7 +173,7 @@ class Testvf_daemon(TestCase):
         """
         Load sniff packets, strip and return vlan id from dump message
         """
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         vlans = []
         for pkt in pkts:
             vlan = pkt.strip_element_vlan("vlan")
@@ -422,7 +422,7 @@ class Testvf_daemon(TestCase):
         self.dut_testpmd.execute_cmd('set tx loopback 0 off')
         time.sleep(5)
 
-        inst = sniff_packets(self.tester_intf, timeout=10)
+        inst = self.tester.tcpdump_sniff_packets(self.tester_intf, timeout=10)
 
         self.vm1_testpmd.execute_cmd('set burst 5')
         self.vm1_testpmd.execute_cmd('start tx_first')
@@ -438,7 +438,7 @@ class Testvf_daemon(TestCase):
         self.dut_testpmd.execute_cmd('set tx loopback 0 on')
         time.sleep(3)
 
-        inst = sniff_packets(self.tester_intf, timeout=10)
+        inst = self.tester.tcpdump_sniff_packets(self.tester_intf, timeout=10)
 
         self.vm1_testpmd.execute_cmd('stop')
         self.vm1_testpmd.execute_cmd('start tx_first')
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v5 14/22] tests/vf_vlan: replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-09-04  8:26       ` [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine Phil Yang
                           ` (11 preceding siblings ...)
  2018-09-04  8:26         ` [dts] [PATCH v5 13/22] tests/vf_daemon: " Phil Yang
@ 2018-09-04  8:26         ` Phil Yang
  2018-09-04  8:26         ` [dts] [PATCH v5 15/22] tests/vlan_ethertype_config: remove unused sniff_packets Phil Yang
                           ` (10 subsequent siblings)
  23 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-09-04  8:26 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, Phil Yang

From: Phil Yang <phil.yang@arm.com>

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
---
 tests/TestSuite_vf_vlan.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/TestSuite_vf_vlan.py b/tests/TestSuite_vf_vlan.py
index 75d99f2..4c7b42d 100644
--- a/tests/TestSuite_vf_vlan.py
+++ b/tests/TestSuite_vf_vlan.py
@@ -6,7 +6,7 @@ import time
 from virt_common import VM
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets
+from packet import Packet
 from settings import get_nic_name
 import random
 
@@ -173,9 +173,9 @@ class TestVfVlan(TestCase):
 
         pkt = Packet(pkt_type='UDP')
         pkt.config_layer('ether', {'dst': self.vf1_mac})
-        inst = sniff_packets(self.tester_intf0, timeout=5)
+        inst = self.tester.tcpdump_sniff_packets(self.tester_intf0, timeout=5)
         pkt.send_pkt(tx_port=self.tester_intf1)
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
 
         self.verify(len(pkts), "Not receive expected packet")
         self.vm0_testpmd.quit()
@@ -258,13 +258,13 @@ class TestVfVlan(TestCase):
             "ip link set %s vf 0 vlan 0" % (self.host_intf0), "# ")
 
     def tx_and_check(self, tx_vlan=1):
-        inst = sniff_packets(self.tester_intf0, timeout=5)
+        inst = self.tester.tcpdump_sniff_packets(self.tester_intf0, timeout=5)
         self.vm0_testpmd.execute_cmd('set burst 1')
         self.vm0_testpmd.execute_cmd('start tx_first')
         self.vm0_testpmd.execute_cmd('stop')
 
         # strip sniffered vlans
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         vlans = []
         for pkt in pkts:
             vlan = pkt.strip_element_vlan("vlan")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v5 15/22] tests/vlan_ethertype_config: remove unused sniff_packets
  2018-09-04  8:26       ` [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine Phil Yang
                           ` (12 preceding siblings ...)
  2018-09-04  8:26         ` [dts] [PATCH v5 14/22] tests/vf_vlan: " Phil Yang
@ 2018-09-04  8:26         ` Phil Yang
  2018-09-04  8:26         ` [dts] [PATCH v5 16/22] tests/vlan: replaced sniff_packets to tester.tcpdump_sniff_packets Phil Yang
                           ` (9 subsequent siblings)
  23 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-09-04  8:26 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, Phil Yang

From: Phil Yang <phil.yang@arm.com>

remove unused sniff_packets import

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
---
 tests/TestSuite_vlan_ethertype_config.py | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tests/TestSuite_vlan_ethertype_config.py b/tests/TestSuite_vlan_ethertype_config.py
index 1fb30fb..8eba49c 100644
--- a/tests/TestSuite_vlan_ethertype_config.py
+++ b/tests/TestSuite_vlan_ethertype_config.py
@@ -43,7 +43,6 @@ import utils
 
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets
 from scapy.utils import struct, socket, wrpcap, rdpcap
 from scapy.layers.inet import Ether, IP, TCP, UDP, ICMP
 from scapy.layers.l2 import Dot1Q, ARP, GRE
@@ -125,7 +124,6 @@ class TestVlanEthertypeConfig(TestCase):
         # off
         self.dmac = self.dut.get_mac_address(dutRxPortId)
 
-        self.inst = sniff_packets(self.rxItf)
         pkt = []
         if outer_vid < 0 or outer_tpid <= 0:
             pkt = [
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v5 16/22] tests/vlan: replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-09-04  8:26       ` [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine Phil Yang
                           ` (13 preceding siblings ...)
  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         ` Phil Yang
  2018-09-04  8:26         ` [dts] [PATCH v5 17/22] tests/ipgre: " Phil Yang
                           ` (8 subsequent siblings)
  23 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-09-04  8:26 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, Phil Yang

From: Phil Yang <phil.yang@arm.com>

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
---
 tests/TestSuite_vlan.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_vlan.py b/tests/TestSuite_vlan.py
index 0f1833b..b2bda71 100644
--- a/tests/TestSuite_vlan.py
+++ b/tests/TestSuite_vlan.py
@@ -43,7 +43,7 @@ import time
 
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets
+from packet import Packet
 
 
 class TestVlan(TestCase):
@@ -88,7 +88,7 @@ class TestVlan(TestCase):
             netobj.add_vlan(vlan_id = self.vlan)
 
     def get_tcpdump_package(self):
-        pkts = load_sniff_packets(self.inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(self.inst)
         vlans = []
         for packet in pkts:
             vlan = packet.strip_element_vlan("vlan")
@@ -110,7 +110,7 @@ class TestVlan(TestCase):
         # the package dect mac must is dut tx port id when the port promisc is off
         self.dmac = self.dut.get_mac_address(dutRxPortId)
 
-        self.inst = sniff_packets(self.rxItf)
+        self.inst = self.tester.tcpdump_sniff_packets(self.rxItf)
         # FIXME  send a burst with only num packet
         if vid == -1:
             pkt = Packet(pkt_type='UDP')
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v5 17/22] tests/ipgre: replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-09-04  8:26       ` [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine Phil Yang
                           ` (14 preceding siblings ...)
  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         ` Phil Yang
  2018-09-04  8:26         ` [dts] [PATCH v5 18/22] tests/hotplug: remove unused packet sniff import Phil Yang
                           ` (7 subsequent siblings)
  23 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-09-04  8:26 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, Phil Yang

From: Phil Yang <phil.yang@arm.com>

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
---
 tests/TestSuite_ipgre.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_ipgre.py b/tests/TestSuite_ipgre.py
index 2dccb9c..e400161 100644
--- a/tests/TestSuite_ipgre.py
+++ b/tests/TestSuite_ipgre.py
@@ -44,7 +44,7 @@ import re
 import time
 import os
 
-from packet import Packet, sniff_packets, load_sniff_packets, NVGRE, IPPROTO_NVGRE
+from packet import Packet, NVGRE, IPPROTO_NVGRE
 
 from scapy.utils import wrpcap, rdpcap
 from scapy.packet import split_layers,bind_layers
@@ -98,11 +98,11 @@ class TestIpgre(TestCase):
             if layer_configs:
                 for layer in layer_configs.keys():
                     pkt.config_layer(layer, layer_configs[layer])
-            inst = sniff_packets(self.tester_iface, count=1, timeout=8)
+            inst = self.tester.tcpdump_sniff_packets(self.tester_iface, count=1, timeout=8)
             pkt.send_pkt(tx_port=self.tester_iface)
             out = self.dut.get_session_output(timeout=2)
             time.sleep(1)
-            load_sniff_packets(inst)
+            self.tester.load_tcpdump_sniff_packets(inst)
             if self.printFlag: # debug output
                 print out
             for pkt_layer_name in pkt_names:
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v5 18/22] tests/hotplug: remove unused packet sniff import
  2018-09-04  8:26       ` [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine Phil Yang
                           ` (15 preceding siblings ...)
  2018-09-04  8:26         ` [dts] [PATCH v5 17/22] tests/ipgre: " Phil Yang
@ 2018-09-04  8:26         ` Phil Yang
  2018-09-04  8:26         ` [dts] [PATCH v5 19/22] tests/keep_alive: " Phil Yang
                           ` (6 subsequent siblings)
  23 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-09-04  8:26 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, Phil Yang

From: Phil Yang <phil.yang@arm.com>

remove unused packet sniff import.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
---
 tests/TestSuite_hotplug.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/TestSuite_hotplug.py b/tests/TestSuite_hotplug.py
index c0e1741..7d63b71 100644
--- a/tests/TestSuite_hotplug.py
+++ b/tests/TestSuite_hotplug.py
@@ -43,7 +43,7 @@ from test_case import TestCase
 from plotting import Plotting
 from settings import HEADER_SIZE
 from etgen import IxiaPacketGenerator
-from packet import Packet, sniff_packets, load_sniff_packets
+from packet import Packet
 
 class TestPortHotPlug(TestCase):
     """
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v5 19/22] tests/keep_alive: remove unused packet sniff import
  2018-09-04  8:26       ` [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine Phil Yang
                           ` (16 preceding siblings ...)
  2018-09-04  8:26         ` [dts] [PATCH v5 18/22] tests/hotplug: remove unused packet sniff import Phil Yang
@ 2018-09-04  8:26         ` Phil Yang
  2018-09-04  8:26         ` [dts] [PATCH v5 20/22] tests/link_status_interrupt: " Phil Yang
                           ` (5 subsequent siblings)
  23 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-09-04  8:26 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, Phil Yang

From: Phil Yang <phil.yang@arm.com>

remove unused packet sniff import.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
---
 tests/TestSuite_keep_alive.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tests/TestSuite_keep_alive.py b/tests/TestSuite_keep_alive.py
index 41c8732..711d8ce 100644
--- a/tests/TestSuite_keep_alive.py
+++ b/tests/TestSuite_keep_alive.py
@@ -43,7 +43,6 @@ from test_case import TestCase
 from plotting import Plotting 
 from settings import HEADER_SIZE   
 from etgen import IxiaPacketGenerator
-from packet import Packet, sniff_packets, load_sniff_packets
 
 class TestKeepAlive(TestCase):
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v5 20/22] tests/link_status_interrupt: remove unused packet sniff import
  2018-09-04  8:26       ` [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine Phil Yang
                           ` (17 preceding siblings ...)
  2018-09-04  8:26         ` [dts] [PATCH v5 19/22] tests/keep_alive: " Phil Yang
@ 2018-09-04  8:26         ` Phil Yang
  2018-09-04  8:26         ` [dts] [PATCH v5 21/22] tests/vhost_pmd_xstats: " Phil Yang
                           ` (4 subsequent siblings)
  23 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-09-04  8:26 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, Phil Yang

From: Phil Yang <phil.yang@arm.com>

remove unused packet sniff import.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
---
 tests/TestSuite_link_status_interrupt.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/TestSuite_link_status_interrupt.py b/tests/TestSuite_link_status_interrupt.py
index c31634b..cad6485 100644
--- a/tests/TestSuite_link_status_interrupt.py
+++ b/tests/TestSuite_link_status_interrupt.py
@@ -40,7 +40,7 @@ import string
 import time
 import re
 from test_case import TestCase
-from packet import Packet, sniff_packets, load_sniff_packets
+from packet import Packet
 
 
 class TestLinkStatusInterrupt(TestCase):
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v5 21/22] tests/vhost_pmd_xstats: remove unused packet sniff import
  2018-09-04  8:26       ` [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine Phil Yang
                           ` (18 preceding siblings ...)
  2018-09-04  8:26         ` [dts] [PATCH v5 20/22] tests/link_status_interrupt: " Phil Yang
@ 2018-09-04  8:26         ` Phil Yang
  2018-09-04  8:26         ` [dts] [PATCH v5 22/22] tests/ddp_mpls: " Phil Yang
                           ` (3 subsequent siblings)
  23 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-09-04  8:26 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, Phil Yang

From: Phil Yang <phil.yang@arm.com>

remove unused packet sniff import.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
---
 tests/TestSuite_vhost_pmd_xstats.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/TestSuite_vhost_pmd_xstats.py b/tests/TestSuite_vhost_pmd_xstats.py
index 8c800c7..a01ca16 100644
--- a/tests/TestSuite_vhost_pmd_xstats.py
+++ b/tests/TestSuite_vhost_pmd_xstats.py
@@ -46,7 +46,7 @@ from exception import VerifyFailure
 from settings import HEADER_SIZE
 from etgen import IxiaPacketGenerator
 from qemu_kvm import QEMUKvm
-from packet import Packet, sniff_packets, load_sniff_packets
+from packet import Packet
 
 
 class TestVhostPmdXstats(TestCase):
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v5 22/22] tests/ddp_mpls: remove unused packet sniff import
  2018-09-04  8:26       ` [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine Phil Yang
                           ` (19 preceding siblings ...)
  2018-09-04  8:26         ` [dts] [PATCH v5 21/22] tests/vhost_pmd_xstats: " Phil Yang
@ 2018-09-04  8:26         ` 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)
                           ` (2 subsequent siblings)
  23 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-09-04  8:26 UTC (permalink / raw)
  To: dts; +Cc: nd, yong.liu, Phil Yang

From: Phil Yang <phil.yang@arm.com>

remove unused packet sniff import.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
---
 tests/TestSuite_ddp_mpls.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tests/TestSuite_ddp_mpls.py b/tests/TestSuite_ddp_mpls.py
index 08d58be..691e958 100644
--- a/tests/TestSuite_ddp_mpls.py
+++ b/tests/TestSuite_ddp_mpls.py
@@ -8,7 +8,6 @@ from scapy.utils import rdpcap
 from qemu_kvm import QEMUKvm
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets
 from settings import get_nic_name
 import random
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* Re: [dts] [PATCH v4] framwork/packet: sniff_packet specify running target support
  2018-04-18  6:23       ` Liu, Yong
@ 2018-09-04  8:34         ` Phil Yang (Arm Technology China)
  2018-09-04  8:50           ` Liu, Yong
  0 siblings, 1 reply; 124+ messages in thread
From: Phil Yang (Arm Technology China) @ 2018-09-04  8:34 UTC (permalink / raw)
  To: Liu, Yong, dts; +Cc: nd

Hi Marvin,

Apologize for hung up this thread such a long time. 

I have upstreamed the patch set version 5th, which solved the two issues you had pointed out.

Please review it.

Thanks,
Phil Yang

> -----Original Message-----
> From: Liu, Yong <yong.liu@intel.com>
> Sent: Wednesday, April 18, 2018 2:23 PM
> To: Phil Yang <Phil.Yang@arm.com>; dts@dpdk.org
> Cc: nd <nd@arm.com>
> Subject: RE: [PATCH v4] framwork/packet: sniff_packet specify running target
> support
> 
> 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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* Re: [dts] [PATCH v4] framwork/packet: sniff_packet specify running target support
  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)
  0 siblings, 1 reply; 124+ messages in thread
From: Liu, Yong @ 2018-09-04  8:50 UTC (permalink / raw)
  To: Phil Yang (Arm Technology China), dts; +Cc: nd

Phil, thanks for your great contribution in DTS project. Always can see great ideas from you:)

Regards,
Marvin

> -----Original Message-----
> From: Phil Yang (Arm Technology China) [mailto:Phil.Yang@arm.com]
> Sent: Tuesday, September 04, 2018 4:35 PM
> To: Liu, Yong <yong.liu@intel.com>; dts@dpdk.org
> Cc: nd <nd@arm.com>
> Subject: RE: [PATCH v4] framwork/packet: sniff_packet specify running target
> support
> 
> Hi Marvin,
> 
> Apologize for hung up this thread such a long time.
> 
> I have upstreamed the patch set version 5th, which solved the two issues you
> had pointed out.
> 
> Please review it.
> 
> Thanks,
> Phil Yang
> 
> > -----Original Message-----
> > From: Liu, Yong <yong.liu@intel.com>
> > Sent: Wednesday, April 18, 2018 2:23 PM
> > To: Phil Yang <Phil.Yang@arm.com>; dts@dpdk.org
> > Cc: nd <nd@arm.com>
> > Subject: RE: [PATCH v4] framwork/packet: sniff_packet specify running
> target
> > support
> >
> > 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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* Re: [dts] [PATCH v4] framwork/packet: sniff_packet specify running target support
  2018-09-04  8:50           ` Liu, Yong
@ 2018-09-04  9:14             ` Phil Yang (Arm Technology China)
  0 siblings, 0 replies; 124+ messages in thread
From: Phil Yang (Arm Technology China) @ 2018-09-04  9:14 UTC (permalink / raw)
  To: Liu, Yong, dts; +Cc: nd

Appreciate your comments, Marvin. 
It's my honor to work with the community. 😊

Thanks,
Phil Yang

> -----Original Message-----
> From: Liu, Yong <yong.liu@intel.com>
> Sent: Tuesday, September 4, 2018 4:51 PM
> To: Phil Yang (Arm Technology China) <Phil.Yang@arm.com>; dts@dpdk.org
> Cc: nd <nd@arm.com>
> Subject: RE: [PATCH v4] framwork/packet: sniff_packet specify running target
> support
> 
> Phil, thanks for your great contribution in DTS project. Always can see great
> ideas from you:)
> 
> Regards,
> Marvin
> 
> > -----Original Message-----
> > From: Phil Yang (Arm Technology China) [mailto:Phil.Yang@arm.com]
> > Sent: Tuesday, September 04, 2018 4:35 PM
> > To: Liu, Yong <yong.liu@intel.com>; dts@dpdk.org
> > Cc: nd <nd@arm.com>
> > Subject: RE: [PATCH v4] framwork/packet: sniff_packet specify running
> > target support
> >
> > Hi Marvin,
> >
> > Apologize for hung up this thread such a long time.
> >
> > I have upstreamed the patch set version 5th, which solved the two
> > issues you had pointed out.
> >
> > Please review it.
> >
> > Thanks,
> > Phil Yang
> >
> > > -----Original Message-----
> > > From: Liu, Yong <yong.liu@intel.com>
> > > Sent: Wednesday, April 18, 2018 2:23 PM
> > > To: Phil Yang <Phil.Yang@arm.com>; dts@dpdk.org
> > > Cc: nd <nd@arm.com>
> > > Subject: RE: [PATCH v4] framwork/packet: sniff_packet specify
> > > running
> > target
> > > support
> > >
> > > 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


^ permalink raw reply	[flat|nested] 124+ messages in thread

* Re: [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine
  2018-09-04  8:26       ` [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine Phil Yang
                           ` (20 preceding siblings ...)
  2018-09-04  8:26         ` [dts] [PATCH v5 22/22] tests/ddp_mpls: " Phil Yang
@ 2018-09-17  5:12         ` Phil Yang (Arm Technology China)
  2018-09-21  3:09         ` Tu, Lijuan
  2018-10-16  6:19         ` [dts] [PATCH v6 " Phil Yang
  23 siblings, 0 replies; 124+ messages in thread
From: Phil Yang (Arm Technology China) @ 2018-09-17  5:12 UTC (permalink / raw)
  To: Phil Yang (Arm Technology China), dts; +Cc: nd, yong.liu

Hi,

Any comments for those patches?

Thanks,
Phil Yang

> -----Original Message-----
> From: Phil Yang <phil.yang@arm.com>
> Sent: Tuesday, September 4, 2018 4:26 PM
> To: dts@dpdk.org
> Cc: nd <nd@arm.com>; yong.liu@intel.com; Phil Yang (Arm Technology China)
> <Phil.Yang@arm.com>
> Subject: [PATCH v5 01/22] framework/packet: support packet sniffer to specify
> running machine
> 
> From: Phil Yang <phil.yang@arm.com>
> 
> By default, the Tester is supposed to be the server which running DTS and the
> packet sniff methods are running on it.
> However, if DTS was not running on the Tester and the Tester is another remote
> server, so packet sniff methods cannot sniff Tester's packets correctly.
> 
> This patch adds support for packet sniff methods to specify running machine and
> implements sniff packet methods in class tester.
> 
> 1. Add parameter to sniff_packet and load_sniff_pcap methods to specify the
> running machine.
> 2. Remove load_sniff_packets method in packet.py.
> 3. Add tcpdump_sniff_packets, load_tcpdump_sniff_pcap and
> load_tcpdump_sniff_packets for class tester with the new sniff_packet API.
> 4. Update tester.check_random_pkts method with
> tester.tcpdump_sniff_packets and tester.load_tcpdump_sniff_packets to make
> it execution on the Tester.
> 
> Signed-off-by: Phil Yang <phil.yang@arm.com>
> Suggested-by: Marvin Liu <yong.liu@intel.com>
> ---
>  framework/packet.py | 86 +++++++++++++++++++++++++---------------------------
> -
>  framework/tester.py | 48 +++++++++++++++++++++++++++---
>  2 files changed, 84 insertions(+), 50 deletions(-)
> 
> diff --git a/framework/packet.py b/framework/packet.py index
> 976b82b..1f3f07d 100755
> --- a/framework/packet.py
> +++ b/framework/packet.py
> @@ -812,15 +812,31 @@ 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)
> +    remote_terminate = 0
> +
> +    # 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,22 +866,29 @@ 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)
> +        remote_terminate = 1
> +    else:
> +        args = shlex.split(cmd)
> +        pipe = subprocess.Popen(args)
> 
> -    pipe = subprocess.Popen(args)
>      index = str(time.time())
> -    SNIFF_PIDS[index] = (pipe, intf, timeout)
> +    SNIFF_PIDS[index] = (pipe, intf, timeout, remote_terminate)
>      time.sleep(1)
>      return index
> 
> 
> -def load_sniff_pcap(index=''):
> +def load_sniff_pcap(index='', target=[]):
>      """
>      Stop sniffer and return pcap file
>      """
>      child_exit = False
>      if index in SNIFF_PIDS.keys():
> -        pipe, intf, timeout = SNIFF_PIDS[index]
> +        pipe, intf, timeout, remote_terminate = SNIFF_PIDS[index]
>          time_elapse = int(time.time() - float(index))
>          while time_elapse < timeout:
>              if pipe.poll() is not None:
> @@ -876,6 +899,14 @@ def load_sniff_pcap(index=''):
>              time_elapse += 1
> 
>          if not child_exit:
> +            if remote_terminate == 1:
> +                stop_tcpdump_pipe = subprocess.Popen(['ssh',
> +                                    '%s@%s' % (target[0], target[1]),
> +                                    'kill -2 $(pidof tcpdump)'],
> +                                    stderr=subprocess.PIPE,
> +                                    shell=False)
> +                stop_tcpdump_pipe.wait()
> +
>              pipe.send_signal(signal.SIGINT)
>              pipe.wait()
> 
> @@ -886,42 +917,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:
> @@ -983,7 +978,6 @@ if __name__ == "__main__":
>      inst = sniff_packets("lo", timeout=5)
>      pkt = Packet(pkt_type='UDP')
>      pkt.send_pkt(tx_port='lo')
> -    pkts = load_sniff_packets(inst)
> 
>      pkt = Packet(pkt_type='UDP', pkt_len=1500, ran_payload=True)
>      pkt.send_pkt(tx_port='lo')
> diff --git a/framework/tester.py b/framework/tester.py index a775f68..c5b705d
> 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 @@ -560,8 +561,6 @@ class Tester(Crb):
>          module = __import__("packet")
>          pkt_c = getattr(module, "Packet")
>          send_f = getattr(module, "send_packets")
> -        sniff_f = getattr(module, "sniff_packets")
> -        load_f = getattr(module, "load_sniff_packets")
>          compare_f = getattr(module, "compare_pktload")
>          strip_f = getattr(module, "strip_pktload")
>          save_f = getattr(module, "save_packets") @@ -606,7 +605,7 @@ class
> Tester(Crb):
> 
>              # send and sniff packets
>              save_f(pkts=pkts, filename="/tmp/%s_tx.pcap" % txIntf)
> -            inst = sniff_f(intf=rxIntf, count=pktnum, timeout=timeout, filters=
> +            inst = self.tcpdump_sniff_packets(intf=rxIntf,
> + count=pktnum, timeout=timeout, filters=
>                  [{'layer': 'network', 'config': {'srcport': '65535'}},
>                   {'layer': 'network', 'config': {'dstport': '65535'}}])
>              rx_inst[rxport] = inst
> @@ -627,7 +626,7 @@ class Tester(Crb):
>          # Verify all packets
>          prev_id = -1
>          for txport, rxport in portList:
> -            recv_pkts = load_f(rx_inst[rxport])
> +            recv_pkts =
> + self.load_tcpdump_sniff_packets(rx_inst[rxport])
> 
>              # only report when recevied number not matched
>              if len(tx_pkts[txport]) > len(recv_pkts):
> @@ -704,6 +703,47 @@ 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")
> +
> +        target=[]
> +        target.append(self.get_username())
> +        target.append(self.get_ip_address())
> +        target.append(self.get_password())
> +        pcap = load_pcap_f(index, target)
> +        self.session.copy_file_from(pcap)
> +
> +        return pcap.split(os.sep)[-1]
> +
> +    def load_tcpdump_sniff_packets(self, index=''):
> +        """
> +        Wrapper for packet module load_pcapfile
> +        """
> +        # 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
> 

^ permalink raw reply	[flat|nested] 124+ messages in thread

* Re: [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine
  2018-09-04  8:26       ` [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine Phil Yang
                           ` (21 preceding siblings ...)
  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-10-16  6:19         ` [dts] [PATCH v6 " Phil Yang
  23 siblings, 1 reply; 124+ messages in thread
From: Tu, Lijuan @ 2018-09-21  3:09 UTC (permalink / raw)
  To: Phil, dts; +Cc: nd, Liu, Yong, Phil Yang

One comments, when we ssh to a server, it might request a password, but we don't handle it.


> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Phil@dpdk.org
> Sent: Tuesday, September 4, 2018 4:26 PM
> To: dts@dpdk.org
> Cc: nd@arm.com; Liu, Yong <yong.liu@intel.com>; Phil Yang
> <phil.yang@arm.com>
> Subject: [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to
> specify running machine
> 
> From: Phil Yang <phil.yang@arm.com>
> 
> By default, the Tester is supposed to be the server which running DTS and the
> packet sniff methods are running on it.
> However, if DTS was not running on the Tester and the Tester is another
> remote server, so packet sniff methods cannot sniff Tester's packets
> correctly.
> 
> This patch adds support for packet sniff methods to specify running machine
> and implements sniff packet methods in class tester.
> 
> 1. Add parameter to sniff_packet and load_sniff_pcap methods to specify
> the running machine.
> 2. Remove load_sniff_packets method in packet.py.
> 3. Add tcpdump_sniff_packets, load_tcpdump_sniff_pcap and
> load_tcpdump_sniff_packets for class tester with the new sniff_packet API.
> 4. Update tester.check_random_pkts method with
> tester.tcpdump_sniff_packets and tester.load_tcpdump_sniff_packets to
> make it execution on the Tester.
> 
> Signed-off-by: Phil Yang <phil.yang@arm.com>
> Suggested-by: Marvin Liu <yong.liu@intel.com>
> ---
>  framework/packet.py | 86
> +++++++++++++++++++++++++----------------------------
>  framework/tester.py | 48 +++++++++++++++++++++++++++---
>  2 files changed, 84 insertions(+), 50 deletions(-)
> 
> diff --git a/framework/packet.py b/framework/packet.py index
> 976b82b..1f3f07d 100755
> --- a/framework/packet.py
> +++ b/framework/packet.py
> @@ -812,15 +812,31 @@ 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)
> +    remote_terminate = 0
> +
> +    # 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)
[Lijuan] Action will be blocked if SSH need password.
> +        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,22 +866,29 @@ 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)
> +        remote_terminate = 1
> +    else:
> +        args = shlex.split(cmd)
> +        pipe = subprocess.Popen(args)
> 
> -    pipe = subprocess.Popen(args)
>      index = str(time.time())
> -    SNIFF_PIDS[index] = (pipe, intf, timeout)
> +    SNIFF_PIDS[index] = (pipe, intf, timeout, remote_terminate)
>      time.sleep(1)
>      return index
> 
> 
> -def load_sniff_pcap(index=''):
> +def load_sniff_pcap(index='', target=[]):
>      """
>      Stop sniffer and return pcap file
>      """
>      child_exit = False
>      if index in SNIFF_PIDS.keys():
> -        pipe, intf, timeout = SNIFF_PIDS[index]
> +        pipe, intf, timeout, remote_terminate = SNIFF_PIDS[index]
>          time_elapse = int(time.time() - float(index))
>          while time_elapse < timeout:
>              if pipe.poll() is not None:
> @@ -876,6 +899,14 @@ def load_sniff_pcap(index=''):
>              time_elapse += 1
> 
>          if not child_exit:
> +            if remote_terminate == 1:
> +                stop_tcpdump_pipe = subprocess.Popen(['ssh',
> +                                    '%s@%s' % (target[0],
> target[1]),
> +                                    'kill -2 $(pidof tcpdump)'],
> +                                    stderr=subprocess.PIPE,
> +                                    shell=False)
> +                stop_tcpdump_pipe.wait()
> +
>              pipe.send_signal(signal.SIGINT)
>              pipe.wait()
> 
> @@ -886,42 +917,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:
> @@ -983,7 +978,6 @@ if __name__ == "__main__":
>      inst = sniff_packets("lo", timeout=5)
>      pkt = Packet(pkt_type='UDP')
>      pkt.send_pkt(tx_port='lo')
> -    pkts = load_sniff_packets(inst)
> 
>      pkt = Packet(pkt_type='UDP', pkt_len=1500, ran_payload=True)
>      pkt.send_pkt(tx_port='lo')
> diff --git a/framework/tester.py b/framework/tester.py index
> a775f68..c5b705d 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 @@ -560,8 +561,6 @@ class Tester(Crb):
>          module = __import__("packet")
>          pkt_c = getattr(module, "Packet")
>          send_f = getattr(module, "send_packets")
> -        sniff_f = getattr(module, "sniff_packets")
> -        load_f = getattr(module, "load_sniff_packets")
>          compare_f = getattr(module, "compare_pktload")
>          strip_f = getattr(module, "strip_pktload")
>          save_f = getattr(module, "save_packets") @@ -606,7 +605,7 @@
> class Tester(Crb):
> 
>              # send and sniff packets
>              save_f(pkts=pkts, filename="/tmp/%s_tx.pcap" % txIntf)
> -            inst = sniff_f(intf=rxIntf, count=pktnum, timeout=timeout,
> filters=
> +            inst = self.tcpdump_sniff_packets(intf=rxIntf,
> + count=pktnum, timeout=timeout, filters=
>                  [{'layer': 'network', 'config': {'srcport': '65535'}},
>                   {'layer': 'network', 'config': {'dstport': '65535'}}])
>              rx_inst[rxport] = inst
> @@ -627,7 +626,7 @@ class Tester(Crb):
>          # Verify all packets
>          prev_id = -1
>          for txport, rxport in portList:
> -            recv_pkts = load_f(rx_inst[rxport])
> +            recv_pkts =
> + self.load_tcpdump_sniff_packets(rx_inst[rxport])
> 
>              # only report when recevied number not matched
>              if len(tx_pkts[txport]) > len(recv_pkts):
> @@ -704,6 +703,47 @@ 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")
> +
> +        target=[]
> +        target.append(self.get_username())
> +        target.append(self.get_ip_address())
> +        target.append(self.get_password())
> +        pcap = load_pcap_f(index, target)
> +        self.session.copy_file_from(pcap)
> +
> +        return pcap.split(os.sep)[-1]
> +
> +    def load_tcpdump_sniff_packets(self, index=''):
> +        """
> +        Wrapper for packet module load_pcapfile
> +        """
> +        # 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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* Re: [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine
  2018-09-21  3:09         ` Tu, Lijuan
@ 2018-09-21  3:21           ` Phil Yang (Arm Technology China)
  2018-09-21  3:41             ` Tu, Lijuan
  0 siblings, 1 reply; 124+ messages in thread
From: Phil Yang (Arm Technology China) @ 2018-09-21  3:21 UTC (permalink / raw)
  To: Tu, Lijuan, Phil, dts; +Cc: nd, Liu, Yong

Hi Lijuan,

It also need to follow the DTS setup steps in https://doc.dpdk.org/dts/gsg/sys_reqs.html#authorized-login-session .

Since you know where are your DUT and Tester, so you can use tool ssh-copy-id to save local available keys on DUT and Tester.

Thanks,
Phil Yang

> -----Original Message-----
> From: Tu, Lijuan <lijuan.tu@intel.com>
> Sent: Friday, September 21, 2018 11:09 AM
> To: Phil@dpdk.org; dts@dpdk.org
> Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>; Phil Yang (Arm
> Technology China) <Phil.Yang@arm.com>
> Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to
> specify running machine
> 
> One comments, when we ssh to a server, it might request a password, but we
> don't handle it.
> 
> 
> > -----Original Message-----
> > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Phil@dpdk.org
> > Sent: Tuesday, September 4, 2018 4:26 PM
> > To: dts@dpdk.org
> > Cc: nd@arm.com; Liu, Yong <yong.liu@intel.com>; Phil Yang
> > <phil.yang@arm.com>
> > Subject: [dts] [PATCH v5 01/22] framework/packet: support packet
> > sniffer to specify running machine
> >
> > From: Phil Yang <phil.yang@arm.com>
> >
> > By default, the Tester is supposed to be the server which running DTS
> > and the packet sniff methods are running on it.
> > However, if DTS was not running on the Tester and the Tester is
> > another remote server, so packet sniff methods cannot sniff Tester's
> > packets correctly.
> >
> > This patch adds support for packet sniff methods to specify running
> > machine and implements sniff packet methods in class tester.
> >
> > 1. Add parameter to sniff_packet and load_sniff_pcap methods to
> > specify the running machine.
> > 2. Remove load_sniff_packets method in packet.py.
> > 3. Add tcpdump_sniff_packets, load_tcpdump_sniff_pcap and
> > load_tcpdump_sniff_packets for class tester with the new sniff_packet API.
> > 4. Update tester.check_random_pkts method with
> > tester.tcpdump_sniff_packets and tester.load_tcpdump_sniff_packets to
> > make it execution on the Tester.
> >
> > Signed-off-by: Phil Yang <phil.yang@arm.com>
> > Suggested-by: Marvin Liu <yong.liu@intel.com>
> > ---
> >  framework/packet.py | 86
> > +++++++++++++++++++++++++----------------------------
> >  framework/tester.py | 48 +++++++++++++++++++++++++++---
> >  2 files changed, 84 insertions(+), 50 deletions(-)
> >
> > diff --git a/framework/packet.py b/framework/packet.py index
> > 976b82b..1f3f07d 100755
> > --- a/framework/packet.py
> > +++ b/framework/packet.py
> > @@ -812,15 +812,31 @@ 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)
> > +    remote_terminate = 0
> > +
> > +    # 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)
> [Lijuan] Action will be blocked if SSH need password.
> > +        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,22 +866,29 @@ 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)
> > +        remote_terminate = 1
> > +    else:
> > +        args = shlex.split(cmd)
> > +        pipe = subprocess.Popen(args)
> >
> > -    pipe = subprocess.Popen(args)
> >      index = str(time.time())
> > -    SNIFF_PIDS[index] = (pipe, intf, timeout)
> > +    SNIFF_PIDS[index] = (pipe, intf, timeout, remote_terminate)
> >      time.sleep(1)
> >      return index
> >
> >
> > -def load_sniff_pcap(index=''):
> > +def load_sniff_pcap(index='', target=[]):
> >      """
> >      Stop sniffer and return pcap file
> >      """
> >      child_exit = False
> >      if index in SNIFF_PIDS.keys():
> > -        pipe, intf, timeout = SNIFF_PIDS[index]
> > +        pipe, intf, timeout, remote_terminate = SNIFF_PIDS[index]
> >          time_elapse = int(time.time() - float(index))
> >          while time_elapse < timeout:
> >              if pipe.poll() is not None:
> > @@ -876,6 +899,14 @@ def load_sniff_pcap(index=''):
> >              time_elapse += 1
> >
> >          if not child_exit:
> > +            if remote_terminate == 1:
> > +                stop_tcpdump_pipe = subprocess.Popen(['ssh',
> > +                                    '%s@%s' % (target[0],
> > target[1]),
> > +                                    'kill -2 $(pidof tcpdump)'],
> > +                                    stderr=subprocess.PIPE,
> > +                                    shell=False)
> > +                stop_tcpdump_pipe.wait()
> > +
> >              pipe.send_signal(signal.SIGINT)
> >              pipe.wait()
> >
> > @@ -886,42 +917,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:
> > @@ -983,7 +978,6 @@ if __name__ == "__main__":
> >      inst = sniff_packets("lo", timeout=5)
> >      pkt = Packet(pkt_type='UDP')
> >      pkt.send_pkt(tx_port='lo')
> > -    pkts = load_sniff_packets(inst)
> >
> >      pkt = Packet(pkt_type='UDP', pkt_len=1500, ran_payload=True)
> >      pkt.send_pkt(tx_port='lo')
> > diff --git a/framework/tester.py b/framework/tester.py index
> > a775f68..c5b705d 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 @@ -560,8 +561,6 @@ class Tester(Crb):
> >          module = __import__("packet")
> >          pkt_c = getattr(module, "Packet")
> >          send_f = getattr(module, "send_packets")
> > -        sniff_f = getattr(module, "sniff_packets")
> > -        load_f = getattr(module, "load_sniff_packets")
> >          compare_f = getattr(module, "compare_pktload")
> >          strip_f = getattr(module, "strip_pktload")
> >          save_f = getattr(module, "save_packets") @@ -606,7 +605,7 @@
> > class Tester(Crb):
> >
> >              # send and sniff packets
> >              save_f(pkts=pkts, filename="/tmp/%s_tx.pcap" % txIntf)
> > -            inst = sniff_f(intf=rxIntf, count=pktnum, timeout=timeout,
> > filters=
> > +            inst = self.tcpdump_sniff_packets(intf=rxIntf,
> > + count=pktnum, timeout=timeout, filters=
> >                  [{'layer': 'network', 'config': {'srcport': '65535'}},
> >                   {'layer': 'network', 'config': {'dstport': '65535'}}])
> >              rx_inst[rxport] = inst
> > @@ -627,7 +626,7 @@ class Tester(Crb):
> >          # Verify all packets
> >          prev_id = -1
> >          for txport, rxport in portList:
> > -            recv_pkts = load_f(rx_inst[rxport])
> > +            recv_pkts =
> > + self.load_tcpdump_sniff_packets(rx_inst[rxport])
> >
> >              # only report when recevied number not matched
> >              if len(tx_pkts[txport]) > len(recv_pkts):
> > @@ -704,6 +703,47 @@ 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")
> > +
> > +        target=[]
> > +        target.append(self.get_username())
> > +        target.append(self.get_ip_address())
> > +        target.append(self.get_password())
> > +        pcap = load_pcap_f(index, target)
> > +        self.session.copy_file_from(pcap)
> > +
> > +        return pcap.split(os.sep)[-1]
> > +
> > +    def load_tcpdump_sniff_packets(self, index=''):
> > +        """
> > +        Wrapper for packet module load_pcapfile
> > +        """
> > +        # 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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* Re: [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine
  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)
  0 siblings, 1 reply; 124+ messages in thread
From: Tu, Lijuan @ 2018-09-21  3:41 UTC (permalink / raw)
  To: Phil Yang (Arm Technology China), Phil, dts; +Cc: nd, Liu, Yong

DTS supports  either login server by password or utilize authorized login.
For logging by password, we could get some codes like " self.session = SSHPexpect(host, username, password, dut_id) " in SSHConnection module. and we have ip, username, password information in crb.cfg
I think we don't want to force user to utilize authorized login.

> -----Original Message-----
> From: Phil Yang (Arm Technology China) [mailto:Phil.Yang@arm.com]
> Sent: Friday, September 21, 2018 11:22 AM
> To: Tu, Lijuan <lijuan.tu@intel.com>; Phil@dpdk.org; dts@dpdk.org
> Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support packet
> sniffer to specify running machine
> 
> Hi Lijuan,
> 
> It also need to follow the DTS setup steps in
> https://doc.dpdk.org/dts/gsg/sys_reqs.html#authorized-login-session .
> 
> Since you know where are your DUT and Tester, so you can use tool
> ssh-copy-id to save local available keys on DUT and Tester.
> 
> Thanks,
> Phil Yang
> 
> > -----Original Message-----
> > From: Tu, Lijuan <lijuan.tu@intel.com>
> > Sent: Friday, September 21, 2018 11:09 AM
> > To: Phil@dpdk.org; dts@dpdk.org
> > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>; Phil Yang (Arm
> > Technology China) <Phil.Yang@arm.com>
> > Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support packet
> > sniffer to specify running machine
> >
> > One comments, when we ssh to a server, it might request a password,
> > but we don't handle it.
> >
> >
> > > -----Original Message-----
> > > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Phil@dpdk.org
> > > Sent: Tuesday, September 4, 2018 4:26 PM
> > > To: dts@dpdk.org
> > > Cc: nd@arm.com; Liu, Yong <yong.liu@intel.com>; Phil Yang
> > > <phil.yang@arm.com>
> > > Subject: [dts] [PATCH v5 01/22] framework/packet: support packet
> > > sniffer to specify running machine
> > >
> > > From: Phil Yang <phil.yang@arm.com>
> > >
> > > By default, the Tester is supposed to be the server which running
> > > DTS and the packet sniff methods are running on it.
> > > However, if DTS was not running on the Tester and the Tester is
> > > another remote server, so packet sniff methods cannot sniff Tester's
> > > packets correctly.
> > >
> > > This patch adds support for packet sniff methods to specify running
> > > machine and implements sniff packet methods in class tester.
> > >
> > > 1. Add parameter to sniff_packet and load_sniff_pcap methods to
> > > specify the running machine.
> > > 2. Remove load_sniff_packets method in packet.py.
> > > 3. Add tcpdump_sniff_packets, load_tcpdump_sniff_pcap and
> > > load_tcpdump_sniff_packets for class tester with the new sniff_packet
> API.
> > > 4. Update tester.check_random_pkts method with
> > > tester.tcpdump_sniff_packets and tester.load_tcpdump_sniff_packets
> > > to make it execution on the Tester.
> > >
> > > Signed-off-by: Phil Yang <phil.yang@arm.com>
> > > Suggested-by: Marvin Liu <yong.liu@intel.com>
> > > ---
> > >  framework/packet.py | 86
> > > +++++++++++++++++++++++++----------------------------
> > >  framework/tester.py | 48 +++++++++++++++++++++++++++---
> > >  2 files changed, 84 insertions(+), 50 deletions(-)
> > >
> > > diff --git a/framework/packet.py b/framework/packet.py index
> > > 976b82b..1f3f07d 100755
> > > --- a/framework/packet.py
> > > +++ b/framework/packet.py
> > > @@ -812,15 +812,31 @@ 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)
> > > +    remote_terminate = 0
> > > +
> > > +    # 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)
> > [Lijuan] Action will be blocked if SSH need password.
> > > +        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,22 +866,29 @@ 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)
> > > +        remote_terminate = 1
> > > +    else:
> > > +        args = shlex.split(cmd)
> > > +        pipe = subprocess.Popen(args)
> > >
> > > -    pipe = subprocess.Popen(args)
> > >      index = str(time.time())
> > > -    SNIFF_PIDS[index] = (pipe, intf, timeout)
> > > +    SNIFF_PIDS[index] = (pipe, intf, timeout, remote_terminate)
> > >      time.sleep(1)
> > >      return index
> > >
> > >
> > > -def load_sniff_pcap(index=''):
> > > +def load_sniff_pcap(index='', target=[]):
> > >      """
> > >      Stop sniffer and return pcap file
> > >      """
> > >      child_exit = False
> > >      if index in SNIFF_PIDS.keys():
> > > -        pipe, intf, timeout = SNIFF_PIDS[index]
> > > +        pipe, intf, timeout, remote_terminate = SNIFF_PIDS[index]
> > >          time_elapse = int(time.time() - float(index))
> > >          while time_elapse < timeout:
> > >              if pipe.poll() is not None:
> > > @@ -876,6 +899,14 @@ def load_sniff_pcap(index=''):
> > >              time_elapse += 1
> > >
> > >          if not child_exit:
> > > +            if remote_terminate == 1:
> > > +                stop_tcpdump_pipe = subprocess.Popen(['ssh',
> > > +                                    '%s@%s' % (target[0],
> > > target[1]),
> > > +                                    'kill -2 $(pidof tcpdump)'],
> > > +                                    stderr=subprocess.PIPE,
> > > +                                    shell=False)
> > > +                stop_tcpdump_pipe.wait()
> > > +
> > >              pipe.send_signal(signal.SIGINT)
> > >              pipe.wait()
> > >
> > > @@ -886,42 +917,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:
> > > @@ -983,7 +978,6 @@ if __name__ == "__main__":
> > >      inst = sniff_packets("lo", timeout=5)
> > >      pkt = Packet(pkt_type='UDP')
> > >      pkt.send_pkt(tx_port='lo')
> > > -    pkts = load_sniff_packets(inst)
> > >
> > >      pkt = Packet(pkt_type='UDP', pkt_len=1500, ran_payload=True)
> > >      pkt.send_pkt(tx_port='lo')
> > > diff --git a/framework/tester.py b/framework/tester.py index
> > > a775f68..c5b705d 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 @@ -560,8 +561,6 @@ class Tester(Crb):
> > >          module = __import__("packet")
> > >          pkt_c = getattr(module, "Packet")
> > >          send_f = getattr(module, "send_packets")
> > > -        sniff_f = getattr(module, "sniff_packets")
> > > -        load_f = getattr(module, "load_sniff_packets")
> > >          compare_f = getattr(module, "compare_pktload")
> > >          strip_f = getattr(module, "strip_pktload")
> > >          save_f = getattr(module, "save_packets") @@ -606,7 +605,7
> > > @@ class Tester(Crb):
> > >
> > >              # send and sniff packets
> > >              save_f(pkts=pkts, filename="/tmp/%s_tx.pcap" % txIntf)
> > > -            inst = sniff_f(intf=rxIntf, count=pktnum,
> timeout=timeout,
> > > filters=
> > > +            inst = self.tcpdump_sniff_packets(intf=rxIntf,
> > > + count=pktnum, timeout=timeout, filters=
> > >                  [{'layer': 'network', 'config': {'srcport': '65535'}},
> > >                   {'layer': 'network', 'config': {'dstport': '65535'}}])
> > >              rx_inst[rxport] = inst
> > > @@ -627,7 +626,7 @@ class Tester(Crb):
> > >          # Verify all packets
> > >          prev_id = -1
> > >          for txport, rxport in portList:
> > > -            recv_pkts = load_f(rx_inst[rxport])
> > > +            recv_pkts =
> > > + self.load_tcpdump_sniff_packets(rx_inst[rxport])
> > >
> > >              # only report when recevied number not matched
> > >              if len(tx_pkts[txport]) > len(recv_pkts):
> > > @@ -704,6 +703,47 @@ 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")
> > > +
> > > +        target=[]
> > > +        target.append(self.get_username())
> > > +        target.append(self.get_ip_address())
> > > +        target.append(self.get_password())
> > > +        pcap = load_pcap_f(index, target)
> > > +        self.session.copy_file_from(pcap)
> > > +
> > > +        return pcap.split(os.sep)[-1]
> > > +
> > > +    def load_tcpdump_sniff_packets(self, index=''):
> > > +        """
> > > +        Wrapper for packet module load_pcapfile
> > > +        """
> > > +        # 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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* Re: [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine
  2018-09-21  3:41             ` Tu, Lijuan
@ 2018-09-21  6:58               ` Phil Yang (Arm Technology China)
  2018-09-21  7:19                 ` Tu, Lijuan
  0 siblings, 1 reply; 124+ messages in thread
From: Phil Yang (Arm Technology China) @ 2018-09-21  6:58 UTC (permalink / raw)
  To: Tu, Lijuan, Phil, dts; +Cc: nd, Liu, Yong

Yes. I agreed with that.

I think my patch has also followed this rule. 
In the packet.py, I added one more parameter "target" for sniff_packets and load_sniff_pcap to specify the username and IP address.
In the test.py, I passed the Tester's passwd and IP address to these two functions. Thus, it will make sure sniff packet operation done on the Tester.

Thanks,
Phil Yang

> -----Original Message-----
> From: Tu, Lijuan <lijuan.tu@intel.com>
> Sent: Friday, September 21, 2018 11:42 AM
> To: Phil Yang (Arm Technology China) <Phil.Yang@arm.com>; Phil@dpdk.org;
> dts@dpdk.org
> Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to
> specify running machine
> 
> DTS supports  either login server by password or utilize authorized login.
> For logging by password, we could get some codes like " self.session =
> SSHPexpect(host, username, password, dut_id) " in SSHConnection module. and
> we have ip, username, password information in crb.cfg I think we don't want to
> force user to utilize authorized login.
> 
> > -----Original Message-----
> > From: Phil Yang (Arm Technology China) [mailto:Phil.Yang@arm.com]
> > Sent: Friday, September 21, 2018 11:22 AM
> > To: Tu, Lijuan <lijuan.tu@intel.com>; Phil@dpdk.org; dts@dpdk.org
> > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> > Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support packet
> > sniffer to specify running machine
> >
> > Hi Lijuan,
> >
> > It also need to follow the DTS setup steps in
> > https://doc.dpdk.org/dts/gsg/sys_reqs.html#authorized-login-session .
> >
> > Since you know where are your DUT and Tester, so you can use tool
> > ssh-copy-id to save local available keys on DUT and Tester.
> >
> > Thanks,
> > Phil Yang
> >
> > > -----Original Message-----
> > > From: Tu, Lijuan <lijuan.tu@intel.com>
> > > Sent: Friday, September 21, 2018 11:09 AM
> > > To: Phil@dpdk.org; dts@dpdk.org
> > > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>; Phil Yang (Arm
> > > Technology China) <Phil.Yang@arm.com>
> > > Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support packet
> > > sniffer to specify running machine
> > >
> > > One comments, when we ssh to a server, it might request a password,
> > > but we don't handle it.
> > >
> > >
> > > > -----Original Message-----
> > > > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Phil@dpdk.org
> > > > Sent: Tuesday, September 4, 2018 4:26 PM
> > > > To: dts@dpdk.org
> > > > Cc: nd@arm.com; Liu, Yong <yong.liu@intel.com>; Phil Yang
> > > > <phil.yang@arm.com>
> > > > Subject: [dts] [PATCH v5 01/22] framework/packet: support packet
> > > > sniffer to specify running machine
> > > >
> > > > From: Phil Yang <phil.yang@arm.com>
> > > >
> > > > By default, the Tester is supposed to be the server which running
> > > > DTS and the packet sniff methods are running on it.
> > > > However, if DTS was not running on the Tester and the Tester is
> > > > another remote server, so packet sniff methods cannot sniff
> > > > Tester's packets correctly.
> > > >
> > > > This patch adds support for packet sniff methods to specify
> > > > running machine and implements sniff packet methods in class tester.
> > > >
> > > > 1. Add parameter to sniff_packet and load_sniff_pcap methods to
> > > > specify the running machine.
> > > > 2. Remove load_sniff_packets method in packet.py.
> > > > 3. Add tcpdump_sniff_packets, load_tcpdump_sniff_pcap and
> > > > load_tcpdump_sniff_packets for class tester with the new
> > > > sniff_packet
> > API.
> > > > 4. Update tester.check_random_pkts method with
> > > > tester.tcpdump_sniff_packets and tester.load_tcpdump_sniff_packets
> > > > to make it execution on the Tester.
> > > >
> > > > Signed-off-by: Phil Yang <phil.yang@arm.com>
> > > > Suggested-by: Marvin Liu <yong.liu@intel.com>
> > > > ---
> > > >  framework/packet.py | 86
> > > > +++++++++++++++++++++++++----------------------------
> > > >  framework/tester.py | 48 +++++++++++++++++++++++++++---
> > > >  2 files changed, 84 insertions(+), 50 deletions(-)
> > > >
> > > > diff --git a/framework/packet.py b/framework/packet.py index
> > > > 976b82b..1f3f07d 100755
> > > > --- a/framework/packet.py
> > > > +++ b/framework/packet.py
> > > > @@ -812,15 +812,31 @@ 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)
> > > > +    remote_terminate = 0
> > > > +
> > > > +    # 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)
> > > [Lijuan] Action will be blocked if SSH need password.
> > > > +        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,22 +866,29 @@ 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)
> > > > +        remote_terminate = 1
> > > > +    else:
> > > > +        args = shlex.split(cmd)
> > > > +        pipe = subprocess.Popen(args)
> > > >
> > > > -    pipe = subprocess.Popen(args)
> > > >      index = str(time.time())
> > > > -    SNIFF_PIDS[index] = (pipe, intf, timeout)
> > > > +    SNIFF_PIDS[index] = (pipe, intf, timeout, remote_terminate)
> > > >      time.sleep(1)
> > > >      return index
> > > >
> > > >
> > > > -def load_sniff_pcap(index=''):
> > > > +def load_sniff_pcap(index='', target=[]):
> > > >      """
> > > >      Stop sniffer and return pcap file
> > > >      """
> > > >      child_exit = False
> > > >      if index in SNIFF_PIDS.keys():
> > > > -        pipe, intf, timeout = SNIFF_PIDS[index]
> > > > +        pipe, intf, timeout, remote_terminate = SNIFF_PIDS[index]
> > > >          time_elapse = int(time.time() - float(index))
> > > >          while time_elapse < timeout:
> > > >              if pipe.poll() is not None:
> > > > @@ -876,6 +899,14 @@ def load_sniff_pcap(index=''):
> > > >              time_elapse += 1
> > > >
> > > >          if not child_exit:
> > > > +            if remote_terminate == 1:
> > > > +                stop_tcpdump_pipe = subprocess.Popen(['ssh',
> > > > +                                    '%s@%s' % (target[0],
> > > > target[1]),
> > > > +                                    'kill -2 $(pidof tcpdump)'],
> > > > +                                    stderr=subprocess.PIPE,
> > > > +                                    shell=False)
> > > > +                stop_tcpdump_pipe.wait()
> > > > +
> > > >              pipe.send_signal(signal.SIGINT)
> > > >              pipe.wait()
> > > >
> > > > @@ -886,42 +917,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:
> > > > @@ -983,7 +978,6 @@ if __name__ == "__main__":
> > > >      inst = sniff_packets("lo", timeout=5)
> > > >      pkt = Packet(pkt_type='UDP')
> > > >      pkt.send_pkt(tx_port='lo')
> > > > -    pkts = load_sniff_packets(inst)
> > > >
> > > >      pkt = Packet(pkt_type='UDP', pkt_len=1500, ran_payload=True)
> > > >      pkt.send_pkt(tx_port='lo')
> > > > diff --git a/framework/tester.py b/framework/tester.py index
> > > > a775f68..c5b705d 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 @@ -560,8 +561,6 @@ class Tester(Crb):
> > > >          module = __import__("packet")
> > > >          pkt_c = getattr(module, "Packet")
> > > >          send_f = getattr(module, "send_packets")
> > > > -        sniff_f = getattr(module, "sniff_packets")
> > > > -        load_f = getattr(module, "load_sniff_packets")
> > > >          compare_f = getattr(module, "compare_pktload")
> > > >          strip_f = getattr(module, "strip_pktload")
> > > >          save_f = getattr(module, "save_packets") @@ -606,7 +605,7
> > > > @@ class Tester(Crb):
> > > >
> > > >              # send and sniff packets
> > > >              save_f(pkts=pkts, filename="/tmp/%s_tx.pcap" % txIntf)
> > > > -            inst = sniff_f(intf=rxIntf, count=pktnum,
> > timeout=timeout,
> > > > filters=
> > > > +            inst = self.tcpdump_sniff_packets(intf=rxIntf,
> > > > + count=pktnum, timeout=timeout, filters=
> > > >                  [{'layer': 'network', 'config': {'srcport': '65535'}},
> > > >                   {'layer': 'network', 'config': {'dstport': '65535'}}])
> > > >              rx_inst[rxport] = inst @@ -627,7 +626,7 @@ class
> > > > Tester(Crb):
> > > >          # Verify all packets
> > > >          prev_id = -1
> > > >          for txport, rxport in portList:
> > > > -            recv_pkts = load_f(rx_inst[rxport])
> > > > +            recv_pkts =
> > > > + self.load_tcpdump_sniff_packets(rx_inst[rxport])
> > > >
> > > >              # only report when recevied number not matched
> > > >              if len(tx_pkts[txport]) > len(recv_pkts):
> > > > @@ -704,6 +703,47 @@ 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")
> > > > +
> > > > +        target=[]
> > > > +        target.append(self.get_username())
> > > > +        target.append(self.get_ip_address())
> > > > +        target.append(self.get_password())
> > > > +        pcap = load_pcap_f(index, target)
> > > > +        self.session.copy_file_from(pcap)
> > > > +
> > > > +        return pcap.split(os.sep)[-1]
> > > > +
> > > > +    def load_tcpdump_sniff_packets(self, index=''):
> > > > +        """
> > > > +        Wrapper for packet module load_pcapfile
> > > > +        """
> > > > +        # 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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* Re: [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine
  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)
  0 siblings, 1 reply; 124+ messages in thread
From: Tu, Lijuan @ 2018-09-21  7:19 UTC (permalink / raw)
  To: Phil Yang (Arm Technology China), Phil, dts; +Cc: nd, Liu, Yong

I am glad we reach an agreement.

Of course, the parameter "target" have password, but I found no any function would call it.
Only username and ip are used. The target[2] is the password, and is not called.
+    if target:
+        tcpdump_help_pipe = subprocess.Popen(["ssh",
+                            "%s@%s" % (target[0], target[1]),
+                            "tcpdump -h"],
+                            stderr=subprocess.PIPE,
+                            stdout=subprocess.PIPE,
+                            shell=False)
Anything I missed?


> -----Original Message-----
> From: Phil Yang (Arm Technology China) [mailto:Phil.Yang@arm.com]
> Sent: Friday, September 21, 2018 2:59 PM
> To: Tu, Lijuan <lijuan.tu@intel.com>; Phil@dpdk.org; dts@dpdk.org
> Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support packet
> sniffer to specify running machine
> 
> Yes. I agreed with that.
> 
> I think my patch has also followed this rule.
> In the packet.py, I added one more parameter "target" for sniff_packets and
> load_sniff_pcap to specify the username and IP address.
> In the test.py, I passed the Tester's passwd and IP address to these two
> functions. Thus, it will make sure sniff packet operation done on the Tester.
> 
> Thanks,
> Phil Yang
> 
> > -----Original Message-----
> > From: Tu, Lijuan <lijuan.tu@intel.com>
> > Sent: Friday, September 21, 2018 11:42 AM
> > To: Phil Yang (Arm Technology China) <Phil.Yang@arm.com>;
> > Phil@dpdk.org; dts@dpdk.org
> > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> > Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support packet
> > sniffer to specify running machine
> >
> > DTS supports  either login server by password or utilize authorized login.
> > For logging by password, we could get some codes like " self.session =
> > SSHPexpect(host, username, password, dut_id) " in SSHConnection
> > module. and we have ip, username, password information in crb.cfg I
> > think we don't want to force user to utilize authorized login.
> >
> > > -----Original Message-----
> > > From: Phil Yang (Arm Technology China) [mailto:Phil.Yang@arm.com]
> > > Sent: Friday, September 21, 2018 11:22 AM
> > > To: Tu, Lijuan <lijuan.tu@intel.com>; Phil@dpdk.org; dts@dpdk.org
> > > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> > > Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support packet
> > > sniffer to specify running machine
> > >
> > > Hi Lijuan,
> > >
> > > It also need to follow the DTS setup steps in
> > > https://doc.dpdk.org/dts/gsg/sys_reqs.html#authorized-login-session .
> > >
> > > Since you know where are your DUT and Tester, so you can use tool
> > > ssh-copy-id to save local available keys on DUT and Tester.
> > >
> > > Thanks,
> > > Phil Yang
> > >
> > > > -----Original Message-----
> > > > From: Tu, Lijuan <lijuan.tu@intel.com>
> > > > Sent: Friday, September 21, 2018 11:09 AM
> > > > To: Phil@dpdk.org; dts@dpdk.org
> > > > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>; Phil Yang
> > > > (Arm Technology China) <Phil.Yang@arm.com>
> > > > Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support
> > > > packet sniffer to specify running machine
> > > >
> > > > One comments, when we ssh to a server, it might request a
> > > > password, but we don't handle it.
> > > >
> > > >
> > > > > -----Original Message-----
> > > > > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of
> > > > > Phil@dpdk.org
> > > > > Sent: Tuesday, September 4, 2018 4:26 PM
> > > > > To: dts@dpdk.org
> > > > > Cc: nd@arm.com; Liu, Yong <yong.liu@intel.com>; Phil Yang
> > > > > <phil.yang@arm.com>
> > > > > Subject: [dts] [PATCH v5 01/22] framework/packet: support packet
> > > > > sniffer to specify running machine
> > > > >
> > > > > From: Phil Yang <phil.yang@arm.com>
> > > > >
> > > > > By default, the Tester is supposed to be the server which
> > > > > running DTS and the packet sniff methods are running on it.
> > > > > However, if DTS was not running on the Tester and the Tester is
> > > > > another remote server, so packet sniff methods cannot sniff
> > > > > Tester's packets correctly.
> > > > >
> > > > > This patch adds support for packet sniff methods to specify
> > > > > running machine and implements sniff packet methods in class tester.
> > > > >
> > > > > 1. Add parameter to sniff_packet and load_sniff_pcap methods to
> > > > > specify the running machine.
> > > > > 2. Remove load_sniff_packets method in packet.py.
> > > > > 3. Add tcpdump_sniff_packets, load_tcpdump_sniff_pcap and
> > > > > load_tcpdump_sniff_packets for class tester with the new
> > > > > sniff_packet
> > > API.
> > > > > 4. Update tester.check_random_pkts method with
> > > > > tester.tcpdump_sniff_packets and
> > > > > tester.load_tcpdump_sniff_packets to make it execution on the
> Tester.
> > > > >
> > > > > Signed-off-by: Phil Yang <phil.yang@arm.com>
> > > > > Suggested-by: Marvin Liu <yong.liu@intel.com>
> > > > > ---
> > > > >  framework/packet.py | 86
> > > > > +++++++++++++++++++++++++----------------------------
> > > > >  framework/tester.py | 48 +++++++++++++++++++++++++++---
> > > > >  2 files changed, 84 insertions(+), 50 deletions(-)
> > > > >
> > > > > diff --git a/framework/packet.py b/framework/packet.py index
> > > > > 976b82b..1f3f07d 100755
> > > > > --- a/framework/packet.py
> > > > > +++ b/framework/packet.py
> > > > > @@ -812,15 +812,31 @@ 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)
> > > > > +    remote_terminate = 0
> > > > > +
> > > > > +    # 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)
> > > > [Lijuan] Action will be blocked if SSH need password.
> > > > > +        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,22 +866,29 @@ 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)
> > > > > +        remote_terminate = 1
> > > > > +    else:
> > > > > +        args = shlex.split(cmd)
> > > > > +        pipe = subprocess.Popen(args)
> > > > >
> > > > > -    pipe = subprocess.Popen(args)
> > > > >      index = str(time.time())
> > > > > -    SNIFF_PIDS[index] = (pipe, intf, timeout)
> > > > > +    SNIFF_PIDS[index] = (pipe, intf, timeout, remote_terminate)
> > > > >      time.sleep(1)
> > > > >      return index
> > > > >
> > > > >
> > > > > -def load_sniff_pcap(index=''):
> > > > > +def load_sniff_pcap(index='', target=[]):
> > > > >      """
> > > > >      Stop sniffer and return pcap file
> > > > >      """
> > > > >      child_exit = False
> > > > >      if index in SNIFF_PIDS.keys():
> > > > > -        pipe, intf, timeout = SNIFF_PIDS[index]
> > > > > +        pipe, intf, timeout, remote_terminate =
> > > > > + SNIFF_PIDS[index]
> > > > >          time_elapse = int(time.time() - float(index))
> > > > >          while time_elapse < timeout:
> > > > >              if pipe.poll() is not None:
> > > > > @@ -876,6 +899,14 @@ def load_sniff_pcap(index=''):
> > > > >              time_elapse += 1
> > > > >
> > > > >          if not child_exit:
> > > > > +            if remote_terminate == 1:
> > > > > +                stop_tcpdump_pipe = subprocess.Popen(['ssh',
> > > > > +                                    '%s@%s' % (target[0],
> > > > > target[1]),
> > > > > +                                    'kill -2 $(pidof
> tcpdump)'],
> > > > > +                                    stderr=subprocess.PIPE,
> > > > > +                                    shell=False)
> > > > > +                stop_tcpdump_pipe.wait()
> > > > > +
> > > > >              pipe.send_signal(signal.SIGINT)
> > > > >              pipe.wait()
> > > > >
> > > > > @@ -886,42 +917,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:
> > > > > @@ -983,7 +978,6 @@ if __name__ == "__main__":
> > > > >      inst = sniff_packets("lo", timeout=5)
> > > > >      pkt = Packet(pkt_type='UDP')
> > > > >      pkt.send_pkt(tx_port='lo')
> > > > > -    pkts = load_sniff_packets(inst)
> > > > >
> > > > >      pkt = Packet(pkt_type='UDP', pkt_len=1500,
> ran_payload=True)
> > > > >      pkt.send_pkt(tx_port='lo')
> > > > > diff --git a/framework/tester.py b/framework/tester.py index
> > > > > a775f68..c5b705d 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 @@ -560,8 +561,6 @@ class Tester(Crb):
> > > > >          module = __import__("packet")
> > > > >          pkt_c = getattr(module, "Packet")
> > > > >          send_f = getattr(module, "send_packets")
> > > > > -        sniff_f = getattr(module, "sniff_packets")
> > > > > -        load_f = getattr(module, "load_sniff_packets")
> > > > >          compare_f = getattr(module, "compare_pktload")
> > > > >          strip_f = getattr(module, "strip_pktload")
> > > > >          save_f = getattr(module, "save_packets") @@ -606,7
> > > > > +605,7 @@ class Tester(Crb):
> > > > >
> > > > >              # send and sniff packets
> > > > >              save_f(pkts=pkts, filename="/tmp/%s_tx.pcap" %
> txIntf)
> > > > > -            inst = sniff_f(intf=rxIntf, count=pktnum,
> > > timeout=timeout,
> > > > > filters=
> > > > > +            inst = self.tcpdump_sniff_packets(intf=rxIntf,
> > > > > + count=pktnum, timeout=timeout, filters=
> > > > >                  [{'layer': 'network', 'config': {'srcport': '65535'}},
> > > > >                   {'layer': 'network', 'config': {'dstport':
> '65535'}}])
> > > > >              rx_inst[rxport] = inst @@ -627,7 +626,7 @@ class
> > > > > Tester(Crb):
> > > > >          # Verify all packets
> > > > >          prev_id = -1
> > > > >          for txport, rxport in portList:
> > > > > -            recv_pkts = load_f(rx_inst[rxport])
> > > > > +            recv_pkts =
> > > > > + self.load_tcpdump_sniff_packets(rx_inst[rxport])
> > > > >
> > > > >              # only report when recevied number not matched
> > > > >              if len(tx_pkts[txport]) > len(recv_pkts):
> > > > > @@ -704,6 +703,47 @@ 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")
> > > > > +
> > > > > +        target=[]
> > > > > +        target.append(self.get_username())
> > > > > +        target.append(self.get_ip_address())
> > > > > +        target.append(self.get_password())
> > > > > +        pcap = load_pcap_f(index, target)
> > > > > +        self.session.copy_file_from(pcap)
> > > > > +
> > > > > +        return pcap.split(os.sep)[-1]
> > > > > +
> > > > > +    def load_tcpdump_sniff_packets(self, index=''):
> > > > > +        """
> > > > > +        Wrapper for packet module load_pcapfile
> > > > > +        """
> > > > > +        # 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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* Re: [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine
  2018-09-21  7:19                 ` Tu, Lijuan
@ 2018-09-21  7:32                   ` Phil Yang (Arm Technology China)
  2018-09-21  8:27                     ` Tu, Lijuan
  0 siblings, 1 reply; 124+ messages in thread
From: Phil Yang (Arm Technology China) @ 2018-09-21  7:32 UTC (permalink / raw)
  To: Tu, Lijuan, Phil, dts; +Cc: nd, Liu, Yong

tcpdump_sniff_packet and load_tcpdump_sniff_pcap in class Tester will call those two functions.

    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)

Please check test.py in this patch.

Thanks,
Phil Yang

> -----Original Message-----
> From: Tu, Lijuan <lijuan.tu@intel.com>
> Sent: Friday, September 21, 2018 3:19 PM
> To: Phil Yang (Arm Technology China) <Phil.Yang@arm.com>; Phil@dpdk.org;
> dts@dpdk.org
> Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to
> specify running machine
> 
> I am glad we reach an agreement.
> 
> Of course, the parameter "target" have password, but I found no any function
> would call it.
> Only username and ip are used. The target[2] is the password, and is not called.
> +    if target:
> +        tcpdump_help_pipe = subprocess.Popen(["ssh",
> +                            "%s@%s" % (target[0], target[1]),
> +                            "tcpdump -h"],
> +                            stderr=subprocess.PIPE,
> +                            stdout=subprocess.PIPE,
> +                            shell=False)
> Anything I missed?
> 
> 
> > -----Original Message-----
> > From: Phil Yang (Arm Technology China) [mailto:Phil.Yang@arm.com]
> > Sent: Friday, September 21, 2018 2:59 PM
> > To: Tu, Lijuan <lijuan.tu@intel.com>; Phil@dpdk.org; dts@dpdk.org
> > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> > Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support packet
> > sniffer to specify running machine
> >
> > Yes. I agreed with that.
> >
> > I think my patch has also followed this rule.
> > In the packet.py, I added one more parameter "target" for
> > sniff_packets and load_sniff_pcap to specify the username and IP address.
> > In the test.py, I passed the Tester's passwd and IP address to these
> > two functions. Thus, it will make sure sniff packet operation done on the
> Tester.
> >
> > Thanks,
> > Phil Yang
> >
> > > -----Original Message-----
> > > From: Tu, Lijuan <lijuan.tu@intel.com>
> > > Sent: Friday, September 21, 2018 11:42 AM
> > > To: Phil Yang (Arm Technology China) <Phil.Yang@arm.com>;
> > > Phil@dpdk.org; dts@dpdk.org
> > > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> > > Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support packet
> > > sniffer to specify running machine
> > >
> > > DTS supports  either login server by password or utilize authorized login.
> > > For logging by password, we could get some codes like " self.session
> > > = SSHPexpect(host, username, password, dut_id) " in SSHConnection
> > > module. and we have ip, username, password information in crb.cfg I
> > > think we don't want to force user to utilize authorized login.
> > >
> > > > -----Original Message-----
> > > > From: Phil Yang (Arm Technology China) [mailto:Phil.Yang@arm.com]
> > > > Sent: Friday, September 21, 2018 11:22 AM
> > > > To: Tu, Lijuan <lijuan.tu@intel.com>; Phil@dpdk.org; dts@dpdk.org
> > > > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> > > > Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support
> > > > packet sniffer to specify running machine
> > > >
> > > > Hi Lijuan,
> > > >
> > > > It also need to follow the DTS setup steps in
> > > > https://doc.dpdk.org/dts/gsg/sys_reqs.html#authorized-login-session .
> > > >
> > > > Since you know where are your DUT and Tester, so you can use tool
> > > > ssh-copy-id to save local available keys on DUT and Tester.
> > > >
> > > > Thanks,
> > > > Phil Yang
> > > >
> > > > > -----Original Message-----
> > > > > From: Tu, Lijuan <lijuan.tu@intel.com>
> > > > > Sent: Friday, September 21, 2018 11:09 AM
> > > > > To: Phil@dpdk.org; dts@dpdk.org
> > > > > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>; Phil Yang
> > > > > (Arm Technology China) <Phil.Yang@arm.com>
> > > > > Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support
> > > > > packet sniffer to specify running machine
> > > > >
> > > > > One comments, when we ssh to a server, it might request a
> > > > > password, but we don't handle it.
> > > > >
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of
> > > > > > Phil@dpdk.org
> > > > > > Sent: Tuesday, September 4, 2018 4:26 PM
> > > > > > To: dts@dpdk.org
> > > > > > Cc: nd@arm.com; Liu, Yong <yong.liu@intel.com>; Phil Yang
> > > > > > <phil.yang@arm.com>
> > > > > > Subject: [dts] [PATCH v5 01/22] framework/packet: support
> > > > > > packet sniffer to specify running machine
> > > > > >
> > > > > > From: Phil Yang <phil.yang@arm.com>
> > > > > >
> > > > > > By default, the Tester is supposed to be the server which
> > > > > > running DTS and the packet sniff methods are running on it.
> > > > > > However, if DTS was not running on the Tester and the Tester
> > > > > > is another remote server, so packet sniff methods cannot sniff
> > > > > > Tester's packets correctly.
> > > > > >
> > > > > > This patch adds support for packet sniff methods to specify
> > > > > > running machine and implements sniff packet methods in class tester.
> > > > > >
> > > > > > 1. Add parameter to sniff_packet and load_sniff_pcap methods
> > > > > > to specify the running machine.
> > > > > > 2. Remove load_sniff_packets method in packet.py.
> > > > > > 3. Add tcpdump_sniff_packets, load_tcpdump_sniff_pcap and
> > > > > > load_tcpdump_sniff_packets for class tester with the new
> > > > > > sniff_packet
> > > > API.
> > > > > > 4. Update tester.check_random_pkts method with
> > > > > > tester.tcpdump_sniff_packets and
> > > > > > tester.load_tcpdump_sniff_packets to make it execution on the
> > Tester.
> > > > > >
> > > > > > Signed-off-by: Phil Yang <phil.yang@arm.com>
> > > > > > Suggested-by: Marvin Liu <yong.liu@intel.com>
> > > > > > ---
> > > > > >  framework/packet.py | 86
> > > > > > +++++++++++++++++++++++++----------------------------
> > > > > >  framework/tester.py | 48 +++++++++++++++++++++++++++---
> > > > > >  2 files changed, 84 insertions(+), 50 deletions(-)
> > > > > >
> > > > > > diff --git a/framework/packet.py b/framework/packet.py index
> > > > > > 976b82b..1f3f07d 100755
> > > > > > --- a/framework/packet.py
> > > > > > +++ b/framework/packet.py
> > > > > > @@ -812,15 +812,31 @@ 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)
> > > > > > +    remote_terminate = 0
> > > > > > +
> > > > > > +    # 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)
> > > > > [Lijuan] Action will be blocked if SSH need password.
> > > > > > +        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,22 +866,29 @@ 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)
> > > > > > +        remote_terminate = 1
> > > > > > +    else:
> > > > > > +        args = shlex.split(cmd)
> > > > > > +        pipe = subprocess.Popen(args)
> > > > > >
> > > > > > -    pipe = subprocess.Popen(args)
> > > > > >      index = str(time.time())
> > > > > > -    SNIFF_PIDS[index] = (pipe, intf, timeout)
> > > > > > +    SNIFF_PIDS[index] = (pipe, intf, timeout,
> > > > > > + remote_terminate)
> > > > > >      time.sleep(1)
> > > > > >      return index
> > > > > >
> > > > > >
> > > > > > -def load_sniff_pcap(index=''):
> > > > > > +def load_sniff_pcap(index='', target=[]):
> > > > > >      """
> > > > > >      Stop sniffer and return pcap file
> > > > > >      """
> > > > > >      child_exit = False
> > > > > >      if index in SNIFF_PIDS.keys():
> > > > > > -        pipe, intf, timeout = SNIFF_PIDS[index]
> > > > > > +        pipe, intf, timeout, remote_terminate =
> > > > > > + SNIFF_PIDS[index]
> > > > > >          time_elapse = int(time.time() - float(index))
> > > > > >          while time_elapse < timeout:
> > > > > >              if pipe.poll() is not None:
> > > > > > @@ -876,6 +899,14 @@ def load_sniff_pcap(index=''):
> > > > > >              time_elapse += 1
> > > > > >
> > > > > >          if not child_exit:
> > > > > > +            if remote_terminate == 1:
> > > > > > +                stop_tcpdump_pipe = subprocess.Popen(['ssh',
> > > > > > +                                    '%s@%s' % (target[0],
> > > > > > target[1]),
> > > > > > +                                    'kill -2 $(pidof
> > tcpdump)'],
> > > > > > +                                    stderr=subprocess.PIPE,
> > > > > > +                                    shell=False)
> > > > > > +                stop_tcpdump_pipe.wait()
> > > > > > +
> > > > > >              pipe.send_signal(signal.SIGINT)
> > > > > >              pipe.wait()
> > > > > >
> > > > > > @@ -886,42 +917,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:
> > > > > > @@ -983,7 +978,6 @@ if __name__ == "__main__":
> > > > > >      inst = sniff_packets("lo", timeout=5)
> > > > > >      pkt = Packet(pkt_type='UDP')
> > > > > >      pkt.send_pkt(tx_port='lo')
> > > > > > -    pkts = load_sniff_packets(inst)
> > > > > >
> > > > > >      pkt = Packet(pkt_type='UDP', pkt_len=1500,
> > ran_payload=True)
> > > > > >      pkt.send_pkt(tx_port='lo') diff --git
> > > > > > a/framework/tester.py b/framework/tester.py index
> > > > > > a775f68..c5b705d 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 @@ -560,8 +561,6 @@ class Tester(Crb):
> > > > > >          module = __import__("packet")
> > > > > >          pkt_c = getattr(module, "Packet")
> > > > > >          send_f = getattr(module, "send_packets")
> > > > > > -        sniff_f = getattr(module, "sniff_packets")
> > > > > > -        load_f = getattr(module, "load_sniff_packets")
> > > > > >          compare_f = getattr(module, "compare_pktload")
> > > > > >          strip_f = getattr(module, "strip_pktload")
> > > > > >          save_f = getattr(module, "save_packets") @@ -606,7
> > > > > > +605,7 @@ class Tester(Crb):
> > > > > >
> > > > > >              # send and sniff packets
> > > > > >              save_f(pkts=pkts, filename="/tmp/%s_tx.pcap" %
> > txIntf)
> > > > > > -            inst = sniff_f(intf=rxIntf, count=pktnum,
> > > > timeout=timeout,
> > > > > > filters=
> > > > > > +            inst = self.tcpdump_sniff_packets(intf=rxIntf,
> > > > > > + count=pktnum, timeout=timeout, filters=
> > > > > >                  [{'layer': 'network', 'config': {'srcport': '65535'}},
> > > > > >                   {'layer': 'network', 'config': {'dstport':
> > '65535'}}])
> > > > > >              rx_inst[rxport] = inst @@ -627,7 +626,7 @@ class
> > > > > > Tester(Crb):
> > > > > >          # Verify all packets
> > > > > >          prev_id = -1
> > > > > >          for txport, rxport in portList:
> > > > > > -            recv_pkts = load_f(rx_inst[rxport])
> > > > > > +            recv_pkts =
> > > > > > + self.load_tcpdump_sniff_packets(rx_inst[rxport])
> > > > > >
> > > > > >              # only report when recevied number not matched
> > > > > >              if len(tx_pkts[txport]) > len(recv_pkts):
> > > > > > @@ -704,6 +703,47 @@ 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")
> > > > > > +
> > > > > > +        target=[]
> > > > > > +        target.append(self.get_username())
> > > > > > +        target.append(self.get_ip_address())
> > > > > > +        target.append(self.get_password())
> > > > > > +        pcap = load_pcap_f(index, target)
> > > > > > +        self.session.copy_file_from(pcap)
> > > > > > +
> > > > > > +        return pcap.split(os.sep)[-1]
> > > > > > +
> > > > > > +    def load_tcpdump_sniff_packets(self, index=''):
> > > > > > +        """
> > > > > > +        Wrapper for packet module load_pcapfile
> > > > > > +        """
> > > > > > +        # 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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* Re: [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine
  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)
  0 siblings, 1 reply; 124+ messages in thread
From: Tu, Lijuan @ 2018-09-21  8:27 UTC (permalink / raw)
  To: Phil Yang (Arm Technology China), Phil, dts; +Cc: nd, Liu, Yong



> -----Original Message-----
> From: Phil Yang (Arm Technology China) [mailto:Phil.Yang@arm.com]
> Sent: Friday, September 21, 2018 3:32 PM
> To: Tu, Lijuan <lijuan.tu@intel.com>; Phil@dpdk.org; dts@dpdk.org
> Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support packet
> sniffer to specify running machine
> 
> tcpdump_sniff_packet and load_tcpdump_sniff_pcap in class Tester will call
> those two functions.
> 
>     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)
[Lijuan] Here It calls sniff_packets which is in packet.py, but sniff_packets don't use target[2] which means password. If I missed, could you figure out which code would call target[2]?
> 
> Please check test.py in this patch.
> 
> Thanks,
> Phil Yang
> 
> > -----Original Message-----
> > From: Tu, Lijuan <lijuan.tu@intel.com>
> > Sent: Friday, September 21, 2018 3:19 PM
> > To: Phil Yang (Arm Technology China) <Phil.Yang@arm.com>;
> > Phil@dpdk.org; dts@dpdk.org
> > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> > Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support packet
> > sniffer to specify running machine
> >
> > I am glad we reach an agreement.
> >
> > Of course, the parameter "target" have password, but I found no any
> > function would call it.
> > Only username and ip are used. The target[2] is the password, and is not
> called.
> > +    if target:
> > +        tcpdump_help_pipe = subprocess.Popen(["ssh",
> > +                            "%s@%s" % (target[0], target[1]),
> > +                            "tcpdump -h"],
> > +                            stderr=subprocess.PIPE,
> > +                            stdout=subprocess.PIPE,
> > +                            shell=False)
> > Anything I missed?
> >
> >
> > > -----Original Message-----
> > > From: Phil Yang (Arm Technology China) [mailto:Phil.Yang@arm.com]
> > > Sent: Friday, September 21, 2018 2:59 PM
> > > To: Tu, Lijuan <lijuan.tu@intel.com>; Phil@dpdk.org; dts@dpdk.org
> > > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> > > Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support packet
> > > sniffer to specify running machine
> > >
> > > Yes. I agreed with that.
> > >
> > > I think my patch has also followed this rule.
> > > In the packet.py, I added one more parameter "target" for
> > > sniff_packets and load_sniff_pcap to specify the username and IP
> address.
> > > In the test.py, I passed the Tester's passwd and IP address to these
> > > two functions. Thus, it will make sure sniff packet operation done
> > > on the
> > Tester.
> > >
> > > Thanks,
> > > Phil Yang
> > >
> > > > -----Original Message-----
> > > > From: Tu, Lijuan <lijuan.tu@intel.com>
> > > > Sent: Friday, September 21, 2018 11:42 AM
> > > > To: Phil Yang (Arm Technology China) <Phil.Yang@arm.com>;
> > > > Phil@dpdk.org; dts@dpdk.org
> > > > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> > > > Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support
> > > > packet sniffer to specify running machine
> > > >
> > > > DTS supports  either login server by password or utilize authorized
> login.
> > > > For logging by password, we could get some codes like "
> > > > self.session = SSHPexpect(host, username, password, dut_id) " in
> > > > SSHConnection module. and we have ip, username, password
> > > > information in crb.cfg I think we don't want to force user to utilize
> authorized login.
> > > >
> > > > > -----Original Message-----
> > > > > From: Phil Yang (Arm Technology China)
> > > > > [mailto:Phil.Yang@arm.com]
> > > > > Sent: Friday, September 21, 2018 11:22 AM
> > > > > To: Tu, Lijuan <lijuan.tu@intel.com>; Phil@dpdk.org;
> > > > > dts@dpdk.org
> > > > > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> > > > > Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support
> > > > > packet sniffer to specify running machine
> > > > >
> > > > > Hi Lijuan,
> > > > >
> > > > > It also need to follow the DTS setup steps in
> > > > >
> https://doc.dpdk.org/dts/gsg/sys_reqs.html#authorized-login-session .
> > > > >
> > > > > Since you know where are your DUT and Tester, so you can use
> > > > > tool ssh-copy-id to save local available keys on DUT and Tester.
> > > > >
> > > > > Thanks,
> > > > > Phil Yang
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: Tu, Lijuan <lijuan.tu@intel.com>
> > > > > > Sent: Friday, September 21, 2018 11:09 AM
> > > > > > To: Phil@dpdk.org; dts@dpdk.org
> > > > > > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>; Phil Yang
> > > > > > (Arm Technology China) <Phil.Yang@arm.com>
> > > > > > Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support
> > > > > > packet sniffer to specify running machine
> > > > > >
> > > > > > One comments, when we ssh to a server, it might request a
> > > > > > password, but we don't handle it.
> > > > > >
> > > > > >
> > > > > > > -----Original Message-----
> > > > > > > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of
> > > > > > > Phil@dpdk.org
> > > > > > > Sent: Tuesday, September 4, 2018 4:26 PM
> > > > > > > To: dts@dpdk.org
> > > > > > > Cc: nd@arm.com; Liu, Yong <yong.liu@intel.com>; Phil Yang
> > > > > > > <phil.yang@arm.com>
> > > > > > > Subject: [dts] [PATCH v5 01/22] framework/packet: support
> > > > > > > packet sniffer to specify running machine
> > > > > > >
> > > > > > > From: Phil Yang <phil.yang@arm.com>
> > > > > > >
> > > > > > > By default, the Tester is supposed to be the server which
> > > > > > > running DTS and the packet sniff methods are running on it.
> > > > > > > However, if DTS was not running on the Tester and the Tester
> > > > > > > is another remote server, so packet sniff methods cannot
> > > > > > > sniff Tester's packets correctly.
> > > > > > >
> > > > > > > This patch adds support for packet sniff methods to specify
> > > > > > > running machine and implements sniff packet methods in class
> tester.
> > > > > > >
> > > > > > > 1. Add parameter to sniff_packet and load_sniff_pcap methods
> > > > > > > to specify the running machine.
> > > > > > > 2. Remove load_sniff_packets method in packet.py.
> > > > > > > 3. Add tcpdump_sniff_packets, load_tcpdump_sniff_pcap and
> > > > > > > load_tcpdump_sniff_packets for class tester with the new
> > > > > > > sniff_packet
> > > > > API.
> > > > > > > 4. Update tester.check_random_pkts method with
> > > > > > > tester.tcpdump_sniff_packets and
> > > > > > > tester.load_tcpdump_sniff_packets to make it execution on
> > > > > > > the
> > > Tester.
> > > > > > >
> > > > > > > Signed-off-by: Phil Yang <phil.yang@arm.com>
> > > > > > > Suggested-by: Marvin Liu <yong.liu@intel.com>
> > > > > > > ---
> > > > > > >  framework/packet.py | 86
> > > > > > > +++++++++++++++++++++++++----------------------------
> > > > > > >  framework/tester.py | 48 +++++++++++++++++++++++++++---
> > > > > > >  2 files changed, 84 insertions(+), 50 deletions(-)
> > > > > > >
> > > > > > > diff --git a/framework/packet.py b/framework/packet.py index
> > > > > > > 976b82b..1f3f07d 100755
> > > > > > > --- a/framework/packet.py
> > > > > > > +++ b/framework/packet.py
> > > > > > > @@ -812,15 +812,31 @@ 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)
> > > > > > > +    remote_terminate = 0
> > > > > > > +
> > > > > > > +    # 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)
> > > > > > [Lijuan] Action will be blocked if SSH need password.
> > > > > > > +        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,22 +866,29 @@ 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)
> > > > > > > +        remote_terminate = 1
> > > > > > > +    else:
> > > > > > > +        args = shlex.split(cmd)
> > > > > > > +        pipe = subprocess.Popen(args)
> > > > > > >
> > > > > > > -    pipe = subprocess.Popen(args)
> > > > > > >      index = str(time.time())
> > > > > > > -    SNIFF_PIDS[index] = (pipe, intf, timeout)
> > > > > > > +    SNIFF_PIDS[index] = (pipe, intf, timeout,
> > > > > > > + remote_terminate)
> > > > > > >      time.sleep(1)
> > > > > > >      return index
> > > > > > >
> > > > > > >
> > > > > > > -def load_sniff_pcap(index=''):
> > > > > > > +def load_sniff_pcap(index='', target=[]):
> > > > > > >      """
> > > > > > >      Stop sniffer and return pcap file
> > > > > > >      """
> > > > > > >      child_exit = False
> > > > > > >      if index in SNIFF_PIDS.keys():
> > > > > > > -        pipe, intf, timeout = SNIFF_PIDS[index]
> > > > > > > +        pipe, intf, timeout, remote_terminate =
> > > > > > > + SNIFF_PIDS[index]
> > > > > > >          time_elapse = int(time.time() - float(index))
> > > > > > >          while time_elapse < timeout:
> > > > > > >              if pipe.poll() is not None:
> > > > > > > @@ -876,6 +899,14 @@ def load_sniff_pcap(index=''):
> > > > > > >              time_elapse += 1
> > > > > > >
> > > > > > >          if not child_exit:
> > > > > > > +            if remote_terminate == 1:
> > > > > > > +                stop_tcpdump_pipe =
> subprocess.Popen(['ssh',
> > > > > > > +                                    '%s@%s' %
> (target[0],
> > > > > > > target[1]),
> > > > > > > +                                    'kill -2 $(pidof
> > > tcpdump)'],
> > > > > > > +
> stderr=subprocess.PIPE,
> > > > > > > +                                    shell=False)
> > > > > > > +                stop_tcpdump_pipe.wait()
> > > > > > > +
> > > > > > >              pipe.send_signal(signal.SIGINT)
> > > > > > >              pipe.wait()
> > > > > > >
> > > > > > > @@ -886,42 +917,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:
> > > > > > > @@ -983,7 +978,6 @@ if __name__ == "__main__":
> > > > > > >      inst = sniff_packets("lo", timeout=5)
> > > > > > >      pkt = Packet(pkt_type='UDP')
> > > > > > >      pkt.send_pkt(tx_port='lo')
> > > > > > > -    pkts = load_sniff_packets(inst)
> > > > > > >
> > > > > > >      pkt = Packet(pkt_type='UDP', pkt_len=1500,
> > > ran_payload=True)
> > > > > > >      pkt.send_pkt(tx_port='lo') diff --git
> > > > > > > a/framework/tester.py b/framework/tester.py index
> > > > > > > a775f68..c5b705d 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 @@ -560,8 +561,6 @@ class
> Tester(Crb):
> > > > > > >          module = __import__("packet")
> > > > > > >          pkt_c = getattr(module, "Packet")
> > > > > > >          send_f = getattr(module, "send_packets")
> > > > > > > -        sniff_f = getattr(module, "sniff_packets")
> > > > > > > -        load_f = getattr(module, "load_sniff_packets")
> > > > > > >          compare_f = getattr(module, "compare_pktload")
> > > > > > >          strip_f = getattr(module, "strip_pktload")
> > > > > > >          save_f = getattr(module, "save_packets") @@ -606,7
> > > > > > > +605,7 @@ class Tester(Crb):
> > > > > > >
> > > > > > >              # send and sniff packets
> > > > > > >              save_f(pkts=pkts, filename="/tmp/%s_tx.pcap" %
> > > txIntf)
> > > > > > > -            inst = sniff_f(intf=rxIntf, count=pktnum,
> > > > > timeout=timeout,
> > > > > > > filters=
> > > > > > > +            inst = self.tcpdump_sniff_packets(intf=rxIntf,
> > > > > > > + count=pktnum, timeout=timeout, filters=
> > > > > > >                  [{'layer': 'network', 'config': {'srcport':
> '65535'}},
> > > > > > >                   {'layer': 'network', 'config': {'dstport':
> > > '65535'}}])
> > > > > > >              rx_inst[rxport] = inst @@ -627,7 +626,7 @@
> > > > > > > class
> > > > > > > Tester(Crb):
> > > > > > >          # Verify all packets
> > > > > > >          prev_id = -1
> > > > > > >          for txport, rxport in portList:
> > > > > > > -            recv_pkts = load_f(rx_inst[rxport])
> > > > > > > +            recv_pkts =
> > > > > > > + self.load_tcpdump_sniff_packets(rx_inst[rxport])
> > > > > > >
> > > > > > >              # only report when recevied number not matched
> > > > > > >              if len(tx_pkts[txport]) > len(recv_pkts):
> > > > > > > @@ -704,6 +703,47 @@ 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")
> > > > > > > +
> > > > > > > +        target=[]
> > > > > > > +        target.append(self.get_username())
> > > > > > > +        target.append(self.get_ip_address())
> > > > > > > +        target.append(self.get_password())
> > > > > > > +        pcap = load_pcap_f(index, target)
> > > > > > > +        self.session.copy_file_from(pcap)
> > > > > > > +
> > > > > > > +        return pcap.split(os.sep)[-1]
> > > > > > > +
> > > > > > > +    def load_tcpdump_sniff_packets(self, index=''):
> > > > > > > +        """
> > > > > > > +        Wrapper for packet module load_pcapfile
> > > > > > > +        """
> > > > > > > +        # 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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* Re: [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine
  2018-09-21  8:27                     ` Tu, Lijuan
@ 2018-09-21 12:05                       ` Phil Yang (Arm Technology China)
  2018-09-26  5:15                         ` Tu, Lijuan
  0 siblings, 1 reply; 124+ messages in thread
From: Phil Yang (Arm Technology China) @ 2018-09-21 12:05 UTC (permalink / raw)
  To: Tu, Lijuan, Phil, dts; +Cc: nd, Liu, Yong

Hi Lijuan,

Yes, you are right.

I am thinking about pass the password through pipe.communication() when creating popen ssh connection,  such like:
tcpdump_help = "".join(tuple(tcpdump_help_pipe.communicate(input=target[2])))

Any other suggestion for this?  If you agree with this approach I can re-spin the patch.

Thanks,
Phil Yang

> -----Original Message-----
> From: Tu, Lijuan <lijuan.tu@intel.com>
> Sent: Friday, September 21, 2018 4:28 PM
> To: Phil Yang (Arm Technology China) <Phil.Yang@arm.com>; Phil@dpdk.org;
> dts@dpdk.org
> Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to
> specify running machine
> 
> 
> 
> > -----Original Message-----
> > From: Phil Yang (Arm Technology China) [mailto:Phil.Yang@arm.com]
> > Sent: Friday, September 21, 2018 3:32 PM
> > To: Tu, Lijuan <lijuan.tu@intel.com>; Phil@dpdk.org; dts@dpdk.org
> > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> > Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support packet
> > sniffer to specify running machine
> >
> > tcpdump_sniff_packet and load_tcpdump_sniff_pcap in class Tester will
> > call those two functions.
> >
> >     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)
> [Lijuan] Here It calls sniff_packets which is in packet.py, but sniff_packets don't
> use target[2] which means password. If I missed, could you figure out which
> code would call target[2]?
> >
> > Please check test.py in this patch.
> >
> > Thanks,
> > Phil Yang
> >
> > > -----Original Message-----
> > > From: Tu, Lijuan <lijuan.tu@intel.com>
> > > Sent: Friday, September 21, 2018 3:19 PM
> > > To: Phil Yang (Arm Technology China) <Phil.Yang@arm.com>;
> > > Phil@dpdk.org; dts@dpdk.org
> > > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> > > Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support packet
> > > sniffer to specify running machine
> > >
> > > I am glad we reach an agreement.
> > >
> > > Of course, the parameter "target" have password, but I found no any
> > > function would call it.
> > > Only username and ip are used. The target[2] is the password, and is
> > > not
> > called.
> > > +    if target:
> > > +        tcpdump_help_pipe = subprocess.Popen(["ssh",
> > > +                            "%s@%s" % (target[0], target[1]),
> > > +                            "tcpdump -h"],
> > > +                            stderr=subprocess.PIPE,
> > > +                            stdout=subprocess.PIPE,
> > > +                            shell=False)
> > > Anything I missed?
> > >
> > >
> > > > -----Original Message-----
> > > > From: Phil Yang (Arm Technology China) [mailto:Phil.Yang@arm.com]
> > > > Sent: Friday, September 21, 2018 2:59 PM
> > > > To: Tu, Lijuan <lijuan.tu@intel.com>; Phil@dpdk.org; dts@dpdk.org
> > > > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> > > > Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support
> > > > packet sniffer to specify running machine
> > > >
> > > > Yes. I agreed with that.
> > > >
> > > > I think my patch has also followed this rule.
> > > > In the packet.py, I added one more parameter "target" for
> > > > sniff_packets and load_sniff_pcap to specify the username and IP
> > address.
> > > > In the test.py, I passed the Tester's passwd and IP address to
> > > > these two functions. Thus, it will make sure sniff packet
> > > > operation done on the
> > > Tester.
> > > >
> > > > Thanks,
> > > > Phil Yang
> > > >
> > > > > -----Original Message-----
> > > > > From: Tu, Lijuan <lijuan.tu@intel.com>
> > > > > Sent: Friday, September 21, 2018 11:42 AM
> > > > > To: Phil Yang (Arm Technology China) <Phil.Yang@arm.com>;
> > > > > Phil@dpdk.org; dts@dpdk.org
> > > > > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> > > > > Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support
> > > > > packet sniffer to specify running machine
> > > > >
> > > > > DTS supports  either login server by password or utilize
> > > > > authorized
> > login.
> > > > > For logging by password, we could get some codes like "
> > > > > self.session = SSHPexpect(host, username, password, dut_id) " in
> > > > > SSHConnection module. and we have ip, username, password
> > > > > information in crb.cfg I think we don't want to force user to
> > > > > utilize
> > authorized login.
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: Phil Yang (Arm Technology China)
> > > > > > [mailto:Phil.Yang@arm.com]
> > > > > > Sent: Friday, September 21, 2018 11:22 AM
> > > > > > To: Tu, Lijuan <lijuan.tu@intel.com>; Phil@dpdk.org;
> > > > > > dts@dpdk.org
> > > > > > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> > > > > > Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support
> > > > > > packet sniffer to specify running machine
> > > > > >
> > > > > > Hi Lijuan,
> > > > > >
> > > > > > It also need to follow the DTS setup steps in
> > > > > >
> > https://doc.dpdk.org/dts/gsg/sys_reqs.html#authorized-login-session .
> > > > > >
> > > > > > Since you know where are your DUT and Tester, so you can use
> > > > > > tool ssh-copy-id to save local available keys on DUT and Tester.
> > > > > >
> > > > > > Thanks,
> > > > > > Phil Yang
> > > > > >
> > > > > > > -----Original Message-----
> > > > > > > From: Tu, Lijuan <lijuan.tu@intel.com>
> > > > > > > Sent: Friday, September 21, 2018 11:09 AM
> > > > > > > To: Phil@dpdk.org; dts@dpdk.org
> > > > > > > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>; Phil
> > > > > > > Yang (Arm Technology China) <Phil.Yang@arm.com>
> > > > > > > Subject: RE: [dts] [PATCH v5 01/22] framework/packet:
> > > > > > > support packet sniffer to specify running machine
> > > > > > >
> > > > > > > One comments, when we ssh to a server, it might request a
> > > > > > > password, but we don't handle it.
> > > > > > >
> > > > > > >
> > > > > > > > -----Original Message-----
> > > > > > > > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of
> > > > > > > > Phil@dpdk.org
> > > > > > > > Sent: Tuesday, September 4, 2018 4:26 PM
> > > > > > > > To: dts@dpdk.org
> > > > > > > > Cc: nd@arm.com; Liu, Yong <yong.liu@intel.com>; Phil Yang
> > > > > > > > <phil.yang@arm.com>
> > > > > > > > Subject: [dts] [PATCH v5 01/22] framework/packet: support
> > > > > > > > packet sniffer to specify running machine
> > > > > > > >
> > > > > > > > From: Phil Yang <phil.yang@arm.com>
> > > > > > > >
> > > > > > > > By default, the Tester is supposed to be the server which
> > > > > > > > running DTS and the packet sniff methods are running on it.
> > > > > > > > However, if DTS was not running on the Tester and the
> > > > > > > > Tester is another remote server, so packet sniff methods
> > > > > > > > cannot sniff Tester's packets correctly.
> > > > > > > >
> > > > > > > > This patch adds support for packet sniff methods to
> > > > > > > > specify running machine and implements sniff packet
> > > > > > > > methods in class
> > tester.
> > > > > > > >
> > > > > > > > 1. Add parameter to sniff_packet and load_sniff_pcap
> > > > > > > > methods to specify the running machine.
> > > > > > > > 2. Remove load_sniff_packets method in packet.py.
> > > > > > > > 3. Add tcpdump_sniff_packets, load_tcpdump_sniff_pcap and
> > > > > > > > load_tcpdump_sniff_packets for class tester with the new
> > > > > > > > sniff_packet
> > > > > > API.
> > > > > > > > 4. Update tester.check_random_pkts method with
> > > > > > > > tester.tcpdump_sniff_packets and
> > > > > > > > tester.load_tcpdump_sniff_packets to make it execution on
> > > > > > > > the
> > > > Tester.
> > > > > > > >
> > > > > > > > Signed-off-by: Phil Yang <phil.yang@arm.com>
> > > > > > > > Suggested-by: Marvin Liu <yong.liu@intel.com>
> > > > > > > > ---
> > > > > > > >  framework/packet.py | 86
> > > > > > > > +++++++++++++++++++++++++----------------------------
> > > > > > > >  framework/tester.py | 48 +++++++++++++++++++++++++++---
> > > > > > > >  2 files changed, 84 insertions(+), 50 deletions(-)
> > > > > > > >
> > > > > > > > diff --git a/framework/packet.py b/framework/packet.py
> > > > > > > > index 976b82b..1f3f07d 100755
> > > > > > > > --- a/framework/packet.py
> > > > > > > > +++ b/framework/packet.py
> > > > > > > > @@ -812,15 +812,31 @@ 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)
> > > > > > > > +    remote_terminate = 0
> > > > > > > > +
> > > > > > > > +    # 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)
> > > > > > > [Lijuan] Action will be blocked if SSH need password.
> > > > > > > > +        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,22 +866,29 @@ 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)
> > > > > > > > +        remote_terminate = 1
> > > > > > > > +    else:
> > > > > > > > +        args = shlex.split(cmd)
> > > > > > > > +        pipe = subprocess.Popen(args)
> > > > > > > >
> > > > > > > > -    pipe = subprocess.Popen(args)
> > > > > > > >      index = str(time.time())
> > > > > > > > -    SNIFF_PIDS[index] = (pipe, intf, timeout)
> > > > > > > > +    SNIFF_PIDS[index] = (pipe, intf, timeout,
> > > > > > > > + remote_terminate)
> > > > > > > >      time.sleep(1)
> > > > > > > >      return index
> > > > > > > >
> > > > > > > >
> > > > > > > > -def load_sniff_pcap(index=''):
> > > > > > > > +def load_sniff_pcap(index='', target=[]):
> > > > > > > >      """
> > > > > > > >      Stop sniffer and return pcap file
> > > > > > > >      """
> > > > > > > >      child_exit = False
> > > > > > > >      if index in SNIFF_PIDS.keys():
> > > > > > > > -        pipe, intf, timeout = SNIFF_PIDS[index]
> > > > > > > > +        pipe, intf, timeout, remote_terminate =
> > > > > > > > + SNIFF_PIDS[index]
> > > > > > > >          time_elapse = int(time.time() - float(index))
> > > > > > > >          while time_elapse < timeout:
> > > > > > > >              if pipe.poll() is not None:
> > > > > > > > @@ -876,6 +899,14 @@ def load_sniff_pcap(index=''):
> > > > > > > >              time_elapse += 1
> > > > > > > >
> > > > > > > >          if not child_exit:
> > > > > > > > +            if remote_terminate == 1:
> > > > > > > > +                stop_tcpdump_pipe =
> > subprocess.Popen(['ssh',
> > > > > > > > +                                    '%s@%s' %
> > (target[0],
> > > > > > > > target[1]),
> > > > > > > > +                                    'kill -2 $(pidof
> > > > tcpdump)'],
> > > > > > > > +
> > stderr=subprocess.PIPE,
> > > > > > > > +                                    shell=False)
> > > > > > > > +                stop_tcpdump_pipe.wait()
> > > > > > > > +
> > > > > > > >              pipe.send_signal(signal.SIGINT)
> > > > > > > >              pipe.wait()
> > > > > > > >
> > > > > > > > @@ -886,42 +917,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:
> > > > > > > > @@ -983,7 +978,6 @@ if __name__ == "__main__":
> > > > > > > >      inst = sniff_packets("lo", timeout=5)
> > > > > > > >      pkt = Packet(pkt_type='UDP')
> > > > > > > >      pkt.send_pkt(tx_port='lo')
> > > > > > > > -    pkts = load_sniff_packets(inst)
> > > > > > > >
> > > > > > > >      pkt = Packet(pkt_type='UDP', pkt_len=1500,
> > > > ran_payload=True)
> > > > > > > >      pkt.send_pkt(tx_port='lo') diff --git
> > > > > > > > a/framework/tester.py b/framework/tester.py index
> > > > > > > > a775f68..c5b705d 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 @@ -560,8 +561,6 @@ class
> > Tester(Crb):
> > > > > > > >          module = __import__("packet")
> > > > > > > >          pkt_c = getattr(module, "Packet")
> > > > > > > >          send_f = getattr(module, "send_packets")
> > > > > > > > -        sniff_f = getattr(module, "sniff_packets")
> > > > > > > > -        load_f = getattr(module, "load_sniff_packets")
> > > > > > > >          compare_f = getattr(module, "compare_pktload")
> > > > > > > >          strip_f = getattr(module, "strip_pktload")
> > > > > > > >          save_f = getattr(module, "save_packets") @@
> > > > > > > > -606,7
> > > > > > > > +605,7 @@ class Tester(Crb):
> > > > > > > >
> > > > > > > >              # send and sniff packets
> > > > > > > >              save_f(pkts=pkts, filename="/tmp/%s_tx.pcap"
> > > > > > > > %
> > > > txIntf)
> > > > > > > > -            inst = sniff_f(intf=rxIntf, count=pktnum,
> > > > > > timeout=timeout,
> > > > > > > > filters=
> > > > > > > > +            inst =
> > > > > > > > + self.tcpdump_sniff_packets(intf=rxIntf,
> > > > > > > > + count=pktnum, timeout=timeout, filters=
> > > > > > > >                  [{'layer': 'network', 'config': {'srcport':
> > '65535'}},
> > > > > > > >                   {'layer': 'network', 'config': {'dstport':
> > > > '65535'}}])
> > > > > > > >              rx_inst[rxport] = inst @@ -627,7 +626,7 @@
> > > > > > > > class
> > > > > > > > Tester(Crb):
> > > > > > > >          # Verify all packets
> > > > > > > >          prev_id = -1
> > > > > > > >          for txport, rxport in portList:
> > > > > > > > -            recv_pkts = load_f(rx_inst[rxport])
> > > > > > > > +            recv_pkts =
> > > > > > > > + self.load_tcpdump_sniff_packets(rx_inst[rxport])
> > > > > > > >
> > > > > > > >              # only report when recevied number not matched
> > > > > > > >              if len(tx_pkts[txport]) > len(recv_pkts):
> > > > > > > > @@ -704,6 +703,47 @@ 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")
> > > > > > > > +
> > > > > > > > +        target=[]
> > > > > > > > +        target.append(self.get_username())
> > > > > > > > +        target.append(self.get_ip_address())
> > > > > > > > +        target.append(self.get_password())
> > > > > > > > +        pcap = load_pcap_f(index, target)
> > > > > > > > +        self.session.copy_file_from(pcap)
> > > > > > > > +
> > > > > > > > +        return pcap.split(os.sep)[-1]
> > > > > > > > +
> > > > > > > > +    def load_tcpdump_sniff_packets(self, index=''):
> > > > > > > > +        """
> > > > > > > > +        Wrapper for packet module load_pcapfile
> > > > > > > > +        """
> > > > > > > > +        # 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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* Re: [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine
  2018-09-21 12:05                       ` Phil Yang (Arm Technology China)
@ 2018-09-26  5:15                         ` Tu, Lijuan
  0 siblings, 0 replies; 124+ messages in thread
From: Tu, Lijuan @ 2018-09-26  5:15 UTC (permalink / raw)
  To: Phil Yang (Arm Technology China), Phil, dts; +Cc: nd, Liu, Yong

It seems not work out for me, I tried communicate method, it still stops at the password prompt.

Another idea, we can create a new ssh session to handle the sniff thing. I think this is more convenience to handle the remote thing. It just like bash command.
session_sniff=self.create_session()
session_sniff.send_expect("tcpdump -h")
session_sniff.send_expect("cmd", "#")
self.destroy_session(session_sniff)

> -----Original Message-----
> From: Phil Yang (Arm Technology China) [mailto:Phil.Yang@arm.com]
> Sent: Friday, September 21, 2018 8:06 PM
> To: Tu, Lijuan <lijuan.tu@intel.com>; Phil@dpdk.org; dts@dpdk.org
> Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support packet
> sniffer to specify running machine
> 
> Hi Lijuan,
> 
> Yes, you are right.
> 
> I am thinking about pass the password through pipe.communication() when
> creating popen ssh connection,  such like:
> tcpdump_help =
> "".join(tuple(tcpdump_help_pipe.communicate(input=target[2])))
> 
> Any other suggestion for this?  If you agree with this approach I can re-spin
> the patch.
> 
> Thanks,
> Phil Yang
> 
> > -----Original Message-----
> > From: Tu, Lijuan <lijuan.tu@intel.com>
> > Sent: Friday, September 21, 2018 4:28 PM
> > To: Phil Yang (Arm Technology China) <Phil.Yang@arm.com>;
> > Phil@dpdk.org; dts@dpdk.org
> > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> > Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support packet
> > sniffer to specify running machine
> >
> >
> >
> > > -----Original Message-----
> > > From: Phil Yang (Arm Technology China) [mailto:Phil.Yang@arm.com]
> > > Sent: Friday, September 21, 2018 3:32 PM
> > > To: Tu, Lijuan <lijuan.tu@intel.com>; Phil@dpdk.org; dts@dpdk.org
> > > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> > > Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support packet
> > > sniffer to specify running machine
> > >
> > > tcpdump_sniff_packet and load_tcpdump_sniff_pcap in class Tester
> > > will call those two functions.
> > >
> > >     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)
> > [Lijuan] Here It calls sniff_packets which is in packet.py, but
> > sniff_packets don't use target[2] which means password. If I missed,
> > could you figure out which code would call target[2]?
> > >
> > > Please check test.py in this patch.
> > >
> > > Thanks,
> > > Phil Yang
> > >
> > > > -----Original Message-----
> > > > From: Tu, Lijuan <lijuan.tu@intel.com>
> > > > Sent: Friday, September 21, 2018 3:19 PM
> > > > To: Phil Yang (Arm Technology China) <Phil.Yang@arm.com>;
> > > > Phil@dpdk.org; dts@dpdk.org
> > > > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> > > > Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support
> > > > packet sniffer to specify running machine
> > > >
> > > > I am glad we reach an agreement.
> > > >
> > > > Of course, the parameter "target" have password, but I found no
> > > > any function would call it.
> > > > Only username and ip are used. The target[2] is the password, and
> > > > is not
> > > called.
> > > > +    if target:
> > > > +        tcpdump_help_pipe = subprocess.Popen(["ssh",
> > > > +                            "%s@%s" % (target[0], target[1]),
> > > > +                            "tcpdump -h"],
> > > > +                            stderr=subprocess.PIPE,
> > > > +                            stdout=subprocess.PIPE,
> > > > +                            shell=False)
> > > > Anything I missed?
> > > >
> > > >
> > > > > -----Original Message-----
> > > > > From: Phil Yang (Arm Technology China)
> > > > > [mailto:Phil.Yang@arm.com]
> > > > > Sent: Friday, September 21, 2018 2:59 PM
> > > > > To: Tu, Lijuan <lijuan.tu@intel.com>; Phil@dpdk.org;
> > > > > dts@dpdk.org
> > > > > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> > > > > Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support
> > > > > packet sniffer to specify running machine
> > > > >
> > > > > Yes. I agreed with that.
> > > > >
> > > > > I think my patch has also followed this rule.
> > > > > In the packet.py, I added one more parameter "target" for
> > > > > sniff_packets and load_sniff_pcap to specify the username and IP
> > > address.
> > > > > In the test.py, I passed the Tester's passwd and IP address to
> > > > > these two functions. Thus, it will make sure sniff packet
> > > > > operation done on the
> > > > Tester.
> > > > >
> > > > > Thanks,
> > > > > Phil Yang
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: Tu, Lijuan <lijuan.tu@intel.com>
> > > > > > Sent: Friday, September 21, 2018 11:42 AM
> > > > > > To: Phil Yang (Arm Technology China) <Phil.Yang@arm.com>;
> > > > > > Phil@dpdk.org; dts@dpdk.org
> > > > > > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> > > > > > Subject: RE: [dts] [PATCH v5 01/22] framework/packet: support
> > > > > > packet sniffer to specify running machine
> > > > > >
> > > > > > DTS supports  either login server by password or utilize
> > > > > > authorized
> > > login.
> > > > > > For logging by password, we could get some codes like "
> > > > > > self.session = SSHPexpect(host, username, password, dut_id) "
> > > > > > in SSHConnection module. and we have ip, username, password
> > > > > > information in crb.cfg I think we don't want to force user to
> > > > > > utilize
> > > authorized login.
> > > > > >
> > > > > > > -----Original Message-----
> > > > > > > From: Phil Yang (Arm Technology China)
> > > > > > > [mailto:Phil.Yang@arm.com]
> > > > > > > Sent: Friday, September 21, 2018 11:22 AM
> > > > > > > To: Tu, Lijuan <lijuan.tu@intel.com>; Phil@dpdk.org;
> > > > > > > dts@dpdk.org
> > > > > > > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>
> > > > > > > Subject: RE: [dts] [PATCH v5 01/22] framework/packet:
> > > > > > > support packet sniffer to specify running machine
> > > > > > >
> > > > > > > Hi Lijuan,
> > > > > > >
> > > > > > > It also need to follow the DTS setup steps in
> > > > > > >
> > > https://doc.dpdk.org/dts/gsg/sys_reqs.html#authorized-login-session .
> > > > > > >
> > > > > > > Since you know where are your DUT and Tester, so you can use
> > > > > > > tool ssh-copy-id to save local available keys on DUT and Tester.
> > > > > > >
> > > > > > > Thanks,
> > > > > > > Phil Yang
> > > > > > >
> > > > > > > > -----Original Message-----
> > > > > > > > From: Tu, Lijuan <lijuan.tu@intel.com>
> > > > > > > > Sent: Friday, September 21, 2018 11:09 AM
> > > > > > > > To: Phil@dpdk.org; dts@dpdk.org
> > > > > > > > Cc: nd <nd@arm.com>; Liu, Yong <yong.liu@intel.com>; Phil
> > > > > > > > Yang (Arm Technology China) <Phil.Yang@arm.com>
> > > > > > > > Subject: RE: [dts] [PATCH v5 01/22] framework/packet:
> > > > > > > > support packet sniffer to specify running machine
> > > > > > > >
> > > > > > > > One comments, when we ssh to a server, it might request a
> > > > > > > > password, but we don't handle it.
> > > > > > > >
> > > > > > > >
> > > > > > > > > -----Original Message-----
> > > > > > > > > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of
> > > > > > > > > Phil@dpdk.org
> > > > > > > > > Sent: Tuesday, September 4, 2018 4:26 PM
> > > > > > > > > To: dts@dpdk.org
> > > > > > > > > Cc: nd@arm.com; Liu, Yong <yong.liu@intel.com>; Phil
> > > > > > > > > Yang <phil.yang@arm.com>
> > > > > > > > > Subject: [dts] [PATCH v5 01/22] framework/packet:
> > > > > > > > > support packet sniffer to specify running machine
> > > > > > > > >
> > > > > > > > > From: Phil Yang <phil.yang@arm.com>
> > > > > > > > >
> > > > > > > > > By default, the Tester is supposed to be the server
> > > > > > > > > which running DTS and the packet sniff methods are running
> on it.
> > > > > > > > > However, if DTS was not running on the Tester and the
> > > > > > > > > Tester is another remote server, so packet sniff methods
> > > > > > > > > cannot sniff Tester's packets correctly.
> > > > > > > > >
> > > > > > > > > This patch adds support for packet sniff methods to
> > > > > > > > > specify running machine and implements sniff packet
> > > > > > > > > methods in class
> > > tester.
> > > > > > > > >
> > > > > > > > > 1. Add parameter to sniff_packet and load_sniff_pcap
> > > > > > > > > methods to specify the running machine.
> > > > > > > > > 2. Remove load_sniff_packets method in packet.py.
> > > > > > > > > 3. Add tcpdump_sniff_packets, load_tcpdump_sniff_pcap
> > > > > > > > > and load_tcpdump_sniff_packets for class tester with the
> > > > > > > > > new sniff_packet
> > > > > > > API.
> > > > > > > > > 4. Update tester.check_random_pkts method with
> > > > > > > > > tester.tcpdump_sniff_packets and
> > > > > > > > > tester.load_tcpdump_sniff_packets to make it execution
> > > > > > > > > on the
> > > > > Tester.
> > > > > > > > >
> > > > > > > > > Signed-off-by: Phil Yang <phil.yang@arm.com>
> > > > > > > > > Suggested-by: Marvin Liu <yong.liu@intel.com>
> > > > > > > > > ---
> > > > > > > > >  framework/packet.py | 86
> > > > > > > > > +++++++++++++++++++++++++----------------------------
> > > > > > > > >  framework/tester.py | 48
> +++++++++++++++++++++++++++---
> > > > > > > > >  2 files changed, 84 insertions(+), 50 deletions(-)
> > > > > > > > >
> > > > > > > > > diff --git a/framework/packet.py b/framework/packet.py
> > > > > > > > > index 976b82b..1f3f07d 100755
> > > > > > > > > --- a/framework/packet.py
> > > > > > > > > +++ b/framework/packet.py
> > > > > > > > > @@ -812,15 +812,31 @@ 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)
> > > > > > > > > +    remote_terminate = 0
> > > > > > > > > +
> > > > > > > > > +    # 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)
> > > > > > > > [Lijuan] Action will be blocked if SSH need password.
> > > > > > > > > +        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,22 +866,29 @@ 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)
> > > > > > > > > +        remote_terminate = 1
> > > > > > > > > +    else:
> > > > > > > > > +        args = shlex.split(cmd)
> > > > > > > > > +        pipe = subprocess.Popen(args)
> > > > > > > > >
> > > > > > > > > -    pipe = subprocess.Popen(args)
> > > > > > > > >      index = str(time.time())
> > > > > > > > > -    SNIFF_PIDS[index] = (pipe, intf, timeout)
> > > > > > > > > +    SNIFF_PIDS[index] = (pipe, intf, timeout,
> > > > > > > > > + remote_terminate)
> > > > > > > > >      time.sleep(1)
> > > > > > > > >      return index
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > -def load_sniff_pcap(index=''):
> > > > > > > > > +def load_sniff_pcap(index='', target=[]):
> > > > > > > > >      """
> > > > > > > > >      Stop sniffer and return pcap file
> > > > > > > > >      """
> > > > > > > > >      child_exit = False
> > > > > > > > >      if index in SNIFF_PIDS.keys():
> > > > > > > > > -        pipe, intf, timeout = SNIFF_PIDS[index]
> > > > > > > > > +        pipe, intf, timeout, remote_terminate =
> > > > > > > > > + SNIFF_PIDS[index]
> > > > > > > > >          time_elapse = int(time.time() - float(index))
> > > > > > > > >          while time_elapse < timeout:
> > > > > > > > >              if pipe.poll() is not None:
> > > > > > > > > @@ -876,6 +899,14 @@ def load_sniff_pcap(index=''):
> > > > > > > > >              time_elapse += 1
> > > > > > > > >
> > > > > > > > >          if not child_exit:
> > > > > > > > > +            if remote_terminate == 1:
> > > > > > > > > +                stop_tcpdump_pipe =
> > > subprocess.Popen(['ssh',
> > > > > > > > > +                                    '%s@%s' %
> > > (target[0],
> > > > > > > > > target[1]),
> > > > > > > > > +                                    'kill -2 $(pidof
> > > > > tcpdump)'],
> > > > > > > > > +
> > > stderr=subprocess.PIPE,
> > > > > > > > > +                                    shell=False)
> > > > > > > > > +                stop_tcpdump_pipe.wait()
> > > > > > > > > +
> > > > > > > > >              pipe.send_signal(signal.SIGINT)
> > > > > > > > >              pipe.wait()
> > > > > > > > >
> > > > > > > > > @@ -886,42 +917,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:
> > > > > > > > > @@ -983,7 +978,6 @@ if __name__ == "__main__":
> > > > > > > > >      inst = sniff_packets("lo", timeout=5)
> > > > > > > > >      pkt = Packet(pkt_type='UDP')
> > > > > > > > >      pkt.send_pkt(tx_port='lo')
> > > > > > > > > -    pkts = load_sniff_packets(inst)
> > > > > > > > >
> > > > > > > > >      pkt = Packet(pkt_type='UDP', pkt_len=1500,
> > > > > ran_payload=True)
> > > > > > > > >      pkt.send_pkt(tx_port='lo') diff --git
> > > > > > > > > a/framework/tester.py b/framework/tester.py index
> > > > > > > > > a775f68..c5b705d 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 @@ -560,8 +561,6 @@
> > > > > > > > > class
> > > Tester(Crb):
> > > > > > > > >          module = __import__("packet")
> > > > > > > > >          pkt_c = getattr(module, "Packet")
> > > > > > > > >          send_f = getattr(module, "send_packets")
> > > > > > > > > -        sniff_f = getattr(module, "sniff_packets")
> > > > > > > > > -        load_f = getattr(module, "load_sniff_packets")
> > > > > > > > >          compare_f = getattr(module, "compare_pktload")
> > > > > > > > >          strip_f = getattr(module, "strip_pktload")
> > > > > > > > >          save_f = getattr(module, "save_packets") @@
> > > > > > > > > -606,7
> > > > > > > > > +605,7 @@ class Tester(Crb):
> > > > > > > > >
> > > > > > > > >              # send and sniff packets
> > > > > > > > >              save_f(pkts=pkts,
> filename="/tmp/%s_tx.pcap"
> > > > > > > > > %
> > > > > txIntf)
> > > > > > > > > -            inst = sniff_f(intf=rxIntf, count=pktnum,
> > > > > > > timeout=timeout,
> > > > > > > > > filters=
> > > > > > > > > +            inst =
> > > > > > > > > + self.tcpdump_sniff_packets(intf=rxIntf,
> > > > > > > > > + count=pktnum, timeout=timeout, filters=
> > > > > > > > >                  [{'layer': 'network', 'config': {'srcport':
> > > '65535'}},
> > > > > > > > >                   {'layer': 'network', 'config': {'dstport':
> > > > > '65535'}}])
> > > > > > > > >              rx_inst[rxport] = inst @@ -627,7 +626,7 @@
> > > > > > > > > class
> > > > > > > > > Tester(Crb):
> > > > > > > > >          # Verify all packets
> > > > > > > > >          prev_id = -1
> > > > > > > > >          for txport, rxport in portList:
> > > > > > > > > -            recv_pkts = load_f(rx_inst[rxport])
> > > > > > > > > +            recv_pkts =
> > > > > > > > > + self.load_tcpdump_sniff_packets(rx_inst[rxport])
> > > > > > > > >
> > > > > > > > >              # only report when recevied number not
> matched
> > > > > > > > >              if len(tx_pkts[txport]) > len(recv_pkts):
> > > > > > > > > @@ -704,6 +703,47 @@ 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")
> > > > > > > > > +
> > > > > > > > > +        target=[]
> > > > > > > > > +        target.append(self.get_username())
> > > > > > > > > +        target.append(self.get_ip_address())
> > > > > > > > > +        target.append(self.get_password())
> > > > > > > > > +        pcap = load_pcap_f(index, target)
> > > > > > > > > +        self.session.copy_file_from(pcap)
> > > > > > > > > +
> > > > > > > > > +        return pcap.split(os.sep)[-1]
> > > > > > > > > +
> > > > > > > > > +    def load_tcpdump_sniff_packets(self, index=''):
> > > > > > > > > +        """
> > > > > > > > > +        Wrapper for packet module load_pcapfile
> > > > > > > > > +        """
> > > > > > > > > +        # 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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v6 01/22] framework/packet: support packet sniffer to specify running machine
  2018-09-04  8:26       ` [dts] [PATCH v5 01/22] framework/packet: support packet sniffer to specify running machine Phil Yang
                           ` (22 preceding siblings ...)
  2018-09-21  3:09         ` Tu, Lijuan
@ 2018-10-16  6:19         ` 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
                             ` (22 more replies)
  23 siblings, 23 replies; 124+ messages in thread
From: Phil Yang @ 2018-10-16  6:19 UTC (permalink / raw)
  To: dts; +Cc: nd, lijuan.tu

By default, the Tester is supposed to be the server which running DTS
and the packet sniff methods are running on it.
However, if DTS was not running on the Tester and the Tester is another
remote server, so packet sniff methods cannot sniff Tester's packets
correctly.

This patch adds support for packet sniff methods to specify running
machine and implements sniff packet methods in class tester.

1. Add parameter to sniff_packet and load_sniff_pcap methods to specify
the running machine.
2. Remove load_sniff_packets method in packet.py.
3. Add tcpdump_sniff_packets, load_tcpdump_sniff_pcap and
load_tcpdump_sniff_packets for class tester with the new sniff_packet
API.
4. Update tester.check_random_pkts method with
tester.tcpdump_sniff_packets and tester.load_tcpdump_sniff_packets to
make it execution on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
Suggested-by: Tu Lijuan <lijuan.tu@intel.com>
---
 framework/packet.py | 100 +++++++++++++++++++++++++++-------------------------
 framework/tester.py |  48 ++++++++++++++++++++++---
 2 files changed, 95 insertions(+), 53 deletions(-)

diff --git a/framework/packet.py b/framework/packet.py
index 976b82b..517c93d 100755
--- a/framework/packet.py
+++ b/framework/packet.py
@@ -33,7 +33,6 @@
 Generic packet create, transmit and analyze module
 Base on scapy(python program for packet manipulation)
 """
-
 import os
 import time
 import sys
@@ -61,6 +60,7 @@ from scapy.route import *
 from scapy.packet import bind_layers, Raw
 from scapy.sendrecv import sendp
 from scapy.arch import get_if_hwaddr
+from pexpect import pxssh
 
 # load extension layers
 exec_file = os.path.realpath(__file__)
@@ -812,15 +812,31 @@ 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)
+    remote_terminate = 0 # session remote terminate flag
+
+    # target[] contain the remote machine info for ssh connection
+    # target[0]: username
+    # target[1]: ip address
+    # target[2]: pass word
+    if target:
+	tcpdump_help_session=pxssh.pxssh()
+	tcpdump_help_session.login(server=target[1], username=target[0],
+                                   password=target[2], original_prompt='[$#>]',
+                                   login_timeout=20)
+	tcpdump_help_session.sendline('tcpdump -h')
+	tcpdump_help_session.prompt()
+	tcpdump_help=tcpdump_help_session.before
+	tcpdump_help_session.logout()
+    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,22 +866,31 @@ def sniff_packets(intf, count=0, timeout=5, filters=[]):
     else:
         cmd = sniff_cmd % options
 
-    args = shlex.split(cmd)
+    if target:
+        tcpdump_session=pxssh.pxssh()
+        tcpdump_session.login(server=target[1], username=target[0],
+                              password=target[2], original_prompt='[$#>]',
+                              login_timeout=20)
+        tcpdump_session.sendline(cmd)
+        pipe = tcpdump_session
+        remote_terminate = 1
+    else:
+        args = shlex.split(cmd)
+        pipe = subprocess.Popen(args)
 
-    pipe = subprocess.Popen(args)
     index = str(time.time())
-    SNIFF_PIDS[index] = (pipe, intf, timeout)
+    SNIFF_PIDS[index] = (pipe, intf, timeout, remote_terminate)
     time.sleep(1)
     return index
 
 
-def load_sniff_pcap(index=''):
+def load_sniff_pcap(index='', target=[]):
     """
     Stop sniffer and return pcap file
     """
     child_exit = False
     if index in SNIFF_PIDS.keys():
-        pipe, intf, timeout = SNIFF_PIDS[index]
+        pipe, intf, timeout, remote_terminate = SNIFF_PIDS[index]
         time_elapse = int(time.time() - float(index))
         while time_elapse < timeout:
             if pipe.poll() is not None:
@@ -876,8 +901,22 @@ def load_sniff_pcap(index=''):
             time_elapse += 1
 
         if not child_exit:
-            pipe.send_signal(signal.SIGINT)
-            pipe.wait()
+            if remote_terminate == 1:
+                tcpdump_quit_session=pxssh.pxssh()
+                tcpdump_quit_session.login(server=target[1], username=target[0],
+                                           password=target[2], original_prompt='[$#>]',
+                                           login_timeout=20)
+                tcpdump_quit_session.sendline('kill -2 $(pidof tcpdump)')
+                tcpdump_quit_session.prompt()
+                tcpdump_quit_session.logout()
+                # Teminate the tcpdump_session
+                pipe.prompt()
+                pipe.logout()
+                pipe = None
+
+            if pipe is not None:
+                pipe.send_signal(signal.SIGINT)
+                pipe.wait()
 
         # wait pcap file ready
         time.sleep(1)
@@ -886,42 +925,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:
@@ -983,7 +986,6 @@ if __name__ == "__main__":
     inst = sniff_packets("lo", timeout=5)
     pkt = Packet(pkt_type='UDP')
     pkt.send_pkt(tx_port='lo')
-    pkts = load_sniff_packets(inst)
 
     pkt = Packet(pkt_type='UDP', pkt_len=1500, ran_payload=True)
     pkt.send_pkt(tx_port='lo')
diff --git a/framework/tester.py b/framework/tester.py
index a775f68..c5b705d 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
@@ -560,8 +561,6 @@ class Tester(Crb):
         module = __import__("packet")
         pkt_c = getattr(module, "Packet")
         send_f = getattr(module, "send_packets")
-        sniff_f = getattr(module, "sniff_packets")
-        load_f = getattr(module, "load_sniff_packets")
         compare_f = getattr(module, "compare_pktload")
         strip_f = getattr(module, "strip_pktload")
         save_f = getattr(module, "save_packets")
@@ -606,7 +605,7 @@ class Tester(Crb):
 
             # send and sniff packets
             save_f(pkts=pkts, filename="/tmp/%s_tx.pcap" % txIntf)
-            inst = sniff_f(intf=rxIntf, count=pktnum, timeout=timeout, filters=
+            inst = self.tcpdump_sniff_packets(intf=rxIntf, count=pktnum, timeout=timeout, filters=
                 [{'layer': 'network', 'config': {'srcport': '65535'}},
                  {'layer': 'network', 'config': {'dstport': '65535'}}])
             rx_inst[rxport] = inst
@@ -627,7 +626,7 @@ class Tester(Crb):
         # Verify all packets
         prev_id = -1
         for txport, rxport in portList:
-            recv_pkts = load_f(rx_inst[rxport])
+            recv_pkts = self.load_tcpdump_sniff_packets(rx_inst[rxport])
 
             # only report when recevied number not matched
             if len(tx_pkts[txport]) > len(recv_pkts):
@@ -704,6 +703,47 @@ 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")
+
+        target=[]
+        target.append(self.get_username())
+        target.append(self.get_ip_address())
+        target.append(self.get_password())
+        pcap = load_pcap_f(index, target)
+        self.session.copy_file_from(pcap)
+
+        return pcap.split(os.sep)[-1]
+
+    def load_tcpdump_sniff_packets(self, index=''):
+        """
+        Wrapper for packet module load_pcapfile
+        """
+        # 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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v6 02/22] tests/checksum_offload: Replace sniff_packet to tester.tcpdump_sniff_packet
  2018-10-16  6:19         ` [dts] [PATCH v6 " Phil Yang
@ 2018-10-16  6:19           ` Phil Yang
  2018-10-16  6:19           ` [dts] [PATCH v6 03/22] tests/etag: " Phil Yang
                             ` (21 subsequent siblings)
  22 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-10-16  6:19 UTC (permalink / raw)
  To: dts; +Cc: nd, lijuan.tu

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
Suggested-by: Tu Lijuan <lijuan.tu@intel.com>
---
 tests/TestSuite_checksum_offload.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_checksum_offload.py b/tests/TestSuite_checksum_offload.py
index 2ff5c2f..6541ba5 100644
--- a/tests/TestSuite_checksum_offload.py
+++ b/tests/TestSuite_checksum_offload.py
@@ -43,7 +43,6 @@ import utils
 
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets, strip_pktload
 from test_capabilities import DRIVER_TEST_LACK_CAPA
 
 class TestChecksumOffload(TestCase):
@@ -175,13 +174,14 @@ class TestChecksumOffload(TestCase):
 
         self.tester.send_expect("exit()", "#")
 
-        inst = sniff_packets(intf=rx_interface, count=len(packets_sent), filters=[{'layer':'ether', 'config':{'src': sniff_src}}])
+        inst = self.tester.tcpdump_sniff_packets(intf=rx_interface, count=len(packets_sent),
+                filters=[{'layer':'ether', 'config':{'src': sniff_src}}])
 
         for packet_type in packets_sent.keys():
             self.tester.scapy_append('sendp([%s], iface="%s")' % (packets_sent[packet_type], tx_interface))
 
         self.tester.scapy_execute()
-	p = load_sniff_packets(inst)
+	p = self.tester.load_tcpdump_sniff_packets(inst)
 	nr_packets=len(p)
 	reslist = [p[i].pktgen.pkt.sprintf("%IP.chksum%;%TCP.chksum%;%UDP.chksum%;%SCTP.chksum%") for i in range(nr_packets)]
 	out = string.join(reslist, ",")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v6 03/22] tests/etag: Replace sniff_packet to tester.tcpdump_sniff_packet
  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           ` Phil Yang
  2018-10-16  6:19           ` [dts] [PATCH v6 04/22] tests/ipfrag: " Phil Yang
                             ` (20 subsequent siblings)
  22 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-10-16  6:19 UTC (permalink / raw)
  To: dts; +Cc: nd, lijuan.tu

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
Suggested-by: Tu Lijuan <lijuan.tu@intel.com>
---
 tests/TestSuite_etag.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_etag.py b/tests/TestSuite_etag.py
index 642fb2b..68cca44 100644
--- a/tests/TestSuite_etag.py
+++ b/tests/TestSuite_etag.py
@@ -46,7 +46,7 @@ from exception import VerifyFailure
 
 from scapy.utils import rdpcap
 
-from packet import Packet, sniff_packets, load_sniff_packets
+from packet import Packet
 
 VM_CORES_MASK = 'all'
 
@@ -325,11 +325,11 @@ class TestEtag(TestCase):
         pkt_types = {'IP_RAW': {'layer_configs': config_layers}}
 
         intf = self.src_intf
-        inst = sniff_packets(intf)
+        inst = self.tester.tcpdump_sniff_packets(intf)
 
         self.check_packet_transmission(pkt_types)
         time.sleep(1)
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         self.host_testpmd.execute_cmd('E-tag set insertion off port-tag-id 1000 port 0 vf 0')
 
         # load sniff pcap file, check received packet's content
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v6 04/22] tests/ipfrag: Replace sniff_packet to tester.tcpdump_sniff_packet
  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           ` 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
                             ` (19 subsequent siblings)
  22 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-10-16  6:19 UTC (permalink / raw)
  To: dts; +Cc: nd, lijuan.tu

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
Suggested-by: Tu Lijuan <lijuan.tu@intel.com>
---
 tests/TestSuite_ipfrag.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/TestSuite_ipfrag.py b/tests/TestSuite_ipfrag.py
index f23dbe1..38e00d7 100644
--- a/tests/TestSuite_ipfrag.py
+++ b/tests/TestSuite_ipfrag.py
@@ -39,7 +39,7 @@ import string
 import re
 import time
 from settings import HEADER_SIZE
-from packet import Packet, sniff_packets, load_sniff_packets
+from packet import Packet
 
 lpm_table_ipv4 = [
     "{IPv4(100,10,0,0), 16, P1}",
@@ -159,7 +159,7 @@ l3fwd_ipv4_route_array[] = {\\\n"
                 expPkts = 1
                 val = 2
 
-            inst = sniff_packets(intf=self.rxItf, timeout=5)
+            inst = self.tester.tcpdump_sniff_packets(intf=self.rxItf, timeout=5)
             # send packet
             for times in range(burst):
                 pkt_size = pkt_sizes[pkt_sizes.index(size) + times]
@@ -169,7 +169,7 @@ l3fwd_ipv4_route_array[] = {\\\n"
                 pkt.send_pkt(tx_port=self.txItf)
 
             # verify normal packet just by number, verify fragment packet by all elements
-            pkts = load_sniff_packets(inst)
+            pkts = self.tester.load_tcpdump_sniff_packets(inst)
             self.verify(len(pkts) == expPkts, "Failed on forward packet size " + str(size))
             if flag == 'frag':
                 idx = 1
@@ -209,7 +209,7 @@ l3fwd_ipv4_route_array[] = {\\\n"
                 expPkts = 1
                 val = 2
 
-            inst = sniff_packets(intf=self.rxItf, timeout=5)
+            inst = self.tester.tcpdump_sniff_packets(intf=self.rxItf, timeout=5)
             # send packet
             for times in range(burst):
                 pkt_size = pkt_sizes[pkt_sizes.index(size) + times]
@@ -219,7 +219,7 @@ l3fwd_ipv4_route_array[] = {\\\n"
                 pkt.send_pkt(tx_port=self.txItf)
 
             # verify normal packet just by number, verify fragment packet by all elements
-            pkts = load_sniff_packets(inst)
+            pkts = self.tester.load_tcpdump_sniff_packets(inst)
             self.verify(len(pkts) == expPkts, "Failed on forward packet size " + str(size))
             if flag == 'frag':
                 idx = 1
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v6 05/22] tests/l2fwd_crypto: replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-10-16  6:19         ` [dts] [PATCH v6 " Phil Yang
                             ` (2 preceding siblings ...)
  2018-10-16  6:19           ` [dts] [PATCH v6 04/22] tests/ipfrag: " Phil Yang
@ 2018-10-16  6:19           ` 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
                             ` (18 subsequent siblings)
  22 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-10-16  6:19 UTC (permalink / raw)
  To: dts; +Cc: nd, lijuan.tu

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
Suggested-by: Tu Lijuan <lijuan.tu@intel.com>
---
 tests/TestSuite_l2fwd_crypto.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_l2fwd_crypto.py b/tests/TestSuite_l2fwd_crypto.py
index d559909..ea35a29 100644
--- a/tests/TestSuite_l2fwd_crypto.py
+++ b/tests/TestSuite_l2fwd_crypto.py
@@ -38,7 +38,7 @@ import sys
 import utils
 import commands
 from test_case import TestCase
-from packet import Packet, sniff_packets, load_sniff_packets, save_packets
+from packet import Packet, save_packets
 
 from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
 from cryptography.hazmat.backends import default_backend
@@ -501,7 +501,7 @@ class TestL2fwdCrypto(TestCase):
 
             payload = self.__format_hex_to_list(test_vector["input"])
 
-            inst = sniff_packets(self.rx_interface, timeout=5)
+            inst = self.tester.tcpdump_sniff_packets(self.rx_interface, timeout=5)
 
             PACKET_COUNT = 65
             pkt = Packet()
@@ -512,7 +512,7 @@ class TestL2fwdCrypto(TestCase):
             pkt.send_pkt(tx_port=self.tx_interface, count=PACKET_COUNT)
             pkt.pktgen.pkt.show()
 
-            pkt_rec = load_sniff_packets(inst)
+            pkt_rec = self.tester.load_tcpdump_sniff_packets(inst)
 
             for pkt_r in pkt_rec:
                 packet_hex = pkt_r.strip_element_layer4("load")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v6 06/22] tests/netmap_compat: replaced sniff_packet to tester.tcpdump_sniff_packet
  2018-10-16  6:19         ` [dts] [PATCH v6 " Phil Yang
                             ` (3 preceding siblings ...)
  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           ` 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
                             ` (17 subsequent siblings)
  22 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-10-16  6:19 UTC (permalink / raw)
  To: dts; +Cc: nd, lijuan.tu

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
Suggested-by: Tu Lijuan <lijuan.tu@intel.com>
---
 tests/TestSuite_netmap_compat.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/tests/TestSuite_netmap_compat.py b/tests/TestSuite_netmap_compat.py
index 5225a27..84136c7 100644
--- a/tests/TestSuite_netmap_compat.py
+++ b/tests/TestSuite_netmap_compat.py
@@ -43,7 +43,6 @@ from test_case import TestCase
 from plotting import Plotting 
 from settings import HEADER_SIZE   
 from etgen import IxiaPacketGenerator
-from packet import Packet, sniff_packets, load_sniff_packets
 
 class TestNetmapCompat(TestCase):
 
@@ -80,7 +79,7 @@ class TestNetmapCompat(TestCase):
 
         self.rxItf = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0]))
 
-        self.inst = sniff_packets(self.rxItf)
+        self.inst = self.tester.tcpdump_sniff_packets(self.rxItf)
 
         self.scapy_send_packet()
 
@@ -98,7 +97,7 @@ class TestNetmapCompat(TestCase):
         self.dut.send_expect(cmd,"Port %s now in Netmap mode" % self.dut_ports[0], 60)
        
         self.rxItf = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[1]))
-        self.inst = sniff_packets(self.rxItf)
+        self.inst = self.tester.tcpdump_sniff_packets(self.rxItf)
 
         self.scapy_send_packet()
 
@@ -117,7 +116,7 @@ class TestNetmapCompat(TestCase):
 
 
     def get_tcpdump_package(self):  
-        pkts = load_sniff_packets(self.inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(self.inst)
         dsts = []  
         for packet in pkts:  
             dst = packet.strip_element_layer2("dst")  
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v6 07/22] tests/queue_start_stop: replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-10-16  6:19         ` [dts] [PATCH v6 " Phil Yang
                             ` (4 preceding siblings ...)
  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           ` Phil Yang
  2018-10-16  6:19           ` [dts] [PATCH v6 08/22] tests/quota_watermark: " Phil Yang
                             ` (16 subsequent siblings)
  22 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-10-16  6:19 UTC (permalink / raw)
  To: dts; +Cc: nd, lijuan.tu

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
Suggested-by: Tu Lijuan <lijuan.tu@intel.com>
---
 tests/TestSuite_queue_start_stop.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_queue_start_stop.py b/tests/TestSuite_queue_start_stop.py
index 3dd37b3..6cd6831 100644
--- a/tests/TestSuite_queue_start_stop.py
+++ b/tests/TestSuite_queue_start_stop.py
@@ -44,7 +44,7 @@ import os
 from test_case import TestCase
 from pmd_output import PmdOutput
 from settings import FOLDERS
-from packet import Packet, sniff_packets, load_sniff_packets, strip_pktload
+from packet import Packet, strip_pktload
 
 #
 #
@@ -99,10 +99,10 @@ class TestQueueStartStop(TestCase):
         dmac = self.dut.get_mac_address(txPort)
 
         pkt = Packet(pkt_type="UDP", pkt_len=pktSize)
-        inst = sniff_packets(rxitf)
+        inst = self.tester.tcpdump_sniff_packets(rxitf)
         pkt.config_layer('ether', {'dst': dmac})
         pkt.send_pkt(tx_port=txitf)
-        sniff_pkts = load_sniff_packets(inst)
+        sniff_pkts = self.tester.load_tcpdump_sniff_packets(inst)
 
         if received:
             res = strip_pktload(sniff_pkts[0], layer="L4")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v6 08/22] tests/quota_watermark: replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-10-16  6:19         ` [dts] [PATCH v6 " Phil Yang
                             ` (5 preceding siblings ...)
  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           ` Phil Yang
  2018-10-16  6:19           ` [dts] [PATCH v6 09/22] tests/rxtx_callback: " Phil Yang
                             ` (15 subsequent siblings)
  22 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-10-16  6:19 UTC (permalink / raw)
  To: dts; +Cc: nd, lijuan.tu

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
Suggested-by: Tu Lijuan <lijuan.tu@intel.com>
---
 tests/TestSuite_quota_watermark.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_quota_watermark.py b/tests/TestSuite_quota_watermark.py
index ecacf38..845b27f 100644
--- a/tests/TestSuite_quota_watermark.py
+++ b/tests/TestSuite_quota_watermark.py
@@ -39,7 +39,6 @@ import time
 import utils
 from test_case import TestCase
 from etgen import IxiaPacketGenerator
-from packet import Packet, sniff_packets, load_sniff_packets
 
 test_config = {
     'frames_to_sent': 15 * 10 ** 6,
@@ -311,9 +310,9 @@ class TestQuotaWatermark(TestCase, IxiaPacketGenerator):
         rx_intf = self.tester.get_interface(rev_port)
         tx_intf = self.tester.get_interface(send_port)
         # send and sniff packet
-        rx_inst = sniff_packets(rx_intf, timeout=5)
+        rx_inst = self.tester.tcpdump_sniff_packets(rx_intf, timeout=5)
         self.send_pcap_pkt_by_scapy(self.tester, tgen_input[0][2], tx_intf)
-        pkts = load_sniff_packets(rx_inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(rx_inst)
         self.verify(len(pkts) == pkt_cnt, "Packet not forwarded as expected")
 
         return
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v6 09/22] tests/rxtx_callback: replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-10-16  6:19         ` [dts] [PATCH v6 " Phil Yang
                             ` (6 preceding siblings ...)
  2018-10-16  6:19           ` [dts] [PATCH v6 08/22] tests/quota_watermark: " Phil Yang
@ 2018-10-16  6:19           ` Phil Yang
  2018-10-16  6:19           ` [dts] [PATCH v6 10/22] tests/scatter: " Phil Yang
                             ` (14 subsequent siblings)
  22 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-10-16  6:19 UTC (permalink / raw)
  To: dts; +Cc: nd, lijuan.tu

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
Suggested-by: Tu Lijuan <lijuan.tu@intel.com>
---
 tests/TestSuite_rxtx_callbacks.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_rxtx_callbacks.py b/tests/TestSuite_rxtx_callbacks.py
index dd968a4..a654480 100644
--- a/tests/TestSuite_rxtx_callbacks.py
+++ b/tests/TestSuite_rxtx_callbacks.py
@@ -41,7 +41,6 @@ from test_case import TestCase
 from plotting import Plotting
 from settings import HEADER_SIZE
 from etgen import IxiaPacketGenerator
-from packet import Packet, sniff_packets, load_sniff_packets
 
 
 class TestRxtxCallbacks(TestCase):
@@ -77,7 +76,7 @@ class TestRxtxCallbacks(TestCase):
         self.iface_port0 = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0]))
         self.iface_port1 = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[1]))
 
-        self.inst_port1 = sniff_packets(self.iface_port1)
+        self.inst_port1 = self.tester.tcpdump_sniff_packets(self.iface_port1)
         self.scapy_send_packet(self.iface_port0)
 
         out_port1 = self.get_tcpdump_package(self.inst_port1)
@@ -92,7 +91,7 @@ class TestRxtxCallbacks(TestCase):
         self.tester.scapy_execute()
 
     def get_tcpdump_package(self,inst):
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         dsts = []
         for packet in pkts:
             dst = packet.strip_element_layer2("dst")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v6 10/22] tests/scatter: replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-10-16  6:19         ` [dts] [PATCH v6 " Phil Yang
                             ` (7 preceding siblings ...)
  2018-10-16  6:19           ` [dts] [PATCH v6 09/22] tests/rxtx_callback: " Phil Yang
@ 2018-10-16  6:19           ` Phil Yang
  2018-10-16  6:19           ` [dts] [PATCH v6 11/22] tests/skeleton: " Phil Yang
                             ` (13 subsequent siblings)
  22 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-10-16  6:19 UTC (permalink / raw)
  To: dts; +Cc: nd, lijuan.tu

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
Suggested-by: Tu Lijuan <lijuan.tu@intel.com>
---
 tests/TestSuite_scatter.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_scatter.py b/tests/TestSuite_scatter.py
index d6aef49..0d38513 100644
--- a/tests/TestSuite_scatter.py
+++ b/tests/TestSuite_scatter.py
@@ -35,7 +35,7 @@ Test Scattered Packets.
 """
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets, strip_pktload
+from packet import Packet, strip_pktload
 import time
 #
 #
@@ -82,11 +82,11 @@ class TestScatter(TestCase):
         """
         dmac = self.dut.get_mac_address(self.port)
 
-        inst = sniff_packets(self.intf)
+        inst = self.tester.tcpdump_sniff_packets(self.intf)
         pkt = Packet(pkt_type="IP_RAW", pkt_len=pktsize)
         pkt.config_layer('ether', {'dst': dmac})
         pkt.send_pkt(tx_port=self.intf)
-        sniff_pkts = load_sniff_packets(inst)
+        sniff_pkts = self.tester.load_tcpdump_sniff_packets(inst)
 
         res = ""
         if len(sniff_pkts):
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v6 11/22] tests/skeleton: replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-10-16  6:19         ` [dts] [PATCH v6 " Phil Yang
                             ` (8 preceding siblings ...)
  2018-10-16  6:19           ` [dts] [PATCH v6 10/22] tests/scatter: " Phil Yang
@ 2018-10-16  6:19           ` Phil Yang
  2018-10-16  6:19           ` [dts] [PATCH v6 12/22] tests/userspace_ethtool: " Phil Yang
                             ` (12 subsequent siblings)
  22 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-10-16  6:19 UTC (permalink / raw)
  To: dts; +Cc: nd, lijuan.tu

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
Suggested-by: Tu Lijuan <lijuan.tu@intel.com>
---
 tests/TestSuite_skeleton.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_skeleton.py b/tests/TestSuite_skeleton.py
index 77f95e1..b56d955 100644
--- a/tests/TestSuite_skeleton.py
+++ b/tests/TestSuite_skeleton.py
@@ -42,7 +42,6 @@ from plotting import Plotting
 from settings import HEADER_SIZE
 from etgen import IxiaPacketGenerator
 
-from packet import Packet, sniff_packets, load_sniff_packets
 
 
 class TestSkeleton(TestCase):
@@ -80,7 +79,7 @@ class TestSkeleton(TestCase):
         self.iface_port0 = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0]))
         self.iface_port1 = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[1]))
 
-        self.inst_port1 = sniff_packets(self.iface_port1)
+        self.inst_port1 = self.tester.tcpdump_sniff_packets(self.iface_port1)
         self.scapy_send_packet(self.iface_port0)
 
         out_port1 = self.get_tcpdump_package(self.inst_port1)
@@ -95,7 +94,7 @@ class TestSkeleton(TestCase):
         self.tester.scapy_execute()
 
     def get_tcpdump_package(self,inst):
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         dsts = []
         for packet in pkts:
             dst = packet.strip_element_layer2("dst")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v6 12/22] tests/userspace_ethtool: replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-10-16  6:19         ` [dts] [PATCH v6 " Phil Yang
                             ` (9 preceding siblings ...)
  2018-10-16  6:19           ` [dts] [PATCH v6 11/22] tests/skeleton: " Phil Yang
@ 2018-10-16  6:19           ` Phil Yang
  2018-10-16  6:19           ` [dts] [PATCH v6 13/22] tests/vf_daemon: " Phil Yang
                             ` (11 subsequent siblings)
  22 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-10-16  6:19 UTC (permalink / raw)
  To: dts; +Cc: nd, lijuan.tu

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
Suggested-by: Tu Lijuan <lijuan.tu@intel.com>
---
 tests/TestSuite_userspace_ethtool.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_userspace_ethtool.py b/tests/TestSuite_userspace_ethtool.py
index eccc77b..8ade421 100644
--- a/tests/TestSuite_userspace_ethtool.py
+++ b/tests/TestSuite_userspace_ethtool.py
@@ -39,7 +39,7 @@ import utils
 import time
 import re
 from test_case import TestCase
-from packet import Packet, sniff_packets, load_sniff_packets
+from packet import Packet
 import random
 from etgen import IxiaPacketGenerator
 from settings import HEADER_SIZE
@@ -490,9 +490,9 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator):
             tester_port = self.tester.get_local_port(port)
             intf = self.tester.get_interface(tester_port)
             # send and sniff packet
-            inst = sniff_packets(intf, timeout=5)
+            inst = self.tester.tcpdump_sniff_packets(intf, timeout=5)
             pkt.send_pkt(tx_port=intf)
-            pkts = load_sniff_packets(inst)
+            pkts = self.tester.load_tcpdump_sniff_packets(inst)
             self.verify(len(pkts) == 1, "Packet not forwarded as expected")
             src_mac = pkts[0].strip_layer_element("layer2", "src")
             self.verify(src_mac == valid_mac, "Forwarded packet not match default mac")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v6 13/22] tests/vf_daemon: replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-10-16  6:19         ` [dts] [PATCH v6 " Phil Yang
                             ` (10 preceding siblings ...)
  2018-10-16  6:19           ` [dts] [PATCH v6 12/22] tests/userspace_ethtool: " Phil Yang
@ 2018-10-16  6:19           ` Phil Yang
  2018-10-16  6:19           ` [dts] [PATCH v6 14/22] tests/vf_vlan: " Phil Yang
                             ` (10 subsequent siblings)
  22 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-10-16  6:19 UTC (permalink / raw)
  To: dts; +Cc: nd, lijuan.tu

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
Suggested-by: Tu Lijuan <lijuan.tu@intel.com>
---
 tests/TestSuite_vf_daemon.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tests/TestSuite_vf_daemon.py b/tests/TestSuite_vf_daemon.py
index c264911..42a14e5 100644
--- a/tests/TestSuite_vf_daemon.py
+++ b/tests/TestSuite_vf_daemon.py
@@ -8,7 +8,7 @@ from scapy.utils import rdpcap
 from qemu_kvm import QEMUKvm
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets
+from packet import Packet
 from settings import get_nic_name
 import random
 
@@ -154,7 +154,7 @@ class Testvf_daemon(TestCase):
             pkt.config_layer('vlan', {'vlan': vlan_id})
         pkt.config_layer('ether', {'dst': dst_mac})
 
-        inst = sniff_packets(self.tester_intf, timeout=30)
+        inst = self.tester.tcpdump_sniff_packets(self.tester_intf, timeout=30)
         pkt.send_pkt(tx_port=self.tester_intf, count=num)
         return inst
 
@@ -162,7 +162,7 @@ class Testvf_daemon(TestCase):
         """
         Load sniff packets, strip and return mac address from dump message
         """
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         macs = []
         for pkt in pkts:
             mac = pkt.strip_element_layer2(element)
@@ -173,7 +173,7 @@ class Testvf_daemon(TestCase):
         """
         Load sniff packets, strip and return vlan id from dump message
         """
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         vlans = []
         for pkt in pkts:
             vlan = pkt.strip_element_vlan("vlan")
@@ -422,7 +422,7 @@ class Testvf_daemon(TestCase):
         self.dut_testpmd.execute_cmd('set tx loopback 0 off')
         time.sleep(5)
 
-        inst = sniff_packets(self.tester_intf, timeout=10)
+        inst = self.tester.tcpdump_sniff_packets(self.tester_intf, timeout=10)
 
         self.vm1_testpmd.execute_cmd('set burst 5')
         self.vm1_testpmd.execute_cmd('start tx_first')
@@ -438,7 +438,7 @@ class Testvf_daemon(TestCase):
         self.dut_testpmd.execute_cmd('set tx loopback 0 on')
         time.sleep(3)
 
-        inst = sniff_packets(self.tester_intf, timeout=10)
+        inst = self.tester.tcpdump_sniff_packets(self.tester_intf, timeout=10)
 
         self.vm1_testpmd.execute_cmd('stop')
         self.vm1_testpmd.execute_cmd('start tx_first')
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v6 14/22] tests/vf_vlan: replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-10-16  6:19         ` [dts] [PATCH v6 " Phil Yang
                             ` (11 preceding siblings ...)
  2018-10-16  6:19           ` [dts] [PATCH v6 13/22] tests/vf_daemon: " Phil Yang
@ 2018-10-16  6:19           ` Phil Yang
  2018-10-16  6:19           ` [dts] [PATCH v6 15/22] tests/vlan_ethertype_config: remove unused sniff_packets Phil Yang
                             ` (9 subsequent siblings)
  22 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-10-16  6:19 UTC (permalink / raw)
  To: dts; +Cc: nd, lijuan.tu

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
Suggested-by: Tu Lijuan <lijuan.tu@intel.com>
---
 tests/TestSuite_vf_vlan.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/TestSuite_vf_vlan.py b/tests/TestSuite_vf_vlan.py
index 75d99f2..4c7b42d 100644
--- a/tests/TestSuite_vf_vlan.py
+++ b/tests/TestSuite_vf_vlan.py
@@ -6,7 +6,7 @@ import time
 from virt_common import VM
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets
+from packet import Packet
 from settings import get_nic_name
 import random
 
@@ -173,9 +173,9 @@ class TestVfVlan(TestCase):
 
         pkt = Packet(pkt_type='UDP')
         pkt.config_layer('ether', {'dst': self.vf1_mac})
-        inst = sniff_packets(self.tester_intf0, timeout=5)
+        inst = self.tester.tcpdump_sniff_packets(self.tester_intf0, timeout=5)
         pkt.send_pkt(tx_port=self.tester_intf1)
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
 
         self.verify(len(pkts), "Not receive expected packet")
         self.vm0_testpmd.quit()
@@ -258,13 +258,13 @@ class TestVfVlan(TestCase):
             "ip link set %s vf 0 vlan 0" % (self.host_intf0), "# ")
 
     def tx_and_check(self, tx_vlan=1):
-        inst = sniff_packets(self.tester_intf0, timeout=5)
+        inst = self.tester.tcpdump_sniff_packets(self.tester_intf0, timeout=5)
         self.vm0_testpmd.execute_cmd('set burst 1')
         self.vm0_testpmd.execute_cmd('start tx_first')
         self.vm0_testpmd.execute_cmd('stop')
 
         # strip sniffered vlans
-        pkts = load_sniff_packets(inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(inst)
         vlans = []
         for pkt in pkts:
             vlan = pkt.strip_element_vlan("vlan")
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v6 15/22] tests/vlan_ethertype_config: remove unused sniff_packets
  2018-10-16  6:19         ` [dts] [PATCH v6 " Phil Yang
                             ` (12 preceding siblings ...)
  2018-10-16  6:19           ` [dts] [PATCH v6 14/22] tests/vf_vlan: " Phil Yang
@ 2018-10-16  6:19           ` Phil Yang
  2018-10-16  6:19           ` [dts] [PATCH v6 16/22] tests/vlan: replaced sniff_packets to tester.tcpdump_sniff_packets Phil Yang
                             ` (8 subsequent siblings)
  22 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-10-16  6:19 UTC (permalink / raw)
  To: dts; +Cc: nd, lijuan.tu

remove unused sniff_packets

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
Suggested-by: Tu Lijuan <lijuan.tu@intel.com>
---
 tests/TestSuite_vlan_ethertype_config.py | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tests/TestSuite_vlan_ethertype_config.py b/tests/TestSuite_vlan_ethertype_config.py
index 1fb30fb..8eba49c 100644
--- a/tests/TestSuite_vlan_ethertype_config.py
+++ b/tests/TestSuite_vlan_ethertype_config.py
@@ -43,7 +43,6 @@ import utils
 
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets
 from scapy.utils import struct, socket, wrpcap, rdpcap
 from scapy.layers.inet import Ether, IP, TCP, UDP, ICMP
 from scapy.layers.l2 import Dot1Q, ARP, GRE
@@ -125,7 +124,6 @@ class TestVlanEthertypeConfig(TestCase):
         # off
         self.dmac = self.dut.get_mac_address(dutRxPortId)
 
-        self.inst = sniff_packets(self.rxItf)
         pkt = []
         if outer_vid < 0 or outer_tpid <= 0:
             pkt = [
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v6 16/22] tests/vlan: replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-10-16  6:19         ` [dts] [PATCH v6 " Phil Yang
                             ` (13 preceding siblings ...)
  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           ` Phil Yang
  2018-10-16  6:19           ` [dts] [PATCH v6 17/22] tests/ipgre: " Phil Yang
                             ` (7 subsequent siblings)
  22 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-10-16  6:19 UTC (permalink / raw)
  To: dts; +Cc: nd, lijuan.tu

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
Suggested-by: Tu Lijuan <lijuan.tu@intel.com>
---
 tests/TestSuite_vlan.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_vlan.py b/tests/TestSuite_vlan.py
index 0f1833b..b2bda71 100644
--- a/tests/TestSuite_vlan.py
+++ b/tests/TestSuite_vlan.py
@@ -43,7 +43,7 @@ import time
 
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets
+from packet import Packet
 
 
 class TestVlan(TestCase):
@@ -88,7 +88,7 @@ class TestVlan(TestCase):
             netobj.add_vlan(vlan_id = self.vlan)
 
     def get_tcpdump_package(self):
-        pkts = load_sniff_packets(self.inst)
+        pkts = self.tester.load_tcpdump_sniff_packets(self.inst)
         vlans = []
         for packet in pkts:
             vlan = packet.strip_element_vlan("vlan")
@@ -110,7 +110,7 @@ class TestVlan(TestCase):
         # the package dect mac must is dut tx port id when the port promisc is off
         self.dmac = self.dut.get_mac_address(dutRxPortId)
 
-        self.inst = sniff_packets(self.rxItf)
+        self.inst = self.tester.tcpdump_sniff_packets(self.rxItf)
         # FIXME  send a burst with only num packet
         if vid == -1:
             pkt = Packet(pkt_type='UDP')
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v6 17/22] tests/ipgre: replaced sniff_packets to tester.tcpdump_sniff_packets
  2018-10-16  6:19         ` [dts] [PATCH v6 " Phil Yang
                             ` (14 preceding siblings ...)
  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           ` Phil Yang
  2018-10-16  6:19           ` [dts] [PATCH v6 18/22] tests/hotplug: remove unused packet sniff import Phil Yang
                             ` (6 subsequent siblings)
  22 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-10-16  6:19 UTC (permalink / raw)
  To: dts; +Cc: nd, lijuan.tu

Make packet sniff run on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
Suggested-by: Tu Lijuan <lijuan.tu@intel.com>
---
 tests/TestSuite_ipgre.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_ipgre.py b/tests/TestSuite_ipgre.py
index 2dccb9c..e400161 100644
--- a/tests/TestSuite_ipgre.py
+++ b/tests/TestSuite_ipgre.py
@@ -44,7 +44,7 @@ import re
 import time
 import os
 
-from packet import Packet, sniff_packets, load_sniff_packets, NVGRE, IPPROTO_NVGRE
+from packet import Packet, NVGRE, IPPROTO_NVGRE
 
 from scapy.utils import wrpcap, rdpcap
 from scapy.packet import split_layers,bind_layers
@@ -98,11 +98,11 @@ class TestIpgre(TestCase):
             if layer_configs:
                 for layer in layer_configs.keys():
                     pkt.config_layer(layer, layer_configs[layer])
-            inst = sniff_packets(self.tester_iface, count=1, timeout=8)
+            inst = self.tester.tcpdump_sniff_packets(self.tester_iface, count=1, timeout=8)
             pkt.send_pkt(tx_port=self.tester_iface)
             out = self.dut.get_session_output(timeout=2)
             time.sleep(1)
-            load_sniff_packets(inst)
+            self.tester.load_tcpdump_sniff_packets(inst)
             if self.printFlag: # debug output
                 print out
             for pkt_layer_name in pkt_names:
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v6 18/22] tests/hotplug: remove unused packet sniff import
  2018-10-16  6:19         ` [dts] [PATCH v6 " Phil Yang
                             ` (15 preceding siblings ...)
  2018-10-16  6:19           ` [dts] [PATCH v6 17/22] tests/ipgre: " Phil Yang
@ 2018-10-16  6:19           ` Phil Yang
  2018-10-16  6:19           ` [dts] [PATCH v6 19/22] tests/keep_alive: " Phil Yang
                             ` (5 subsequent siblings)
  22 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-10-16  6:19 UTC (permalink / raw)
  To: dts; +Cc: nd, lijuan.tu

remove unused packet sniff import.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
Suggested-by: Tu Lijuan <lijuan.tu@intel.com>
---
 tests/TestSuite_hotplug.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/TestSuite_hotplug.py b/tests/TestSuite_hotplug.py
index c0e1741..7d63b71 100644
--- a/tests/TestSuite_hotplug.py
+++ b/tests/TestSuite_hotplug.py
@@ -43,7 +43,7 @@ from test_case import TestCase
 from plotting import Plotting
 from settings import HEADER_SIZE
 from etgen import IxiaPacketGenerator
-from packet import Packet, sniff_packets, load_sniff_packets
+from packet import Packet
 
 class TestPortHotPlug(TestCase):
     """
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v6 19/22] tests/keep_alive: remove unused packet sniff import
  2018-10-16  6:19         ` [dts] [PATCH v6 " Phil Yang
                             ` (16 preceding siblings ...)
  2018-10-16  6:19           ` [dts] [PATCH v6 18/22] tests/hotplug: remove unused packet sniff import Phil Yang
@ 2018-10-16  6:19           ` Phil Yang
  2018-10-16  6:20           ` [dts] [PATCH v6 20/22] tests/link_status_interrupt: " Phil Yang
                             ` (4 subsequent siblings)
  22 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-10-16  6:19 UTC (permalink / raw)
  To: dts; +Cc: nd, lijuan.tu

remove unused packet sniff import.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
Suggested-by: Tu Lijuan <lijuan.tu@intel.com>
---
 tests/TestSuite_keep_alive.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tests/TestSuite_keep_alive.py b/tests/TestSuite_keep_alive.py
index 41c8732..711d8ce 100644
--- a/tests/TestSuite_keep_alive.py
+++ b/tests/TestSuite_keep_alive.py
@@ -43,7 +43,6 @@ from test_case import TestCase
 from plotting import Plotting 
 from settings import HEADER_SIZE   
 from etgen import IxiaPacketGenerator
-from packet import Packet, sniff_packets, load_sniff_packets
 
 class TestKeepAlive(TestCase):
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v6 20/22] tests/link_status_interrupt: remove unused packet sniff import
  2018-10-16  6:19         ` [dts] [PATCH v6 " Phil Yang
                             ` (17 preceding siblings ...)
  2018-10-16  6:19           ` [dts] [PATCH v6 19/22] tests/keep_alive: " Phil Yang
@ 2018-10-16  6:20           ` Phil Yang
  2018-10-16  6:20           ` [dts] [PATCH v6 21/22] tests/vhost_pmd_xstats: " Phil Yang
                             ` (3 subsequent siblings)
  22 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-10-16  6:20 UTC (permalink / raw)
  To: dts; +Cc: nd, lijuan.tu

remove unused packet sniff import.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
Suggested-by: Tu Lijuan <lijuan.tu@intel.com>
---
 tests/TestSuite_link_status_interrupt.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/TestSuite_link_status_interrupt.py b/tests/TestSuite_link_status_interrupt.py
index c31634b..cad6485 100644
--- a/tests/TestSuite_link_status_interrupt.py
+++ b/tests/TestSuite_link_status_interrupt.py
@@ -40,7 +40,7 @@ import string
 import time
 import re
 from test_case import TestCase
-from packet import Packet, sniff_packets, load_sniff_packets
+from packet import Packet
 
 
 class TestLinkStatusInterrupt(TestCase):
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v6 21/22] tests/vhost_pmd_xstats: remove unused packet sniff import
  2018-10-16  6:19         ` [dts] [PATCH v6 " Phil Yang
                             ` (18 preceding siblings ...)
  2018-10-16  6:20           ` [dts] [PATCH v6 20/22] tests/link_status_interrupt: " Phil Yang
@ 2018-10-16  6:20           ` Phil Yang
  2018-10-16  6:20           ` [dts] [PATCH v6 22/22] tests/ddp_mpls: " Phil Yang
                             ` (2 subsequent siblings)
  22 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-10-16  6:20 UTC (permalink / raw)
  To: dts; +Cc: nd, lijuan.tu

remove unused packet sniff import.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
Suggested-by: Tu Lijuan <lijuan.tu@intel.com>
---
 tests/TestSuite_vhost_pmd_xstats.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/TestSuite_vhost_pmd_xstats.py b/tests/TestSuite_vhost_pmd_xstats.py
index 8c800c7..a01ca16 100644
--- a/tests/TestSuite_vhost_pmd_xstats.py
+++ b/tests/TestSuite_vhost_pmd_xstats.py
@@ -46,7 +46,7 @@ from exception import VerifyFailure
 from settings import HEADER_SIZE
 from etgen import IxiaPacketGenerator
 from qemu_kvm import QEMUKvm
-from packet import Packet, sniff_packets, load_sniff_packets
+from packet import Packet
 
 
 class TestVhostPmdXstats(TestCase):
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v6 22/22] tests/ddp_mpls: remove unused packet sniff import
  2018-10-16  6:19         ` [dts] [PATCH v6 " Phil Yang
                             ` (19 preceding siblings ...)
  2018-10-16  6:20           ` [dts] [PATCH v6 21/22] tests/vhost_pmd_xstats: " Phil Yang
@ 2018-10-16  6:20           ` 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-19  9:25           ` [dts] [PATCH v7] " Phil Yang
  22 siblings, 0 replies; 124+ messages in thread
From: Phil Yang @ 2018-10-16  6:20 UTC (permalink / raw)
  To: dts; +Cc: nd, lijuan.tu

remove unused packet sniff import.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
Suggested-by: Tu Lijuan <lijuan.tu@intel.com>
---
 tests/TestSuite_ddp_mpls.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tests/TestSuite_ddp_mpls.py b/tests/TestSuite_ddp_mpls.py
index 08d58be..691e958 100644
--- a/tests/TestSuite_ddp_mpls.py
+++ b/tests/TestSuite_ddp_mpls.py
@@ -8,7 +8,6 @@ from scapy.utils import rdpcap
 from qemu_kvm import QEMUKvm
 from test_case import TestCase
 from pmd_output import PmdOutput
-from packet import Packet, sniff_packets, load_sniff_packets
 from settings import get_nic_name
 import random
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 124+ messages in thread

* Re: [dts] [PATCH v6 01/22] framework/packet: support packet sniffer to specify running machine
  2018-10-16  6:19         ` [dts] [PATCH v6 " Phil Yang
                             ` (20 preceding siblings ...)
  2018-10-16  6:20           ` [dts] [PATCH v6 22/22] tests/ddp_mpls: " Phil Yang
@ 2018-10-18  9:15           ` Tu, Lijuan
  2018-10-18 10:00             ` Phil Yang (Arm Technology China)
  2018-10-19  9:25           ` [dts] [PATCH v7] " Phil Yang
  22 siblings, 1 reply; 124+ messages in thread
From: Tu, Lijuan @ 2018-10-18  9:15 UTC (permalink / raw)
  To: phil.yang, dts; +Cc: nd

Hi Phil,
Poll is an attribute of Popen, but not pxssh.

To make sniff function more clear, I prefer to remove the old code instead of keeping them.
As in dts, we always pass the parameter target, the tester information, we could raise exception when finding target is None.

> -----Original Message-----
> From: phil.yang@arm.com [mailto:phil.yang@arm.com]
> Sent: Tuesday, October 16, 2018 2:20 PM
> To: dts@dpdk.org
> Cc: nd@arm.com; Tu, Lijuan <lijuan.tu@intel.com>
> Subject: [PATCH v6 01/22] framework/packet: support packet sniffer to
> specify running machine
> 
> By default, the Tester is supposed to be the server which running DTS and the
> packet sniff methods are running on it.
> However, if DTS was not running on the Tester and the Tester is another
> remote server, so packet sniff methods cannot sniff Tester's packets
> correctly.
> 
> This patch adds support for packet sniff methods to specify running machine
> and implements sniff packet methods in class tester.
> 
> 1. Add parameter to sniff_packet and load_sniff_pcap methods to specify
> the running machine.
> 2. Remove load_sniff_packets method in packet.py.
> 3. Add tcpdump_sniff_packets, load_tcpdump_sniff_pcap and
> load_tcpdump_sniff_packets for class tester with the new sniff_packet API.
> 4. Update tester.check_random_pkts method with
> tester.tcpdump_sniff_packets and tester.load_tcpdump_sniff_packets to
> make it execution on the Tester.
> 
> Signed-off-by: Phil Yang <phil.yang@arm.com>
> Suggested-by: Marvin Liu <yong.liu@intel.com>
> Suggested-by: Tu Lijuan <lijuan.tu@intel.com>
> ---
>  framework/packet.py | 100
> +++++++++++++++++++++++++++-------------------------
>  framework/tester.py |  48 ++++++++++++++++++++++---
>  2 files changed, 95 insertions(+), 53 deletions(-)
> 
> diff --git a/framework/packet.py b/framework/packet.py index
> 976b82b..517c93d 100755
> --- a/framework/packet.py
> +++ b/framework/packet.py
> @@ -33,7 +33,6 @@
>  Generic packet create, transmit and analyze module  Base on
> scapy(python program for packet manipulation)  """
> -
>  import os
>  import time
>  import sys
> @@ -61,6 +60,7 @@ from scapy.route import *  from scapy.packet import
> bind_layers, Raw  from scapy.sendrecv import sendp  from scapy.arch
> import get_if_hwaddr
> +from pexpect import pxssh
> 
>  # load extension layers
>  exec_file = os.path.realpath(__file__)
> @@ -812,15 +812,31 @@ 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)
> +    remote_terminate = 0 # session remote terminate flag
> +
> +    # target[] contain the remote machine info for ssh connection
> +    # target[0]: username
> +    # target[1]: ip address
> +    # target[2]: pass word
> +    if target:
> +	tcpdump_help_session=pxssh.pxssh()
> +	tcpdump_help_session.login(server=target[1], username=target[0],
> +                                   password=target[2],
> original_prompt='[$#>]',
> +                                   login_timeout=20)
> +	tcpdump_help_session.sendline('tcpdump -h')
> +	tcpdump_help_session.prompt()
> +	tcpdump_help=tcpdump_help_session.before
> +	tcpdump_help_session.logout()
> +    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,22 +866,31 @@ def sniff_packets(intf, count=0, timeout=5,
> filters=[]):
>      else:
>          cmd = sniff_cmd % options
> 
> -    args = shlex.split(cmd)
> +    if target:
> +        tcpdump_session=pxssh.pxssh()
> +        tcpdump_session.login(server=target[1], username=target[0],
> +                              password=target[2],
> original_prompt='[$#>]',
> +                              login_timeout=20)
> +        tcpdump_session.sendline(cmd)
> +        pipe = tcpdump_session
> +        remote_terminate = 1
> +    else:
> +        args = shlex.split(cmd)
> +        pipe = subprocess.Popen(args)
> 
> -    pipe = subprocess.Popen(args)
>      index = str(time.time())
> -    SNIFF_PIDS[index] = (pipe, intf, timeout)
> +    SNIFF_PIDS[index] = (pipe, intf, timeout, remote_terminate)
>      time.sleep(1)
>      return index
> 
> 
> -def load_sniff_pcap(index=''):
> +def load_sniff_pcap(index='', target=[]):
>      """
>      Stop sniffer and return pcap file
>      """
>      child_exit = False
>      if index in SNIFF_PIDS.keys():
> -        pipe, intf, timeout = SNIFF_PIDS[index]
> +        pipe, intf, timeout, remote_terminate = SNIFF_PIDS[index]
>          time_elapse = int(time.time() - float(index))
>          while time_elapse < timeout:
>              if pipe.poll() is not None:
[Lijuan] Exception happened here because poll is not an attribute of pxssh.
> @@ -876,8 +901,22 @@ def load_sniff_pcap(index=''):
>              time_elapse += 1
> 
>          if not child_exit:
> -            pipe.send_signal(signal.SIGINT)
> -            pipe.wait()
> +            if remote_terminate == 1:
> +                tcpdump_quit_session=pxssh.pxssh()
> +                tcpdump_quit_session.login(server=target[1],
> username=target[0],
> +                                           password=target[2],
> original_prompt='[$#>]',
> +                                           login_timeout=20)
> +                tcpdump_quit_session.sendline('kill -2 $(pidof
> tcpdump)')
> +                tcpdump_quit_session.prompt()
> +                tcpdump_quit_session.logout()
> +                # Teminate the tcpdump_session
> +                pipe.prompt()
> +                pipe.logout()
> +                pipe = None
> +
> +            if pipe is not None:
> +                pipe.send_signal(signal.SIGINT)
> +                pipe.wait()
> 
>          # wait pcap file ready
>          time.sleep(1)
> @@ -886,42 +925,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:
> @@ -983,7 +986,6 @@ if __name__ == "__main__":
>      inst = sniff_packets("lo", timeout=5)
>      pkt = Packet(pkt_type='UDP')
>      pkt.send_pkt(tx_port='lo')
> -    pkts = load_sniff_packets(inst)
> 
>      pkt = Packet(pkt_type='UDP', pkt_len=1500, ran_payload=True)
>      pkt.send_pkt(tx_port='lo')
> diff --git a/framework/tester.py b/framework/tester.py index
> a775f68..c5b705d 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 @@ -560,8 +561,6 @@ class Tester(Crb):
>          module = __import__("packet")
>          pkt_c = getattr(module, "Packet")
>          send_f = getattr(module, "send_packets")
> -        sniff_f = getattr(module, "sniff_packets")
> -        load_f = getattr(module, "load_sniff_packets")
>          compare_f = getattr(module, "compare_pktload")
>          strip_f = getattr(module, "strip_pktload")
>          save_f = getattr(module, "save_packets") @@ -606,7 +605,7 @@
> class Tester(Crb):
> 
>              # send and sniff packets
>              save_f(pkts=pkts, filename="/tmp/%s_tx.pcap" % txIntf)
> -            inst = sniff_f(intf=rxIntf, count=pktnum, timeout=timeout,
> filters=
> +            inst = self.tcpdump_sniff_packets(intf=rxIntf,
> + count=pktnum, timeout=timeout, filters=
>                  [{'layer': 'network', 'config': {'srcport': '65535'}},
>                   {'layer': 'network', 'config': {'dstport': '65535'}}])
>              rx_inst[rxport] = inst
> @@ -627,7 +626,7 @@ class Tester(Crb):
>          # Verify all packets
>          prev_id = -1
>          for txport, rxport in portList:
> -            recv_pkts = load_f(rx_inst[rxport])
> +            recv_pkts =
> + self.load_tcpdump_sniff_packets(rx_inst[rxport])
> 
>              # only report when recevied number not matched
>              if len(tx_pkts[txport]) > len(recv_pkts):
> @@ -704,6 +703,47 @@ 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")
> +
> +        target=[]
> +        target.append(self.get_username())
> +        target.append(self.get_ip_address())
> +        target.append(self.get_password())
> +        pcap = load_pcap_f(index, target)
> +        self.session.copy_file_from(pcap)
> +
> +        return pcap.split(os.sep)[-1]
> +
> +    def load_tcpdump_sniff_packets(self, index=''):
> +        """
> +        Wrapper for packet module load_pcapfile
> +        """
> +        # 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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* Re: [dts] [PATCH v6 01/22] framework/packet: support packet sniffer to specify running machine
  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)
  0 siblings, 1 reply; 124+ messages in thread
From: Phil Yang (Arm Technology China) @ 2018-10-18 10:00 UTC (permalink / raw)
  To: Tu, Lijuan, dts; +Cc: nd

Hi Lijuan,

Agree.

I can sanity the patch in the new version.

Thanks,
Phil Yang

> -----Original Message-----
> From: Tu, Lijuan <lijuan.tu@intel.com>
> Sent: Thursday, October 18, 2018 5:15 PM
> To: Phil Yang (Arm Technology China) <Phil.Yang@arm.com>; dts@dpdk.org
> Cc: nd <nd@arm.com>
> Subject: RE: [PATCH v6 01/22] framework/packet: support packet sniffer to
> specify running machine
> 
> Hi Phil,
> Poll is an attribute of Popen, but not pxssh.
> 
> To make sniff function more clear, I prefer to remove the old code instead of
> keeping them.
> As in dts, we always pass the parameter target, the tester information, we could
> raise exception when finding target is None.
> 
> > -----Original Message-----
> > From: phil.yang@arm.com [mailto:phil.yang@arm.com]
> > Sent: Tuesday, October 16, 2018 2:20 PM
> > To: dts@dpdk.org
> > Cc: nd@arm.com; Tu, Lijuan <lijuan.tu@intel.com>
> > Subject: [PATCH v6 01/22] framework/packet: support packet sniffer to
> > specify running machine
> >
> > By default, the Tester is supposed to be the server which running DTS
> > and the packet sniff methods are running on it.
> > However, if DTS was not running on the Tester and the Tester is
> > another remote server, so packet sniff methods cannot sniff Tester's
> > packets correctly.
> >
> > This patch adds support for packet sniff methods to specify running
> > machine and implements sniff packet methods in class tester.
> >
> > 1. Add parameter to sniff_packet and load_sniff_pcap methods to
> > specify the running machine.
> > 2. Remove load_sniff_packets method in packet.py.
> > 3. Add tcpdump_sniff_packets, load_tcpdump_sniff_pcap and
> > load_tcpdump_sniff_packets for class tester with the new sniff_packet API.
> > 4. Update tester.check_random_pkts method with
> > tester.tcpdump_sniff_packets and tester.load_tcpdump_sniff_packets to
> > make it execution on the Tester.
> >
> > Signed-off-by: Phil Yang <phil.yang@arm.com>
> > Suggested-by: Marvin Liu <yong.liu@intel.com>
> > Suggested-by: Tu Lijuan <lijuan.tu@intel.com>
> > ---
> >  framework/packet.py | 100
> > +++++++++++++++++++++++++++-------------------------
> >  framework/tester.py |  48 ++++++++++++++++++++++---
> >  2 files changed, 95 insertions(+), 53 deletions(-)
> >
> > diff --git a/framework/packet.py b/framework/packet.py index
> > 976b82b..517c93d 100755
> > --- a/framework/packet.py
> > +++ b/framework/packet.py
> > @@ -33,7 +33,6 @@
> >  Generic packet create, transmit and analyze module  Base on
> > scapy(python program for packet manipulation)  """
> > -
> >  import os
> >  import time
> >  import sys
> > @@ -61,6 +60,7 @@ from scapy.route import *  from scapy.packet import
> > bind_layers, Raw  from scapy.sendrecv import sendp  from scapy.arch
> > import get_if_hwaddr
> > +from pexpect import pxssh
> >
> >  # load extension layers
> >  exec_file = os.path.realpath(__file__) @@ -812,15 +812,31 @@ 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)
> > +    remote_terminate = 0 # session remote terminate flag
> > +
> > +    # target[] contain the remote machine info for ssh connection
> > +    # target[0]: username
> > +    # target[1]: ip address
> > +    # target[2]: pass word
> > +    if target:
> > +	tcpdump_help_session=pxssh.pxssh()
> > +	tcpdump_help_session.login(server=target[1], username=target[0],
> > +                                   password=target[2],
> > original_prompt='[$#>]',
> > +                                   login_timeout=20)
> > +	tcpdump_help_session.sendline('tcpdump -h')
> > +	tcpdump_help_session.prompt()
> > +	tcpdump_help=tcpdump_help_session.before
> > +	tcpdump_help_session.logout()
> > +    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,22 +866,31 @@ def sniff_packets(intf, count=0, timeout=5,
> > filters=[]):
> >      else:
> >          cmd = sniff_cmd % options
> >
> > -    args = shlex.split(cmd)
> > +    if target:
> > +        tcpdump_session=pxssh.pxssh()
> > +        tcpdump_session.login(server=target[1], username=target[0],
> > +                              password=target[2],
> > original_prompt='[$#>]',
> > +                              login_timeout=20)
> > +        tcpdump_session.sendline(cmd)
> > +        pipe = tcpdump_session
> > +        remote_terminate = 1
> > +    else:
> > +        args = shlex.split(cmd)
> > +        pipe = subprocess.Popen(args)
> >
> > -    pipe = subprocess.Popen(args)
> >      index = str(time.time())
> > -    SNIFF_PIDS[index] = (pipe, intf, timeout)
> > +    SNIFF_PIDS[index] = (pipe, intf, timeout, remote_terminate)
> >      time.sleep(1)
> >      return index
> >
> >
> > -def load_sniff_pcap(index=''):
> > +def load_sniff_pcap(index='', target=[]):
> >      """
> >      Stop sniffer and return pcap file
> >      """
> >      child_exit = False
> >      if index in SNIFF_PIDS.keys():
> > -        pipe, intf, timeout = SNIFF_PIDS[index]
> > +        pipe, intf, timeout, remote_terminate = SNIFF_PIDS[index]
> >          time_elapse = int(time.time() - float(index))
> >          while time_elapse < timeout:
> >              if pipe.poll() is not None:
> [Lijuan] Exception happened here because poll is not an attribute of pxssh.
> > @@ -876,8 +901,22 @@ def load_sniff_pcap(index=''):
> >              time_elapse += 1
> >
> >          if not child_exit:
> > -            pipe.send_signal(signal.SIGINT)
> > -            pipe.wait()
> > +            if remote_terminate == 1:
> > +                tcpdump_quit_session=pxssh.pxssh()
> > +                tcpdump_quit_session.login(server=target[1],
> > username=target[0],
> > +                                           password=target[2],
> > original_prompt='[$#>]',
> > +                                           login_timeout=20)
> > +                tcpdump_quit_session.sendline('kill -2 $(pidof
> > tcpdump)')
> > +                tcpdump_quit_session.prompt()
> > +                tcpdump_quit_session.logout()
> > +                # Teminate the tcpdump_session
> > +                pipe.prompt()
> > +                pipe.logout()
> > +                pipe = None
> > +
> > +            if pipe is not None:
> > +                pipe.send_signal(signal.SIGINT)
> > +                pipe.wait()
> >
> >          # wait pcap file ready
> >          time.sleep(1)
> > @@ -886,42 +925,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:
> > @@ -983,7 +986,6 @@ if __name__ == "__main__":
> >      inst = sniff_packets("lo", timeout=5)
> >      pkt = Packet(pkt_type='UDP')
> >      pkt.send_pkt(tx_port='lo')
> > -    pkts = load_sniff_packets(inst)
> >
> >      pkt = Packet(pkt_type='UDP', pkt_len=1500, ran_payload=True)
> >      pkt.send_pkt(tx_port='lo')
> > diff --git a/framework/tester.py b/framework/tester.py index
> > a775f68..c5b705d 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 @@ -560,8 +561,6 @@ class Tester(Crb):
> >          module = __import__("packet")
> >          pkt_c = getattr(module, "Packet")
> >          send_f = getattr(module, "send_packets")
> > -        sniff_f = getattr(module, "sniff_packets")
> > -        load_f = getattr(module, "load_sniff_packets")
> >          compare_f = getattr(module, "compare_pktload")
> >          strip_f = getattr(module, "strip_pktload")
> >          save_f = getattr(module, "save_packets") @@ -606,7 +605,7 @@
> > class Tester(Crb):
> >
> >              # send and sniff packets
> >              save_f(pkts=pkts, filename="/tmp/%s_tx.pcap" % txIntf)
> > -            inst = sniff_f(intf=rxIntf, count=pktnum, timeout=timeout,
> > filters=
> > +            inst = self.tcpdump_sniff_packets(intf=rxIntf,
> > + count=pktnum, timeout=timeout, filters=
> >                  [{'layer': 'network', 'config': {'srcport': '65535'}},
> >                   {'layer': 'network', 'config': {'dstport': '65535'}}])
> >              rx_inst[rxport] = inst
> > @@ -627,7 +626,7 @@ class Tester(Crb):
> >          # Verify all packets
> >          prev_id = -1
> >          for txport, rxport in portList:
> > -            recv_pkts = load_f(rx_inst[rxport])
> > +            recv_pkts =
> > + self.load_tcpdump_sniff_packets(rx_inst[rxport])
> >
> >              # only report when recevied number not matched
> >              if len(tx_pkts[txport]) > len(recv_pkts):
> > @@ -704,6 +703,47 @@ 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")
> > +
> > +        target=[]
> > +        target.append(self.get_username())
> > +        target.append(self.get_ip_address())
> > +        target.append(self.get_password())
> > +        pcap = load_pcap_f(index, target)
> > +        self.session.copy_file_from(pcap)
> > +
> > +        return pcap.split(os.sep)[-1]
> > +
> > +    def load_tcpdump_sniff_packets(self, index=''):
> > +        """
> > +        Wrapper for packet module load_pcapfile
> > +        """
> > +        # 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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* [dts] [PATCH v7] framework/packet: support packet sniffer to specify running machine
  2018-10-16  6:19         ` [dts] [PATCH v6 " Phil Yang
                             ` (21 preceding siblings ...)
  2018-10-18  9:15           ` [dts] [PATCH v6 01/22] framework/packet: support packet sniffer to specify running machine Tu, Lijuan
@ 2018-10-19  9:25           ` Phil Yang
  2018-10-23  9:44             ` Tu, Lijuan
  22 siblings, 1 reply; 124+ messages in thread
From: Phil Yang @ 2018-10-19  9:25 UTC (permalink / raw)
  To: dts; +Cc: nd, lijuan.tu

By default, the Tester is supposed to be the server which running DTS
and the packet sniff methods are running on it.
However, if DTS was not running on the Tester and the Tester is another
remote server, so packet sniff methods cannot sniff Tester's packets
correctly.

This patch adds support for packet sniff methods to specify running
machine and implements sniff packet methods in class tester.

1. Add parameter to sniff_packet and load_sniff_pcap methods to specify
the running machine.
2. Remove load_sniff_packets method in packet.py.
3. Add tcpdump_sniff_packets, load_tcpdump_sniff_pcap and
load_tcpdump_sniff_packets for class tester with the new sniff_packet
API.
4. Update tester.check_random_pkts method with
tester.tcpdump_sniff_packets and tester.load_tcpdump_sniff_packets to
make it execution on the Tester.

Signed-off-by: Phil Yang <phil.yang@arm.com>
Suggested-by: Marvin Liu <yong.liu@intel.com>
Suggested-by: Tu Lijuan <lijuan.tu@intel.com>
---
 framework/packet.py | 97 +++++++++++++++++++++++++----------------------------
 framework/tester.py | 48 +++++++++++++++++++++++---
 2 files changed, 89 insertions(+), 56 deletions(-)

diff --git a/framework/packet.py b/framework/packet.py
index 976b82b..d5b8517 100755
--- a/framework/packet.py
+++ b/framework/packet.py
@@ -33,7 +33,6 @@
 Generic packet create, transmit and analyze module
 Base on scapy(python program for packet manipulation)
 """
-
 import os
 import time
 import sys
@@ -61,6 +60,7 @@ from scapy.route import *
 from scapy.packet import bind_layers, Raw
 from scapy.sendrecv import sendp
 from scapy.arch import get_if_hwaddr
+from pexpect import pxssh
 
 # load extension layers
 exec_file = os.path.realpath(__file__)
@@ -812,15 +812,26 @@ 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)
+
+    try:
+        tcpdump_help_session=pxssh.pxssh()
+        tcpdump_help_session.login(server=target[0], username=target[1],
+                                   password=target[2], original_prompt='[$#>]',
+                                   login_timeout=20)
+        tcpdump_help_session.sendline('tcpdump -h')
+        tcpdump_help_session.prompt()
+        tcpdump_help=tcpdump_help_session.before
+        tcpdump_help_session.logout()
+    except pxssh.ExceptionPxssh as e:
+        print ('pxssh failed on login.')
+        print (e)
+
     for line in tcpdump_help.split('\n'):
         m = re.match(direct_param, line)
         if m:
@@ -850,16 +861,24 @@ def sniff_packets(intf, count=0, timeout=5, filters=[]):
     else:
         cmd = sniff_cmd % options
 
-    args = shlex.split(cmd)
+    try:
+        tcpdump_session=pxssh.pxssh()
+        tcpdump_session.login(server=target[0], username=target[1],
+                              password=target[2], original_prompt='[$#>]',
+                              login_timeout=20)
+        tcpdump_session.sendline(cmd)
+        pipe = tcpdump_session
+    except pxssh.ExceptionPxssh as e:
+        print ('pxssh failed on login.')
+        print (e)
 
-    pipe = subprocess.Popen(args)
     index = str(time.time())
     SNIFF_PIDS[index] = (pipe, intf, timeout)
     time.sleep(1)
     return index
 
 
-def load_sniff_pcap(index=''):
+def load_sniff_pcap(index='', target=[]):
     """
     Stop sniffer and return pcap file
     """
@@ -868,58 +887,36 @@ def load_sniff_pcap(index=''):
         pipe, intf, timeout = SNIFF_PIDS[index]
         time_elapse = int(time.time() - float(index))
         while time_elapse < timeout:
-            if pipe.poll() is not None:
+            if pipe.prompt(timeout=1):
                 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)
-        return "/tmp/sniff_%s.pcap" % intf
-
-    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:
+            try:
+                # Stop Tcpdump on the target server
+                tcpdump_quit_session=pxssh.pxssh()
+                tcpdump_quit_session.login(server=target[0], username=target[1],
+                                           password=target[2], original_prompt='[$#>]',
+                                           login_timeout=20)
+                tcpdump_quit_session.sendline('kill -2 $(pidof tcpdump)')
+                tcpdump_quit_session.prompt()
+                tcpdump_quit_session.logout()
                 child_exit = True
-                break
+            except pxssh.ExceptionPxssh as e:
+                print ('pxssh failed on login.')
+                print (e)
 
-            time.sleep(1)
-            time_elapse += 1
-
-        if not child_exit:
-            pipe.send_signal(signal.SIGINT)
-            pipe.wait()
+        # Close the Tcpdump_session
+        pipe.prompt()
+        pipe.logout()
 
         # 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 "/tmp/sniff_%s.pcap" % intf
 
-    return pkts
+    return ""
 
 
 def load_pcapfile(filename=""):
@@ -978,12 +975,8 @@ def strip_pktload(pkt=None, layer="L2"):
 ###############################################################################
 ###############################################################################
 if __name__ == "__main__":
-    inst = sniff_packets("lo", timeout=5, filters=[{'layer': 'ether',
-                         'config': {'dst': 'FF:FF:FF:FF:FF:FF'}}])
-    inst = sniff_packets("lo", timeout=5)
     pkt = Packet(pkt_type='UDP')
     pkt.send_pkt(tx_port='lo')
-    pkts = load_sniff_packets(inst)
 
     pkt = Packet(pkt_type='UDP', pkt_len=1500, ran_payload=True)
     pkt.send_pkt(tx_port='lo')
diff --git a/framework/tester.py b/framework/tester.py
index a775f68..4e651a1 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
@@ -560,8 +561,6 @@ class Tester(Crb):
         module = __import__("packet")
         pkt_c = getattr(module, "Packet")
         send_f = getattr(module, "send_packets")
-        sniff_f = getattr(module, "sniff_packets")
-        load_f = getattr(module, "load_sniff_packets")
         compare_f = getattr(module, "compare_pktload")
         strip_f = getattr(module, "strip_pktload")
         save_f = getattr(module, "save_packets")
@@ -606,7 +605,7 @@ class Tester(Crb):
 
             # send and sniff packets
             save_f(pkts=pkts, filename="/tmp/%s_tx.pcap" % txIntf)
-            inst = sniff_f(intf=rxIntf, count=pktnum, timeout=timeout, filters=
+            inst = self.tcpdump_sniff_packets(intf=rxIntf, count=pktnum, timeout=timeout, filters=
                 [{'layer': 'network', 'config': {'srcport': '65535'}},
                  {'layer': 'network', 'config': {'dstport': '65535'}}])
             rx_inst[rxport] = inst
@@ -627,7 +626,7 @@ class Tester(Crb):
         # Verify all packets
         prev_id = -1
         for txport, rxport in portList:
-            recv_pkts = load_f(rx_inst[rxport])
+            recv_pkts = self.load_tcpdump_sniff_packets(rx_inst[rxport])
 
             # only report when recevied number not matched
             if len(tx_pkts[txport]) > len(recv_pkts):
@@ -704,6 +703,47 @@ 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_ip_address())
+        target.append(self.get_username())
+        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")
+
+        target=[]
+        target.append(self.get_ip_address())
+        target.append(self.get_username())
+        target.append(self.get_password())
+        pcap = load_pcap_f(index, target)
+        self.session.copy_file_from(pcap)
+
+        return pcap.split(os.sep)[-1]
+
+    def load_tcpdump_sniff_packets(self, index=''):
+        """
+        Wrapper for packet module load_pcapfile
+        """
+        # 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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* Re: [dts] [PATCH v6 01/22] framework/packet: support packet sniffer to specify running machine
  2018-10-18 10:00             ` Phil Yang (Arm Technology China)
@ 2018-10-19  9:29               ` Phil Yang (Arm Technology China)
  0 siblings, 0 replies; 124+ messages in thread
From: Phil Yang (Arm Technology China) @ 2018-10-19  9:29 UTC (permalink / raw)
  To: Phil Yang (Arm Technology China), Tu, Lijuan, dts; +Cc: nd

Hi Lijuan,

I have sent out the 7th version of this single patch. Other patches in this series kept on the 6th version.
Please review it.

Thanks,
Phil Yang

> -----Original Message-----
> From: dts <dts-bounces@dpdk.org> On Behalf Of Phil Yang (Arm Technology
> China)
> Sent: Thursday, October 18, 2018 6:00 PM
> To: Tu, Lijuan <lijuan.tu@intel.com>; dts@dpdk.org
> Cc: nd <nd@arm.com>
> Subject: Re: [dts] [PATCH v6 01/22] framework/packet: support packet sniffer to
> specify running machine
> 
> Hi Lijuan,
> 
> Agree.
> 
> I can sanity the patch in the new version.
> 
> Thanks,
> Phil Yang
> 
> > -----Original Message-----
> > From: Tu, Lijuan <lijuan.tu@intel.com>
> > Sent: Thursday, October 18, 2018 5:15 PM
> > To: Phil Yang (Arm Technology China) <Phil.Yang@arm.com>; dts@dpdk.org
> > Cc: nd <nd@arm.com>
> > Subject: RE: [PATCH v6 01/22] framework/packet: support packet sniffer
> > to specify running machine
> >
> > Hi Phil,
> > Poll is an attribute of Popen, but not pxssh.
> >
> > To make sniff function more clear, I prefer to remove the old code
> > instead of keeping them.
> > As in dts, we always pass the parameter target, the tester
> > information, we could raise exception when finding target is None.
> >
> > > -----Original Message-----
> > > From: phil.yang@arm.com [mailto:phil.yang@arm.com]
> > > Sent: Tuesday, October 16, 2018 2:20 PM
> > > To: dts@dpdk.org
> > > Cc: nd@arm.com; Tu, Lijuan <lijuan.tu@intel.com>
> > > Subject: [PATCH v6 01/22] framework/packet: support packet sniffer
> > > to specify running machine
> > >
> > > By default, the Tester is supposed to be the server which running
> > > DTS and the packet sniff methods are running on it.
> > > However, if DTS was not running on the Tester and the Tester is
> > > another remote server, so packet sniff methods cannot sniff Tester's
> > > packets correctly.
> > >
> > > This patch adds support for packet sniff methods to specify running
> > > machine and implements sniff packet methods in class tester.
> > >
> > > 1. Add parameter to sniff_packet and load_sniff_pcap methods to
> > > specify the running machine.
> > > 2. Remove load_sniff_packets method in packet.py.
> > > 3. Add tcpdump_sniff_packets, load_tcpdump_sniff_pcap and
> > > load_tcpdump_sniff_packets for class tester with the new sniff_packet API.
> > > 4. Update tester.check_random_pkts method with
> > > tester.tcpdump_sniff_packets and tester.load_tcpdump_sniff_packets
> > > to make it execution on the Tester.
> > >
> > > Signed-off-by: Phil Yang <phil.yang@arm.com>
> > > Suggested-by: Marvin Liu <yong.liu@intel.com>
> > > Suggested-by: Tu Lijuan <lijuan.tu@intel.com>
> > > ---
> > >  framework/packet.py | 100
> > > +++++++++++++++++++++++++++-------------------------
> > >  framework/tester.py |  48 ++++++++++++++++++++++---
> > >  2 files changed, 95 insertions(+), 53 deletions(-)
> > >
> > > diff --git a/framework/packet.py b/framework/packet.py index
> > > 976b82b..517c93d 100755
> > > --- a/framework/packet.py
> > > +++ b/framework/packet.py
> > > @@ -33,7 +33,6 @@
> > >  Generic packet create, transmit and analyze module  Base on
> > > scapy(python program for packet manipulation)  """
> > > -
> > >  import os
> > >  import time
> > >  import sys
> > > @@ -61,6 +60,7 @@ from scapy.route import *  from scapy.packet
> > > import bind_layers, Raw  from scapy.sendrecv import sendp  from
> > > scapy.arch import get_if_hwaddr
> > > +from pexpect import pxssh
> > >
> > >  # load extension layers
> > >  exec_file = os.path.realpath(__file__) @@ -812,15 +812,31 @@ 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)
> > > +    remote_terminate = 0 # session remote terminate flag
> > > +
> > > +    # target[] contain the remote machine info for ssh connection
> > > +    # target[0]: username
> > > +    # target[1]: ip address
> > > +    # target[2]: pass word
> > > +    if target:
> > > +	tcpdump_help_session=pxssh.pxssh()
> > > +	tcpdump_help_session.login(server=target[1], username=target[0],
> > > +                                   password=target[2],
> > > original_prompt='[$#>]',
> > > +                                   login_timeout=20)
> > > +	tcpdump_help_session.sendline('tcpdump -h')
> > > +	tcpdump_help_session.prompt()
> > > +	tcpdump_help=tcpdump_help_session.before
> > > +	tcpdump_help_session.logout()
> > > +    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,22 +866,31 @@ def sniff_packets(intf, count=0, timeout=5,
> > > filters=[]):
> > >      else:
> > >          cmd = sniff_cmd % options
> > >
> > > -    args = shlex.split(cmd)
> > > +    if target:
> > > +        tcpdump_session=pxssh.pxssh()
> > > +        tcpdump_session.login(server=target[1], username=target[0],
> > > +                              password=target[2],
> > > original_prompt='[$#>]',
> > > +                              login_timeout=20)
> > > +        tcpdump_session.sendline(cmd)
> > > +        pipe = tcpdump_session
> > > +        remote_terminate = 1
> > > +    else:
> > > +        args = shlex.split(cmd)
> > > +        pipe = subprocess.Popen(args)
> > >
> > > -    pipe = subprocess.Popen(args)
> > >      index = str(time.time())
> > > -    SNIFF_PIDS[index] = (pipe, intf, timeout)
> > > +    SNIFF_PIDS[index] = (pipe, intf, timeout, remote_terminate)
> > >      time.sleep(1)
> > >      return index
> > >
> > >
> > > -def load_sniff_pcap(index=''):
> > > +def load_sniff_pcap(index='', target=[]):
> > >      """
> > >      Stop sniffer and return pcap file
> > >      """
> > >      child_exit = False
> > >      if index in SNIFF_PIDS.keys():
> > > -        pipe, intf, timeout = SNIFF_PIDS[index]
> > > +        pipe, intf, timeout, remote_terminate = SNIFF_PIDS[index]
> > >          time_elapse = int(time.time() - float(index))
> > >          while time_elapse < timeout:
> > >              if pipe.poll() is not None:
> > [Lijuan] Exception happened here because poll is not an attribute of pxssh.
> > > @@ -876,8 +901,22 @@ def load_sniff_pcap(index=''):
> > >              time_elapse += 1
> > >
> > >          if not child_exit:
> > > -            pipe.send_signal(signal.SIGINT)
> > > -            pipe.wait()
> > > +            if remote_terminate == 1:
> > > +                tcpdump_quit_session=pxssh.pxssh()
> > > +                tcpdump_quit_session.login(server=target[1],
> > > username=target[0],
> > > +                                           password=target[2],
> > > original_prompt='[$#>]',
> > > +                                           login_timeout=20)
> > > +                tcpdump_quit_session.sendline('kill -2 $(pidof
> > > tcpdump)')
> > > +                tcpdump_quit_session.prompt()
> > > +                tcpdump_quit_session.logout()
> > > +                # Teminate the tcpdump_session
> > > +                pipe.prompt()
> > > +                pipe.logout()
> > > +                pipe = None
> > > +
> > > +            if pipe is not None:
> > > +                pipe.send_signal(signal.SIGINT)
> > > +                pipe.wait()
> > >
> > >          # wait pcap file ready
> > >          time.sleep(1)
> > > @@ -886,42 +925,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:
> > > @@ -983,7 +986,6 @@ if __name__ == "__main__":
> > >      inst = sniff_packets("lo", timeout=5)
> > >      pkt = Packet(pkt_type='UDP')
> > >      pkt.send_pkt(tx_port='lo')
> > > -    pkts = load_sniff_packets(inst)
> > >
> > >      pkt = Packet(pkt_type='UDP', pkt_len=1500, ran_payload=True)
> > >      pkt.send_pkt(tx_port='lo')
> > > diff --git a/framework/tester.py b/framework/tester.py index
> > > a775f68..c5b705d 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 @@ -560,8 +561,6 @@ class Tester(Crb):
> > >          module = __import__("packet")
> > >          pkt_c = getattr(module, "Packet")
> > >          send_f = getattr(module, "send_packets")
> > > -        sniff_f = getattr(module, "sniff_packets")
> > > -        load_f = getattr(module, "load_sniff_packets")
> > >          compare_f = getattr(module, "compare_pktload")
> > >          strip_f = getattr(module, "strip_pktload")
> > >          save_f = getattr(module, "save_packets") @@ -606,7 +605,7
> > > @@ class Tester(Crb):
> > >
> > >              # send and sniff packets
> > >              save_f(pkts=pkts, filename="/tmp/%s_tx.pcap" % txIntf)
> > > -            inst = sniff_f(intf=rxIntf, count=pktnum, timeout=timeout,
> > > filters=
> > > +            inst = self.tcpdump_sniff_packets(intf=rxIntf,
> > > + count=pktnum, timeout=timeout, filters=
> > >                  [{'layer': 'network', 'config': {'srcport': '65535'}},
> > >                   {'layer': 'network', 'config': {'dstport': '65535'}}])
> > >              rx_inst[rxport] = inst
> > > @@ -627,7 +626,7 @@ class Tester(Crb):
> > >          # Verify all packets
> > >          prev_id = -1
> > >          for txport, rxport in portList:
> > > -            recv_pkts = load_f(rx_inst[rxport])
> > > +            recv_pkts =
> > > + self.load_tcpdump_sniff_packets(rx_inst[rxport])
> > >
> > >              # only report when recevied number not matched
> > >              if len(tx_pkts[txport]) > len(recv_pkts):
> > > @@ -704,6 +703,47 @@ 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")
> > > +
> > > +        target=[]
> > > +        target.append(self.get_username())
> > > +        target.append(self.get_ip_address())
> > > +        target.append(self.get_password())
> > > +        pcap = load_pcap_f(index, target)
> > > +        self.session.copy_file_from(pcap)
> > > +
> > > +        return pcap.split(os.sep)[-1]
> > > +
> > > +    def load_tcpdump_sniff_packets(self, index=''):
> > > +        """
> > > +        Wrapper for packet module load_pcapfile
> > > +        """
> > > +        # 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

^ permalink raw reply	[flat|nested] 124+ messages in thread

* Re: [dts] [PATCH v7] framework/packet: support packet sniffer to specify running machine
  2018-10-19  9:25           ` [dts] [PATCH v7] " Phil Yang
@ 2018-10-23  9:44             ` Tu, Lijuan
  0 siblings, 0 replies; 124+ messages in thread
From: Tu, Lijuan @ 2018-10-23  9:44 UTC (permalink / raw)
  To: phil.yang, dts; +Cc: nd

Applied, thanks

> -----Original Message-----
> From: phil.yang@arm.com [mailto:phil.yang@arm.com]
> Sent: Friday, October 19, 2018 5:25 PM
> To: dts@dpdk.org
> Cc: nd@arm.com; Tu, Lijuan <lijuan.tu@intel.com>
> Subject: [PATCH v7] framework/packet: support packet sniffer to specify
> running machine
> 
> By default, the Tester is supposed to be the server which running DTS and the
> packet sniff methods are running on it.
> However, if DTS was not running on the Tester and the Tester is another
> remote server, so packet sniff methods cannot sniff Tester's packets
> correctly.
> 
> This patch adds support for packet sniff methods to specify running machine
> and implements sniff packet methods in class tester.
> 
> 1. Add parameter to sniff_packet and load_sniff_pcap methods to specify
> the running machine.
> 2. Remove load_sniff_packets method in packet.py.
> 3. Add tcpdump_sniff_packets, load_tcpdump_sniff_pcap and
> load_tcpdump_sniff_packets for class tester with the new sniff_packet API.
> 4. Update tester.check_random_pkts method with
> tester.tcpdump_sniff_packets and tester.load_tcpdump_sniff_packets to
> make it execution on the Tester.
> 
> Signed-off-by: Phil Yang <phil.yang@arm.com>
> Suggested-by: Marvin Liu <yong.liu@intel.com>
> Suggested-by: Tu Lijuan <lijuan.tu@intel.com>
> ---
>  framework/packet.py | 97
> +++++++++++++++++++++++++----------------------------
>  framework/tester.py | 48 +++++++++++++++++++++++---
>  2 files changed, 89 insertions(+), 56 deletions(-)
> 
> diff --git a/framework/packet.py b/framework/packet.py index
> 976b82b..d5b8517 100755
> --- a/framework/packet.py
> +++ b/framework/packet.py
> @@ -33,7 +33,6 @@
>  Generic packet create, transmit and analyze module  Base on
> scapy(python program for packet manipulation)  """
> -
>  import os
>  import time
>  import sys
> @@ -61,6 +60,7 @@ from scapy.route import *  from scapy.packet import
> bind_layers, Raw  from scapy.sendrecv import sendp  from scapy.arch
> import get_if_hwaddr
> +from pexpect import pxssh
> 
>  # load extension layers
>  exec_file = os.path.realpath(__file__)
> @@ -812,15 +812,26 @@ 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)
> +
> +    try:
> +        tcpdump_help_session=pxssh.pxssh()
> +        tcpdump_help_session.login(server=target[0],
> username=target[1],
> +                                   password=target[2],
> original_prompt='[$#>]',
> +                                   login_timeout=20)
> +        tcpdump_help_session.sendline('tcpdump -h')
> +        tcpdump_help_session.prompt()
> +        tcpdump_help=tcpdump_help_session.before
> +        tcpdump_help_session.logout()
> +    except pxssh.ExceptionPxssh as e:
> +        print ('pxssh failed on login.')
> +        print (e)
> +
>      for line in tcpdump_help.split('\n'):
>          m = re.match(direct_param, line)
>          if m:
> @@ -850,16 +861,24 @@ def sniff_packets(intf, count=0, timeout=5,
> filters=[]):
>      else:
>          cmd = sniff_cmd % options
> 
> -    args = shlex.split(cmd)
> +    try:
> +        tcpdump_session=pxssh.pxssh()
> +        tcpdump_session.login(server=target[0], username=target[1],
> +                              password=target[2],
> original_prompt='[$#>]',
> +                              login_timeout=20)
> +        tcpdump_session.sendline(cmd)
> +        pipe = tcpdump_session
> +    except pxssh.ExceptionPxssh as e:
> +        print ('pxssh failed on login.')
> +        print (e)
> 
> -    pipe = subprocess.Popen(args)
>      index = str(time.time())
>      SNIFF_PIDS[index] = (pipe, intf, timeout)
>      time.sleep(1)
>      return index
> 
> 
> -def load_sniff_pcap(index=''):
> +def load_sniff_pcap(index='', target=[]):
>      """
>      Stop sniffer and return pcap file
>      """
> @@ -868,58 +887,36 @@ def load_sniff_pcap(index=''):
>          pipe, intf, timeout = SNIFF_PIDS[index]
>          time_elapse = int(time.time() - float(index))
>          while time_elapse < timeout:
> -            if pipe.poll() is not None:
> +            if pipe.prompt(timeout=1):
>                  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)
> -        return "/tmp/sniff_%s.pcap" % intf
> -
> -    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:
> +            try:
> +                # Stop Tcpdump on the target server
> +                tcpdump_quit_session=pxssh.pxssh()
> +                tcpdump_quit_session.login(server=target[0],
> username=target[1],
> +                                           password=target[2],
> original_prompt='[$#>]',
> +                                           login_timeout=20)
> +                tcpdump_quit_session.sendline('kill -2 $(pidof
> tcpdump)')
> +                tcpdump_quit_session.prompt()
> +                tcpdump_quit_session.logout()
>                  child_exit = True
> -                break
> +            except pxssh.ExceptionPxssh as e:
> +                print ('pxssh failed on login.')
> +                print (e)
> 
> -            time.sleep(1)
> -            time_elapse += 1
> -
> -        if not child_exit:
> -            pipe.send_signal(signal.SIGINT)
> -            pipe.wait()
> +        # Close the Tcpdump_session
> +        pipe.prompt()
> +        pipe.logout()
> 
>          # 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 "/tmp/sniff_%s.pcap" % intf
> 
> -    return pkts
> +    return ""
> 
> 
>  def load_pcapfile(filename=""):
> @@ -978,12 +975,8 @@ def strip_pktload(pkt=None, layer="L2"):
> 
> ##############################################################
> #################
> 
> ##############################################################
> #################
>  if __name__ == "__main__":
> -    inst = sniff_packets("lo", timeout=5, filters=[{'layer': 'ether',
> -                         'config': {'dst': 'FF:FF:FF:FF:FF:FF'}}])
> -    inst = sniff_packets("lo", timeout=5)
>      pkt = Packet(pkt_type='UDP')
>      pkt.send_pkt(tx_port='lo')
> -    pkts = load_sniff_packets(inst)
> 
>      pkt = Packet(pkt_type='UDP', pkt_len=1500, ran_payload=True)
>      pkt.send_pkt(tx_port='lo')
> diff --git a/framework/tester.py b/framework/tester.py index
> a775f68..4e651a1 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 @@ -560,8 +561,6 @@ class Tester(Crb):
>          module = __import__("packet")
>          pkt_c = getattr(module, "Packet")
>          send_f = getattr(module, "send_packets")
> -        sniff_f = getattr(module, "sniff_packets")
> -        load_f = getattr(module, "load_sniff_packets")
>          compare_f = getattr(module, "compare_pktload")
>          strip_f = getattr(module, "strip_pktload")
>          save_f = getattr(module, "save_packets") @@ -606,7 +605,7 @@
> class Tester(Crb):
> 
>              # send and sniff packets
>              save_f(pkts=pkts, filename="/tmp/%s_tx.pcap" % txIntf)
> -            inst = sniff_f(intf=rxIntf, count=pktnum, timeout=timeout,
> filters=
> +            inst = self.tcpdump_sniff_packets(intf=rxIntf,
> + count=pktnum, timeout=timeout, filters=
>                  [{'layer': 'network', 'config': {'srcport': '65535'}},
>                   {'layer': 'network', 'config': {'dstport': '65535'}}])
>              rx_inst[rxport] = inst
> @@ -627,7 +626,7 @@ class Tester(Crb):
>          # Verify all packets
>          prev_id = -1
>          for txport, rxport in portList:
> -            recv_pkts = load_f(rx_inst[rxport])
> +            recv_pkts =
> + self.load_tcpdump_sniff_packets(rx_inst[rxport])
> 
>              # only report when recevied number not matched
>              if len(tx_pkts[txport]) > len(recv_pkts):
> @@ -704,6 +703,47 @@ 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_ip_address())
> +        target.append(self.get_username())
> +        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")
> +
> +        target=[]
> +        target.append(self.get_ip_address())
> +        target.append(self.get_username())
> +        target.append(self.get_password())
> +        pcap = load_pcap_f(index, target)
> +        self.session.copy_file_from(pcap)
> +
> +        return pcap.split(os.sep)[-1]
> +
> +    def load_tcpdump_sniff_packets(self, index=''):
> +        """
> +        Wrapper for packet module load_pcapfile
> +        """
> +        # 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

^ permalink raw reply	[flat|nested] 124+ messages in thread

end of thread, other threads:[~2018-10-23  9:44 UTC | newest]

Thread overview: 124+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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).