1. 18 Apr, 2019 1 commit
    • Thomas Haller's avatar
      shared: move most of "shared/nm-utils" to "shared/nm-glib-aux" · 80db06f7
      Thomas Haller authored
      From the files under "shared/nm-utils" we build an internal library
      that provides glib-based helper utilities.
      
      Move the files of that basic library to a new subdirectory
      "shared/nm-glib-aux" and rename the helper library "libnm-core-base.la"
      to "libnm-glib-aux.la".
      
      Reasons:
      
       - the name "utils" is overused in our code-base. Everything's an
         "utils". Give this thing a more distinct name.
      
       - there were additional files under "shared/nm-utils", which are not
         part of this internal library "libnm-utils-base.la". All the files
         that are part of this library should be together in the same
         directory, but files that are not, should not be there.
      
       - the new name should better convey what this library is and what is isn't:
         it's a set of utilities and helper functions that extend glib with
         funcitonality that we commonly need.
      
      There are still some files left under "shared/nm-utils". They have less
      a unifying propose to be in their own directory, so I leave them there
      for now. But at least they are separate from "shared/nm-glib-aux",
      which has a very clear purpose.
      80db06f7
  2. 11 Mar, 2019 2 commits
    • Thomas Haller's avatar
      shared/systemd: fix gettid() compat implementation shadowing function from glibc · cfb970b2
      Thomas Haller authored
      On Fedora rawhide we get the following build failure:
      
          In file included from shared/systemd/src/basic/alloc-util.c:3:
          ./shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h:114:21: error: static declaration of 'gettid' follows non-static declaration
            114 | static inline pid_t gettid(void) {
                |                     ^~~~~~
          In file included from /usr/include/unistd.h:1170,
                           from /usr/include/glib-2.0/gio/gcredentials.h:32,
                           from /usr/include/glib-2.0/gio/gio.h:46,
                           from ./shared/nm-utils/nm-macros-internal.h:31,
                           from ./shared/nm-default.h:293,
                           from ./shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h:22,
                           from shared/systemd/src/basic/alloc-util.c:3:
          /usr/include/bits/unistd_ext.h:34:16: note: previous declaration of 'gettid' was here
             34 | extern __pid_t gettid (void) __THROW;
                |                ^~~~~~
      
      glibc supports now gettid() call ([1]) which conflicts with our compat
      implementation. Rename it.
      
      [1] https://sourceware.org/git/?p=glibc.git;a=commit;h=1d0fc213824eaa2a8f8c4385daaa698ee8fb7c92
      
      (cherry picked from commit 10276322)
      cfb970b2
    • Thomas Haller's avatar
      shared/systemd: fix gettid() compat implementation shadowing function from glibc · 10276322
      Thomas Haller authored
      On Fedora rawhide we get the following build failure:
      
          In file included from shared/systemd/src/basic/alloc-util.c:3:
          ./shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h:114:21: error: static declaration of 'gettid' follows non-static declaration
            114 | static inline pid_t gettid(void) {
                |                     ^~~~~~
          In file included from /usr/include/unistd.h:1170,
                           from /usr/include/glib-2.0/gio/gcredentials.h:32,
                           from /usr/include/glib-2.0/gio/gio.h:46,
                           from ./shared/nm-utils/nm-macros-internal.h:31,
                           from ./shared/nm-default.h:293,
                           from ./shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h:22,
                           from shared/systemd/src/basic/alloc-util.c:3:
          /usr/include/bits/unistd_ext.h:34:16: note: previous declaration of 'gettid' was here
             34 | extern __pid_t gettid (void) __THROW;
                |                ^~~~~~
      
      glibc supports now gettid() call ([1]) which conflicts with our compat
      implementation. Rename it.
      
      [1] https://sourceware.org/git/?p=glibc.git;a=commit;h=1d0fc213824eaa2a8f8c4385daaa698ee8fb7c92
      10276322
  3. 12 Feb, 2019 2 commits
  4. 11 Feb, 2019 1 commit
  5. 05 Feb, 2019 1 commit
    • Thomas Haller's avatar
      logging: make nm-logging thread-safe · fcfd4f4f
      Thomas Haller authored
      NetworkManager is single-threaded and uses a mainloop.
      
      However, sometimes we may need multiple threads. For example, we will
      need to write sysctl values asynchronously, using the glib thread-pool.
      For that to work, we also need to switch the network-namespace of the
      thread-pool thread. We want to use NMPNetns for that. Hence it's better
      to have NMPNetns thread-safe, instead of coming up with a duplicate
      implementation. But NMPNetns may want to log, so we also need nm-logging
      thread-safe.
      
      In general, code under "shared/nm-utils" and nm-logging should be usable
      from multiple threads. It's simpler to make this code thread-safe than
      re-implementing it. Also, it's a bad limitation to be unable to log
      from other threads. If there is an error, the best we can often do is to
      log about it.
      
      Make nm-logging thread-safe. Actually, we only need to be able to log
      from multiple threads. We don't need to setup or configure logging from
      multiple threads. This restriction allows us to access logging from the
      main-thread without any thread-synchronization (because all changes in
      the logging setup are also done from the main-thread).
      
      So, while logging from other threads requires a mutex, logging from the
      main-thread is lock-free.
      fcfd4f4f
  6. 02 Jan, 2019 2 commits
    • Thomas Haller's avatar
      systemd: move basic systemd library to shared/nm-utils · 2c537b9d
      Thomas Haller authored
      For better or worse, we already pull in large parts of systemd sources.
      
      I need a base64 decode implementation (because glib's g_base64_decode()
      cannot reject invalid encodings). Instead of coming up with my own or
      copy-paste if from somewhere, reuse systemd's unbase64mem().
      
      But for that, make systemd's basic bits an independent static library
      first because I will need it in libnm-core.
      
      This doesn't really change anything except making "libnm-systemd-core.la"
      an indpendent static library that could be used from "libnm-core". We
      shall still be mindful about which internal code of systemd we use, and only
      access functionality that is exposed via "systemd/nm-sd-utils-shared.h".
      2c537b9d
    • Thomas Haller's avatar
      systemd: drop workaround for missing C11 header <uchar.h> · 5f945adf
      Thomas Haller authored
      Now as we build as C11, we can us it.
      5f945adf
  7. 30 Dec, 2018 1 commit
  8. 18 Jun, 2018 1 commit
    • Lubomir Rintel's avatar
      all: remove CLOCK_BOOTTIME defintions · e27b15c0
      Lubomir Rintel authored
      It's useless and redundant noise.
      
      The original motivation seems to have been compatibility with ancient
      versions uClibc (2011), but given CLOCK_BOOTTIME definition is shipped with
      kernel headers, the libc version shall not matter anyway.
      
      Even if it was the case, uClibc has shipped the definition for over
      7 years now and been superseded by uClibc-ng that always had the
      definition.
      e27b15c0
  9. 30 Apr, 2018 1 commit
  10. 08 Jan, 2018 1 commit
    • Thomas Haller's avatar
      build: refine the NETWORKMANAGER_COMPILATION define · 22ef6a50
      Thomas Haller authored
      Note that:
      
       - we compile some source files multiple times. Most notably those
         under "shared/".
      
       - we include a default header "shared/nm-default.h" in every source
         file. This header is supposed to setup a common environment by defining
         and including parts that are commonly used. As we always include the
         same header, the header must behave differently depending
         one whether the compilation is for libnm-core, NetworkManager or
         libnm-glib. E.g. it must include <glib/gi18n.h> or <glib/gi18n-lib.h>
         depending on whether we compile a library or an application.
      
      For that, the source files need the NETWORKMANAGER_COMPILATION #define
      to behave accordingly.
      
      Extend the define to be composed of flags. These flags are all named
      NM_NETWORKMANAGER_COMPILATION_WITH_*, they indicate which part of the
      build are available. E.g. when building libnm-core.la itself, then
      WITH_LIBNM_CORE, WITH_LIBNM_CORE_INTERNAL, and WITH_LIBNM_CORE_PRIVATE
      are available. When building NetworkManager, WITH_LIBNM_CORE_PRIVATE
      is not available but the internal parts are still accessible. When
      building nmcli, only WITH_LIBNM_CORE (the public part) is available.
      This granularily controls the build.
      22ef6a50
  11. 30 Oct, 2017 1 commit
    • Thomas Haller's avatar
      systemd: avoid coverity warning about Deadcode · 6d63b648
      Thomas Haller authored
      Coverity is unhappy about comparing the literal LOG_DEBUG value:
      
      1. Defect type: CONSTANT_EXPRESSION_RESULT
      1. NetworkManager-1.9.2/src/systemd/src/libsystemd/sd-event/sd-event.c:2652:
      result_independent_of_operands: "7 >= (_level & 7)" is always true regardless
      of the values of its operands. This occurs as the logical first operand of "?:".
      
      Work around by instead using an inline function.
      6d63b648
  12. 24 Mar, 2017 1 commit
  13. 12 Aug, 2016 2 commits
  14. 17 Mar, 2016 1 commit
  15. 11 Mar, 2016 2 commits
    • 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".
      aed3c810
    • Thomas Haller's avatar
      systemd: integrate sd-event into glib main loop · a8bc65b1
      Thomas Haller authored
      We should not try to reimplement sd-event based on glib,
      instead we should hook sd-event into the glib mainloop.
      a8bc65b1
  16. 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
        https://www.gnu.org/software/autoconf/manual/autoconf.html#Configuration-Headers
      8bace23b
  17. 12 Feb, 2016 1 commit
  18. 13 Nov, 2015 1 commit
  19. 23 Sep, 2015 1 commit
  20. 16 Sep, 2015 1 commit
  21. 05 Aug, 2015 2 commits
  22. 02 Jun, 2015 1 commit
    • Lubomir Rintel's avatar
      systemd-dhcp: fix build with Linux 3.2.0 headers · 3811a683
      Lubomir Rintel authored
      Fixes build on Ubuntu 12.04.
      
      systemd/src/libsystemd-network/dhcp-network.c: In function '_bind_raw_socket':
      systemd/src/libsystemd-network/dhcp-network.c:75:17: error: 'BPF_XOR' undeclared (first use in this function)
      systemd/src/libsystemd-network/dhcp-network.c:75:17: note: each undeclared identifier is reported only once for each function it appears in
      make[4]: *** [libsystemd_nm_la-dhcp-network.lo] Error 1
      3811a683
  23. 19 May, 2015 1 commit