test suite reviews and discussions
 help / color / mirror / Atom feed
From: Herbert Guan <herbert.guan@arm.com>
To: dts@dpdk.org
Cc: Herbert Guan <herbert.guan@arm.com>
Subject: [dts] [PATCH] framework: enhance check_random_pkts by src/dst port filtering
Date: Thu, 21 Dec 2017 13:50:13 +0800	[thread overview]
Message-ID: <1513835413-13101-1-git-send-email-herbert.guan@arm.com> (raw)

There might be undesried packets captured when doing check_random_pkts,
such as dhcp packets, etc. Since check_random_pkts is setting src/dst
ports to 65535, src/dst port filter option can be added to avoiding
unwanted packets being captured and thus fail the test case.


Signed-off-by: Herbert Guan <herbert.guan@arm.com>
---
 framework/packet.py | 10 ++++++++++
 framework/tester.py |  4 +++-
 2 files changed, 13 insertions(+), 1 deletion(-)
 mode change 100644 => 100755 framework/tester.py

diff --git a/framework/packet.py b/framework/packet.py
index fc9c9cc..2aa2188 100755
--- a/framework/packet.py
+++ b/framework/packet.py
@@ -772,6 +772,16 @@ def get_filter_cmd(filters=[]):
                         filter_cmd = 'ether[12:2] = %s' % type_hex
                     elif m.group(1) == 'not':
                         filter_cmd = 'ether[12:2] != %s' % type_hex
+        elif pktfilter['layer'] == 'network':
+            if pktfilter['config'].keys()[0] == 'srcport':
+                sport = pktfilter['config']['srcport']
+                filter_cmd = "src port %s" % sport
+            elif pktfilter['config'].keys()[0] == 'dstport':
+                dport = pktfilter['config']['dstport']
+                filter_cmd = "dst port %s" % dport
+        elif pktfilter['layer'] == 'userdefined':
+            if pktfilter['config'].keys()[0] == 'pcap-filter':
+                filter_cmd = pktfilter['config']['pcap-filter']
 
         if len(filter_cmds):
             if len(filter_cmd):
diff --git a/framework/tester.py b/framework/tester.py
old mode 100644
new mode 100755
index 1c854d7..cca4276
--- a/framework/tester.py
+++ b/framework/tester.py
@@ -606,7 +606,9 @@ 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)
+            inst = sniff_f(intf=rxIntf, count=pktnum, timeout=timeout, filters=
+                [{'layer': 'network', 'config': {'srcport': '65535'}},
+                 {'layer': 'network', 'config': {'dstport': '65535'}}])
             rx_inst[rxport] = inst
 
         # Transmit packet simultaneously
-- 
1.8.3.1

             reply	other threads:[~2017-12-21  5:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-21  5:50 Herbert Guan [this message]
2018-01-02 17:07 ` Liu, Yong

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=1513835413-13101-1-git-send-email-herbert.guan@arm.com \
    --to=herbert.guan@arm.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).