summaryrefslogtreecommitdiffstats
path: root/src/osmo_gsm_tester/pcap_recorder.py
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2018-10-26 15:53:35 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2018-10-31 09:59:02 +0100
commit772b2b14bbae02d36f9f815706d59186a08b2556 (patch)
treee8fc8765bb4b3f38306e4ddac7a172dd5a3441d7 /src/osmo_gsm_tester/pcap_recorder.py
parentfd4c14404908c683a00e9132a50fdb9a91ccd698 (diff)
pcap_recorder: Add support to run in netns
Diffstat (limited to 'src/osmo_gsm_tester/pcap_recorder.py')
-rw-r--r--src/osmo_gsm_tester/pcap_recorder.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/osmo_gsm_tester/pcap_recorder.py b/src/osmo_gsm_tester/pcap_recorder.py
index 98dea8b..70833d0 100644
--- a/src/osmo_gsm_tester/pcap_recorder.py
+++ b/src/osmo_gsm_tester/pcap_recorder.py
@@ -26,7 +26,7 @@ from . import log, util, config, template, process, osmo_ctrl
class PcapRecorder(log.Origin):
- def __init__(self, suite_run, run_dir, iface=None, filters=''):
+ def __init__(self, suite_run, run_dir, iface=None, filters='', netns=None):
self.iface = iface
if not self.iface:
self.iface = "any"
@@ -34,16 +34,20 @@ class PcapRecorder(log.Origin):
super().__init__(log.C_RUN, 'pcap-recorder_%s' % self.iface, filters=self.filters)
self.suite_run = suite_run
self.run_dir = run_dir
+ self.netns = netns
self.start()
def start(self):
self.dbg('Recording pcap', self.run_dir, self.filters)
dumpfile = os.path.join(os.path.abspath(self.run_dir), self.name() + ".pcap")
- self.process = process.Process(self.name(), self.run_dir,
- ('tcpdump', '-n',
- '-i', self.iface,
- '-w', dumpfile,
- self.filters))
+ popen_args = ('tcpdump', '-n',
+ '-i', self.iface,
+ '-w', dumpfile,
+ self.filters)
+ if self.netns:
+ self.process = process.NetNSProcess(self.name(), self.run_dir, self.netns, popen_args)
+ else:
+ self.process = process.Process(self.name(), self.run_dir, popen_args)
self.suite_run.remember_to_stop(self.process)
self.process.launch()