Skip to content
  • Thomas Haller's avatar
    device: track system interface state in NMDevice · 850c9779
    Thomas Haller authored
    When deciding whether to touch a device we sometimes look at whether
    the active connection is external/assumed. In many cases however,
    there is no active connection around (e.g. while moving the device
    from state unmanaged to disconnected before assuming).
    So in most cases we instead look at the device-state-reason to decide
    whether to touch the interface (see nm_device_state_reason_check()).
    
    Often it's desirable to have no state and passing data as function
    arguments. However, the state reason has to be passed along several hops
    (e.g. a queued state change). Or a change to a master/slave can affect
    the slave/master, where we pass on the state reason. Or an intermediate
    event might invalidate a previous state reason. Passing the state
    whether to touch a device or not as a state-reason is cumbersome
    and limited.
    
    Instead, the device should be aware of whats going on. Add a
    sys-iface-state with:
      - SYS_IFACE_STATE_EXTERNAL: meaning, NM should not touch it
      - SYS_IFACE_STATE_ASSUME: meaning, NM is gracefully taking over
      - SYS_IFACE_STATE_MANAGED: meaning, the device is managed by NM
      - SYS_IFACE_STATE_REMOVED: the device no longer exists
    
    This replaces most checks of nm_device_state_reason_check() and
    nm_active_connection_get_activation_type() by instead looking at
    the sys-iface-state of the device.
    
    This patch probably has still issues, but the previous behavior was
    not very clear either. We will need to identify those issues in future
    tests and tweak the behavior. At least, now there is one flag that
    describes how to behave.
    850c9779