1. 12 Feb, 2019 2 commits
  2. 19 Dec, 2018 1 commit
    • Thomas Haller's avatar
      all: don't use static buffer for nm_utils_inet*_ntop() · a51c09dc
      Thomas Haller authored
      While nm_utils_inet*_ntop() accepts a %NULL buffer to fallback
      to a static buffer, don't do that.
      I find the possibility of using a static buffer here error prone
      and something that should be avoided. There is of course the downside,
      that in some cases it requires an additional line of code to allocate
      the buffer on the stack as auto-variable.
  3. 30 Sep, 2018 2 commits
    • Thomas Haller's avatar
      all: drop _nm_utils_bin2hexstr() · b537c038
      Thomas Haller authored
      We already have nm_utils_bin2hexstr() and _nm_utils_bin2hexstr_full().
      This is confusing.
        - nm_utils_bin2hexstr() is public API of libnm. Also, it has
          a last argument @final_len to truncate the string at that
          It uses no delimiter and lower-case characters.
        - _nm_utils_bin2hexstr_full() does not do any truncation, but
          it has options to specify a delimiter, the character case,
          and to update a given buffer in-place. Also, like
          nm_utils_bin2hexstr() and _nm_utils_bin2hexstr() it can
          allocate a new buffer on demand.
        - _nm_utils_bin2hexstr() would use ':' as delimiter and make
          the case configurable. Also, it would always allocate the returned
      It's too much and confusing. Drop _nm_utils_bin2hexstr() which is internal
      API and just a wrapper around _nm_utils_bin2hexstr_full().
    • Thomas Haller's avatar
      all/trivial: rename hexstr<>bin conversion functions · 67144406
      Thomas Haller authored
      "bin2str" and "str2bin" are not very clear. These strings are
      hex-strings. Rename.
  4. 11 Jul, 2018 1 commit
    • Thomas Haller's avatar
      all: don't use gchar/gshort/gint/glong but C types · e1c7a2b5
      Thomas Haller authored
      We commonly don't use the glib typedefs for char/short/int/long,
      but their C types directly.
          $ git grep '\<g\(char\|short\|int\|long\|float\|double\)\>' | wc -l
          $ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l
      One could argue that using the glib typedefs is preferable in
      public API (of our glib based libnm library) or where it clearly
      is related to glib, like during
        g_object_set (obj, PROPERTY, (gint) value, NULL);
      However, that argument does not seem strong, because in practice we don't
      follow that argument today, and seldomly use the glib typedefs.
      Also, the style guide for this would be hard to formalize, because
      "using them where clearly related to a glib" is a very loose suggestion.
      Also note that glib typedefs will always just be typedefs of the
      underlying C types. There is no danger of glib changing the meaning
      of these typedefs (because that would be a major API break of glib).
      A simple style guide is instead: don't use these typedefs.
      No manual actions, I only ran the bash script:
        FILES=($(git ls-files '*.[hc]'))
        sed -i \
            -e 's/\<g\(char\|short\|int\|long\|float\|double\)\>\( [^ ]\)/\1\2/g' \
            -e 's/\<g\(char\|short\|int\|long\|float\|double\)\>  /\1   /g' \
            -e 's/\<g\(char\|short\|int\|long\|float\|double\)\>/\1/g' \
  5. 15 Feb, 2018 1 commit
  6. 04 Jan, 2018 1 commit
    • Thomas Haller's avatar
      dhcp: cleanup handling of ipv4.dhcp-client-id and avoid assertion failure · 686afe53
      Thomas Haller authored
      The internal client asserts that the length of the client ID is not more
      than MAX_CLIENT_ID_LEN. Avoid that assert by truncating the string.
      Also add new nm_dhcp_client_set_client_id_*() setters, that either
      set the ID based on a string (in our common dhclient specific
      format), or based on the binary data (as obtained from systemd client).
      Also, add checks and assertions that the client ID which is
      set via nm_dhcp_client_set_client_id() is always of length
      of at least 2 (as required by rfc2132, section-9.14).
  7. 10 Oct, 2017 1 commit
    • Thomas Haller's avatar
      core: rework tracking of gateway/default-route in ip-config · 5c299454
      Thomas Haller authored
      Instead of having 3 properties @gateway, @never_default and @has_gateway
      on NMIP4Config/NMIP6Config that determine the default-route, track the
      default-route as a regular route.
      The gateway setting is the configuration knob for the default-route.
      Since an NMIP4Config/NMIP6Config instance only has one gateway property,
      it cannot track more then one default-routes (see related bug rh#1445417).
      Especially with policy routing, it might be interesting to configure a
      default-route in multiple tables.
      Also, later it might be interesting to allow adding default-routes as
      regular static routes in a connection, so that the user can configure additional
      route parameters for the default-route or add default-routes in multiple tables.
      With this patch, default-routes now have a rt_source property according to their
      Also, the previous commits of this branch broke handling of the
      default-route :) . That should be working now again.
  8. 09 Oct, 2017 1 commit
  9. 06 Oct, 2017 1 commit
  10. 08 Sep, 2017 1 commit
  11. 05 Sep, 2017 1 commit
  12. 25 Jul, 2017 1 commit
    • Thomas Haller's avatar
      core: prevent invalid routes in NMIP4Config/NMIP6Config · 5f995123
      Thomas Haller authored
      Kernel requires that the host part of a route (based on network/plen)
      is zero. Routes with non-zero host part don't really exist.
      In settings (NMIPRoute), we don't enforce that. Hence we must ensure
      that we don't let such invalid routes into NMIP4Config/NMIP6Config.
      Also at other places where we obtain routes from untrusted sources,
      we must sanitize them first.
      Also add an assertion to catch such bugs.
  13. 05 Jul, 2017 1 commit
    • Thomas Haller's avatar
      core: pass NMDedupMultiIndex instance to NMIP4Config and other · 89385bd9
      Thomas Haller authored
      NMIP4Config, NMIP6Config, and NMPlatform shall share one
      NMDedupMultiIndex instance.
      For that, pass an NMDedupMultiIndex instance to NMPlatform and NMNetns.
      NMNetns than passes it on to NMDevice, NMDhcpClient, NMIP4Config and NMIP6Config.
      So currently NMNetns is the access point to the shared NMDedupMultiIndex
      instance, and it gets it from it's NMPlatform instance.
      The NMDedupMultiIndex instance is really a singleton, we don't want
      multiple instances of it. However, for testing, instead of adding a
      singleton instance, pass the instance explicitly around.
  14. 16 May, 2017 1 commit
    • Beniamino Galvani's avatar
      dhcp: don't add route to DHCP4 server · 36e97f5d
      Beniamino Galvani authored
      This basically reverts commit 31fe84e4 "core: Add host route for
      DHCP4 server if outside assigned subnet (bgo #721767)" because the
      additional route added by NM does more harm than good.
      First, the code does not consider routes pushed by the server and thus
      it can add a route conflicting with the ones from the network
      Second, there is no specification on what a DHCP client should do when
      the server is not reachable via unicast, and adding arbitrary logic
      into the client is likely to break things in specific cases. If
      network administrators want to make the DHCP server reachable from a
      client in a different subnet, they should push proper routes with the
      In any case, if the DHCP server is not reachable through unicast,
      before the lease expiration (after timeout T2) the client will resort
      to broadcast and so there won't be any network disruption; the renewal
      will only happen at a later time.
      Fixes: 31fe84e4
  15. 21 Nov, 2016 2 commits
    • 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.
    • Thomas Haller's avatar
      build: rename "src/dhcp-manager" to "src/dhcp" · e0539968
      Thomas Haller authored
      The dhcp directory does not only contain the manager
      instance, but various files related to DHCP.
  16. 09 Nov, 2016 2 commits
  17. 03 Oct, 2016 1 commit
  18. 10 Jul, 2016 2 commits
  19. 28 Apr, 2016 1 commit
    • Thomas Haller's avatar
      core/trivial: rename "source" field of addresses and routes · 6bf02235
      Thomas Haller authored
      The "source" field of NMPlatformIPRoute (now "rt_source") maps to the
      protocol field of the route. The source of NMPlatformIPAddress (now
      "addr_source") has no direct equivalent in the kernel.
      As their use is different, they should have different names. Also,
      the name "source" is used all over the place. Hence give the fields
      a more distinct name.
  20. 11 Apr, 2016 2 commits
  21. 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
  22. 03 Dec, 2015 1 commit
  23. 02 Nov, 2015 1 commit
    • Thomas Haller's avatar
      platform: properly handle IPv4 peer-addresses · 6c8aa669
      Thomas Haller authored
      The peer-address (IFA_ADDRESS) can also be all-zero (
      That is distinct from an usual address without explicit peer-address,
      which implicitly has the same peer and local address.
      Previously, we treated an all-zero peer_address as having peer and
      local address equal. This is especially grave, because the peer is part
      of the primary key for an IPv4 address. So we not only get a property of
      the address wrong, but we wrongly consider two different addresses as
      one and the same.
      To properly handle these addresses, we always must explicitly set the peer.
  24. 01 Nov, 2015 1 commit
    • Thomas Haller's avatar
      platform: add buffer argument to platform to-string functions · a2d59f5f
      Thomas Haller authored
      Arguably, it is more convenient to use the static buffer as
      it saves typing.
      But having such a low-level function use a static buffer also
      limits the way how to use it. As it was, you could not avoid
      using the static buffer.
      E.g. you cannot do:
        char buf[100];
        _LOGD ("nmp-object: %s; platform-link: %s",
               nmp_object_to_string (nmpobj, buf, sizeof(buf)),
               nm_platform_link_to_string (link));
      This will fail for non-obvious reasons because both
      to-string functions end up using the same static buffer.
      Also change the to-string implementations to accept NULL
      as valid and return it as "(null)".
  25. 05 Aug, 2015 1 commit
  26. 24 Jul, 2015 1 commit
    • Dan Winship's avatar
      all: rename nm-glib-compat.h to nm-glib.h, use everywhere · 3452ee2a
      Dan Winship authored
      Rather than randomly including one or more of <glib.h>,
      <glib-object.h>, and <gio/gio.h> everywhere (and forgetting to include
      "nm-glib-compat.h" most of the time), rename nm-glib-compat.h to
      nm-glib.h, include <gio/gio.h> from there, and then change all .c
      files in NM to include "nm-glib.h" rather than including the glib
      headers directly.
      (Public headers files still have to include the real glib headers,
      since nm-glib.h isn't installed...)
      Also, remove glib includes from header files that are already
      including a base object header file (which must itself already include
      the glib headers).
  27. 09 Jun, 2015 1 commit
  28. 27 Feb, 2015 4 commits
  29. 09 Feb, 2015 1 commit
  30. 13 Nov, 2014 1 commit
    • Dan Winship's avatar
      all: consistently include config.h · 3bfb163a
      Dan Winship authored
      config.h should be included from every .c file, and it should be
      included before any other include. Fix that.
      (As a side effect of how I did this, this also changes us to
      consistently use "config.h" rather than <config.h>. To the extent that
      it matters [which is not much], quotes are more correct anyway, since
      we're talking about a file in our own build tree, not a system
  31. 07 Nov, 2014 1 commit
    • Dan Williams's avatar
      libnm,core: enhance nm_utils_hexstr2bin() · 22762324
      Dan Williams authored
      Make the type return GBytes since most in-tree users want that.
      Allow the function to accept many more formats as valid hex, including
      bytes delimited by ':' and a leading '0x'.