1. 01 Jun, 2018 1 commit
  2. 31 May, 2018 4 commits
    • Thomas Haller's avatar
      build/meson: fix meson build for shared files · f445128a
      Thomas Haller authored
      The files in shared/nm-utils are not compiled as one static library,
      instead each subproject that needs (parts of) them, re-compiles the
      files individually.
      
      The major reason for that is, because we might have different compile
      flags, depending on whether we build libnm-core or
      libnm-util/libnm-glib. Actually, I think that is not really the case,
      and maybe this should be refactored, to indeed build them all as a
      static library first.
      
      Anyway, libnm-util, libnm-glib, clients' common lib, they all need a
      different set of shared files that they should compile. Refactor
      "shared/meson.build" to account for that and handle it like autotools
      does.
      
      Another change is, that "shared_c_siphash_dep" no longer advertises
      "include_directories: include_directories('c-siphash/src')". We don't
      put c-siphash.h into the include search path. Users who need it, should
      include it via "#include <c-siphash/src/c-siphash.h>". The only exception
      is when building shared_n_acd library, which is not under our control.
      f445128a
    • Thomas Haller's avatar
      all: replace systemd's siphash24 with c-siphash · b8b6100c
      Thomas Haller authored
      Originally, we used "nm-utils/siphash24.c", which was copied
      from systemd's source tree. It was both used by our own NetworkManager
      code, and by our internal systemd fork.
      
      Then, we added "shared/c-siphash" as a dependency for n-acd.
      
      Now, drop systemd's implementation and use c-siphash also
      for our internal purpose. Also, let systemd code use c-siphash,
      by patching "src/systemd/src/basic/siphash24.h".
      b8b6100c
    • Thomas Haller's avatar
      build: use default NM_BUILD_* defines for tests · b7426e91
      Thomas Haller authored
      Use two common defines NM_BUILD_SRCDIR and NM_BUILD_BUILDDIR
      for specifying the location of srcdir and builddir.
      
      Note that this is only relevant for tests, as they expect
      a certain layout of the directories, to find files that concern
      them.
      b7426e91
    • Thomas Haller's avatar
      build: don't add shared/nm-utils directory to include search path · 82b088ab
      Thomas Haller authored
      All users are supposed to include files from nm-utils by fully specifying
      the path. -I.*shared/nm-utils is wrong.
      
      Only, systemd code likes to include "siphash24.h" directly. Instead of
      adding "-Ishared/nm-utils" to the search path, add an intermediary
      header to sd-adapt. Note, that in the meantime we anyway should rework
      siphash24 to use shared/c-siphash instead.
      
      This also fixes build for meson, which was broken recently.
      82b088ab
  3. 30 May, 2018 1 commit
    • Thomas Haller's avatar
      shared: don't use nm_str_hash() in "nm-enum-utils.c" · 54356ac8
      Thomas Haller authored
      This was only used for some extra assertions. It' is not essential.
      If this would be for real usage, we should add a dependancy so that
      nm-utils/nm-enum-utils.c requires nm-hash-utils.h. But as it is,
      this is not necessary.
      
      This fixes build for meson, which wrongly tries to build nm-enum-utils.c
      for libnm-util, but then fails to include nm-hash-utils.c. That should
      be fixed independently.
      
      Fixes: 84a6eff1
      54356ac8
  4. 29 May, 2018 5 commits
    • Thomas Haller's avatar
      shared: don't allow aliases re-numbering in _nm_utils_enum_from_str_full() · 84a6eff1
      Thomas Haller authored
      For _nm_utils_enum_to_str_full(), we always first look whether we have
      an alias/nick for the numeric value, and preferably use that. That makes a
      lot of sense, as it allows the caller to provide better names (aliases),
      which are preferred over the name from the GLib type. It renames the
      numeric value.
      
      For the reverse conversion, this makes less sense. A name should have a
      unique numeric value. That is, we should not use one name that maps to
      a different numeric value based on value_infos and GLib type. IOW, we
      should not re-number names.
      
      Add an assertion that we don't provide such a value_infos parameter,
      that conflicts with names from GLib type.
      
      Also, although the case where GLib type and value_infos disagree is now
      forbidden by an assert, reorder the statements in _nm_utils_enum_from_str_full()
      too. There is no difference in practice, but it mirros what we do in the
      to-str case.
      84a6eff1
    • Thomas Haller's avatar
      shared/trivial: rename local variable class · 3021a8cf
      Thomas Haller authored
      There is no real problem with using "class" in C. However, it would
      be a keyword in C++. Just avoid it, and use "klass" instead.
      3021a8cf
    • Thomas Haller's avatar
      shared: fix parsing aliases for flags in _nm_utils_enum_from_str_full() · 3c6bd676
      Thomas Haller authored
      Otherwise, the last alias overwrites previous values.
      
      Fixes: b9fa0e0a
      3c6bd676
    • Beniamino Galvani's avatar
      n-acd: better handle interfaces going temporarily down · d082af6b
      Beniamino Galvani authored
      NM sometimes brings an interface temporarily down (for example to
      change a VLAN MAC to align it to the parent interface's one). When
      this happens, any recv() or send() in n-acd fails, the n-acd instance
      is reset to the initial state and a DOWN event is reported to the
      manager, which currently does not handle it. The result is an
      inconsistent state.
      
      There is no simple way of dealing with the DOWN event in the
      manager. What we can do instead is to:
      
       - ignore errors during recv() because there is really nothing we can
         do, except for waiting timeouts to expire;
      
       - during probe, ignore errors during send() so that we don't exceed
         the probe timeout;
      
       - during announcement, retry after a send() error to ensure we send
         all 3 announcements.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1578675
      d082af6b
    • Beniamino Galvani's avatar
      n-acd: use RFC 5227 timeout for announcements · 2f4b3392
      Beniamino Galvani authored
      When doing announcements, use the the timeout specified by RFC
      5227. Note that timeout_multiplier might be 0.
      
      This aligns behavior to upstream version of n-acd.
      2f4b3392
  5. 26 May, 2018 1 commit
  6. 24 May, 2018 1 commit
  7. 14 May, 2018 4 commits
  8. 11 May, 2018 4 commits
  9. 10 May, 2018 2 commits
    • 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
    • Lubomir Rintel's avatar
      all: add and utilize nm_utils_is_separator() · f0c1efbf
      Lubomir Rintel authored
      It is meant to be rather similar in nature to isblank() or
      g_ascii_isspace().
      
      Sadly, isblank() is locale dependent while g_ascii_isspace() also considers
      vertical whitespace as a space. That's no good for configuration files that
      are strucutured into lines, which happens to be a pretty common case.
      f0c1efbf
  10. 30 Apr, 2018 1 commit
  11. 24 Apr, 2018 1 commit
  12. 23 Apr, 2018 2 commits
    • Thomas Haller's avatar
      systemd: update code from upstream (2018-04-23) · c4dd6208
      Thomas Haller authored
      This is a direct dump from systemd git.
      
      ======
      
      SYSTEMD_DIR=../systemd
      COMMIT=41d0da0f6a800b7f1d56d6d15cf90edb6c062050
      
      (
        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"
      c4dd6208
    • Lubomir Rintel's avatar
      n-acd: don't use a return value in deallocator · de8bf742
      Lubomir Rintel authored
      ...so that its prototype is compatible with GDestroyNotify:
      
      src/devices/nm-acd-manager.c: In function ‘destroy_address_info’:
      /usr/include/glib-2.0/glib/gmem.h:120:31: error: cast between incompatible function types from ‘NAcd * (*)(NAcd *)’ {aka ‘struct NAcd * (*)(struct NAcd *)’} to ‘void (*)(void *)’ [-Werror=cast-function-type]
           GDestroyNotify _destroy = (GDestroyNotify) (destroy);                      \
                                     ^
      src/devices/nm-acd-manager.c:430:2: note: in expansion of macro ‘g_clear_pointer’
        g_clear_pointer (&info->acd, n_acd_free);
        ^~~~~~~~~~~~~~~
      
      The same change was done upstream, so the subsequent subtree pull of n-acd
      won't mess this up.
      de8bf742
  13. 19 Apr, 2018 1 commit
    • Thomas Haller's avatar
      shared: move cmp functions to nm-shared-utils.c · bc1b15cf
      Thomas Haller authored
      For one, these functions are not often needed. No need to define them in the
      "nm-macros-internal.h" header, which is included everywhere. Move them to
      "nm-shared-utils.h", which must be explicitly included.
      
      Also, these functions are usually not called directly, but by passing their
      function pointer to a sort function or similar. There is no point in having
      defined in the header file.
      bc1b15cf
  14. 18 Apr, 2018 8 commits
  15. 16 Apr, 2018 1 commit
  16. 13 Apr, 2018 1 commit
  17. 09 Apr, 2018 2 commits