test suite reviews and discussions
 help / color / mirror / Atom feed
From: Yong Liu <yong.liu@intel.com>
To: dts@dpdk.org
Subject: [dts] [PATCH] framework packet: kindly terminate sniff process
Date: Wed, 11 Nov 2015 22:42:09 +0800	[thread overview]
Message-ID: <1447252929-6843-1-git-send-email-yong.liu@intel.com> (raw)

From: Marvin Liu <yong.liu@intel.com>

Send signal to tcpdump process and wait the process exit normally.
Add "VLAN_UDP" basic type which layers like Ether/Vlan/IP/UDP/Raw.

Signed-off-by: Marvin Liu <yong.liu@intel.com>

diff --git a/framework/packet.py b/framework/packet.py
index 238b94f..6d16a9e 100755
--- a/framework/packet.py
+++ b/framework/packet.py
@@ -36,7 +36,6 @@ Base on scapy(python program for packet manipulation)
 
 import os
 import time
-import signal
 import sys
 import re
 import signal
@@ -325,6 +324,7 @@ class Packet(object):
         'LLDP': {'layers': ['ether', 'lldp'], 'cfgload': False},
         'TCP': {'layers': ['ether', 'ipv4', 'tcp', 'raw'], 'cfgload': True},
         'UDP': {'layers': ['ether', 'ipv4', 'udp', 'raw'], 'cfgload': True},
+        'VLAN_UDP': {'layers': ['ether', 'dot1q', 'ipv4', 'udp', 'raw'], 'cfgload': True},
         'SCTP': {'layers': ['ether', 'ipv4', 'sctp', 'raw'], 'cfgload': True},
         'IPv6_TCP': {'layers': ['ether', 'ipv6', 'tcp', 'raw'], 'cfgload': True},
         'IPv6_UDP': {'layers': ['ether', 'ipv6', 'udp', 'raw'], 'cfgload': True},
@@ -578,6 +578,9 @@ class Packet(object):
 
         return strip_element(element)
 
+    def strip_element_layer2(self, element):
+        return self.pktgen.strip_layer2(element)
+
     def strip_element_dot1q(self, element):
         return self.pktgen.strip_dot1q(element)
 
@@ -668,7 +671,8 @@ def load_sniff_packets(index=''):
             time_elapse += 1
 
         if not child_exit:
-            pipe.kill()
+            pipe.send_signal(signal.SIGINT)
+            pipe.wait()
 
         # wait pcap file ready
         time.sleep(1)
@@ -709,7 +713,8 @@ def compare_pktload(pkt1=None, pkt2=None, layer="L2"):
 ###############################################################################
 if __name__ == "__main__":
     inst = sniff_packets("lo", timeout=5)
-    time.sleep(3)
+    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)
@@ -718,6 +723,9 @@ if __name__ == "__main__":
     pkt.send_pkt(tx_port='lo')
     pkt = Packet(pkt_type='IPv6_SCTP')
     pkt.send_pkt(tx_port='lo')
+    pkt = Packet(pkt_type='VLAN_UDP')
+    pkt.config_layer('dot1q', {'vlan': 2})
+    pkt.send_pkt(tx_port='lo')
 
     pkt = Packet()
     pkt.assign_layers(['ether', 'dot1q', 'ipv4', 'udp',
-- 
1.9.3

                 reply	other threads:[~2015-11-11 14:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=1447252929-6843-1-git-send-email-yong.liu@intel.com \
    --to=yong.liu@intel.com \
    --cc=dts@dpdk.org \
    /path/to/YOUR_REPLY

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

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