1. 10 Apr, 2018 4 commits
    • Thomas Haller's avatar
      connectivity: rework async connectivity check requests · d8a31794
      Thomas Haller authored
      An asynchronous request should either be cancellable or not keep
      the target object alive. Preferably both.
      
      Otherwise, it is impossible to do a controlled shutdown when terminating
      NetworkManager. Currently, when NetworkManager is about to terminate,
      it just quits the mainloop and essentially leaks everything. That is a
      bug. If we ever want to fix that, every asynchronous request must be
      cancellable in a controlled way (or it must not prevent objects from
      getting disposed, where disposing the object automatically cancels the
      callback).
      
      Rework the asynchronous request for connectivity check to
      
      - return a handle that can be used to cancel the operation.
        Cancelling is optional. The caller may choose to ignore the handle
        because the asynchronous operation does not keep the target object
        alive. That means, it is still possible to shutdown, by everybody
        giving up their reference to the target object. In which case the
        callback will be invoked during dispose() of the target object.
      
      - also, the callback will always be invoked exactly once, and never
        synchronously from within the asynchronous start call. But during
        cancel(), the callback is invoked synchronously from within cancel().
        Note that it's only allowed to cancel an action at most once, and
        never after the callback is invoked (also not from within the callback
        itself).
      
      - also, NMConnectivity already supports a fake handler, in case
        connectivity check is disabled via configuration. Hence, reuse
        the same code paths also when compiling without --enable-concheck.
        That means, instead of having #if WITH_CONCHECK at various callers,
        move them into NMConnectivity. The downside is, that if you build
        without concheck, there is a small overhead compared to before. The
        upside is, we reuse the same code paths when compiling with or without
        concheck.
      
      - also, the patch synchronizes the connecitivty states. For example,
        previously `nmcli networking connectivity check` would schedule
        requests in parallel, and return the accumulated result of the individual
        requests.
        However, the global connectivity state of the manager might have have
        been the same as the answer to the explicit connecitivity check,
        because while the answer for the manual check is waiting for all
        pending checks to complete, the global connectivity state could
        already change. That is just wrong. There are not multiple global
        connectivity states at the same time, there is just one. A manual
        connectivity check should have the meaning of ensure that the global
        state is up to date, but it still should return the global
        connectivity state -- not the answers for several connectivity checks
        issued in parallel.
        This is related to commit b799de28
        (libnm: update property in the manager after connectivity check),
        which tries to address a similar problem client side.
        Similarly, each device has a connectivity state. While there might
        be several connectivity checks per device pending, whenever a check
        completes, it can update the per-device state (and return that device
        state as result), but the immediate answer of the individual check
        might not matter. This is especially the case, when a later request
        returns earlier and obsoletes all earlier requests. In that case,
        earlier requests return with the result of the currend devices
        connectivity state.
      
      This patch cleans up the internal API and gives a better defined behavior
      to the user (thus, the simple API which simplifies implementation for the
      caller). However, the implementation of getting this API right and properly
      handle cancel and destruction of the target object is more complicated and
      complex. But this but is not just for the sake of a nicer API. This fixes
      actual issues explained above.
      
      Also, get rid of GAsyncResult to track information about the pending request.
      Instead, allocate our own handle structure, which ends up to be nicer
      because it's strongly typed and has exactly the properties that are
      useful to track the request. Also, it gets rid of the awkward
      _finish() API by passing the relevant arguments to the callback
      directly.
      d8a31794
    • Thomas Haller's avatar
      core: add nm_utils_get_monotonic_timestamp_ns_cached() helper · 4417b8bf
      Thomas Haller authored
      Add a helper function to cache the current timestamp and return
      it. The caching is a performance optimization, but it serves a
      much more important purpose: repeatedly getting the timestamp
      likely will yield different timings. So, commonly, within a
      certain context we want to get the current time once, and stick
      to that as "now".
      4417b8bf
    • Thomas Haller's avatar
      platform: minor cleanup of nm_platform_ip6_address_sync() · 43dee5f1
      Thomas Haller authored
      Drop the "delete_remaining" variable, and instead rely on the value of "i_know"
      alone. Also, add a code comment explaining better what is happening.
      43dee5f1
    • Thomas Haller's avatar
      platform: fix IPv6 address sync after for link local addresses · b50d7cc6
      Thomas Haller authored
      Since commit 78ed0a4a (device: add
      IPv6 link local address via merge-and-apply) we handle also IPv6 link
      local addresses like regular addresses. That is, we also add them during
      merge-and-apply and sync them via nm_platform_ip6_address_sync().
      
      ip6-address-sync loops over the platform addresses, to find which
      addresses shall be deleted, and which shall be deleted in order to
      fix the address order/priority. At that point, we must not ignore
      link-local addresses anymore, but handle them too.
      
      Otherwise, during each resync we have link local addresses, and
      platform-sync thinks that the address order is wrong. That wrongly
      leads to remove most addresses and re-adding them.
      
      Fixes: 78ed0a4a
      b50d7cc6
  2. 09 Apr, 2018 16 commits
  3. 08 Apr, 2018 2 commits
  4. 06 Apr, 2018 5 commits
  5. 05 Apr, 2018 9 commits
  6. 04 Apr, 2018 4 commits
    • Thomas Haller's avatar
      systemd: merge branch systemd into master · c4048d4d
      Thomas Haller authored
      c4048d4d
    • Thomas Haller's avatar
      64708c34
    • Thomas Haller's avatar
      systemd: update code from upstream (2018-04-04) · 14098cbc
      Thomas Haller authored
      This is a direct dump from systemd git.
      
      ======
      
      SYSTEMD_DIR=../systemd
      COMMIT=c0f9017c1195b9bc3743e8dd000a18d3898b0034
      
      (
        cd "$SYSTEMD_DIR"
        git checkout "$COMMIT"
        git reset --hard
        git clean -fdx
      )
      
      git ls-files :/src/systemd/src/ \
                   :/shared/nm-utils/siphash24.c \
                   :/shared/nm-utils/siphash24.h \
                   :/shared/nm-utils/unaligned.h | \
        xargs -d '\n' rm -f
      
      nm_copy_sd() {
          mkdir -p "./src/systemd/$(dirname "$1")"
          cp "$SYSTEMD_DIR/$1" "./src/systemd/$1"
      }
      
      nm_copy_sd_shared() {
          mkdir -p "./shared/nm-utils/"
          cp "$SYSTEMD_DIR/$1" "./shared/nm-utils/${1##*/}"
      }
      
      nm_copy_sd "src/basic/alloc-util.c"
      nm_copy_sd "src/basic/alloc-util.h"
      nm_copy_sd "src/basic/async.h"
      nm_copy_sd "src/basic/escape.c"
      nm_copy_sd "src/basic/escape.h"
      nm_copy_sd "src/basic/ether-addr-util.c"
      nm_copy_sd "src/basic/ether-addr-util.h"
      nm_copy_sd "src/basic/extract-word.c"
      nm_copy_sd "src/basic/extract-word.h"
      nm_copy_sd "src/basic/fileio.c"
      nm_copy_sd "src/basic/fileio.h"
      nm_copy_sd "src/basic/fd-util.c"
      nm_copy_sd "src/basic/fd-util.h"
      nm_copy_sd "src/basic/fs-util.c"
      nm_copy_sd "src/basic/fs-util.h"
      nm_copy_sd "src/basic/hash-funcs.c"
      nm_copy_sd "src/basic/hash-funcs.h"
      nm_copy_sd "src/basic/hashmap.c"
      nm_copy_sd "src/basic/hashmap.h"
      nm_copy_sd "src/basic/hexdecoct.c"
      nm_copy_sd "src/basic/hexdecoct.h"
      nm_copy_sd "src/basic/hostname-util.c"
      nm_copy_sd "src/basic/hostname-util.h"
      nm_copy_sd "src/basic/in-addr-util.c"
      nm_copy_sd "src/basic/in-addr-util.h"
      nm_copy_sd "src/basic/io-util.c"
      nm_copy_sd "src/basic/io-util.h"
      nm_copy_sd "src/basic/list.h"
      nm_copy_sd "src/basic/log.h"
      nm_copy_sd "src/basic/macro.h"
      nm_copy_sd "src/basic/mempool.h"
      nm_copy_sd "src/basic/mempool.c"
      nm_copy_sd "src/basic/parse-util.c"
      nm_copy_sd "src/basic/parse-util.h"
      nm_copy_sd "src/basic/path-util.c"
      nm_copy_sd "src/basic/path-util.h"
      nm_copy_sd "src/basic/prioq.h"
      nm_copy_sd "src/basic/prioq.c"
      nm_copy_sd "src/basic/process-util.h"
      nm_copy_sd "src/basic/process-util.c"
      nm_copy_sd "src/basic/random-util.c"
      nm_copy_sd "src/basic/random-util.h"
      nm_copy_sd "src/basic/refcnt.h"
      nm_copy_sd "src/basic/set.h"
      nm_copy_sd "src/basic/signal-util.h"
      nm_copy_sd_shared "src/basic/siphash24.c"
      nm_copy_sd_shared "src/basic/siphash24.h"
      nm_copy_sd "src/basic/socket-util.c"
      nm_copy_sd "src/basic/socket-util.h"
      nm_copy_sd "src/basic/sparse-endian.h"
      nm_copy_sd "src/basic/stdio-util.h"
      nm_copy_sd "src/basic/string-table.c"
      nm_copy_sd "src/basic/string-table.h"
      nm_copy_sd "src/basic/string-util.c"
      nm_copy_sd "src/basic/string-util.h"
      nm_copy_sd "src/basic/strv.c"
      nm_copy_sd "src/basic/strv.h"
      nm_copy_sd "src/basic/time-util.c"
      nm_copy_sd "src/basic/time-util.h"
      nm_copy_sd "src/basic/umask-util.h"
      nm_copy_sd_shared "src/basic/unaligned.h"
      nm_copy_sd "src/basic/utf8.c"
      nm_copy_sd "src/basic/utf8.h"
      nm_copy_sd "src/basic/util.c"
      nm_copy_sd "src/basic/util.h"
      nm_copy_sd "src/libsystemd-network/arp-util.c"
      nm_copy_sd "src/libsystemd-network/arp-util.h"
      nm_copy_sd "src/libsystemd-network/dhcp6-internal.h"
      nm_copy_sd "src/libsystemd-network/dhcp6-lease-internal.h"
      nm_copy_sd "src/libsystemd-network/dhcp6-network.c"
      nm_copy_sd "src/libsystemd-network/dhcp6-option.c"
      nm_copy_sd "src/libsystemd-network/dhcp6-protocol.h"
      nm_copy_sd "src/libsystemd-network/dhcp-identifier.c"
      nm_copy_sd "src/libsystemd-network/dhcp-identifier.h"
      nm_copy_sd "src/libsystemd-network/dhcp-internal.h"
      nm_copy_sd "src/libsystemd-network/dhcp-lease-internal.h"
      nm_copy_sd "src/libsystemd-network/dhcp-network.c"
      nm_copy_sd "src/libsystemd-network/dhcp-option.c"
      nm_copy_sd "src/libsystemd-network/dhcp-packet.c"
      nm_copy_sd "src/libsystemd-network/dhcp-protocol.h"
      nm_copy_sd "src/libsystemd-network/lldp-internal.h"
      nm_copy_sd "src/libsystemd-network/lldp-neighbor.c"
      nm_copy_sd "src/libsystemd-network/lldp-neighbor.h"
      nm_copy_sd "src/libsystemd-network/lldp-network.c"
      nm_copy_sd "src/libsystemd-network/lldp-network.h"
      nm_copy_sd "src/libsystemd-network/network-internal.c"
      nm_copy_sd "src/libsystemd-network/network-internal.h"
      nm_copy_sd "src/libsystemd-network/sd-dhcp6-client.c"
      nm_copy_sd "src/libsystemd-network/sd-dhcp6-lease.c"
      nm_copy_sd "src/libsystemd-network/sd-dhcp-client.c"
      nm_copy_sd "src/libsystemd-network/sd-dhcp-lease.c"
      nm_copy_sd "src/libsystemd-network/sd-ipv4ll.c"
      nm_copy_sd "src/libsystemd-network/sd-ipv4acd.c"
      nm_copy_sd "src/libsystemd-network/sd-lldp.c"
      nm_copy_sd "src/libsystemd/sd-event/sd-event.c"
      nm_copy_sd "src/libsystemd/sd-id128/id128-util.c"
      nm_copy_sd "src/libsystemd/sd-id128/id128-util.h"
      nm_copy_sd "src/libsystemd/sd-id128/sd-id128.c"
      nm_copy_sd "src/shared/dns-domain.c"
      nm_copy_sd "src/shared/dns-domain.h"
      nm_copy_sd "src/systemd/_sd-common.h"
      nm_copy_sd "src/systemd/sd-dhcp6-client.h"
      nm_copy_sd "src/systemd/sd-dhcp6-lease.h"
      nm_copy_sd "src/systemd/sd-dhcp-client.h"
      nm_copy_sd "src/systemd/sd-dhcp-lease.h"
      nm_copy_sd "src/systemd/sd-event.h"
      nm_copy_sd "src/systemd/sd-ndisc.h"
      nm_copy_sd "src/systemd/sd-id128.h"
      nm_copy_sd "src/systemd/sd-ipv4acd.h"
      nm_copy_sd "src/systemd/sd-ipv4ll.h"
      nm_copy_sd "src/systemd/sd-lldp.h"
      14098cbc
    • Beniamino Galvani's avatar