diff --git a/daq/base_gateway.py b/daq/base_gateway.py index c7b8ff7c2..62689599c 100644 --- a/daq/base_gateway.py +++ b/daq/base_gateway.py @@ -71,8 +71,8 @@ def _initialize(self): vol_maps = [os.path.abspath(os.path.join(DAQ_RUN_DIR, 'config')) + ':/config/inst'] host = self.runner.add_host(host_name, port=host_port, cls=cls, tmpdir=self.tmpdir, vol_maps=vol_maps, env_vars=env_vars) - host.activate() self.host = host + host.activate() self.host_intf = self.runner.get_host_interface(host) LOGGER.info("Added networking host %s on port %d at %s as %s", host_name, host_port, host.IP(), self.host_intf) diff --git a/daq/host.py b/daq/host.py index a9a8c078a..1785d42a2 100644 --- a/daq/host.py +++ b/daq/host.py @@ -558,7 +558,7 @@ def _shorten_filename(self, long_name): def _monitor_scan(self, output_file, timeout=None): assert not self._monitor_ref, 'tcp_monitor already active' network = self.runner.network - tcp_filter = '' + tcp_filter = 'ether broadcast or ether host %s' % self.device.mac self.logger.info('Target device %s pcap intf %s for %s seconds output in %s', self, self._mirror_intf_name, timeout if timeout else 'infinite', self._shorten_filename(output_file)) diff --git a/daq/network.py b/daq/network.py index d8ce91079..4c0b2ed40 100644 --- a/daq/network.py +++ b/daq/network.py @@ -100,7 +100,12 @@ def add_host(self, name, cls=DAQHost, ip_addr=None, env_vars=None, vol_maps=None params['tmpdir'] = os.path.join(tmpdir, 'nodes') if tmpdir else None params['env_vars'] = env_vars if env_vars else [] params['vol_maps'] = vol_maps if vol_maps else [] - host = self.net.addHost(name, cls, **params) + try: + host = self._retry_func(partial(self.net.addHost, name, cls, **params)) + except Exception as e: + # If addHost fails, ip allocation needs to be explicityly cleaned up. + self._reset_mininet_next_ip() + raise e try: switch_link = self._retry_func( partial(self.net.addLink, self.pri, host, port1=port, fast=False)) @@ -145,14 +150,17 @@ def _switch_del_intf(self, switch, intf): del switch.ports[intf] del switch.nameToIntf[intf.name] + def _reset_mininet_next_ip(self): + # Resets Mininet's next ip so subnet ips don't run out. + # IP overrides are excluded from this set. + self.net.nextIP = max(self._used_ip_indices or [0]) + 1 + def remove_host(self, host): """Remove a host from the ecosystem""" index = self.net.hosts.index(host) if host.IP() and self._get_host_ip_index(host) in self._used_ip_indices: - # Resets Mininet's next ip so subnet ips don't run out. - # IP overrides are excluded from this set. self._used_ip_indices.remove(self._get_host_ip_index(host)) - self.net.nextIP = max(self._used_ip_indices or [0]) + 1 + self._reset_mininet_next_ip() if index: del self.net.hosts[index] if host in self.switch_links: diff --git a/debian/control b/debian/control index 173982d03..0a495ad33 100644 --- a/debian/control +++ b/debian/control @@ -20,6 +20,7 @@ Depends: python3-mininet, python3-cairocffi, arp-scan, nmap, + jq, weasyprint, python3-pypandoc, python3-netifaces,