1. 13 Oct, 2017 1 commit
  2. 12 Oct, 2017 9 commits
    • Thomas Haller's avatar
      core: use router preference for IPv6 routes · 032b4e43
      Thomas Haller authored
      For routes and the default-route from NDisc, set the router preference
      RTA_PREF.
      
      Also, previously, we would only configure one IPv6 default-route. That by itself
      was not really a problem, as long as NetworkManager would always make sure that
      it configured the route to the ~best~ router.
      
      Actually, NM should have done that already. It keeps the list of gateways
      sorted, and prefers them according to their preference. But maybe
      it didn't, so we have bug rh#1445417 (??).
      
      Change that by configuring a default-route for all gateways, with
      appropriate router prefrence. In case, kernel doesn't support RTA_PREF
      yet, only configure all routes that share the same maxiumum preference.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1445417
      032b4e43
    • Thomas Haller's avatar
    • Thomas Haller's avatar
      platform: support pref option for IPv6 routes (RTA_PREF) · 37ffc8ba
      Thomas Haller authored
      Support IPv6 router preference (RFC4191) in platform code.
      37ffc8ba
    • Thomas Haller's avatar
      platform: refactor detecting kernel support · 5b0745e7
      Thomas Haller authored
      We are going to add another parameter to check. Instead of adding multiple
      virtual functions, add a NMPlatformKernelSupportFlags flags enum.
      5b0745e7
    • Thomas Haller's avatar
      ndisc: some cleanup of RA handling · 5b507d57
      Thomas Haller authored
      - add assert code to check that our internal tracking of
        the gateways is consistent.
      
      - assert (gracefully) against libndp returning :: as gateway
        address.
      5b507d57
    • Thomas Haller's avatar
      ndisc: rename NMNDiscPreference to NMIcmpv6RouterPref · 32142a63
      Thomas Haller authored
      We encounter the same enum in 3 forms:
      
        - NMNDiscPreference in NetworkManager
        - "enum ndp_route_preference" in <ndp.h>
        - ICMPV6_ROUTER_PREF_* in <linux/icmpv6.h>
      
      Move our enum to nm-core-utils.h, so that it can be used
      by platform code as well (platform code should not include
      ndisc/nm-ndisc.h).
      
      Also, NMNDiscPreference was not numerically identical to their
      native values (meaning: it shuffled the names and numbers).
      Make them all numerically equal, so that they can be used in
      the same context.
      This means, while previously we could compare NMNDiscPreference
      directly according to their priority, we now need _preference_to_priority().
      On the other hand, we could omit translate_preference() -- but actually,
      we still have _route_preference_coerce() because pref comes from libndp
      and is thus untrusted. We still have to range check it.
      32142a63
    • Thomas Haller's avatar
      ndisc: cleanup handling of timestamps · 7d59641d
      Thomas Haller authored
      We have the timestamp nm_utils_get_monotonic_time_s(), which should be
      gint32 type. Then we also have timestamps in the NMNDisc* objects, which
      consist of guint32 timestamp and lifetime.
      
      Cleanup handling the times and calculation of the timestamps by using
      the correct integer type consistently and ensuring that no integer overflow
      occurs.
      7d59641d
    • Thomas Haller's avatar
      ndisc: use unsigned int for loop index variable · cd954702
      Thomas Haller authored
      The @i variable to loop over the arrays should have the same type as
      GArray.len, to which it is compared. In this case "guint".
      
      As we remove items from the arrays while iterating over it, it gets
      a bit complicated either way. I disliked that
      
        g_array_remove_index (rdata->gateways, i--);
      
      would underflow for unsigned integers. While that would work fine,
      I think that is confusing. So, the variable is no longer incremented
      in the increment statement of the for loop.
      cd954702
    • Beniamino Galvani's avatar
      bus-manager: don't leak connections · 5b81d403
      Beniamino Galvani authored
      The bus manager takes extra references to the GDBusConnection every
      time g_dbus_object_manager_server_get_connection() its called,
      preventing its disposal once the connection is closed. This causes a
      leak for each DHCP event.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1461643
      5b81d403
  3. 11 Oct, 2017 3 commits
    • Thomas Haller's avatar
      systemd: fix compilation if libc doesn't provide getrandom() · 8b26cf43
      Thomas Haller authored
      Before commit 650a7022, we would
      always forego using getrandom(). That changed, and now we detect
      at compile time whether getrandom() is provided by libc. So, if you
      build against recent libc, we use it too.
      
      However, systemd's src/basic/missing_syscall.h also provides getrandom() by
      calling the syscall directly. We don't do that, because it seems too cumbersome
      to maintain.
      
      Fixes: 650a7022
      8b26cf43
    • Thomas Haller's avatar
      systemd: update code from upstream (2017-10-11) · 03b7c384
      Thomas Haller authored
      This is a direct dump from systemd git on 2017-10-11, git commit
      0da812036f6fd60a7b5477fafb2eead9e98f4c78.
      
      ======
      
      SYSTEMD_DIR=../systemd
      COMMIT=0da812036f6fd60a7b5477fafb2eead9e98f4c78
      
      (
        cd "$SYSTEMD_DIR"
        git checkout "$COMMIT"
        git reset --hard
        git clean -fdx
      )
      
      git ls-files :/src/systemd/src/ | xargs -d '\n' rm -f
      
      nm_copy_sd() {
          mkdir -p "./src/systemd/$(dirname "$1")"
          cp "$SYSTEMD_DIR/$1" "./src/systemd/$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/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.c"
      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/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 "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"
      03b7c384
    • Thomas Haller's avatar
      core: cleanup implementation of nm_auto* macros to use nm_auto() · 1a8f1233
      Thomas Haller authored
      Don't use __attribute__((cleanup(func))) directly.
      1a8f1233
  4. 10 Oct, 2017 3 commits
    • Beniamino Galvani's avatar
      connectivity: fix memory leak · 92e8ec5e
      Beniamino Galvani authored
      The server response, allocated in easy_write_cb(), was not freed.
      
      Fixes: 7307dea9
      92e8ec5e
    • Beniamino Galvani's avatar
      core: fix memory leaks in NMIP{4,6}Config · 31ad3dbc
      Beniamino Galvani authored
      Fixes: 03e1cc96
      Fixes: 9a3117f1
      31ad3dbc
    • 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
  5. 09 Oct, 2017 9 commits
    • Thomas Haller's avatar
      core: don't track route metric in ip-config · 2bdfc092
      Thomas Haller authored
      It's not needed. Whenever we add a route, we pass in the
      route metric (for example, based on the device's configuration).
      No need to merge and track it into the NMIP4Config/NMIP6Config.
      
      The metric was only used in nm_ip4_config_create_setting()
      and nm_ip6_config_create_setting(). In fact it's wrong to do
      that, because it means we first capture some settings, and guess
      the configured route metric. But we cannot do that. Our best
      guess what a configured setting might be is -1.
      2bdfc092
    • Thomas Haller's avatar
      core: don't track route MSS in ip-config · 9003dae6
      Thomas Haller authored
      The MSS is only set for VPN connections (by merging it in the respective
      NMIP4Config/NMIP6Config).
      
      It is also only used when setting the MSS of the default route.
      
      Don't track that property in NMIP4Config/NMIP6Config, instead, set the
      mss of the route directly in nm_vpn_connection_ip4_config_get() and
      nm_vpn_connection_ip6_config_get().
      
      There is a potential change in behavior here: NMDevice also consisdered
      the MSS for the default route, but that would only be set if the MSS
      gets merged from an vpn-ip-config. Which at most is the case for
      iterface-less VPN types (libreswan). But even in that case, it doesn't
      seem right to me to use the VPN's MSS for the device's default-route.
      9003dae6
    • Thomas Haller's avatar
      core: use ipv6.route-table setting for other IPv6 routes · 2e146148
      Thomas Haller authored
      Including device-routes, default-route, SLAAC.
      2e146148
    • Thomas Haller's avatar
      core: use ipv4.route-table setting for other IPv4 routes · 01930c96
      Thomas Haller authored
      Including device-routes, default-route, DHCPv4, IPv4LL.
      01930c96
    • Thomas Haller's avatar
      all: rework configuring route table support by adding "route-table" setting · cc1ee1d2
      Thomas Haller authored
      We added "ipv4.route-table-sync" and "ipv6.route-table-sync" to not change
      behavior for users that configured policy routing outside of NetworkManager,
      for example, via a dispatcher script. Users had to explicitly opt-in
      for NetworkManager to fully manage all routing tables.
      
      These settings were awkward. Replace them with new settings "ipv4.route-table"
      and "ipv6.route-table". Note that this commit breaks API/ABI on the unstable
      development branch by removing recently added API.
      
      As before, a connection will have no route-table set by default. This
      has the meaning that policy-routing is not enabled and only the main table
      will be fully synced. Once the user sets a table, we recognize that and
      NetworkManager manages all routing tables.
      
      The new route-table setting has other important uses: analog to
      "ipv4.route-metric", it is the default that applies to all routes.
      Currently it only works for static routes, not DHCP, SLAAC,
      default-route, etc. That will be implemented later.
      
      For static routes, each route still can explicitly set a table, and
      overwrite the per-connection setting in "ipv4.route-table" and
      "ipv6.route-table".
      cc1ee1d2
    • Thomas Haller's avatar
      dns: merge IPv4 and IPv6 implementation for update_add_ip_config() · 17ca5c4c
      Thomas Haller authored
      How nice would it be to have a NMIPConfig class that is
      agnostic for IPv4 and IPv6. Another small step, in unifying
      v4 and v6.
      17ca5c4c
    • Thomas Haller's avatar
      core: refactor parsing resolve.conf · 8f1ef161
      Thomas Haller authored
      - merge the IPv4 and IPv6 implementations. They are for the most
        part identical. Also, they are independent of NMIP4Config/NMIP6Config.
      
      - parse the entire file at once. Don't parse it twice, once for the
        name servers and once for the options. This also avoids loading
        /etc/resolv.conf twice, as it would be done before.
      8f1ef161
    • Thomas Haller's avatar
      platform: mark static nla_policy variables as const · 637c6cb3
      Thomas Haller authored
      These static variables really never be modified.
      Mark them as const, which allows the linker to mark them as
      read-only.
      
      The problem is libnl3's API, which has these parameters
      not as const. Add a workaround for that. Clearly libnl3 is
      not gonna modify the policy, that the API was fixed too [1]
      
      [1] https://github.com/thom311/libnl/commit/b4802a17a7655bfeee3e9c06e649d30b96dbad3b
      637c6cb3
    • Thomas Haller's avatar
  6. 06 Oct, 2017 13 commits
  7. 05 Oct, 2017 2 commits