1. 18 Dec, 2017 2 commits
  2. 15 Dec, 2017 1 commit
    • Thomas Haller's avatar
      utils: extend binary-search to return the first/last index · d83eee5d
      Thomas Haller authored
      binary-search can find an index of a matching entry in a sorted
      list. However, if the list contains multiple entries that compare
      equal, it can be interesting to find the first/last entry. For example,
      if you want to append new items after the last.
      
      Extend binary search to optionally continue the binary search
      to determine the range that compares equal.
      d83eee5d
  3. 12 Dec, 2017 1 commit
  4. 11 Dec, 2017 8 commits
  5. 08 Dec, 2017 2 commits
    • Thomas Haller's avatar
      libnm: use nm_utils_named_values_from_str_dict() · b11eac1a
      Thomas Haller authored
      Make use of NMUtilsNamedValue in nm_utils_format_variant_attributes().
      This avoids creating a GList and sorting it.
      
      Also, reuse nm_utils_named_values_from_str_dict() in
      nm_setting_bond_get_option().
      b11eac1a
    • Thomas Haller's avatar
      Revert "Makefile: rework team compilation flags" · b1c65d32
      Thomas Haller authored
      I don't think we should do this.
      
      - renamining/dropping configure options is still an annoyance,
        because it requires to different ./configure options depending
        on the version. The rename from --enable-teamctl to --enable-team
        might be theoretically nice, but more annoying then helpful.
      
      - There is no strict dependency between --enable-team and
        --enable-json-validation. At most, one could argue that
        when enabling the team plugin (--enable-teamctl), then
        libnm must also be build with --enable-json-validation.
        But in fact, the team plugin will happily work with a
        libnm that doesn't link against libjansson.
        That is --enable-teamctl --disable-json-validation will work
        in practice just fine.
        On the other hand, libnm is a client library to create connection
        profiles, fully supporting team profiles also makes sense if the
        actual plugin is not installed (or build). Thus, --disable-teamctl
        --enable-json-validation certainly makes sense.
      
      At this point, one might ask whether libnm is even still complete without
      libjansson. Maybe libnm should *require* --enable-json-validation.
      But that is not what the patch was doing, and it would also need
      some careful consideration before doing so.
      
      This reverts commit 9d5cd7ea.
      b1c65d32
  6. 07 Dec, 2017 9 commits
  7. 29 Nov, 2017 1 commit
  8. 24 Nov, 2017 1 commit
  9. 21 Nov, 2017 1 commit
  10. 16 Nov, 2017 2 commits
    • Thomas Haller's avatar
      all: use nm_str_hash() instead of g_str_hash() · a6be2f4a
      Thomas Haller authored
      We also do this for libnm and libnm-core, where it causes visible changes
      in behavior. But if somebody would rely on the hashing implementation
      for hash tables, it would be seriously flawed.
      a6be2f4a
    • Thomas Haller's avatar
      all: include "nm-utils/nm-hash-utils.h" by default · 3ee8de20
      Thomas Haller authored
      Next we will use siphash24() instead of the glib version g_direct_hash() or
      g_str_hash(). Hence, the "nm-utils/nm-hash-utils.h" header becomes very
      fundamental and will be needed basically everywhere.
      
      Instead of requiring the users to include them, let it be included via
      "nm-default.h" header.
      3ee8de20
  11. 14 Nov, 2017 1 commit
    • Beniamino Galvani's avatar
      build: fix wrong jansson prerequisites · 07d5c86e
      Beniamino Galvani authored
      Currently there are multiple features that require Jansson support,
      but WITH_JANSSON=1 is set only when configuring with
      --enable-json-validation.  Therefore a build with
      "--disable-json-validation --enable-ovs" fails.
      
      The availability of Jansson (WITH_JANSSON) should only be used:
      
       - to check if dependent features can be enabled
       - to determine compiler and linker flags in the Makefile
       - in nm-jansson.h to define compatibility functions if needed
      
      Everything else must be controlled by a configure switch.
      
      https://bugzilla.gnome.org/show_bug.cgi?id=790233
      07d5c86e
  12. 09 Nov, 2017 4 commits
  13. 30 Oct, 2017 1 commit
  14. 23 Oct, 2017 1 commit
    • Thomas Haller's avatar
      libnm: reject colon in nm_utils_is_valid_iface_name() · 5f882e8e
      Thomas Haller authored
      Since kernel commit a4176a9391868bfa87705bcd2e3b49e9b9dd2996 (net:
      reject creation of netdev names with colons), kernel rejects any
      colons in the interface name.
      
      Since kernel could get away with tightening up the check, we can
      too.
      
      The user anyway can not choose arbitrary interface names, like
      "all", "default", "bonding_masters" are all going to fail one
      way or another.
      5f882e8e
  15. 19 Oct, 2017 1 commit
  16. 18 Oct, 2017 2 commits
    • Thomas Haller's avatar
      all: add helper functions for nm_hash_update*() · 2f56de74
      Thomas Haller authored
      By using a macro, we don't cast all the types to guint. Instead,
      we use their native types directly. Hence, we don't need
      nm_hash_update_uint64() nor nm_hash_update_ptr().
      Also, for types smaller then guint like char, we save hashing
      the all zero bytes.
      2f56de74
    • Thomas Haller's avatar
      all: refactor hashing by introducing NMHashState · 0e9e35e3
      Thomas Haller authored
      The privious NM_HASH_* macros directly operated on a guint value
      and were thus close to the actual implementation.
      
      Replace them by adding a NMHashState struct and accessors to
      update the hash state. This hides the implementation better
      and would allow us to carry more state. For example, we could
      switch to siphash24() transparently.
      
      For now, we still do a form basically djb2 hashing, albeit with
      differing start seed.
      
      Also add nm_hash_str() and nm_str_hash():
      
      - nm_hash_str() is our own string hashing implementation
      
      - nm_str_hash() is our own string implementation, but with a
        GHashFunc signature, suitable to pass it to g_hash_table_new().
        Also, it has this name in order to remind you of g_str_hash(),
        which it is replacing.
      0e9e35e3
  17. 17 Oct, 2017 1 commit
    • Thomas Haller's avatar
      shared: split random and hash utils · 281d2d9f
      Thomas Haller authored
      "nm-utils/nm-shared-utils.h" shall contain utility function without other
      dependencies. It is intended to be used by other projects as-is.
      
      nm_utils_random_bytes() requires getrandom() and a HAVE_GETRANDOM configure
      check. That makes it more cumbersome to re-use "nm-shared-utils.h", in
      cases where you don't care about nm_utils_random_bytes().
      
      Split nm_utils_random_bytes() out to a separate file.
      
      Same for hash utils, which depend on nm_utils_random_bytes(). Also, hash
      utils will eventually be extended to use siphash24.
      281d2d9f
  18. 13 Oct, 2017 1 commit
    • Thomas Haller's avatar
      core: introduce NM_HASH_INIT() to initialize hash seed · 4a279843
      Thomas Haller authored
      Introduce a NM_HASH_INIT() function. It makes the places
      where we initialize a hash with a certain seed visually clear.
      
      Also, move them from "shared/nm-utils/nm-shared-utils.h" to
      "shared/nm-utils/nm-macros-internal.h". We might want to
      have NM_HASH_INIT() non-inline (hence, define it in the
      source file).
      4a279843