Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

network: fix crash when Wi-Fi or eth interface gets removed from the system #1789

Merged
merged 1 commit into from Sep 7, 2023

Commits on Sep 7, 2023

  1. network: fix crash when Wi-Fi or eth interface gets removed from the …

    …system
    
    When a network interface is disconnected from the system (e.g.,
    physically removed if it's a USB adapter), probert asynchronously calls
    the del_link() method.
    
    Upon receiving this notification, Subiquity server wants to send an
    update to the Subiquity clients. The update contains information about
    the interface that disappeared - which is obtained through a call to
    netdev_info.
    
    Unfortunately, for Wi-Fi and Ethernet interfaces, netdev_info
    dereferences the NetworkDev.info variable. Interfaces that no longer
    exist on the system (and also interfaces that do not yet exist), have
    their "info" variable set to None - so an exception is raised when
    dereferencing it.
    
    Wi-Fi interface:
    
        File "subiquitycore/models/network.py", line 227, in netdev_info
          scan_state=self.info.wlan['scan_state'],
      AttributeError: 'NoneType' object has no attribute 'wlan'
    
    Ethernet interface:
    
        File "subiquitycore/models/network.py", line 201, in netdev_info
          is_connected = bool(self.info.is_connected)
      AttributeError: 'NoneType' object has no attribute 'is_connected'
    
    Fixed by making sure netdev_info does not raise if the dev.info variable
    is None. This is a valid use-case.
    
    Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
    ogayot committed Sep 7, 2023
    Configuration menu
    Copy the full SHA
    e10343b View commit details
    Browse the repository at this point in the history