1. 04 Sep, 2018 3 commits
  2. 30 Aug, 2018 2 commits
  3. 28 Aug, 2018 3 commits
    • Thomas Haller's avatar
      settings: use delegation instead of inheritance for NMSettingsConnection and NMConnection · 38273a88
      Thomas Haller authored
      NMConnection is an interface, which is implemented by the types
      NMSimpleConnection (libnm-core), NMSettingsConnection (src) and
      NMRemoteConnection (libnm).
      
      NMSettingsConnection does a lot of things already:
      
        1) it "is-a" NMDBusObject and exports the API of a connection profile
           on D-Bus
        2) it interacts with NMSettings and contains functionality
           for tracking the profiles.
        3) it is the base-class of types like NMSKeyfileConnection and
           NMIfcfgConnection. These handle how the profile is persisted
           on disk.
        4) it implements NMConnection interface, to itself track the
           settings of the profile.
      
      3) and 4) would be better implemented via delegation than inheritance.
      
      Address 4) and don't let NMSettingsConnection implemente the NMConnection
      interface. Instead, a settings-connection references now a NMSimpleConnection
      instance, to which it delegates for keeping the actual profiles.
      
      Advantages:
      
        - by delegating, there is a clearer separation of what
          NMSettingsConnection does. For example, in C we often required
          casts from NMSettingsConnection to NMConnection. NMConnection
          is a very trivial object with very little logic. When we have
          a NMConnection instance at hand, it's good to know that it is
          *only* that simple instead of also being an entire
          NMSettingsConnection instance.
      
          The main purpose of this patch is to simplify the code by separating
          the NMConnection from the NMSettingsConnection. We should generally
          be aware whether we handle a NMSettingsConnection or a trivial
          NMConnection instance. Now, because NMSettingsConnection no longer
          "is-a" NMConnection, this distinction is apparent.
      
        - NMConnection is implemented as an interface and we create
          NMSimpleConnection instances whenever we need a real instance.
          In GLib, interfaces have a performance overhead, that we needlessly
          pay all the time. With this change, we no longer require
          NMConnection to be an interface. Thus, in the future we could compile
          a version of libnm-core for the daemon, where NMConnection is not an
          interface but a GObject implementation akin to NMSimpleConnection.
      
        - In the previous implementation, we cannot treat NMConnection immutable
          and copy-on-write.
          For example, when NMDevice needs a snapshot of the activated
          profile as applied-connection, all it can do is clone the entire
          NMSettingsConnection as a NMSimpleConnection.
          Likewise, when we get a NMConnection instance and want to keep
          a reference to it, we cannot do that, because we never know
          who also references and modifies the instance.
          By separating NMSettingsConnection we could in the future have
          NMConnection immutable and copy-on-write, to avoid all unnecessary
          clones.
      38273a88
    • Thomas Haller's avatar
      device: don't limit try count in nm_device_ethernet_utils_get_default_wired_name() · 3a99c343
      Thomas Haller authored
      The limit of trying up to 10000 was arbitrary. In practice, we are not expected
      that we need that many searches. If that would be the case (and we would have
      10000 conflicting connections that take all the names), then we anyway would
      need to refactor the code not to scale with O(n^2).
      
      Replace the arbitrary limit with an even larger one. The new limit is so
      large that in practice it's impossible to reach it.
      3a99c343
    • Thomas Haller's avatar
      device: refactor setting parent in device's update_connection() · 72de0afa
      Thomas Haller authored
      Add a helper function nm_device_parent_find_for_connection() to
      unify implementations of setting the parent in update_connection().
      
      There is some change in behavior, in particular for nm-device-vlan.c,
      which no longer compares the link information from platform. But
      update_connection() is anyway a questionable concept, only used
      for external assumed connection (which itself, is questionable). Meaning,
      update_connection() is a hack not science, and it's not at all clear
      what the correct behavior is.
      
      Also, note how vlan's implementation differs from all others. Why?
      Should we always resort to also check the information from platform?
      Either way, one of the two approaches should be used consistently and
      nm_device_parent_find_for_connection() opts to not consult platform
      cache.
      72de0afa
  4. 27 Aug, 2018 2 commits
    • Thomas Haller's avatar
      build: cleanup build defines for session-tracking · 1a9bc224
      Thomas Haller authored
      - always define the SESSION_TRACKING_* defines to replace
        "#ifdef" with "#if".
      
      - drop defining the consolekit database path CKDB_PATH in
        config.h. The path was not customizable via configure/meson.
      
      - fix meson build to enable consolekit support for session tracking
        without also enabling logind/elogind session tracking.
        logind/elogind is mutually exclusive, but consolekit session tracking
        goes together just fine.
      1a9bc224
    • Thomas Haller's avatar
      build: always define NM_MORE_LOGGING define and don't check with #ifdef · 3b5f8c91
      Thomas Haller authored
      Using '#ifdef' is generally error prone. It's better to always define
      a define and check for it explicitly. This way, the compiler can issue
      a warning if the define does not exist.
      
      Also, note how meson would always define NM_MORE_LOGGING, possibly to
      "0". That means, for meson, we unintentionally always enabled more
      logging because the define was always present.
      
      Fix that.
      3b5f8c91
  5. 26 Aug, 2018 2 commits
    • Thomas Haller's avatar
      wifi: don't use :1 bitfield for gboolean type · 610ca870
      Thomas Haller authored
      gboolean is a typedef for "int".
      
      While older compilers might treat such bitfields as unsigned ([1]),
      commonly such a bitfield is signed and can only contain the values 0
      and -1.
      
      We only want to use numeric 1 for TRUE, hence, creating such bitfields
      is wrong, or at least error prone.
      
      In fact, in this case it's a bug, because later we compare
      it with a regular gboolean
      
        if (priv->scanning != new_scanning)
      
      [1] https://lgtm.com/rules/1506024027114/
      
      Fixes: e0f96770
      610ca870
    • Thomas Haller's avatar
      systemd: update code from upstream (2018-08-26) · 8aa8d747
      Thomas Haller authored
      This is a direct dump from systemd git.
      
      ======
      
      SYSTEMD_DIR=../systemd
      COMMIT=56663345dfb1dd3ff23cac5fbc955aba54477efa
      
      (
        cd "$SYSTEMD_DIR"
        git checkout "$COMMIT"
        git reset --hard
        git clean -fdx
      )
      
      git ls-files :/src/systemd/src/ \
                   :/shared/nm-utils/unaligned.h | \
        xargs -d '\n' rm -f
      
      nm_copy_sd() {
          mkdir -p "./src/systemd/$(dirname "$1")"
          cp "$SYSTEMD_DIR/$1" "./src/systemd/$1"
      }
      
      nm_copy_sd_shared() {
          mkdir -p "./shared/nm-utils/"
          cp "$SYSTEMD_DIR/$1" "./shared/nm-utils/${1##*/}"
      }
      
      nm_copy_sd "src/basic/alloc-util.c"
      nm_copy_sd "src/basic/alloc-util.h"
      nm_copy_sd "src/basic/async.h"
      nm_copy_sd "src/basic/env-util.c"
      nm_copy_sd "src/basic/env-util.h"
      nm_copy_sd "src/basic/escape.c"
      nm_copy_sd "src/basic/escape.h"
      nm_copy_sd "src/basic/ether-addr-util.c"
      nm_copy_sd "src/basic/ether-addr-util.h"
      nm_copy_sd "src/basic/extract-word.c"
      nm_copy_sd "src/basic/extract-word.h"
      nm_copy_sd "src/basic/fileio.c"
      nm_copy_sd "src/basic/fileio.h"
      nm_copy_sd "src/basic/fd-util.c"
      nm_copy_sd "src/basic/fd-util.h"
      nm_copy_sd "src/basic/fs-util.c"
      nm_copy_sd "src/basic/fs-util.h"
      nm_copy_sd "src/basic/hash-funcs.c"
      nm_copy_sd "src/basic/hash-funcs.h"
      nm_copy_sd "src/basic/hashmap.c"
      nm_copy_sd "src/basic/hashmap.h"
      nm_copy_sd "src/basic/hexdecoct.c"
      nm_copy_sd "src/basic/hexdecoct.h"
      nm_copy_sd "src/basic/hostname-util.c"
      nm_copy_sd "src/basic/hostname-util.h"
      nm_copy_sd "src/basic/in-addr-util.c"
      nm_copy_sd "src/basic/in-addr-util.h"
      nm_copy_sd "src/basic/io-util.c"
      nm_copy_sd "src/basic/io-util.h"
      nm_copy_sd "src/basic/list.h"
      nm_copy_sd "src/basic/log.h"
      nm_copy_sd "src/basic/macro.h"
      nm_copy_sd "src/basic/mempool.h"
      nm_copy_sd "src/basic/mempool.c"
      nm_copy_sd "src/basic/parse-util.c"
      nm_copy_sd "src/basic/parse-util.h"
      nm_copy_sd "src/basic/path-util.c"
      nm_copy_sd "src/basic/path-util.h"
      nm_copy_sd "src/basic/prioq.h"
      nm_copy_sd "src/basic/prioq.c"
      nm_copy_sd "src/basic/process-util.h"
      nm_copy_sd "src/basic/process-util.c"
      nm_copy_sd "src/basic/random-util.c"
      nm_copy_sd "src/basic/random-util.h"
      nm_copy_sd "src/basic/refcnt.h"
      nm_copy_sd "src/basic/set.h"
      nm_copy_sd "src/basic/signal-util.h"
      nm_copy_sd "src/basic/siphash24.h"
      nm_copy_sd "src/basic/socket-util.c"
      nm_copy_sd "src/basic/socket-util.h"
      nm_copy_sd "src/basic/sparse-endian.h"
      nm_copy_sd "src/basic/stat-util.c"
      nm_copy_sd "src/basic/stat-util.h"
      nm_copy_sd "src/basic/stdio-util.h"
      nm_copy_sd "src/basic/string-table.c"
      nm_copy_sd "src/basic/string-table.h"
      nm_copy_sd "src/basic/string-util.c"
      nm_copy_sd "src/basic/string-util.h"
      nm_copy_sd "src/basic/strv.c"
      nm_copy_sd "src/basic/strv.h"
      nm_copy_sd "src/basic/time-util.c"
      nm_copy_sd "src/basic/time-util.h"
      nm_copy_sd "src/basic/umask-util.h"
      nm_copy_sd_shared "src/basic/unaligned.h"
      nm_copy_sd "src/basic/utf8.c"
      nm_copy_sd "src/basic/utf8.h"
      nm_copy_sd "src/basic/util.c"
      nm_copy_sd "src/basic/util.h"
      nm_copy_sd "src/libsystemd-network/arp-util.c"
      nm_copy_sd "src/libsystemd-network/arp-util.h"
      nm_copy_sd "src/libsystemd-network/dhcp6-internal.h"
      nm_copy_sd "src/libsystemd-network/dhcp6-lease-internal.h"
      nm_copy_sd "src/libsystemd-network/dhcp6-network.c"
      nm_copy_sd "src/libsystemd-network/dhcp6-option.c"
      nm_copy_sd "src/libsystemd-network/dhcp6-protocol.h"
      nm_copy_sd "src/libsystemd-network/dhcp-identifier.c"
      nm_copy_sd "src/libsystemd-network/dhcp-identifier.h"
      nm_copy_sd "src/libsystemd-network/dhcp-internal.h"
      nm_copy_sd "src/libsystemd-network/dhcp-lease-internal.h"
      nm_copy_sd "src/libsystemd-network/dhcp-network.c"
      nm_copy_sd "src/libsystemd-network/dhcp-option.c"
      nm_copy_sd "src/libsystemd-network/dhcp-packet.c"
      nm_copy_sd "src/libsystemd-network/dhcp-protocol.h"
      nm_copy_sd "src/libsystemd-network/lldp-internal.h"
      nm_copy_sd "src/libsystemd-network/lldp-neighbor.c"
      nm_copy_sd "src/libsystemd-network/lldp-neighbor.h"
      nm_copy_sd "src/libsystemd-network/lldp-network.c"
      nm_copy_sd "src/libsystemd-network/lldp-network.h"
      nm_copy_sd "src/libsystemd-network/network-internal.c"
      nm_copy_sd "src/libsystemd-network/network-internal.h"
      nm_copy_sd "src/libsystemd-network/sd-dhcp6-client.c"
      nm_copy_sd "src/libsystemd-network/sd-dhcp6-lease.c"
      nm_copy_sd "src/libsystemd-network/sd-dhcp-client.c"
      nm_copy_sd "src/libsystemd-network/sd-dhcp-lease.c"
      nm_copy_sd "src/libsystemd-network/sd-ipv4ll.c"
      nm_copy_sd "src/libsystemd-network/sd-ipv4acd.c"
      nm_copy_sd "src/libsystemd-network/sd-lldp.c"
      nm_copy_sd "src/libsystemd/sd-event/sd-event.c"
      nm_copy_sd "src/libsystemd/sd-id128/id128-util.c"
      nm_copy_sd "src/libsystemd/sd-id128/id128-util.h"
      nm_copy_sd "src/libsystemd/sd-id128/sd-id128.c"
      nm_copy_sd "src/shared/dns-domain.c"
      nm_copy_sd "src/shared/dns-domain.h"
      nm_copy_sd "src/systemd/_sd-common.h"
      nm_copy_sd "src/systemd/sd-dhcp6-client.h"
      nm_copy_sd "src/systemd/sd-dhcp6-lease.h"
      nm_copy_sd "src/systemd/sd-dhcp-client.h"
      nm_copy_sd "src/systemd/sd-dhcp-lease.h"
      nm_copy_sd "src/systemd/sd-event.h"
      nm_copy_sd "src/systemd/sd-ndisc.h"
      nm_copy_sd "src/systemd/sd-id128.h"
      nm_copy_sd "src/systemd/sd-ipv4acd.h"
      nm_copy_sd "src/systemd/sd-ipv4ll.h"
      nm_copy_sd "src/systemd/sd-lldp.h"
      8aa8d747
  6. 22 Aug, 2018 10 commits
  7. 20 Aug, 2018 1 commit
    • Lubomir Rintel's avatar
      platform: if AF_INET6 is not available, don't warn · 20d905e5
      Lubomir Rintel authored
      These should be logged on DEBUG level:
      
        <warn>  platform-linux: do-change-link[2]: failure changing link: failure 97 (Address family not supported by protocol)
        <warn>  device (wlo1): failed to enable userspace IPv6LL address handling (unspecified)
      
      #10
      20d905e5
  8. 14 Aug, 2018 3 commits
  9. 11 Aug, 2018 3 commits
  10. 10 Aug, 2018 11 commits
    • Thomas Haller's avatar
      all/ethtool: add support for all currently supported kernel features · da109a29
      Thomas Haller authored
      As of upstream kernel v4.18-rc8.
      
      Note that we name the features like they are called in ethtool's
      ioctl API ETH_SS_FEATURES.
      
      Except, for features like "tx-gro", which ethtool utility aliases
      as "gro". So, for those features where ethtool has a built-in,
      alternative name, we prefer the alias.
      
      And again, note that a few aliases of ethtool utility ("sg", "tso", "tx")
      actually affect more than one underlying kernel feature.
      
      Note that 3 kernel features which are announced via ETH_SS_FEATURES are
      explicitly exluded because kernel marks them as "never_changed":
      
          #define NETIF_F_NEVER_CHANGE (NETIF_F_VLAN_CHALLENGED | \
                                        NETIF_F_LLTX | NETIF_F_NETNS_LOCAL)
      da109a29
    • Thomas Haller's avatar
      8c752076
    • Thomas Haller's avatar
      platform/ethtool: add code to get/set offload features via ethtool · c085b6e3
      Thomas Haller authored
      Also, add two more features "tx-tcp-segmentation" and
      "tx-tcp6-segmentation". There are two reasons for that:
      
       - systemd-networkd supports setting these two features,
         so lets support them too (apparently they are important
         enough for networkd).
      
       - these two features are already implicitly covered by "tso".
         Like for the "ethtool" program, "tso" is an alias for several
         actual features. By adding two features that are already
         also covered by an alias (which sets multiple kernel names
         at once), we showcase how aliases for the same feature can
         coexist. In particular, note how setting
         "tso on tx-tcp6-segmentation off" will behave as one would
         expect: all 4 tso features covered by the alias are enabled,
         except that particular one.
      c085b6e3
    • Thomas Haller's avatar
      platform/mii: use SocketHandle also for nmp_utils_mii_supports_carrier_detect() · 14f963cd
      Thomas Haller authored
      There is little difference in practice because there is only one caller.
      Still re-use the SocketHandle also for mii. If only, to make it clear
      that SocketHandle is not only suitable for ethtool, but also mii.
      14f963cd
    • Thomas Haller's avatar
      platform/ethtool: add SocketHandle to reuse socket for ethtool requests · bdd9f748
      Thomas Haller authored
      Previously, each call to ethtool_get() would resolve the ifindex and
      create a new socket for the ethtool request.
      
      This is partly done, because ethtool only supports making requests by
      name. Since interfaces can be renamed, this is inherrently racy. So,
      we want to fetch the latest name shortly before making the request.
      
      Some functions like nmp_utils_ethtool_supports_vlans() require multiple
      ioctls. And next, we will introduce more ethtool functions, that make an
      even larger number of individual requests.
      
      Add a simple SocketHandle struct, to create the socket once and reuse
      it for multiple requests. This is still entirely internal API in
      "nm-platform-utils.c".
      bdd9f748
    • Thomas Haller's avatar
      platform/ethtool: split functions for ETHTOOL_GSTRINGS · 29266e00
      Thomas Haller authored
      ethtool_get_stringset() will be used later, independently.
      
      Also, don't trust and ensure that the block of strings
      returned by ETHTOOL_GSTRINGS are NUL terminated.
      29266e00
    • Thomas Haller's avatar
      libnm, cli, ifcfg-rh: add NMSettingEthtool setting · df30651b
      Thomas Haller authored
      Note that in NetworkManager API (D-Bus, libnm, and nmcli),
      the features are called "feature-xyz". The "feature-" prefix
      is used, because NMSettingEthtool possibly will gain support
      for options that are not only -K|--offload|--features, for
      example -C|--coalesce.
      
      The "xzy" suffix is either how ethtool utility calls the feature
      ("tso", "rx"). Or, if ethtool utility specifies no alias for that
      feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
      If possible, we prefer ethtool utility's naming.
      
      Also note, how the features "feature-sg", "feature-tso", and
      "feature-tx" actually refer to multiple underlying kernel features
      at once. This too follows what ethtool utility does.
      
      The functionality is not yet implemented server-side.
      df30651b
    • Thomas Haller's avatar
    • Thomas Haller's avatar
      ifcfg-rh: refactor parsing in parse_ethtool_option() to not call helper functions · bcbea6fe
      Thomas Haller authored
      Parsing can be complicated enough. It's simpler to just work
      top-to-bottom, without calling various helper functions. This was,
      you can see all the code in one place, without need to jump to
      the helper function to see what it is doing.
      
      In general, a static function that is only called once, does sometimes
      not simplify but obfuscate the code.
      bcbea6fe
    • Thomas Haller's avatar
      ifcfg-rh: always reset ETHTOOL_WAKE_ON_LAN value · 64e0e241
      Thomas Haller authored
      We must always set all variables, because othewise a previously set
      value might be merged into the new setting.
      64e0e241
    • Thomas Haller's avatar
      ifcfg-rh: split setting ETHTOOL_OPTS from write_wired_setting() · cd442112
      Thomas Haller authored
      Will be used later, because we will not only have ethtool options
      in conjunction with wired settings.
      cd442112