1. 04 Apr, 2018 21 commits
    • Thomas Haller's avatar
      checkpoint: allow overlapping checkpoints · 5c283356
      Thomas Haller authored
      Introduce a new flag NM_CHECKPOINT_CREATE_FLAG_ALLOW_OVERLAPPING
      that allows the creation of overlapping checkpoints. Before, and
      by default, checkpoints that reference a same device conflict,
      and creating such a checkpoint failed.
      
      Now, allow this. But during rollback automatically destroy all
      overlapping checkpoints that were created after the checkpoint
      that is about to rollback.
      
      With this, you can create a series of checkpoints, and rollback them
      individually. With the restriction, that if you once rolled back to an
      older checkpoint, you no longer can roll"forward" to a younger one.
      
      What this implies and what is new here, is that the checkpoint might be
      automatically destroyed by NetworkManager before the timeout expires. When
      the user later would try to manually destroy/rollback such a checkpoint, it
      would fail because the checkpoint no longer exists.
      5c283356
    • Thomas Haller's avatar
      checkpoint: don't let nm_checkpoint_new() fail · e5fc9a30
      Thomas Haller authored
      We already do error checking in nm_checkpoint_manager_create(). No need
      to split it in two places. Let all error conditions be handled by
      nm_checkpoint_manager_create() first, and then once we decide all is
      good, nm_checkpoint_new() can no longer fail.
      e5fc9a30
    • Thomas Haller's avatar
      checkpoint: let each checkpoint schedule its own timeout · 5fb65b7f
      Thomas Haller authored
      Instead of scheduling one timeout only, let each checkpoint instance
      individually schedule a timeout. This has some overhead, but glib
      is supposed to make scheduling many timers efficient. Otherwise,
      glib should be fixed.
      
      This simplifies in my opinion the code, because it's up to each
      checkpoint to maintain its own timeout.
      
      Later we will also add a AdjustRollbackTimeout operation, which
      allow to reschedule the timeout. It also seems slightly simpler,
      if scheduling of the timeout is done by the NMCheckpoint instance
      itself.
      5fb65b7f
    • Thomas Haller's avatar
      checkpoint: simplify device_checkpoint_create() to never fail · 6f28749a
      Thomas Haller authored
      It never failed already. Don't pretend it could.
      6f28749a
    • Thomas Haller's avatar
      e6e0eb92
    • Thomas Haller's avatar
      checkpoint: don't explicitly track checkpoints in a GHashTable · 79458a55
      Thomas Haller authored
      We already have a GHashTable for exported objects. We can use
      that if we want to look up by path efficiently.
      79458a55
    • Thomas Haller's avatar
      checkpoint: refactor nm_checkpoint_manager_create() to simplify creating device list · 63e3bff9
      Thomas Haller authored
      If no device paths are given, we can take the devices directly.
      We don't need to first create a list of paths, and then
      look them up by path again to add them to the list.
      63e3bff9
    • Thomas Haller's avatar
      checkpoint: skip unrealized devices in nm_checkpoint_manager_create() · daf3d5cb
      Thomas Haller authored
      We already do it for the case where no paths are provided.
      daf3d5cb
    • Thomas Haller's avatar
      checkpoint/trivial: rename local variable @checkpoint_path · 6d6b3890
      Thomas Haller authored
      path is long enough and (in this context) it consistently
      references the checkpoint "path".
      6d6b3890
    • Thomas Haller's avatar
      checkpoint/trivial: rename nm_checkpoint_manager_unref() to nm_checkpoint_manager_free() · 45c24fb9
      Thomas Haller authored
      NMCheckpointManager was added and is not ref-countable, because it
      is not needed.
      
      I still often like for such objects (that are not ref-countable),
      that their destroy function is called "unref". Both for consistency,
      and also if we would later add ref-counting to the object.
      
      However, NMCheckpointManager keeps a pointer to NMManager. So, when
      NMManager gets destroyed, it *MUST* destroy the NMCheckpointManager.
      It cannot accept that the checkpoint manager outlives NMManager,
      but the "unref" name suggests that somebody else might have still
      a reference to this object keeping it alive. That is not the case.
      
      Rename so that this is clear.
      
      I would name it nm_checkpoint_manager_destroy(), but "destroy" already
      has a meaning for NMCheckpoint instances, so use "free".
      45c24fb9
    • Thomas Haller's avatar
      checkpoint: embed CList in NMCheckpoint instance · ffb49267
      Thomas Haller authored
      We don't need an external CheckpointItem, just to wrap the
      CList instance. Embed it directly in NMCheckpoint.
      
      Sure, that exposes the checkpoints_lst field in the (internal)
      header file, hiding the private member less.
      ffb49267
    • Thomas Haller's avatar
      libnm: fix crash creating checkpoint during find_checkpoint_info() · 6f85d3e0
      Thomas Haller authored
      Now that the D-Bus signals in server are reordered, creating
      a checkpoint in libnm crashes:
      
        $ examples/python/gi/checkpoint.py create 4
      
          #0  0x00007ffff6d011ee in __strcmp_sse2_unaligned () at /lib64/libc.so.6
          #1  0x00007fffeb611c90 in find_checkpoint_info (manager=manager@entry=0x5555559e5110 [NMManager], path=0x7fffdc0092f0 "/org/freedesktop/NetworkManager/Checkpoint/6")
              at libnm/nm-manager.c:153
          #2  0x00007fffeb611d8f in checkpoint_added (manager=0x5555559e5110 [NMManager], checkpoint=checkpoint@entry=0x555555a122d0 [NMCheckpoint]) at libnm/nm-manager.c:1194
          #3  0x00007fffef7db929 in g_cclosure_marshal_VOID__OBJECTv (closure=0x5555559e4b30, return_value=<optimized out>, instance=<optimized out>, args=<optimized out>, marshal_data=<optimized out>, n_params=<optimized out>, param_types=0x5555559e2fc0) at gmarshal.c:2102
          #4  0x00007fffef7d8976 in _g_closure_invoke_va (closure=0x5555559e4b30, return_value=0x0, instance=0x5555559e5110, args=0x7fffffffc1c8, n_params=1, param_types=0x5555559e2fc0)
              at gclosure.c:867
          #5  0x00007fffef7f3ff4 in g_signal_emit_valist (instance=instance@entry=0x5555559e5110, signal_id=signal_id@entry=97, detail=0, var_args=var_args@entry=0x7fffffffc1c8) at gsignal.c:3300
          #6  0x00007fffef7f4b48 in g_signal_emit_by_name (instance=instance@entry=0x5555559e5110, detailed_signal=detailed_signal@entry=0x7fffffffc310 "checkpoint-added") at gsignal.c:3487
          #7  0x00007fffeb6156d1 in deferred_notify_cb (data=0x5555559e5110) at libnm/nm-object.c:219
          #8  0x00007fffeb615ae7 in object_property_maybe_complete (self=0x5555559e5110 [NMManager]) at libnm/nm-object.c:555
          #9  0x00007fffeb615e5d in object_created (obj=<optimized out>, path=<optimized out>, user_data=<optimized out>) at libnm/nm-object.c:576
          #10 0x00007fffeb61648b in handle_object_array_property (pi=<optimized out>, value=0x7fffdc075070, property_name=0x7fffeb67f117 "checkpoints", self=0x5555559e5110 [NMManager])
              at libnm/nm-object.c:671
          #11 0x00007fffeb61648b in handle_property_changed (self=self@entry=0x5555559e5110 [NMManager], dbus_name=<optimized out>, value=<optimized out>) at libnm/nm-object.c:740
          #12 0x00007fffeb6166e9 in properties_changed (proxy=<optimized out>, changed_properties=<optimized out>, invalidated_properties=<optimized out>, user_data=0x5555559e5110)
              at libnm/nm-object.c:772
          ...
      
      That is, because NetworkManager now first emits signals that the checkpoint
      object was created, before answering the D-Bus request. That makes more
      sense, but leads to this crash.
      
      The ugliness of how libnm handles object visibility is considerable.
      libnm hides objects until they are fully initialized. So, when
      the async create-checkpoint operation returns, the object might not
      yet be ready to be exposed. We need to delay the result. It would be
      better if the API would simply return the created path.
      6f85d3e0
    • Thomas Haller's avatar
      4c67e0d5
    • Thomas Haller's avatar
      device/trival: rename NMIwdManagerPrivate.nm_manager field to "manager" · 21b262f2
      Thomas Haller authored
      Similar cases of such a field are named "manager". Also,
      internal names shall not have an "nm" prefix, contrary
      to names in a header file, which shall have such a prefix.
      21b262f2
    • Thomas Haller's avatar
      core: add macro for iterating CList of devices of NMManager · 8de522fa
      Thomas Haller authored
      I find it slightly nicer and explict. Also, the list elements
      are strictly speaking private, we should better not explicitly
      use them outside of NMManager/NMDevice. The macro hides this.
      8de522fa
    • Thomas Haller's avatar
    • Thomas Haller's avatar
    • Thomas Haller's avatar
    • Beniamino Galvani's avatar
    • Beniamino Galvani's avatar
      core: remove @indicated argument of nm_utils_match_connection() · 34606418
      Beniamino Galvani authored
      It is not needed anymore.
      34606418
    • Beniamino Galvani's avatar
      manager: relax checks for assuming connections after restart · f0357b8f
      Beniamino Galvani authored
      Instead of generating a connection and checking whether it is
      compatible with the connection indicated in the state file, just pick
      the indicated connection after a basic check of compatibility with the
      device.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1551958
      f0357b8f
  2. 01 Apr, 2018 1 commit
  3. 30 Mar, 2018 4 commits
  4. 28 Mar, 2018 1 commit
  5. 27 Mar, 2018 12 commits
    • Thomas Haller's avatar
      contrib/nm-live-vm: remove nm-live-vm scripts · a1875852
      Thomas Haller authored
      They were not (notably) touched in more than 3 years.
      I doubt anybody is using them.
      
      Also, nowadays we have contrib/rpm to build NetworkManager
      packages for Fedora/RPM. We have copr, we have automated CI
      in CentOS CI and beaker.
      
      Also, nowadays it should be easy to spawn a a fedora image
      in a container or tools like vagrant.
      
      I think there are better alternatives. Drop the scripts.
      a1875852
    • Thomas Haller's avatar
      shared/nm-glib: add compat implementation for g_autofree · b2edcdc9
      Thomas Haller authored
      Eventually, we should replace our uses of libgsystem's gsystem-local-alloc.h
      by glib's g_auto*. As a first tiny step, add a compat implementation for g_autofree,
      so that we could at least go ahead and use it instead of gs_free.
      
      https://bugzilla.gnome.org/show_bug.cgi?id=794294
      b2edcdc9
    • Thomas Haller's avatar
      libnm: add nm-autoptr.h header · ff8e5633
      Thomas Haller authored
      "nm-autoptr.h" is done in a way that allows you to copy the header
      in your source tree to support older versions of libnm, that didn't
      contain the header yet. For example, we might want to use it in
      network-manager-applet, but we don't want to bump the libnm dependency
      to 1.11.2+ only to get this functionality.
      
      Note that G_DEFINE_AUTOPTR_CLEANUP_FUNC() was added in glib 2.43.4,
      and requires compiler support for the cleanup attribute. The compiler
      support is taken as given, because we rely on it already. However,
      NetworkManager and network-manager-applet still don't depend on a glib
      version recent enough to provide these macros. To actually use them
      (*inside*) NetworkManager/network-manager-applet, we either would have
      to bump the glib minimal dependency, or reimplement g_autoptr in
      /shared/nm-utils/nm-glib.h compat header.
      
      https://bugzilla.gnome.org/show_bug.cgi?id=794294
      ff8e5633
    • Thomas Haller's avatar
    • Thomas Haller's avatar
      all: use nm_utils_hash_keys_to_array() · e49a3293
      Thomas Haller authored
      e49a3293
    • Thomas Haller's avatar
      config: cleanup fields in NMGlobalDnsConfig · cd48bc74
      Thomas Haller authored
      - consistently set options, searches, domains fields to %NULL,
        if there are no values.
      
      - in nm_global_dns_config_update_checksum(), ensure that we uniquely
        hash values. E.g. a config with "searches[a], options=[b]" should
        hash differently from "searches=[ab], options=[]".
      
      - in nm_global_dns_config_to_dbus(), reuse the sorted domain list.
        We already have it, and it guarantees a consistent ordering of
        fields.
      
      - in global_dns_domain_from_dbus(), fix memleaks if D-Bus strdict
        contains duplicate entries.
      cd48bc74
    • Thomas Haller's avatar
      config/trivial: rename dns_config local variable · 0f1dc3bc
      Thomas Haller authored
      The variable serves a similar purpose, but is called "dns",
      "conf", and "dns_config". Choose one name: "dns_config".
      0f1dc3bc
    • Thomas Haller's avatar
      938d9a82
    • Thomas Haller's avatar
      wifi: rework tracking of wifi-aps to use CList · d7b1a911
      Thomas Haller authored
      - no longer track APs in a hash table with their exported path
        as key. The exported path is already tracked by NMDBusManager's
        lookup index, so we can reuse that for fast lookup by path. Otherwise,
        track the APs in a CList per device.
      
      - as we now track APs in a CList, their order is well defined.
        We no longer need to sort APs and obsoletes nm_wifi_aps_get_sorted()
        and simplifies nm_wifi_aps_find_first_compatible().
      d7b1a911
    • Thomas Haller's avatar
      core: rework lookup for exported objects by path to use index · 9fafd26f
      Thomas Haller authored
      We already track an index of exported objects in NMDBusManager.
      Actually, that index was unused previously. We either could drop
      it, or use it. Let's use it.
      9fafd26f
    • Thomas Haller's avatar
      manager: convert hwaddr to binary once in find_device_by_permanent_hw_addr() · 199f2df5
      Thomas Haller authored
      For comparing MAC addresses, they anyway have to be normalized
      to binary. Convert it once outside the loop and pass the binary
      form to nm_utils_hwaddr_matches(). Otherwise, we need to re-convert
      it every time.
      199f2df5
    • Thomas Haller's avatar
      core: track devices in manager via embedded CList · 4a705e1a
      Thomas Haller authored
      Instead of using a GSList for tracking the devices, use a CList.
      I think a CList is in most cases the more suitable data structure
      then GSList:
      
       - you can find out in O(1) whether the object is linked. That
         is nice, for example to assert in NMDevice's destructor that
         the object was unlinked, and we will use that later in
         nm_manager_get_device_by_path().
       - you can unlink the element in O(1) and you can unlink the
         element without having access to the link's head
       - Contrary to GSList, this does not require an extra slice
         allocation for the link node. It quite possibliy consumes
         slightly less memory because the CList structure is embedded
         in a struct that we already allocate. Even if slice allocation
         would be perfect to only consume 2*sizeof(gpointer) for the link
         note, it would at most be as-good as CList. Quite possibly,
         there is an overhead though.
       - CList possibly has better memory locality, because the link
         structure and the data are close to each other.
      
      Something which could be seen as disavantage, is that with CList
      one device can only be tracked in one NMManager instance at a time.
      But that is fine. There exists only one NMManager instance for now,
      and even if we would ever introduce multiple managers, we probably
      would not associate one NMDevice instance with multiple managers.
      
      The advantages are arguably not huge, but CList is IMHO clearly the
      more suited data structure. No need to stick to a suboptimal data
      structure for the job. Refactor it.
      4a705e1a
  6. 26 Mar, 2018 1 commit