Commit graph

23511 commits

Author SHA1 Message Date
Tom Gundersen 401fee7c20 dhcp: support notifying the client of the result of DAD
The DHCP client is not meant to use the assigned address before DAD
has completed successfully, if enabled. And if DAD fails, the server
should be notified with a DECLINE, in order to potentially blacklist
the address.

Currently, none of the clients support this, but add the required
callbacks, and allow clients to opt in if they want.
2019-07-05 11:04:32 +02:00
Beniamino Galvani be8f7b5a5d systemd: merge branch systemd into master 2019-07-05 09:13:53 +02:00
Beniamino Galvani 55c47d4efa systemd: update code from upstream (2019-07-04)
This is a direct dump from systemd git.

======

SYSTEMD_DIR=../systemd
COMMIT=52d8bcd131e7f3c9b7629412302e1ea46ddb70ca

(
  cd "$SYSTEMD_DIR"
  git checkout "$COMMIT"
  git reset --hard
  git clean -fdx
)

git ls-files -z :/src/systemd/src/ \
                :/shared/systemd/src/ \
                :/shared/nm-utils/unaligned.h | \
  xargs -0 rm -f

nm_copy_sd_shared() {
    mkdir -p "./shared/systemd/$(dirname "$1")"
    cp "$SYSTEMD_DIR/$1" "./shared/systemd/$1"
}

nm_copy_sd_core() {
    mkdir -p "./src/systemd/$(dirname "$1")"
    cp "$SYSTEMD_DIR/$1" "./src/systemd/$1"
}

nm_copy_sd_nmutils() {
    mkdir -p "./shared/nm-utils/"
    cp "$SYSTEMD_DIR/$1" "./shared/nm-utils/${1##*/}"
}

nm_copy_sd_core "src/libsystemd-network/arp-util.c"
nm_copy_sd_core "src/libsystemd-network/arp-util.h"
nm_copy_sd_core "src/libsystemd-network/dhcp-identifier.c"
nm_copy_sd_core "src/libsystemd-network/dhcp-identifier.h"
nm_copy_sd_core "src/libsystemd-network/dhcp-internal.h"
nm_copy_sd_core "src/libsystemd-network/dhcp-lease-internal.h"
nm_copy_sd_core "src/libsystemd-network/dhcp-network.c"
nm_copy_sd_core "src/libsystemd-network/dhcp-option.c"
nm_copy_sd_core "src/libsystemd-network/dhcp-packet.c"
nm_copy_sd_core "src/libsystemd-network/dhcp-protocol.h"
nm_copy_sd_core "src/libsystemd-network/dhcp6-internal.h"
nm_copy_sd_core "src/libsystemd-network/dhcp6-lease-internal.h"
nm_copy_sd_core "src/libsystemd-network/dhcp6-network.c"
nm_copy_sd_core "src/libsystemd-network/dhcp6-option.c"
nm_copy_sd_core "src/libsystemd-network/dhcp6-protocol.h"
nm_copy_sd_core "src/libsystemd-network/lldp-internal.h"
nm_copy_sd_core "src/libsystemd-network/lldp-neighbor.c"
nm_copy_sd_core "src/libsystemd-network/lldp-neighbor.h"
nm_copy_sd_core "src/libsystemd-network/lldp-network.c"
nm_copy_sd_core "src/libsystemd-network/lldp-network.h"
nm_copy_sd_core "src/libsystemd-network/network-internal.c"
nm_copy_sd_core "src/libsystemd-network/network-internal.h"
nm_copy_sd_core "src/libsystemd-network/sd-dhcp-client.c"
nm_copy_sd_core "src/libsystemd-network/sd-dhcp-lease.c"
nm_copy_sd_core "src/libsystemd-network/sd-dhcp6-client.c"
nm_copy_sd_core "src/libsystemd-network/sd-dhcp6-lease.c"
nm_copy_sd_core "src/libsystemd-network/sd-ipv4acd.c"
nm_copy_sd_core "src/libsystemd-network/sd-ipv4ll.c"
nm_copy_sd_core "src/libsystemd-network/sd-lldp.c"
nm_copy_sd_core "src/libsystemd/sd-event/event-source.h"
nm_copy_sd_core "src/libsystemd/sd-event/event-util.c"
nm_copy_sd_core "src/libsystemd/sd-event/event-util.h"
nm_copy_sd_core "src/libsystemd/sd-event/sd-event.c"
nm_copy_sd_core "src/libsystemd/sd-id128/id128-util.c"
nm_copy_sd_core "src/libsystemd/sd-id128/id128-util.h"
nm_copy_sd_core "src/libsystemd/sd-id128/sd-id128.c"
nm_copy_sd_core "src/shared/dns-domain.c"
nm_copy_sd_core "src/shared/dns-domain.h"
nm_copy_sd_core "src/systemd/_sd-common.h"
nm_copy_sd_core "src/systemd/sd-dhcp-client.h"
nm_copy_sd_core "src/systemd/sd-dhcp-lease.h"
nm_copy_sd_core "src/systemd/sd-dhcp6-client.h"
nm_copy_sd_core "src/systemd/sd-dhcp6-lease.h"
nm_copy_sd_core "src/systemd/sd-event.h"
nm_copy_sd_core "src/systemd/sd-id128.h"
nm_copy_sd_core "src/systemd/sd-ipv4acd.h"
nm_copy_sd_core "src/systemd/sd-ipv4ll.h"
nm_copy_sd_core "src/systemd/sd-lldp.h"
nm_copy_sd_core "src/systemd/sd-ndisc.h"
nm_copy_sd_nmutils "src/basic/unaligned.h"
nm_copy_sd_shared "src/basic/alloc-util.c"
nm_copy_sd_shared "src/basic/alloc-util.h"
nm_copy_sd_shared "src/basic/async.h"
nm_copy_sd_shared "src/basic/env-file.c"
nm_copy_sd_shared "src/basic/env-file.h"
nm_copy_sd_shared "src/basic/env-util.c"
nm_copy_sd_shared "src/basic/env-util.h"
nm_copy_sd_shared "src/basic/errno-util.h"
nm_copy_sd_shared "src/basic/escape.c"
nm_copy_sd_shared "src/basic/escape.h"
nm_copy_sd_shared "src/basic/ether-addr-util.c"
nm_copy_sd_shared "src/basic/ether-addr-util.h"
nm_copy_sd_shared "src/basic/extract-word.c"
nm_copy_sd_shared "src/basic/extract-word.h"
nm_copy_sd_shared "src/basic/fd-util.c"
nm_copy_sd_shared "src/basic/fd-util.h"
nm_copy_sd_shared "src/basic/fileio.c"
nm_copy_sd_shared "src/basic/fileio.h"
nm_copy_sd_shared "src/basic/format-util.c"
nm_copy_sd_shared "src/basic/format-util.h"
nm_copy_sd_shared "src/basic/fs-util.c"
nm_copy_sd_shared "src/basic/fs-util.h"
nm_copy_sd_shared "src/basic/hash-funcs.c"
nm_copy_sd_shared "src/basic/hash-funcs.h"
nm_copy_sd_shared "src/basic/hashmap.c"
nm_copy_sd_shared "src/basic/hashmap.h"
nm_copy_sd_shared "src/basic/hexdecoct.c"
nm_copy_sd_shared "src/basic/hexdecoct.h"
nm_copy_sd_shared "src/basic/hostname-util.c"
nm_copy_sd_shared "src/basic/hostname-util.h"
nm_copy_sd_shared "src/basic/in-addr-util.c"
nm_copy_sd_shared "src/basic/in-addr-util.h"
nm_copy_sd_shared "src/basic/io-util.c"
nm_copy_sd_shared "src/basic/io-util.h"
nm_copy_sd_shared "src/basic/list.h"
nm_copy_sd_shared "src/basic/log.h"
nm_copy_sd_shared "src/basic/macro.h"
nm_copy_sd_shared "src/basic/memory-util.c"
nm_copy_sd_shared "src/basic/memory-util.h"
nm_copy_sd_shared "src/basic/mempool.c"
nm_copy_sd_shared "src/basic/mempool.h"
nm_copy_sd_shared "src/basic/missing_fcntl.h"
nm_copy_sd_shared "src/basic/missing_socket.h"
nm_copy_sd_shared "src/basic/missing_stat.h"
nm_copy_sd_shared "src/basic/missing_type.h"
nm_copy_sd_shared "src/basic/parse-util.c"
nm_copy_sd_shared "src/basic/parse-util.h"
nm_copy_sd_shared "src/basic/path-util.c"
nm_copy_sd_shared "src/basic/path-util.h"
nm_copy_sd_shared "src/basic/prioq.c"
nm_copy_sd_shared "src/basic/prioq.h"
nm_copy_sd_shared "src/basic/process-util.c"
nm_copy_sd_shared "src/basic/process-util.h"
nm_copy_sd_shared "src/basic/random-util.c"
nm_copy_sd_shared "src/basic/random-util.h"
nm_copy_sd_shared "src/basic/set.h"
nm_copy_sd_shared "src/basic/signal-util.h"
nm_copy_sd_shared "src/basic/siphash24.h"
nm_copy_sd_shared "src/basic/socket-util.c"
nm_copy_sd_shared "src/basic/socket-util.h"
nm_copy_sd_shared "src/basic/sort-util.h"
nm_copy_sd_shared "src/basic/sparse-endian.h"
nm_copy_sd_shared "src/basic/stat-util.c"
nm_copy_sd_shared "src/basic/stat-util.h"
nm_copy_sd_shared "src/basic/stdio-util.h"
nm_copy_sd_shared "src/basic/string-table.c"
nm_copy_sd_shared "src/basic/string-table.h"
nm_copy_sd_shared "src/basic/string-util.c"
nm_copy_sd_shared "src/basic/string-util.h"
nm_copy_sd_shared "src/basic/strv.c"
nm_copy_sd_shared "src/basic/strv.h"
nm_copy_sd_shared "src/basic/time-util.c"
nm_copy_sd_shared "src/basic/time-util.h"
nm_copy_sd_shared "src/basic/tmpfile-util.c"
nm_copy_sd_shared "src/basic/tmpfile-util.h"
nm_copy_sd_shared "src/basic/umask-util.h"
nm_copy_sd_shared "src/basic/utf8.c"
nm_copy_sd_shared "src/basic/utf8.h"
nm_copy_sd_shared "src/basic/util.c"
nm_copy_sd_shared "src/basic/util.h"
2019-07-04 18:13:17 +02:00
Thomas Haller fe52a9467b shared: gracefully accept %NULL strings for NM_STR_HAS_PREFIX() and NM_STR_HAS_SUFFIX()
In case it wasn't obvious to a caller, allow %NULL as valid string
argument. Just be a bit more forgiving and fault-tolerant.
2019-07-04 17:11:24 +02:00
Beniamino Galvani c045267837 ifcfg-rh: fix memory leak reading infiniband setting 2019-07-04 11:53:25 +02:00
Beniamino Galvani 17f4a1e794 device: ppp: check that connection has a PPPoE parent
NMDevicePPP only handles connections with the pppoe.parent property
set. match_connection() already checks this when we creating a new
device. We should also perform the same check in
check_connection_compatible().

Fixes: 6c3195931e ('core: implement activation of PPP devices')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/203
2019-07-03 17:56:37 +02:00
Lubomir Rintel bdc57c3d70 release: bump version to 1.19.5-dev 2019-07-03 09:35:17 +02:00
Lubomir Rintel ce89e8b9b0 merge: branch 'lr/bootif'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/195
2019-07-03 09:27:43 +02:00
Lubomir Rintel 93859d8ffd initrd/tests: add some more variations of possible BOOTIF= variables
Test the form with a hwtype and color-separated as well as
hyphen-separated.
2019-07-03 09:16:52 +02:00
Lubomir Rintel 2952953a48 initrd: skip ethernet hwtype in BOOTIF
Dracut documents the BOOTIF argument to be a MAC address and so we
accept one in any of the conventions we recognize. However, the PXE boot
loaders like to prepend a "01-" to denote an ethernet hardware type.
Accept that too.

https://bugzilla.redhat.com/show_bug.cgi?id=1726240
2019-07-03 09:16:52 +02:00
Dan Williams f0e4137e1d cli: complete *-slave types (bond-slave, bridge-slave, team-slave)
While shorthand for "type ethernet slave-type <foo>" they are accepted
as types by nmcli so we might as well complete them.

https://bugzilla.redhat.com/show_bug.cgi?id=1654062

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/193
2019-07-02 18:04:14 +02:00
Thomas Haller e92dca357f all: merge branch 'th/various-settings-cleanup-4'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/192
2019-07-02 17:53:41 +02:00
Thomas Haller c163207b07 core: create virtual device on settings changes in idle handler
The callback from NMSettings about adding/updating a settings comes
from a deep call-stack already. We don't know the context of it, and
we shouldn't just right away create the profile. Instead, schedule an
action to create it in an idle handler.
2019-07-02 17:52:53 +02:00
Thomas Haller 42a034812a ifcfg-rh: refactor code re-reading profile from disk after write
The function only has one caller and it should be simple enough
to perform the necessary steps right in nms_ifcfg_rh_writer_write_connection().

More functions don't (always) simplify the code.
2019-07-02 17:52:53 +02:00
Thomas Haller 5b98f2fb01 device: fix crash releasing destroyed slave
I encountered this on a WIP branch, but I think it can happen
under regular conditions. I think there is no error condition here,
and we should do nothing if we have no ifindex.

  <debug> [1561653068.2192] platform: signal: link removed: 1699: test1p <DOWN;broadcast,multicast> mtu 1500 master 1698 arp 1 veth* init addrgenmode none addr D6:14:45:97:06:75 brd FF:FF:FF:FF:FF:FF driver veth rx:0,0 tx:38,5606
  ...
  <info>  [1561653068.2617] device (test1): state change: activated -> unmanaged (reason 'unmanaged', sys-iface-state: 'removed')
  ...
  <trace> [1561653068.2635] device[0x564058c73750] (test1p): sys-iface-state: external -> removed
  <debug> [1561653068.2635] device[0x564058c73750] (test1p): unrealize (ifindex 1699)
  <debug> [1561653068.2636] device[0x564058c73750] (test1p): parent: clear
  <trace> [1561653068.2636] device[0x564058b98eb0] (vethbr): mtu: commit-mtu...
  <debug> [1561653068.2639] device[0x564058c73750] (test1p): unmanaged: flags set to [platform-init,!sleeping,!by-type,!user-explicit,!user-settings,!user-udev,!is-slave=0x10/0x1479/unmanaged/unrealized], set-unmanaged [platform-init=0x10])
  <debug> [1561653068.2639] device[0x564058c73750] (test1p): unmanaged: flags set to [platform-init,!sleeping,!user-settings=0x10/0x51/unmanaged/unrealized], forget [parent,by-type,user-explicit,user-udev,external-down,is-slave=0x1c2c])
  <info>  [1561653068.2639] device (test1p): state change: activated -> unmanaged (reason 'unmanaged', sys-iface-state: 'removed')
  <debug> [1561653068.2640] device[0x564058c73750] (test1p): deactivating device (reason 'unmanaged') [3]
  <trace> [1561653068.2640] device[0x564058c73750] (test1p): ip4-state: set to 0 (none)
  <trace> [1561653068.2640] device[0x564058c73750] (test1p): ip6-state: set to 0 (none)
  <trace> [1561653068.2640] device[0x564058c73750] (test1p): remove_pending_action (0): 'dhcp6' not pending (expected)
  <trace> [1561653068.2640] device[0x564058c73750] (test1p): remove_pending_action (0): 'autoconf6' not pending (expected)
  <debug> [1561653068.2640] rules-manager: sync
  <debug> [1561653068.2640] device[0x564058c73750] (test1p): set metered value 0
  <debug> [1561653068.2641] device[0x564058c73750] (test1p): ip4-config: update (commit=1, new-config=(nil))
  <debug> [1561653068.2641] device[0x564058c73750] (test1p): ip6-config: update (commit=1, new-config=(nil))
  <debug> [1561653068.2644] device[0x564058b98eb0] (vethbr): slave test1p state change 100 (activated) -> 10 (unmanaged)
  <trace> [1561653068.2644] device[0x564058b98eb0] (vethbr): master: release one slave 0x564058c73750/test1p
  ((src/platform/nm-platform.c:2002)): assertion '<dropped>' failed

backtrace:
  ...
  #3  0x0000564057fb713e _nm_g_return_if_fail_warning (NetworkManager)
  #4  0x000056405808b37c release_slave (NetworkManager)
  #5  0x0000564058079aef nm_device_master_release_one_slave (NetworkManager)
  #6  0x00005640580844d7 slave_state_changed (NetworkManager)
  #7  0x00007efc24833fae ffi_call_unix64 (libffi.so.6)
  #8  0x00007efc2483396f ffi_call (libffi.so.6)
  #9  0x00007efc29b836e5 g_cclosure_marshal_generic (libgobject-2.0.so.0)
  #10 0x00007efc29b82c1d g_closure_invoke (libgobject-2.0.so.0)
  #11 0x00007efc29b96173 signal_emit_unlocked_R (libgobject-2.0.so.0)
  #12 0x00007efc29b9f29a g_signal_emit_valist (libgobject-2.0.so.0)
  #13 0x00007efc29b9f893 g_signal_emit (libgobject-2.0.so.0)
  #14 0x000056405807ab20 _set_state_full (NetworkManager)
  #15 0x000056405807d803 nm_device_unrealize (NetworkManager)
  #16 0x0000564057f6072c _platform_link_cb_idle (NetworkManager)
  #17 0x00007efc296a01db g_idle_dispatch (libglib-2.0.so.0)
  ...
2019-07-02 17:52:53 +02:00
Thomas Haller 7c84227c93 shared: add nm_c_list_elem_free_steal() util 2019-07-02 17:52:53 +02:00
Lubomir Rintel add691a901 core/wired: include the invalide MAC address in error messages
Otherwise the errors don't make much sense:

  802-3-ethernet.mac-address: is not a valid MAC address
2019-07-02 16:06:03 +02:00
Lubomir Rintel 26317ec7e3 merge: branch 'lr/initrd-fixes'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/194
2019-07-02 13:48:13 +02:00
Lubomir Rintel 39d5c8c12f initrd/tests: ensure that nameserver= setting affects the correct connection 2019-07-02 13:43:06 +02:00
Lubomir Rintel 6da2058237 initrd: don't create a default connection if there's already one
Certain arguments (such as "nameserver") don't specify a connection they
apply to and using them would generate a default ethernet connection.
This is probably not the right thing to do.
2019-07-02 13:43:06 +02:00
Lubomir Rintel 77540b2a7c initrd/tests: ensure we accept a prefix in place of an IPv4 mask 2019-07-02 13:42:19 +02:00
Lubomir Rintel 390d79079e initrd: allow specifying the net mask in form of a prefix
This is not documented in dracut.cmdline(7), however it seems to have
worked and has users and Red Hat even seems to recommend this (thanks to
Dan Horak for the pointers):

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/installation_guide/chap-installer-booting-ipl-s390
https://bugzilla.redhat.com/show_bug.cgi?id=1725872
2019-07-02 13:42:19 +02:00
Lubomir Rintel 920e59016f initrd: remove an accidental backspace 2019-07-02 13:42:09 +02:00
Lubomir Rintel 4b097e314e initrd: fix error reporting on bad netmask
It says the address is bad, but what is wrong is the mask.
2019-07-02 10:29:23 +02:00
Hsiu-Ming Chang 3698e24eba po: update Chinese Taiwan (zh_TW) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/190
2019-06-29 09:15:27 +02:00
Thomas Haller a23150a949 settings,libnm: merge branch 'th/settings-seen-bssid-and-timestamps'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/191
2019-06-28 16:53:23 +02:00
Thomas Haller 0d58cab4a0 settings: use nm_connection_to_dbus_full() to avoid cloning the connection during GetSettings() 2019-06-28 16:48:17 +02:00
Thomas Haller df2ba4226d libnm: implement serialization options (inject timestamp/seen-bssids) for nm_connection_to_dbus_full() 2019-06-28 16:48:17 +02:00
Thomas Haller 441dd1f3c8 libnm: add nm_connection_to_dbus_full() with options argument
No options are implemented yet.
2019-06-28 16:48:17 +02:00
Thomas Haller 31c4c111d3 settings: cleanup handling of seen-bssids list in NMSettingsConnection
- most connections are not Wi-Fi connections and thus don't have a seen-bssids
  list. Only create the seen_bssids hash when required. This avoids allocating the
  hash in common cases and avoids checking the hash for the content (which is often
  empty).

- nm_settings_connection_get_seen_bssids() should return a sorted list.
  Leaving the sort order undefined is ugly.

- in try_fill_ssid_for_hidden_ap(), we need to check all
  NMSettingsConnection instances whether they know this bssid.
  Reorder the checks, to first call nm_settings_connection_has_seen_bssid(), which
  is faster and in most cases returns a negative result (shortcutting
  the rest).
2019-06-28 16:48:17 +02:00
Thomas Haller 4d03b16f9d libnm: track wifi.seen-bssids in a GPtrArray instead of a GSList
GPtrArray allows direct lookup by index. Since the NMSettingWireless
API is based on lookup by index, this is a common operation.

Note that nm_setting_wireless_add_seen_bssid() is still O(n), meaning to
add n elements, it takes O(n^2). That's not great but no worse than
before.

The cases where GSList is the best choice for a data type are few.
2019-06-28 16:48:17 +02:00
Thomas Haller b4fe51b5fa shared: add nm_utils_strv_dup() util 2019-06-28 16:48:17 +02:00
Thomas Haller 1d2df314cc shared: add nm_c_list_free_all() macro 2019-06-28 16:45:06 +02:00
Beniamino Galvani 420554a72e clients: fix printing hexadecimal enum values
Use the 'x' conversion specifier for hexadecimal numbers.

Fixes: f53218ed7c ('cli: add property type for enum and showcase for ipv6.addr-gen-mode'):
2019-06-27 17:10:40 +02:00
Beniamino Galvani 2c97ae435e dhcp: systemd: relicense as LGPL
Soon a new DHCP backend will be added that will take code from the
internal one. Change its license to LGPL so that the whole new backend
code can also be LGPL, which is the preferred license for new
NetworkManager code.

Acked-by: Dan Williams <dcbw@redhat.com>
Acked-by: Dan Winship <danw@redhat.com>
Acked-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Thomas Haller <thaller@redhat.com>
2019-06-27 17:08:37 +02:00
Thomas Haller 8a8e894f80 core: add and use nm_keep_alive_destroy()
When we are done with a NMKeepAlive instance, we always should do
three things:

  - unset the owner
  - disarm (freeze) the keep-alive
  - give up our reference.

Add and use nm_keep_alive_destroy() that does this.
2019-06-27 13:25:40 +02:00
Thomas Haller dd5c88b1cc settings: merge branch 'th/various-settings-cleanup-3'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/187
2019-06-26 18:10:17 +02:00
Thomas Haller 7b6f1c2d90 tools: export more symbols from NetworkManager binary to plugins
Plugins also may use nmtst_*() functions (when built with --with-more-asserts)
or c_list_*(). Whitelist them too.
2019-06-26 12:26:11 +02:00
Thomas Haller e36cf1e890 ifcfg-rh: add allow_filename_cb() argument to write-ifcfg-rh function
The function determines the filename automatically, but we
need to blacklist certain names.

That is, because NetworkManager keeps a list of loaded files
in memory. When writing a new file, we really want to choose
a filename that is not yet taken. For that we must not only
consider files on disk, but also files that existed on the last
time of loading.
2019-06-26 12:26:11 +02:00
Thomas Haller e5b21344c5 ifcfg-rh: cleanup utils_detect_ifcfg_path()
- avoid cloing the basename. Determining the basename can be done conveniently
  with strrchr().
- use cleanup macro for temporary variable.
- while in practice it should not happen, check that the colon in the name
  of alias file names is not followed by another '/'.
2019-06-26 12:26:11 +02:00
Thomas Haller a4642c78f7 settings: cache agent and system secrets in a GVariant only
We don't need the full NMConnection.
2019-06-26 12:26:11 +02:00
Thomas Haller f8a20d0a09 manager: don't consider by-user change flag for creating unrealized device
This effectively reverts commit [1].

The by-user argument is not very clear what it means. Is a "nmcli
connection load $FILENAME" a user-action? How about reload?

I don't know whether the problem that this was supposed to fix is still
present. But in any case, the condition here seems not right. It's
already hard to understand when and how we generate unrealized devices.

If the condition from commit [1] should be prevented, then it must happen
somehow differently. In the example, the offending connection is a generated
volatile profile with the device being sys-face-state "external". Of course,
we should not generate devices for such profiles nor autoactivating them.
So adding a device for a volatile connection is always wrong. Don't do that,
which should avoid the original problem.

[1] commit a8a4eb1418 ('manager: don't create the virtual devices on all connection changes')
2019-06-26 12:26:11 +02:00
Thomas Haller d1f269ab36 core: ensure normalized connection during add-and-activate
nm_connection_verify() returns success for fully valid (normalized)
connections and also connections that are NM_SETTING_VERIFY_NORMALIZABLE.

We really want to fully normalize the profiles during add-and-activate.
2019-06-26 12:26:11 +02:00
Thomas Haller 6d4592354f settings: reorder checks in _delete_volatile_connection_do() to perform cheaper check first
Checking whether a settings connection is still tracked is a simple
c_list_is_empty(). It's faster, so do it first.
2019-06-26 12:26:11 +02:00
Thomas Haller 50e193d12c settings: use NMCListElem instead of DeleteVolatileConnectionData for tracking connections to delete
For tracking a CList of one pointer we have NMCListElem API. We don't need
to implement our own struct to hold the list pointers and the data pointer.
2019-06-26 12:26:11 +02:00
Thomas Haller eed4b5253f settings: don't implement settings plugins as singletons
The settings plugins are created by NMSettings when the plugin
gets loaded. There is no need for these instances to be singletons
or to have a singleton getter.

Also, while in practice we create a settings plugin instance of
each type only once, there is nothing that would prevent creating
multiple instances. Hence, having a singleton getter is not right.

What is however useful, is to track them and block shutdown
via nm_shutdown_wait_obj_register*(). While the actual waiting
is not yet implemented, we should mark the plugin instances to
block shutdown (in the future).
2019-06-26 12:26:11 +02:00
Thomas Haller a410873461 core: add flag to nm_shutdown_wait_obj_register_full() for freeing allcated message string
In fact, nm_shutdown_wait_obj_register*() API is still not implemented
and registering an object has no effect currently. That is, blocking
shutdown and waiting for instances to be destroyed during shutdown
is not yet implemented. Still, we already implement the API so that
components can register themself to block the shutdown. The point is
of course, that the callers already use this API, although it's not yet
implemented.

Anyway, sometimes the message string is not static. Add an option to
pass an allocated string and let the string be destroyed when no longer
needed.
2019-06-26 12:26:11 +02:00
Thomas Haller 02a0967520 libnm: fix setting error for nm_connection_update_secrets()
By convention, a function that indicates failure *MUST* set
an error.

Also, an error can only be set once.
2019-06-26 12:26:11 +02:00
Thomas Haller d704f02119 libnm: workaround assertion failure for nmtst_connection_assert_unchanging() when disposing connection
nmtst_connection_assert_unchanging() registers to the changed signals
and asserts that they are not invoked. The purpose is that sometimes
we want to keep a reference to an NMConnection and be sure that it does
not get modified. This allows everybody to keep a reference to the very
same connection instance without cloning it -- provided they too promise
not to change it. This assert is to ensure that.

Note that NMSimpleConnection.dispose() clears the secrets and thus upon
destruction the assertion fails. At that point, the assertion is no longer
relevant, because the purpose was to ensure that no alive instances gets
modified. While destroying the instance, it's fine to modify it (nobody should
have a reference to it anymore).

This avoids the assertion failure when destroying a NMSimpleConnection with secrets
that is set with nmtst_connection_assert_unchanging().
2019-06-26 09:53:54 +02:00
Thomas Haller b9587008fc shared: add nm_clear_error() and patch g_clear_error() to use this inlinable variant 2019-06-26 09:53:54 +02:00