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. 12 Feb, 2019 3 commits
  3. 13 Nov, 2018 6 commits
    • Thomas Haller's avatar
      dhcp/trivial: wrap lines in calling client_start() · ce1cfd72
      Thomas Haller authored
      A possible issue is that client_start() has about 136 arguments.
      It doesn't get simpler by saving lines of code and writing them
      all in the same line.
      
      Wrap the lines.
      
      While at it, use "FALSE" for "enforce_duid" argument, instead of "0".
      It's a boolean.
      ce1cfd72
    • Thomas Haller's avatar
    • Thomas Haller's avatar
      b833d68d
    • Thomas Haller's avatar
      dhcp: don't pass duid to client ip6_start() and stop() · 7d55b134
      Thomas Haller authored
      We don't do that for ip4_start() either. The duid/client-id
      is stored inside the NMDhcpClient instance, and the function can
      access it from there.
      
      Maybe, it is often preferable to have stateless objects and not
      relying on ip4_start() to obtain the client ID from the client's
      state. However, the purpose of the NMDhcpClient object is to
      hold state about DHCP. To simplify the complexity of objects that
      inherrently have state, we should be careful about mutating the state.
      It adds little additional complexity of only reading the state when
      needed anyway. In fact, it adds complexity, because previously
      it wasn't enough to check all callers of nm_dhcp_client_get_client_id()
      to see where the client-id is used. Instead, one would also need to
      follow the @duid argument several layers of the call stack.
      7d55b134
    • Thomas Haller's avatar
      dhcp: refactor nm_dhcp_dhclient_save_duid() to accept original DUID · cd9e418f
      Thomas Haller authored
      There should be lower layers that are concerned with writing
      and reading dhclient configuration files. It's wrong to
      have a nm_dhcp_dhclient_save_duid() function which requires
      the caller to pre-escape the string to write. The caller shouldn't
      be concerned with the file format, that's why the function
      is used in the first place.
      cd9e418f
    • Thomas Haller's avatar
      dhcp: don't re-read DHCP client ID from configuration file for dhclient · 5411fb0c
      Thomas Haller authored
      Why would we do this? The configuration file we are reading back was
      written by NetworkManager in the first place.
      
      Maybe when assuming a connection after restart, this information could
      be interesting. It however is not actually relevant.
      
      Note how nm_dhcp_client_get_client_id() has only very few callers.
      
        - nm_device_spawn_iface_helper() in 'nm-device.c'. In this case,
          we either should use the client-id which we used when starting
          DHCP, or none at all.
      
        - ip4_start() in 'nm-dhcp-dhclient.c', but this is before starting
          DHCP client and before it was re-read from configuration file.
      
        - in "src/dhcp/nm-dhcp-systemd.c", but this has no effect for
          the dhclient plugin.
      5411fb0c
  4. 27 Sep, 2018 1 commit
  5. 18 Sep, 2018 1 commit
    • Lubomir Rintel's avatar
      config: add --configure-and-quit=initrd mode · c263f535
      Lubomir Rintel authored
      We need a mode that:
      
      * doesn't leave processes behind
      * doesn't force an internal dhclient
      * doesn't auto-generate default connections
      * doesn't write out files into libdir, only /run
      
      The original configure-and-quit mode doesn't really fit the initrd use. But
      it's proobably not a good idea to just change its behavior.
      c263f535
  6. 12 Sep, 2018 2 commits
  7. 10 Sep, 2018 2 commits
  8. 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
          587
          $ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l
          21114
      
      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' \
            "${FILES[@]}"
      e1c7a2b5
  9. 20 Jun, 2018 2 commits
  10. 09 Jun, 2018 2 commits
    • Francesco Giudici's avatar
      dhcp: allow to skip DUID search from DHCP client global configuration · f054c3fc
      Francesco Giudici authored
      When the used client is dhclient we were used to search for DUID not
      only in the specific lease files generated by NetworkManager, but also
      in the global lease file generated outside NetworkManager.
      Keep this capability but allow to just search in the NM lease files if
      a value different from the default one is specified in dhcp-duid.
      f054c3fc
    • Francesco Giudici's avatar
      dhcp: remove fallback DUID-UUID generation from dhcp code · 0d841e74
      Francesco Giudici authored
      This commit centralizes the DUID generation in nm-device.c.
      As a consequence, a DUID is always provided when starting a
      DHCPv6 client. The DHCP client can override the passed DUID
      with the value contained in the client-specific lease file.
      0d841e74
  11. 26 May, 2018 4 commits
  12. 30 Apr, 2018 1 commit
  13. 20 Mar, 2018 1 commit
  14. 15 Feb, 2018 4 commits
    • Thomas Haller's avatar
      dhcp: refactor type of NMDhcpClient duid to be GBytes · 578c4af9
      Thomas Haller authored
      GBytes is immutable. It's better suited to contain the duid parameter
      then a GByteArray.
      578c4af9
    • Thomas Haller's avatar
      dhcp: cache info-only parameter in NMDhcpClient · 8ff962d9
      Thomas Haller authored
      Optimally, NMDhcpClient would be stateless and all paramters would
      be passed on as argument. Clearly that is not feasable, because there
      are so many paramters, and in many cases they need to be cached for the
      lifetime of the client instance.
      
      Instead of passing info_only paramter to ip6_start() and cache it
      both in NMDhcpClient and NMDhcpSystemd, keep it in NMDhcpClient at
      one place.
      
      In the next commit, we will initialize info-only only once during the
      constructor, so it is immutable and somewhat stateless.
      8ff962d9
    • Thomas Haller's avatar
      dhcp: chain up parent stop() for NMDhcpSystem client · badace72
      Thomas Haller authored
      The parent's stop() implementation does nothing interesting
      for NMDhcpSystem. Still, call it, it's just unexpected to
      not chain up the parent implementation, if all other subclasses
      do it.
      
      In general, if the parent's implementation is not suitable to be called
      by the derived class, that should be handled differently then just not
      chaining up. Otherwise it's inconsistent and confusing.
      badace72
    • Thomas Haller's avatar
  15. 07 Feb, 2018 1 commit
  16. 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
      origin.
      
      Also, the previous commits of this branch broke handling of the
      default-route :) . That should be working now again.
      5c299454
  17. 09 Oct, 2017 1 commit
  18. 06 Oct, 2017 1 commit
  19. 15 Sep, 2017 1 commit
    • Francesco Giudici's avatar
      dhcp: dhclient: remove the --timeout argument from the command line · 1cb4832f
      Francesco Giudici authored
      the --timeout command line option is a custom feature added in some
      linux distributions (fedora). Passing that command line argument will
      make dhclient fail if the binary does not support it, preventing
      activation of dhcp based connections.
      Worse, the option has just been recently changed from "-timeout", so
      that we are currently incompatibile with Centos, RedHat and older
      versions of Fedora too.
      
      Leverage the "timeout" option in dhclient config file: it will produce
      the expected behavior and will be universally supported.
      
      Fixes test: dhcp-timeout
      Fixes: fa467360
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1491243
      1cb4832f
  20. 11 Sep, 2017 2 commits
    • Thomas Haller's avatar
      core/dhcp: use addr-family parameter for instead of boolean · 3c84dd15
      Thomas Haller authored
      In many cases we want to treat IPv4 and IPv6 generically. That looks nicer
      if we distingish by an @addr_family integer, instead of a boolean.
      
      Replace the @is_ipv6 boolean with an @addr_family paramter. The @is_ipv6
      boolean is inconsistent with other places where we use @is_ipv4 to
      indicate the opposite. Eventually, we should use @addr_family
      everywhere.
      
      Also, at the call site it's not immediately clear what TRUE/FALSE means,
      here AF_INET/AF_INET6 is better.
      3c84dd15
    • Francesco Giudici's avatar
      dhcp: dhclient: fix daemon start when dhcp-timeout is specified · fa467360
      Francesco Giudici authored
      A typo in the new dhcp-timeout option caused the dhclient daemon to exit
      with error when the dhcp-timeout option was specified.
      This prevents dhcp connection to be upped.
      
      Fixes: 82ef497c
      fa467360
  21. 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.
      89385bd9
  22. 09 May, 2017 1 commit