1. 17 Sep, 2018 1 commit
  2. 15 Sep, 2018 1 commit
  3. 24 Jul, 2018 3 commits
    • Thomas Haller's avatar
      core: give better error reason why device is incompatible with profile · 33a88ca5
      Thomas Haller authored
      Note the special error codes  NM_UTILS_ERROR_CONNECTION_AVAILABLE_*.
      This will be used to determine, whether the profile is fundamentally
      incompatible with the device, or whether just some other properties
      mismatch. That information will be importand during a plain `nmcli
      connection up`, where NetworkManager searches all devices for a device
      to activate. If no device is found (and multiple errors happened),
      we want to show the error that is most likely relevant for the user.
      
      Also note, how NMDevice's check_connection_compatible() uses the new
      class field "device_class->connection_type_check_compatible" to simplify
      checks for compatible profiles.
      
      The error reason is still unused.
      33a88ca5
    • Thomas Haller's avatar
      core: give better error reason why device is unavailable · 570e1fa7
      Thomas Haller authored
      The error reason is still unused.
      570e1fa7
    • Thomas Haller's avatar
      wwan/trivial: rename NMModemClass.check_connection_compatible() to use unique name · 39f47e2f
      Thomas Haller authored
      We also have NMDeviceClass.check_connection_compatible(). It is preferable
      to use unique names, especially for the virtual function table. A reasonable
      thing to do is grep for the function name to find all places that implement
      this function. But if different classes use the same name, grep just
      turns up annoying false positives.
      39f47e2f
  4. 11 Jul, 2018 1 commit
    • Thomas Haller's avatar
      all: don't use gchar/gshort/gint/glong but C types · e1c7a2b5
      Thomas Haller authored
      We commonly don't use the glib typedefs for char/short/int/long,
      but their C types directly.
      
          $ git grep '\<g\(char\|short\|int\|long\|float\|double\)\>' | wc -l
          587
          $ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l
          21114
      
      One could argue that using the glib typedefs is preferable in
      public API (of our glib based libnm library) or where it clearly
      is related to glib, like during
      
        g_object_set (obj, PROPERTY, (gint) value, NULL);
      
      However, that argument does not seem strong, because in practice we don't
      follow that argument today, and seldomly use the glib typedefs.
      Also, the style guide for this would be hard to formalize, because
      "using them where clearly related to a glib" is a very loose suggestion.
      
      Also note that glib typedefs will always just be typedefs of the
      underlying C types. There is no danger of glib changing the meaning
      of these typedefs (because that would be a major API break of glib).
      
      A simple style guide is instead: don't use these typedefs.
      
      No manual actions, I only ran the bash script:
      
        FILES=($(git ls-files '*.[hc]'))
        sed -i \
            -e 's/\<g\(char\|short\|int\|long\|float\|double\)\>\( [^ ]\)/\1\2/g' \
            -e 's/\<g\(char\|short\|int\|long\|float\|double\)\>  /\1   /g' \
            -e 's/\<g\(char\|short\|int\|long\|float\|double\)\>/\1/g' \
            "${FILES[@]}"
      e1c7a2b5
  5. 28 Jun, 2018 1 commit
  6. 23 Jun, 2018 1 commit
    • Beniamino Galvani's avatar
      device: introduce mtu source · ccecc6db
      Beniamino Galvani authored
      Instead of returning a boolean @is_user_config value from
      get_configured_mtu(), return an mtu-source enum with possible values
      NONE,CONNECTION. This enum will be expanded later; for now there is no
      change in behavior.
      
      (cherry picked from commit 9f8b0697)
      ccecc6db
  7. 20 Jun, 2018 1 commit
    • Beniamino Galvani's avatar
      device: introduce mtu source · 9f8b0697
      Beniamino Galvani authored
      Instead of returning a boolean @is_user_config value from
      get_configured_mtu(), return an mtu-source enum with possible values
      NONE,CONNECTION. This enum will be expanded later; for now there is no
      change in behavior.
      9f8b0697
  8. 13 Jun, 2018 2 commits
  9. 25 May, 2018 1 commit
    • Thomas Haller's avatar
      ppp-manager: rework stopping NMPPPManager by merging async/sync methods · 43f67b42
      Thomas Haller authored
      Previously, there were two functions nm_ppp_manager_stop_sync() and
      nm_ppp_manager_stop_async().
      
      However, stop-sync() would still kill the process asynchronously (with a
      2 seconds timeout before sending SIGKILL).
      
      On the other hand, stop-async() did pretty much the same thing as
      sync-code, except also using the GAsyncResult.
      
      Merge the two functions. Stopping the instance for the most part can be
      done entirely synchrnous. The only thing that is asynchronous, is
      to wait for the process to terminate. For that, add a new callback
      argument to nm_ppp_manager_stop(). This replaces the GAsyncResult
      pattern.
      
      Also, always ensure that NetworkManager runs the mainloop at least as
      long until the process really terminated. Currently we don't get that
      right, and during shutdown we just stop iterating the mainloop. However,
      fix this from point of view of NMPPPManager and register a wait-object,
      that later will correctly delay shutdown.
      
      Also, NMDeviceWwan cared to wait (asynchronously) until pppd really
      terminated. Keep that functionality. nm_ppp_manager_stop() returns
      a handle that can be used to cancel the asynchrounous request and invoke
      the callback right away. However note, that even when cancelling the
      request, the wait-object that prevents shutdown of NetworkManager is
      kept around, so that we can be sure to properly clean up.
      43f67b42
  10. 18 May, 2018 1 commit
  11. 10 May, 2018 1 commit
    • Lubomir Rintel's avatar
      all: use the elvis operator wherever possible · e69d3869
      Lubomir Rintel authored
      Coccinelle:
      
        @@
        expression a, b;
        @@
        -a ? a : b
        +a ?: b
      
      Applied with:
      
        spatch --sp-file ternary.cocci --in-place --smpl-spacing --dir .
      
      With some manual adjustments on spots that Cocci didn't catch for
      reasons unknown.
      
      Thanks to the marvelous effort of the GNU compiler developer we can now
      spare a couple of bits that could be used for more important things,
      like this commit message. Standards commitees yet have to catch up.
      e69d3869
  12. 09 May, 2018 1 commit
  13. 30 Apr, 2018 1 commit
  14. 20 Mar, 2018 2 commits
    • Thomas Haller's avatar
      core: avoid clone of all-connections list for nm_utils_complete_generic() · e17cd1d7
      Thomas Haller authored
      NMSettings exposes a cached list of all connection. We don't need
      to clone it. Note that this is not save against concurrent modification,
      meaning, add/remove of connections in NMSettings will invalidate the
      list.
      
      However, it wasn't save against that previously either, because
      altough we cloned the container (GSList), we didn't take an additional
      reference to the elements.
      
      This is purely a performance optimization, we don't need to clone the
      list. Also, since the original list is of type "NMConnection *const*",
      use that type insistently, instead of dependent API requiring GSList.
      
      IMO, GSList is anyway not a very nice API for many use cases because
      it requires an additional slice allocation for each element. It's
      slower, and often less convenient to use.
      e17cd1d7
    • Thomas Haller's avatar
      ofono: fix crash during complete-connection for Ofono modem · 14adbc69
      Thomas Haller authored
      nm_modem_complete_connection() cannot just return FALSE in case
      the modem doesn't overwrite complete_connection(). It must set
      the error variable.
      
      This leads to a crash when calling AddAndActivate for Ofono type
      modem. It does not affect the ModemManager implementation
      NMModemBroadband, because that one implements the method.
      14adbc69
  15. 19 Mar, 2018 1 commit
  16. 12 Mar, 2018 1 commit
    • Thomas Haller's avatar
      core/dbus: rework D-Bus implementation to use lower layer GDBusConnection API · 297d4985
      Thomas Haller authored
      Previously, we used the generated GDBusInterfaceSkeleton types and glued
      them via the NMExportedObject base class to our NM types. We also used
      GDBusObjectManagerServer.
      
      Don't do that anymore. The resulting code was more complicated despite (or
      because?) using generated classes. It was hard to understand, complex, had
      ordering-issues, and had a runtime and memory overhead.
      
      This patch refactors this entirely and uses the lower layer API GDBusConnection
      directly. It replaces the generated code, GDBusInterfaceSkeleton, and
      GDBusObjectManagerServer. All this is now done by NMDbusObject and NMDBusManager
      and static descriptor instances of type GDBusInterfaceInfo.
      
      This adds a net plus of more then 1300 lines of hand written code. I claim
      that this implementation is easier to understand. Note that previously we
      also required extensive and complex glue code to bind our objects to the
      generated skeleton objects. Instead, now glue our objects directly to
      GDBusConnection. The result is more immediate and gets rid of layers of
      code in between.
      Now that the D-Bus glue us more under our control, we can address issus and
      bottlenecks better, instead of adding code to bend the generated skeletons
      to our needs.
      
      Note that the current implementation now only supports one D-Bus connection.
      That was effectively the case already, although there were places (and still are)
      where the code pretends it could also support connections from a private socket.
      We dropped private socket support mainly because it was unused, untested and
      buggy, but also because GDBusObjectManagerServer could not export the same
      objects on multiple connections. Now, it would be rather straight forward to
      fix that and re-introduce ObjectManager on each private connection. But this
      commit doesn't do that yet, and the new code intentionally supports only one
      D-Bus connection.
      Also, the D-Bus startup was simplified. There is no retry, either nm_dbus_manager_start()
      succeeds, or it detects the initrd case. In the initrd case, bus manager never tries to
      connect to D-Bus. Since the initrd scenario is not yet used/tested, this is good enough
      for the moment. It could be easily extended later, for example with polling whether the
      system bus appears (like was done previously). Also, restart of D-Bus daemon isn't
      supported either -- just like before.
      
      Note how NMDBusManager now implements the ObjectManager D-Bus interface
      directly.
      
      Also, this fixes race issues in the server, by no longer delaying
      PropertiesChanged signals. NMExportedObject would collect changed
      properties and send the signal out in idle_emit_properties_changed()
      on idle. This messes up the ordering of change events w.r.t. other
      signals and events on the bus. Note that not only NMExportedObject
      messed up the ordering. Also the generated code would hook into
      notify() and process change events in and idle handle, exhibiting the
      same ordering issue too.
      No longer do that. PropertiesChanged signals will be sent right away
      by hooking into dispatch_properties_changed(). This means, changing
      a property in quick succession will no longer be combined and is
      guaranteed to emit signals for each individual state. Quite possibly
      we emit now more PropertiesChanged signals then before.
      However, we are now able to group a set of changes by using standard
      g_object_freeze_notify()/g_object_thaw_notify(). We probably should
      make more use of that.
      
      Also, now that our signals are all handled in the right order, we
      might find places where we still emit them in the wrong order. But that
      is then due to the order in which our GObjects emit signals, not due
      to an ill behavior of the D-Bus glue. Possibly we need to identify
      such ordering issues and fix them.
      
      Numbers (for contrib/rpm --without debug on x86_64):
      
      - the patch changes the code size of NetworkManager by
        - 2809360 bytes
        + 2537528 bytes (-9.7%)
      
      - Runtime measurements are harder because there is a large variance
        during testing. In other words, the numbers are not reproducible.
        Currently, the implementation performs no caching of GVariants at all,
        but it would be rather simple to add it, if that turns out to be
        useful.
        Anyway, without strong claim, it seems that the new form tends to
        perform slightly better. That would be no surprise.
      
        $ time (for i in {1..1000}; do nmcli >/dev/null || break; echo -n .;  done)
        - real    1m39.355s
        + real    1m37.432s
      
        $ time (for i in {1..2000}; do busctl call org.freedesktop.NetworkManager /org/freedesktop org.freedesktop.DBus.ObjectManager GetManagedObjects > /dev/null || break; echo -n .; done)
        - real    0m26.843s
        + real    0m25.281s
      
      - Regarding RSS size, just looking at the processes in similar
        conditions, doesn't give a large difference. On my system they
        consume about 19MB RSS. It seems that the new version has a
        slightly smaller RSS size.
        - 19356 RSS
        + 18660 RSS
      297d4985
  17. 21 Feb, 2018 13 commits
  18. 11 Jan, 2018 1 commit
  19. 10 Jan, 2018 3 commits
    • Beniamino Galvani's avatar
      ppp: introduce SetIfindex pppd plugin D-Bus method · dd98ada3
      Beniamino Galvani authored
      If IPV6CP terminates before IPCP, pppd enters the RUNNING phase and we
      start IP configuration without having an IP interface set, which
      triggers assertions.
      
      Instead, add a SetIfindex() D-Bus method that gets called by the
      plugin when pppd becomes RUNNING. The method sets the IP ifindex of
      the device and starts IP configuration.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1515829
      dd98ada3
    • Thomas Haller's avatar
      build/meson: unconditionally use linker version scripts · 349861ce
      Thomas Haller authored
      We also unconditionally use them with autotools.
      Also, the detection for have_version_script does
      not seem correct to me. At least, it didn't work
      with clang.
      349861ce
    • Inigo Martínez's avatar
      meson: Improve dependency system · 5e16bcf2
      Inigo Martínez authored
      Some targets are missing dependencies on some generated sources in
      the meson port. These makes the build to fail due to missing source
      files on a highly parallelized build.
      
      These dependencies have been resolved by taking advantage of meson's
      internal dependencies which can be used to pass source files,
      include directories, libraries and compiler flags.
      
      One of such internal dependencies called `core_dep` was already in
      use. However, in order to avoid any confusion with another new
      internal dependency called `nm_core_dep`, which is used to include
      directories and source files from the `libnm-core` directory, the
      `core_dep` dependency has been renamed to `nm_dep`.
      
      These changes have allowed minimizing the build details which are
      inherited by using those dependencies. The parallelized build has
      also been improved.
      5e16bcf2
  20. 21 Dec, 2017 3 commits