aboutsummaryrefslogtreecommitdiffstats
path: root/mpm/python/usrp_mpm
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2017-12-11 18:28:25 -0800
committerMartin Braun <martin.braun@ettus.com>2017-12-22 15:05:58 -0800
commit8210fc9b17336146e9691c5ebb0a40d139747cc5 (patch)
tree726ed39c9bbe0c52ac876e18bccb920fd7e1ba54 /mpm/python/usrp_mpm
parent0bf22a3e57dab4af3bfc66dbae999d3d9d11341b (diff)
downloaduhd-8210fc9b17336146e9691c5ebb0a40d139747cc5.tar.gz
uhd-8210fc9b17336146e9691c5ebb0a40d139747cc5.tar.bz2
uhd-8210fc9b17336146e9691c5ebb0a40d139747cc5.zip
mpm: xport: Let UDP manager re-enumerate available CHDR ifaces on init()
This will enumerate CHDR interfaces as late as possible, so that the user changing the IP address will not affect operations. Note that IP is considered static during a UHD session.
Diffstat (limited to 'mpm/python/usrp_mpm')
-rw-r--r--mpm/python/usrp_mpm/xports/xportmgr_udp.py34
1 files changed, 23 insertions, 11 deletions
diff --git a/mpm/python/usrp_mpm/xports/xportmgr_udp.py b/mpm/python/usrp_mpm/xports/xportmgr_udp.py
index 18573bad9..0a7f19ffc 100644
--- a/mpm/python/usrp_mpm/xports/xportmgr_udp.py
+++ b/mpm/python/usrp_mpm/xports/xportmgr_udp.py
@@ -39,22 +39,19 @@ class XportMgrUDP(object):
self.log.trace("Initializing UDP xport manager...")
self._possible_chdr_ifaces = self.iface_config.keys()
self.log.trace("Identifying available network interfaces...")
+ self.chdr_port = EthDispatcherTable.DEFAULT_VITA_PORT[0]
self._chdr_ifaces = \
self._init_interfaces(self._possible_chdr_ifaces)
- self._eth_dispatchers = {
- x: EthDispatcherTable(self.iface_config[x]['label'])
- for x in self._chdr_ifaces
- }
- for ifname, table in iteritems(self._eth_dispatchers):
- table.set_ipv4_addr(self._chdr_ifaces[ifname]['ip_addr'])
- self.chdr_port = EthDispatcherTable.DEFAULT_VITA_PORT[0]
+ self._eth_dispatchers = {}
def _init_interfaces(self, possible_ifaces):
"""
- Initialize the list of network interfaces
+ Enumerate all network interfaces that are currently able to stream CHDR
+ Returns a dictionary iface name -> iface info, where iface info is the
+ return value of get_iface_info().
"""
self.log.trace("Testing available interfaces out of `{}'".format(
- possible_ifaces
+ list(possible_ifaces)
))
valid_ifaces = net.get_valid_interfaces(possible_ifaces)
if len(valid_ifaces):
@@ -66,12 +63,27 @@ class XportMgrUDP(object):
for x in valid_ifaces
}
+ def _update_dispatchers(self):
+ """
+ Updates the self._eth_dispatchers dictionary, makes sure that all IP
+ addresses are programmed correctly.
+
+ After calling this, _chdr_ifaces and _eth_dispatchers are in sync.
+ """
+ for iface in self._chdr_ifaces:
+ if iface not in self._eth_dispatchers:
+ self._eth_dispatchers[iface] = \
+ EthDispatcherTable(self.iface_config[iface]['label'])
+ for ifname, table in iteritems(self._eth_dispatchers):
+ table.set_ipv4_addr(self._chdr_ifaces[ifname]['ip_addr'])
+
def init(self, args):
"""
Call this when the user calls 'init' on the periph manager
"""
- # TODO re-run _init_interfaces, IP addresses could have changed since
- # bootup
+ self._chdr_ifaces = \
+ self._init_interfaces(self._possible_chdr_ifaces)
+ self._update_dispatchers()
for _, table in iteritems(self._eth_dispatchers):
if 'forward_eth' in args or 'forward_bcast' in args:
table.set_forward_policy(