1. 18 Oct, 2017 3 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.
    • Thomas Haller's avatar
      all: use siphash24 for hashing · ee76b097
      Thomas Haller authored
      siphash24() is wildly used by projects nowadays.
      It's certainly slower then our djb hashing that we used before.
      But quite likely it's fast enough for us, given how wildly it is
      used. I think it would be hard to profile NetworkManager to show
      that the performance of hash tables is the issue, be it with
      djb or siphash24.
      Certainly with siphash24() it's much harder to exploit the hashing
      algorithm to cause worst case hash operations (provided that the
      seed is kept private). Does this better resistance against a denial
      of service matter for us? Probably not, but let's better be safe then
      Note that systemd's implementation uses a different seed for each hash
      table (at least, after the hash table grows to a certain size).
      We don't do that and use only one global seed.
    • 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.
  2. 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).
  3. 05 Jul, 2017 1 commit
  4. 05 May, 2017 2 commits
  5. 24 Mar, 2017 2 commits
  6. 21 Nov, 2016 1 commit
    • Thomas Haller's avatar
      build: don't add subdirectories to include search path but require qualified include · 44ecb415
      Thomas Haller authored
      Keep the include paths clean and separate. We use directories to group source
      files together. That makes sense (I guess), but then we should use this
      grouping also when including files. Thus require to #include files with their
      path relative to "src/".
      Also, we build various artifacts from the "src/" tree. Instead of having
      individual CFLAGS for each artifact in Makefile.am, the CFLAGS should be
      unified. Previously, the CFLAGS for each artifact differ and are inconsistent
      in which paths they add to the search path. Fix the inconsistency by just
      don't add the paths at all.
  7. 03 Oct, 2016 1 commit
  8. 27 Sep, 2016 1 commit
    • Thomas Haller's avatar
      build: don't add systemd path the include search path · e3a072f3
      Thomas Haller authored
      Our internal copy of systemd should not be in the search path.
      Instead, let users only
        #include "systemd/nm-sd.h"
      which then includes everything from systemd that we need.
      We want to avoid to accidentally include anything from our
      systemd-copy. Any user of that should only include "nm-sd.h",
      which then includes everything that is needed further.
      For example, "src/devices/wwan/nm-modem-manager.c" has
        #include <systemd/nm-daemon.h>
      which in turn includes
        #include "_sd-common.h"
      This works all correctly before, because #include "" will first
      look in the directory where sd-daemon.h is. However, our mixing of
      external systemd library and internal copy is rather dangerous.
      Try to avoid it further by keeping the include paths clean.
  9. 12 May, 2016 1 commit
  10. 17 Mar, 2016 12 commits
  11. 11 Mar, 2016 1 commit
    • Thomas Haller's avatar
      systemd: split "nm-sd.h" out of "nm-sd-adapt.h" · aed3c810
      Thomas Haller authored
      Now we have:
      "nm-sd.h" is a header file of NetworkManager with utilities
      related to systemd. It can be used anywhere freely.
      Also, systemd headers that are considered public API (like
      "sd-event.h") can be used without restrictions.
      When compiling the systemd sources, we always must include
      "nm-sd-adapt.h" as first. Similarly, systemd headers must
      not include "nm-sd-adapt.h", because they are either public
      (in which case the adapter is not needed) or they are internal
      (in which case they are themself included via a systemd source).
      Sometimes, we must internal API (like "dhcp-lease-internal.h").
      In this case, we also must include "nm-sd-adapt.h".
  12. 10 Mar, 2016 1 commit
  13. 29 Feb, 2016 5 commits
  14. 19 Feb, 2016 1 commit
    • Thomas Haller's avatar
      all: cleanup includes and let "nm-default.h" include "config.h" · 8bace23b
      Thomas Haller authored
      - All internal source files (except "examples", which are not internal)
        should include "config.h" first. As also all internal source
        files should include "nm-default.h", let "config.h" be included
        by "nm-default.h" and include "nm-default.h" as first in every
        source file.
        We already wanted to include "nm-default.h" before other headers
        because it might contains some fixes (like "nm-glib.h" compatibility)
        that is required first.
      - After including "nm-default.h", we optinally allow for including the
        corresponding header file for the source file at hand. The idea
        is to ensure that each header file is self contained.
      - Don't include "config.h" or "nm-default.h" in any header file
        (except "nm-sd-adapt.h"). Public headers anyway must not include
        these headers, and internal headers are never included after
        "nm-default.h", as of the first previous point.
      - Include all internal headers with quotes instead of angle brackets.
        In practice it doesn't matter, because in our public headers we must
        include other headers with angle brackets. As we use our public
        headers also to compile our interal source files, effectively the
        result must be the same. Still do it for consistency.
      - Except for <config.h> itself. Include it with angle brackets as suggested by
  15. 10 Nov, 2015 1 commit
  16. 12 Oct, 2015 1 commit
    • Beniamino Galvani's avatar
      device: export list of LLDP neighbors through D-Bus · 07a9364d
      Beniamino Galvani authored
      This adds a LldpNeighbors property to the Device D-Bus interface
      carrying information about devices discovered through LLDP. The
      property is an array of hashes and each hash describes the values of
      LLDP TLVs for a specific neighbor.