[MERGED] osmo-gsm-tester[master]: pcap: pass complete filter string to PcapRecorder

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Mon May 15 12:50:09 UTC 2017


Neels Hofmeyr has submitted this change and it was merged.

Change subject: pcap: pass complete filter string to PcapRecorder
......................................................................


pcap: pass complete filter string to PcapRecorder

Composing the filter in gen_filter() is more complex than we need. We pass the
address and potentially further filter elements separately, and then
gen_filter() has to guess how to combine these. Instead, have just a filter
string to use right from the start, so that the caller has full control (and
full responsibility).

Remove the addr argument, which was only used for filtering.

This is my conclusion of looking at the patches with change Ids
I62a6ae7bd3a84baceb684c26727d2269c86ed023 (PS 1) and
Icbb0f8d2058fa7ebb7f0f731645f9266cacdb120

I62... PS 2 will add the SSH filtering.

The name 'filter' is a python built-in, which is why I chose the argument
name 'filters' instead. It works with 'filter' as well, but let's try to
avoid naming conflicts like that.

Change-Id: Iff7ddf51d3bf0189ce07b488a3dcdcfce6907aba
---
M src/osmo_gsm_tester/osmo_nitb.py
M src/osmo_gsm_tester/pcap_recorder.py
2 files changed, 5 insertions(+), 12 deletions(-)

Approvals:
  Pau Espin Pedrol: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/osmo_gsm_tester/osmo_nitb.py b/src/osmo_gsm_tester/osmo_nitb.py
index 6ead67a..835bf13 100644
--- a/src/osmo_gsm_tester/osmo_nitb.py
+++ b/src/osmo_gsm_tester/osmo_nitb.py
@@ -52,8 +52,8 @@
             raise RuntimeError('No lib/ in %r' % inst)
 
         iface = util.ip_to_iface(self.addr())
-        pcap_recorder.PcapRecorder(self.suite_run, self.run_dir.new_dir('pcap'),
-                                   iface, self.addr())
+        pcap_recorder.PcapRecorder(self.suite_run, self.run_dir.new_dir('pcap'), iface,
+                                   'host %s' % self.addr())
 
         env = { 'LD_LIBRARY_PATH': util.prepend_library_path(lib) }
 
diff --git a/src/osmo_gsm_tester/pcap_recorder.py b/src/osmo_gsm_tester/pcap_recorder.py
index 8b1fe82..3b3c307 100644
--- a/src/osmo_gsm_tester/pcap_recorder.py
+++ b/src/osmo_gsm_tester/pcap_recorder.py
@@ -26,13 +26,13 @@
 
 class PcapRecorder(log.Origin):
 
-    def __init__(self, suite_run, run_dir, iface=None, addr=None):
+    def __init__(self, suite_run, run_dir, iface=None, filters=''):
         self.suite_run = suite_run
         self.run_dir = run_dir
         self.iface = iface
         if not self.iface:
             self.iface = "any"
-        self.addr = addr
+        self.filters = filters
         self.set_log_category(log.C_RUN)
         self.set_name('pcap-recorder_%s' % self.iface)
         self.start()
@@ -44,16 +44,9 @@
                                        ('tcpdump', '-n',
                                        '-i', self.iface,
                                        '-w', dumpfile,
-                                       self.gen_filter())
-                                       )
+                                       self.filters))
         self.suite_run.remember_to_stop(self.process)
         self.process.launch()
-
-    def gen_filter(self):
-        filter = ""
-        if self.addr:
-            filter += 'host ' + self.addr
-        return filter
 
     def running(self):
         return not self.process.terminated()

-- 
To view, visit https://gerrit.osmocom.org/2629
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Iff7ddf51d3bf0189ce07b488a3dcdcfce6907aba
Gerrit-PatchSet: 3
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>



More information about the gerrit-log mailing list