diff options
author | Martin Braun <martin.braun@ettus.com> | 2018-06-08 14:03:14 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-06-08 14:58:20 -0700 |
commit | 444857598f096764a035fbc9cebb75d97250211e (patch) | |
tree | 6d727392df8a78e12c0b485366ac84a55cfdcd7d /mpm/python | |
parent | 8762a4d444e0ba68b133245e4984763a9521037a (diff) | |
download | uhd-444857598f096764a035fbc9cebb75d97250211e.tar.gz uhd-444857598f096764a035fbc9cebb75d97250211e.tar.bz2 uhd-444857598f096764a035fbc9cebb75d97250211e.zip |
mpm: xportmgr_udp: Catch inconsistent Ethernet device detections
This manager first detects all valid Ethernet devices. The checks for
validity happen across multiple calls in a non-atomic fashion, so it's
possible to end up with inconsistent results. To avoid such issues, we
filter results without talking to the network stack as a final pass.
Diffstat (limited to 'mpm/python')
-rw-r--r-- | mpm/python/usrp_mpm/xports/xportmgr_udp.py | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/mpm/python/usrp_mpm/xports/xportmgr_udp.py b/mpm/python/usrp_mpm/xports/xportmgr_udp.py index 74b3bccfc..6e355115e 100644 --- a/mpm/python/usrp_mpm/xports/xportmgr_udp.py +++ b/mpm/python/usrp_mpm/xports/xportmgr_udp.py @@ -59,15 +59,34 @@ class XportMgrUDP(object): self.log.trace("Testing available interfaces out of `{}'".format( list(possible_ifaces) )) - valid_ifaces = net.get_valid_interfaces(possible_ifaces) - if len(valid_ifaces): - self.log.debug("Found CHDR interfaces: `{}'".format(valid_ifaces)) - else: - self.log.info("No CHDR interfaces found!") - return { + valid_iface_infos = { x: net.get_iface_info(x) - for x in valid_ifaces + for x in net.get_valid_interfaces(possible_ifaces) } + # Because get_iface_info() and get_valid_interfaces() are not one atomic + # operation, there are rare scenarios when their return values are + # inconsistent. To catch these cases, we filter the list again and warn + # the user. Usually, this is not a problem and the next call to + # _init_interfaces() will be back to normal. + valid_iface_infos_filtered = { + x: valid_iface_infos[x] + for x in valid_iface_infos + if valid_iface_infos[x]['ip_addr'] + } + if len(valid_iface_infos) != len(valid_iface_infos_filtered): + self.log.warning( + "Number of detected CHDR devices is inconsistent. Dropped from " + "{} to {}." + .format(len(valid_iface_infos), len(valid_iface_infos_filtered)) + ) + if len(valid_iface_infos_filtered): + self.log.debug( + "Found CHDR interfaces: `{}'" + .format(", ".join(list(valid_iface_infos.keys()))) + ) + else: + self.log.info("No CHDR interfaces found!") + return valid_iface_infos_filtered def _update_dispatchers(self): """ |