1. 18 Apr, 2019 5 commits
    • Thomas Haller's avatar
      shared: build helper "libnm-libnm-core-{intern|aux}.la" library for libnm-core · 284ac92e
      Thomas Haller authored
      "libnm-core" implements common functionality for "NetworkManager" and
      "libnm".
      
      Note that clients like "nmcli" cannot access the internal API provided
      by "libnm-core". So, if nmcli wants to do something that is also done by
      "libnm-core", , "libnm", or "NetworkManager", the code would have to be
      duplicated.
      
      Instead, such code can be in "libnm-libnm-core-{intern|aux}.la".
      Note that:
      
        0) "libnm-libnm-core-intern.la" is used by libnm-core itsself.
           On the other hand, "libnm-libnm-core-aux.la" is not used by
           libnm-core, but provides utilities on top of it.
      
        1) they both extend "libnm-core" with utlities that are not public
           API of libnm itself. Maybe part of the code should one day become
           public API of libnm. On the other hand, this is code for which
           we may not want to commit to a stable interface or which we
           don't want to provide as part of the API.
      
        2) "libnm-libnm-core-intern.la" is statically linked by "libnm-core"
           and thus directly available to "libnm" and "NetworkManager".
           On the other hand, "libnm-libnm-core-aux.la" may be used by "libnm"
           and "NetworkManager".
           Both libraries may be statically linked by libnm clients (like
           nmcli).
      
        3) it must only use glib, libnm-glib-aux.la, and the public API
           of libnm-core.
           This is important: it must not use "libnm-core/nm-core-internal.h"
           nor "libnm-core/nm-utils-private.h" so the static library is usable
           by nmcli which couldn't access these.
      
      Note that "shared/nm-meta-setting.c" is an entirely different case,
      because it behaves differently depending on whether linking against
      "libnm-core" or the client programs. As such, this file must be compiled
      twice.
      
      (cherry picked from commit af07ed01)
      284ac92e
    • Thomas Haller's avatar
      shared: move "nm-dbus-compat.h" header to "nm-std-aux/nm-dbus-compat.h" · 87f7e684
      Thomas Haller authored
      (cherry picked from commit 81833358)
      87f7e684
    • Thomas Haller's avatar
      shared: move most of "shared/nm-utils" to "shared/nm-glib-aux" · d984b2ce
      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.
      
      (cherry picked from commit 80db06f7)
      d984b2ce
    • Thomas Haller's avatar
      shared: move udev helper to separate directory "shared/nm-udev-aux" · 95621586
      Thomas Haller authored
      We built (among others) two libraries from the sources in "shared/nm-utils":
      "libnm-utils-base.la" and "libnm-utils-udev.la".
      
      It's confusing. Instead use directories so there is a direct
      correspondence between these internal libraries and the source files.
      
      (cherry picked from commit 2973d682)
      95621586
    • Thomas Haller's avatar
      shared: split C-only helper "shared/nm-std-aux" utils out of "shared/nm-utils" · 0a6f21fb
      Thomas Haller authored
      "shared/nm-utils" contains general purpose utility functions that only
      depend on glib (and extend glib with some helper functions).
      
      We will also add code that does not use glib, hence it would be good
      if the part of "shared/nm-utils" that does not depend on glib, could be
      used by these future projects.
      
      Also, we use the term "utils" everywhere. While that covers the purpose
      and content well, having everything called "nm-something-utils" is not
      great. Instead, call this "nm-std-aux", inspired by "c-util/c-stdaux".
      
      (cherry picked from commit b434b9ec)
      0a6f21fb
  2. 12 Apr, 2019 2 commits
    • Beniamino Galvani's avatar
      build: fix build with sanitizers · 366f9867
      Beniamino Galvani authored
      Add missing linker flags.
      366f9867
    • Thomas Haller's avatar
      dispatcher/tests: cleanup tests · 0d3bf972
      Thomas Haller authored
      - use cleanup macros everywhere.
      
      - In particular use nm_auto_clear_variant_builder to free the
        GVariantBuilder in the error cases. Note that the error cases
        anyway are asserted against, so during a normal test run there
        was no leak. But we should not write software like that.
      
      - use nm_utils_strsplit_set_with_empty() instead of g_strsplit_set().
        We should use our variant also in unit-tests, because that way the
        function gets more test coverage. And it likely performs better
        anyway.
      0d3bf972
  3. 03 Apr, 2019 1 commit
  4. 02 Apr, 2019 1 commit
  5. 27 Mar, 2019 1 commit
    • Thomas Haller's avatar
      ifcfg-rh: add support for routing rules as "ROUTING_RULE_#" keys · 4d468044
      Thomas Haller authored
      initscripts support rule-* and rule6-* files for that.
      
      Up until now, we ignored these files for the most part, except if
      a user configured such files, the profile could not contain any static
      routes (or specify a route-table setting). This also worked together
      with the dispatcher script "examples/dispatcher/10-ifcfg-rh-routes.sh".
      
      We cannot now start taking over that file format for rules. It might
      break existing setups, because we can never fully understand all rules as
      they are understood by iproute2. Also, if a user has a rule/rule6 file and
      uses NetworkManager successfully today, then clearly there is a script
      in place to make that work. We must not break that when adding rules
      support.
      
      Hence, store routing rules as numbered "ROUTING_RULE_#" and
      "ROUTING_RULE6_#" keys.
      
      Note that we use different keys for IPv4 and IPv6. The main reason is
      that the string format is mostly compatible with iproute2. That means,
      you can take the value and pass it to `ip rule add`.
      However, `ip rule add` only accepts IPv4 rules. For IPv6 rules, the user
      needs to call `ip -6 rule add`. If we would use the same key for IPv4
      and IPv6, then it would be hard to write a script to do this.
      Also, nm_ip_routing_rule_from_string() does take the address family as
      hint in this case. This makes
      
        ROUTING_RULE_1="pref 1"
        ROUTING_RULE6_1="pref 1"
      
      automatically determine that address families. Otherwise, such
      abbreviated forms would be not valid.
      4d468044
  6. 25 Mar, 2019 1 commit
    • Thomas Haller's avatar
      shared: add "shared/nm-libnm-core-utils.h" utils · d0f1e68b
      Thomas Haller authored
      We have code in "shared/nm-utils" which are general purpose
      helpers, independent of "libnm", "libnm-core", "clients" and "src".
      
      We have shared code like "shared/nm-ethtool-utils.h" and
      "shared/nm-meta-setting.h", which is statically linked, shared
      code that contains libnm related helpers. But these helpers already
      have a specific use (e.g. they are related to ethtool or NMSetting
      metadata).
      
      Add a general purpose helper that:
      
       - depends (and extends) libnm-core
      
       - contains unrelated helpers
      
       - can be shared (meaning it will be statically linked).
      
       - this code can be used by any library user of "libnm.so"
         (nmcli, nm-applet) and by "libnm-core" itself. Thus, "src/"
         and "libnm/" may also use this code indirectly, via "libnm-core/".
      d0f1e68b
  7. 20 Mar, 2019 1 commit
  8. 19 Mar, 2019 1 commit
    • Lubomir Rintel's avatar
      all: goodbye libnm-glib · 1de8383a
      Lubomir Rintel authored
      This removes libnm-glib, libnm-glib-vpn, and libnm-util for good.
      The it has been replaced with libnm since NetworkManager 1.0, disabled
      by default since 1.12 and no up-to-date distributions ship it for years
      now.
      
      Removing the libraries allows us to:
      
      * Remove the horrible hacks that were in place to deal with accidental use
        of both the new and old library in a single process.
      * Relief the translators of maintenance burden of similar yet different
        strings.
      * Get rid of known bad code without chances of ever getting fixed
        (libnm-glib/nm-object.c and libnm-glib/nm-object-cache.c)
      * Generally lower the footprint of the releases and our workspace
      
      If there are some really really legacy users; they can just build
      libnm-glib and friends from the NetworkManager-1.16 distribution. The
      D-Bus API is stable and old libnm-glib will keep working forever.
      
      https://github.com/NetworkManager/NetworkManager/pull/308
      1de8383a
  9. 13 Mar, 2019 1 commit
    • Thomas Haller's avatar
      platform: add NMPRulesManager for syncing routing rules · b8398b9e
      Thomas Haller authored
      Routing rules are unlike addresses or routes not tied to an interface.
      NetworkManager thinks in terms of connection profiles. That works well
      for addresses and routes, as one profile configures addresses and routes
      for one device. For example, when activating a profile on a device, the
      configuration does not interfere with the addresses/routes of other
      devices. That is not the case for routing rules, which are global, netns-wide
      entities.
      
      When one connection profile specifies rules, then this per-device configuration
      must be merged with the global configuration. And when a device disconnects later,
      the rules must be removed.
      
      Add a new NMPRulesManager API to track/untrack routing rules. Devices can
      register/add there the routing rules they require. And the sync method will
      apply the configuration. This is be implemented on top of NMPlatform's
      caching API.
      b8398b9e
  10. 07 Mar, 2019 2 commits
  11. 05 Mar, 2019 2 commits
  12. 22 Feb, 2019 1 commit
    • Thomas Haller's avatar
      libnm,cli: add NMSettingWireGuard · b521f426
      Thomas Haller authored
      For now only add the core settings, no peers' data.
      
      To support peers and the allowed-ips of the peers is more complicated
      and will be done later. It's more complicated because these are nested
      lists (allowed-ips) inside a list (peers). That is quite unusual and to
      conveniently support that in D-Bus API, in keyfile format, in libnm,
      and nmcli, is a effort.
      Also, it's further complicated by the fact that each peer has a secret (the
      preshared-key). Thus we probably need secret flags for each peer, which
      is a novelty as well (until now we require a fixed set of secrets per
      profile that is well known).
      b521f426
  13. 05 Feb, 2019 1 commit
  14. 01 Feb, 2019 2 commits
    • Thomas Haller's avatar
      wifi-p2p: rename Wi-Fi P2P · 09090f26
      Thomas Haller authored
      After renaming the files, also rename all the content
      to follow the "Wi-Fi P2P" naming scheme.
      09090f26
    • Thomas Haller's avatar
      wifi-p2p: rename files for consistent Wi-Fi P2P naming · 0420fa1f
      Thomas Haller authored
      We named the types inconsistently:
      
        - "p2p-wireless" ("libnm-core/nm-setting-p2p-wireless.h")
      
        - "p2p" ("libnm/nm-p2p-peer.h")
      
        - "p2p-wifi" ("src/devices/wifi/nm-device-p2p-wifi.h")
      
      It seems to me, "libnm/nm-p2p-peer.h" should be qualified with a "Wi-Fi"
      specific name. It's not just peer-to-peer, it's Wi-Fi P2P.
      Yes, there is an inconsistency now, because there is already
      "libnm/nm-access-point.h".
      
      It seems to me (from looking at the internet), that the name "Wi-Fi P2P"
      is more common than "P2P Wi-Fi" -- although both are used. There is also
      the name "Wi-Fi Direct". But it's not clear which name should be
      preferred here, so stick to "Wi-Fi P2P".
      
      In this first commit only rename the files. The following commit will
      rename the content.
      0420fa1f
  15. 27 Jan, 2019 4 commits
  16. 02 Jan, 2019 5 commits
    • Thomas Haller's avatar
      libnm: use "libnm-systemd-shared.a" in "libnm-core.la" (and "libnm.so") · c4512f83
      Thomas Haller authored
      It's not yet used, but it will be. We will need nm_sd_utils_unbase64mem()
      to strictly validate WireGuard settings, which contain keys in base64 encoding.
      
      Note that we also need a stub implementation for logging. This will do
      nothing for all logging from "libnm-systemd-shared.a". This makes
      sense because "libnm.so" as a library should not log directly. Also,
      "libnm.so" will only use a small portion of "libnm-systemd-shared.a" which
      doesn't log anything. Thus this code is unused and dropped by the linker
      with "--gc-sections".
      c4512f83
    • 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
    • Thomas Haller's avatar
      build: bump C standard to (gcc's) C11 · 066357aa
      Thomas Haller authored
      We already import systemd code which is C11. To get this even
      to build, we need workaround like patching import of <uchar.h>.
      
      Also, the libraries from c-util and nettools are C11. We cannot even
      compile them in C99 mode (and didn't do that either).
      
      It's time to bump the version. We need C11 from now on (or better: gcc's
      dialect of it).
      
      Also, note that since nettools/nacd is not optional, we could not even
      build NetworkManager without a C11 compiler. So, just use it everywhere.
      066357aa
    • Thomas Haller's avatar
      shared,core: move logging enums to header "shared/nm-utils/nm-logging-fwd.h" · ef53b47e
      Thomas Haller authored
      In core ("src/"), we use "nm-logging.h" for all logging. This dispatches
      for logging to syslog, glog or systemd-journald.
      
      If we want to log from a shared component under "shared/", we need to
      use a common logging function. Add "nm-utils/nm-logging-fwd.h" for
      forward declaring the used logging mechaism.
      
      The shared library will still need to link with "src/nm-logging.c"
      or an alternative implementation, depending on whether it is used
      inside core or not.
      ef53b47e
  17. 27 Dec, 2018 1 commit
    • Thomas Haller's avatar
      shared,core: add "nm-errno.h" · 943dcba5
      Thomas Haller authored
      This will be our extension on top of <errno.h>.
      
      We want to use (integer) error numbers, that can both
      contain native errors from <errno.h> and our own defines,
      both merge in one domain. That is, we will reserve a small
      range of integers for our own defines (that hopefully won't
      clash with errors from <errno.h>).
      
      We can use this at places where GError is too cumbersome to use.
      
      The advantage is, that our error numbers extend <errno.h> and can
      be mixed.
      
      This is what "src/platform/nm-netlink.h" already does with nl_errno(). Next,
      the netlink errors from there will be merged into "nm-errno.h".
      
      Also, platform has NMPlatformError, which are a distinct set of error
      numbers. But these work differently in the sense that negative values
      represent codes from <errno.h> and positive numbers are our own platform
      specific defines. NMPlatformError will also be merged into "nm-errno.h".
      
      "nm-errno.h" will unify the error handling of platform and netlink,
      making it more similar to what we are used to from systemd, and give
      room to extend it for our own purpose.
      943dcba5
  18. 12 Dec, 2018 1 commit
  19. 01 Dec, 2018 2 commits
  20. 17 Nov, 2018 1 commit
    • Benjamin Berg's avatar
      core: Introduce helper class to track connection keep alive · 37e8c53e
      Benjamin Berg authored
      For P2P connections it makes sense to bind the connection to the status
      of the operation that is being done. One example is that a wifi display
      (miracast) P2P connection should be shut down when streaming fails for
      some reason.
      
      This new helper class allows binding a connection to the presence of a
      DBus path meaning that it will be torn down if the process disappears.
      37e8c53e
  21. 15 Nov, 2018 1 commit
  22. 12 Nov, 2018 2 commits
    • Thomas Haller's avatar
      build: create intermediate libraries of shared/nm-utils · 70c4e49c
      Thomas Haller authored
      Previously we would compile source files from shared/nm-utils
      multiple times. That not only slows down compilation, but it makes it
      confusing which project require exactly what.
      
      Most of the files in shared/nm-utils are a mixed bag of utility
      functions. Just build one libnm-utils-base library. Since the linker
      will throw away unused parts, there is no problem that not every user
      of libnm-utils-base needs everything.
      
      Also add libnm-utils-udev, which cannot be part of libnm-utils-base as
      it has an additional dependency on libudev.
      70c4e49c
    • Thomas Haller's avatar
      build: move code for shared libs in Makefile.am around · 06ccf3a6
      Thomas Haller authored
      Let's sort the code by the dependencies. The shared/ projects
      have the least dependencies. Move to the beginning.
      06ccf3a6
  23. 25 Oct, 2018 1 commit