1. 16 Mar, 2017 8 commits
  2. 15 Mar, 2017 4 commits
  3. 24 Feb, 2017 1 commit
  4. 23 Feb, 2017 1 commit
    • Thomas Haller's avatar
      device: mark uses of device's state-reason with nm_device_state_reason_check() · 405ee7ca
      Thomas Haller authored
      The state-change of a device has a reason argument, which is mostly for information
      only.
      
      There are many places in code that are the source of a state-reason.
      Mostly these are calls to:
        - nm_device_state_changed()
        - nm_device_queue_state()
        - nm_device_queue_recheck_available()
        - nm_device_set_unmanaged_by_*()
        - nm_device_master_release_one_slave()
        - nm_device_ip_method_failed()
        - nm_modem_emit_prepare_result()
        - nm_modem_emit_ppp_failed()
        - nm_manager_deactivate_connection()
        - NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_*);
      
      However, there are a few places in code that look at the reason
      to decide how to proceed. I think this is a bad pattern, because
      cause and effect are decoupled and it gets hard to understand where
      a certain reason is set and what consequences that has.
      
      Add a nop-function nm_device_state_reason_check() to mark all uses
      of the device state reason that derive decisions from it. That is,
      highlight the "effect" part.
      405ee7ca
  5. 17 Feb, 2017 1 commit
    • Thomas Haller's avatar
      device: separately handle NMDevice's autoconnect by user and internal decision · 2f9166e6
      Thomas Haller authored
      The NMDevice's autoconnect property is settable via D-Bus and is is
      also modified by internal decision, like when no PIN is available.
      
      Certain internal actions cause clearing the internal autoconnect flag,
      but they should not override the user desicion.
      
      For example, when NM awaks from sleep it would reenable autoconnect,
      but it should not reenable it for devices where the user explicitly
      said that autoconnect is to be disabled.
      
      Similarly, activating a device alone is not yet an instruction to
      re-enable autoconnect. If the user consciously disables autoconnect,
      it should stay enabled. On the other hand, activating a device should
      reenable autoconnect if it was blocked by internal decision.
      
      We need to track these two flags separately, and set them accordingly.
      2f9166e6
  6. 16 Feb, 2017 1 commit
  7. 10 Feb, 2017 8 commits
    • Thomas Haller's avatar
      core: define a full sort order for nm_settings_connection_cmp_timestamp() · ef6c3938
      Thomas Haller authored
      We want to have some guaranteed order when comparing different connections.
      So, in case of equal timestamps, proceed with comparing more properties.
      
      It makes sense to consider the autoconnect-priority next.
      This is what get_existing_connection() needs, thus we no longer
      need to pre-sort the list.
      ef6c3938
    • Thomas Haller's avatar
      core: consolidate sorting of connections by autoconnect/timestamp · 93f7ab2c
      Thomas Haller authored
      NMPolicy's auto_activate_device() wants to sort by autoconnect-priority,
      nm_utils_cmp_connection_by_autoconnect_priority() but fallback to the default
      nm_settings_connection_cmp_default(), which includes the timestamp.
      
      Extend nm_settings_connection_cmp_default() to consider the
      autoconnect-priority as well. Thus change behavior so that
      nm_settings_connection_cmp_default() is the sort order that
      auto_activate_device() wants. That makes sense, as
      nm_settings_connection_cmp_default() already considered the
      ability to autoconnect as first. Hence, it should also honor
      the autoconnect priority.
      
      When doing that, rename nm_settings_connection_cmp_default()
      to nm_settings_connection_cmp_autoconnect_priority().
      93f7ab2c
    • Thomas Haller's avatar
      core: refactor nm_manager_get_activatable_connections() to return an array · b3b1793f
      Thomas Haller authored
      ... instead of a GSList.
      b3b1793f
    • Thomas Haller's avatar
      core: refactor nm_settings_get_connections_sorted() to return array instead of GSList · 0861f47a
      Thomas Haller authored
      We call these functions a lot. A GSList is just the wrong tool for the
      job. Refactor the code to use instead a sorted array everywhere.
      
      This means, we malloc() one array for all connections instead
      slice-allocate a GSList item for each. Also, sorting an array
      is faster then sorting a GSList.
      Technically, the GSList implementation had the same big-O runtime
      complexity, but using an array is still faster. That is, sorting
      an array and a GSList is both O(n*log(n)).
      
      Actually, nm_settings_get_connections_sorted() used
      g_slist_insert_sorted() instead of g_slist_sort(). That results
      in O(n^2). That could have been fixed to have O(n*log(n)), but
      instead refactor the code to use an array.
      0861f47a
    • Thomas Haller's avatar
      core: drop nm_settings_get_best_connections() for new nm_settings_get_connections_clone() · da072ff0
      Thomas Haller authored
      nm_settings_get_best_connections() has only one caller: to create
      the hidden-SSID list.
      
      Instead of having a highly specialised function (that accepts 3 ways for
      filtering -- one of them broken, has one hard-coded way of sorting, and
      a @max_requested argument), add a more generic nm_settings_get_connections_clone()
      function.
      
      Also invert nm_settings_sort_connections(). The two callers want
      to sort descending, not ascending.
      da072ff0
    • Thomas Haller's avatar
      core: add and use nm_settings_connection_cmp_timestamp*() · 5c5845c6
      Thomas Haller authored
      Only move the function, no change in behavior.
      5c5845c6
    • Thomas Haller's avatar
      all: use NM_CACHED_QUARK_FCN() instead of G_DEFINE_QUARK() · 7d6b8bab
      Thomas Haller authored
      I think NM_CACHED_QUARK_FCN() is better because:
      
      - the implementation is in our hand, meaning it is clear that
        putting a "static" before NM_CACHED_QUARK_FCN() is guaranteed to
        work -- without relying on G_DEFINE_QUARK() to be defined in a way
        that this works (in fact, we currently never do that and instead
        make all functions non-static).
      - it does not construct function names by appending "_quark".
        Thus you can grep for the entire function name and finding
        the place where it is implemented.
      - same with the stings, where the new macro doesn't stringify the
        argument, which is less surpising. Again, now you can grep
        for the string including the double quoting.
      
      (yes, I really use grep to understand the source-code)
      7d6b8bab
    • Thomas Haller's avatar
      core: use cached GQuark and g_object_[gs]et_qdata() · 8538b61e
      Thomas Haller authored
      Use g_object_[gs]et_qdata() instead of g_object_[gs]et_data() with a cached
      quark. This saves an additional lookup to intern the string.
      8538b61e
  8. 27 Jan, 2017 2 commits
  9. 25 Jan, 2017 2 commits
    • Lubomir Rintel's avatar
      manager: don't let a master device go unmanaged on a slave activation · cd8e8ab1
      Lubomir Rintel authored
      If a slave device activates, we should keep the master up even though it
      was taken over before.
      
      This fixes an issue, where a single slave to a master would be
      reactivated after a daemon restart. The daemon restart would cause the
      master to be treated externally created (would go unmanaged when all the
      slaves are gone) while the reactivation would leave the master without
      slaves for a while.
      
      (cherry picked from commit b605fb27)
      cd8e8ab1
    • Lubomir Rintel's avatar
      manager: don't let a master device go unmanaged on a slave activation · b605fb27
      Lubomir Rintel authored
      If a slave device activates, we should keep the master up even though it
      was taken over before.
      
      This fixes an issue, where a single slave to a master would be
      reactivated after a daemon restart. The daemon restart would cause the
      master to be treated externally created (would go unmanaged when all the
      slaves are gone) while the reactivation would leave the master without
      slaves for a while.
      b605fb27
  10. 16 Jan, 2017 1 commit
  11. 04 Jan, 2017 2 commits
  12. 23 Dec, 2016 1 commit
  13. 15 Dec, 2016 1 commit
  14. 14 Dec, 2016 2 commits
    • Beniamino Galvani's avatar
      manager: don't upgrade the state when connectivity check fails · 7375822c
      Beniamino Galvani authored
      If a connection is ACTIVATED and another one is ACTIVATING but there
      is no global connectivity, we currently set the manager state to
      CONNECTING and start a connectivity check to verify whether the
      manager state can be promoted to CONNECTED_GLOBAL.
      
      If this connectivity check fails, we shouldn't promote a CONNECTING
      state to CONNECTED_SITE.
      
      Fixes: 084da69a
      7375822c
    • Beniamino Galvani's avatar
      manager: don't update the manager state in get_property() · 4cc45ee2
      Beniamino Galvani authored
      The manager state is already computed every time an active connection
      changes state, it is not necessary to call nm_manager_update_state()
      also when the property is read.
      
      Moreover, nm_manager_update_state() emits a "notify::state" signal
      which causes a re-read of the property by the nm-exported-object,
      resulting in a nested execution of nm_manager_update_state().
      4cc45ee2
  15. 13 Dec, 2016 1 commit
  16. 29 Nov, 2016 1 commit
    • Beniamino Galvani's avatar
      manager: fix state transition on resuming from sleep · 5f1e36e0
      Beniamino Galvani authored
      When going to sleep, we unmanage devices setting the unmanaged flags
      immediately but delaying the state transition (because we do it from
      another state transition). The signal handler can be executed after
      the wake and, especially, after we have already re-managed the device,
      making the device unmanaged again.
      
      Detect such situation and force the state to UNMANAGED (which will
      also clear any pending state change), so that later we manage the
      device again and it will try to activate any available connection.
      
      Fixes: 81ea8123
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1382526
      5f1e36e0
  17. 23 Nov, 2016 1 commit
  18. 21 Nov, 2016 1 commit
    • Thomas Haller's avatar
      build: don't add subdirectories to include search path but require qualified include · 44ecb415
      Thomas Haller authored
      Keep the include paths clean and separate. We use directories to group source
      files together. That makes sense (I guess), but then we should use this
      grouping also when including files. Thus require to #include files with their
      path relative to "src/".
      
      Also, we build various artifacts from the "src/" tree. Instead of having
      individual CFLAGS for each artifact in Makefile.am, the CFLAGS should be
      unified. Previously, the CFLAGS for each artifact differ and are inconsistent
      in which paths they add to the search path. Fix the inconsistency by just
      don't add the paths at all.
      44ecb415
  19. 09 Nov, 2016 1 commit