From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id DB0AC231C for ; Wed, 11 Nov 2015 15:42:17 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 11 Nov 2015 06:42:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,276,1444719600"; d="scan'208";a="847932727" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 11 Nov 2015 06:42:15 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id tABEgELC011610; Wed, 11 Nov 2015 22:42:14 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id tABEgAKO006879; Wed, 11 Nov 2015 22:42:12 +0800 Received: (from yliu84x@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id tABEgAxt006875; Wed, 11 Nov 2015 22:42:10 +0800 From: Yong Liu To: dts@dpdk.org Date: Wed, 11 Nov 2015 22:42:09 +0800 Message-Id: <1447252929-6843-1-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dts] [PATCH] framework packet: kindly terminate sniff process X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Nov 2015 14:42:18 -0000 From: Marvin Liu 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 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