diff options
author | Steven Koo <steven.koo@ni.com> | 2020-08-19 17:34:37 -0500 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2020-08-19 18:05:10 -0500 |
commit | 92b2127909465de66cf700f762dbdf82c2068481 (patch) | |
tree | e0ba606ed0171e1ce2118d79949497ec0db13a49 /mpm/python | |
parent | 2a8ba91c1b7a8b98dfe118bf5bc750f0ea67b98c (diff) | |
download | uhd-92b2127909465de66cf700f762dbdf82c2068481.tar.gz uhd-92b2127909465de66cf700f762dbdf82c2068481.tar.bz2 uhd-92b2127909465de66cf700f762dbdf82c2068481.zip |
mpm: exclude internal nic for network hosts
Sometimes the internal nic address is routable in network mode. This
causes mpm find to incorrectly set it as the addr. This commit removes
the internal interfaces from the routable list. This also sets the
forwarding interface as the last resort. mpm will prefer the SFP ports
since they can be higher throughput.
Signed-off-by: Steven Koo <steven.koo@ni.com>
Diffstat (limited to 'mpm/python')
-rw-r--r-- | mpm/python/usrp_mpm/xports/xportmgr_udp.py | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/mpm/python/usrp_mpm/xports/xportmgr_udp.py b/mpm/python/usrp_mpm/xports/xportmgr_udp.py index 7c8680b09..099a67d2a 100644 --- a/mpm/python/usrp_mpm/xports/xportmgr_udp.py +++ b/mpm/python/usrp_mpm/xports/xportmgr_udp.py @@ -172,11 +172,42 @@ class XportMgrUDP: In this case, returns the available IP addresses. """ - available_interfaces = self._init_interfaces(self._possible_chdr_ifaces) - return dict(zip( - ("addr", "second_addr", "third_addr", "fourth_addr"), - (x['ip_addr'] for x in itervalues(available_interfaces)) + # This section of code is intended to prioritize + # the sfp interfaces over the fowarding interface + chdr_interfaces = [ + iface + for iface in self._possible_chdr_ifaces + if(self.iface_config[iface]['type'] != 'internal') + ] + forward_interfaces = [ + iface + for iface in chdr_interfaces + if(self.iface_config[iface]['type'] == 'forward') + ] + + # Call _init_interfaces once to get all valid interfaces then + # split out the forward interfaces from the external interfaces + # _init_interfaces calls cannot be split because it emits + # a user facing warning if no CHDR valid interfaces are found + available_chdr_interfaces = self._init_interfaces(chdr_interfaces) + external_chdr_interfaces = available_chdr_interfaces + forward_chdr_interfaces = {} + for iface in forward_interfaces: + if iface in external_chdr_interfaces.keys(): + forward_chdr_interfaces[iface] = external_chdr_interfaces.pop(iface) + + # Create two dictionaries + # One for the external/sfp interfaces and another forwarding interfaces + # fourth_addr is the lowest priority for mpmd interface selection + external_ip_dict = dict(zip( + ("addr", "second_addr", "third_addr"), + (x['ip_addr'] for x in itervalues(external_chdr_interfaces)) + )) + forward_ip_dict = dict(zip( + ("fourth_addr",), + (x['ip_addr'] for x in itervalues(forward_chdr_interfaces)) )) + return {**external_ip_dict, **forward_ip_dict} def get_chdr_link_options(self, host_location = 'all'): """ |