pretend virtual wlan (i.e. mac80211_hwsim) devices are real

this allows their use for testing
This commit is contained in:
Michael Hudson-Doyle 2021-06-02 12:23:18 +12:00
parent d14fd35330
commit 47b2836aee
1 changed files with 11 additions and 3 deletions

View File

@ -421,11 +421,18 @@ class NetworkModel(object):
def new_link(self, ifindex, link):
log.debug("new_link %s %s %s", ifindex, link.name, link.type)
if link.type in NETDEV_IGNORED_IFACE_TYPES:
log.debug('ignoring based on type')
return
if not self.support_wlan and link.type == "wlan":
log.debug('ignoring based on support_wlan')
return
if link.is_virtual and (
link.type not in NETDEV_ALLOWED_VIRTUAL_IFACE_TYPES):
is_virtual = link.is_virtual
if link.type == "wlan":
# mac80211_hwsim nics show up as virtual but we pretend
# they are real for testing purposes.
is_virtual = False
if is_virtual and link.type not in NETDEV_ALLOWED_VIRTUAL_IFACE_TYPES:
log.debug('ignoring based on is_virtual')
return
dev = self.devices_by_name.get(link.name)
if dev is not None:
@ -438,9 +445,10 @@ class NetworkModel(object):
dev.info = link
else:
config = self.config.config_for_device(link)
if link.is_virtual and not config:
if is_virtual and not config:
# If we see a virtual device without there already
# being a config for it, we just ignore it.
log.debug('ignoring virtual device with no config')
return
dev = NetworkDev(self, link.name, link.type)
dev.info = link