Commit Graph

25263 Commits

Author SHA1 Message Date
Beniamino Galvani
2da77547ba ovs: merge branch 'bg/ovs-interface-mtu-rh1808124'
https://bugzilla.redhat.com/show_bug.cgi?id=1807726
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/433
2020-03-26 21:43:28 +01:00
Beniamino Galvani
c2a9712945 ovs: set the MTU in ovsdb when changing platform MTU of ovs-interface
If we change the the MTU of an ovs interface only through netlink, the
change could be overridden by ovs-vswitchd at any time when other
interfaces change. Set the MTU also in the ovsdb to prevent such
changes.

Note that if the MTU comes from the connection, we already set the
ovsdb MTU at creation time and so this other update becomes
useless. But it is needed when changing the MTU at runtime (reapply)
or when the MTU comes from a different source (e.g. DHCP).
2020-03-26 21:39:49 +01:00
Beniamino Galvani
ad12f26312 ovs: set MTU from connection when creating an internal interface
The ovs-vswitchd.conf.db(5) man page says about the the mtu_request
column in the Interface table:

  "Requested MTU (Maximum Transmission Unit) for the interface. A
   client can fill this column to change the MTU of an
   interface [...] If this is not set and if the interface has
   internal type, Open vSwitch will change the MTU to match the
   minimum of the other interfaces in the bridge."

Therefore, if the connection specifies a MTU, set it early when adding
the interface to the ovsdb so that it will not be changed to the
minimum of other interfaces.
2020-03-26 21:39:49 +01:00
Beniamino Galvani
a4c2c1a843 ovs/ovsdb: support changing the MTU of an ovs interface
Introduce a nm_ovsdb_set_interface_mtu() function to update the MTU of
an ovs interface in the ovsdb.
2020-03-26 21:39:49 +01:00
Beniamino Galvani
6b2f018377 merge: branch 'bg/ipv6-addresses-order-rh1814557'
https://bugzilla.redhat.com/show_bug.cgi?id=1814557
2020-03-26 21:32:42 +01:00
Beniamino Galvani
0118ad5125 platform: improve IPv6 address synchronization
When we must synchronize IPv6 addresses, we compare the order of
addresses to set with what is currently set on platform. Starting from
addresses with lower priority, when a mismatch is found we remove it
from platform and also remove all following addresses, so that we can
re-add them in the right order.

Since kernel keeps addresses internally sorted by scope, we should
consider each scope separately in order to avoid unnecessary address
deletions. For example, if we want to configure addresses
fe80::1/64,2000::1/64 and we currently have on platform 2000::1/64,
it's not necessary to remove the existing address; we can just add the
link-local one.

Co-authored-by: Thomas Haller <thaller@redhat.com>

https://bugzilla.redhat.com/show_bug.cgi?id=1814557
2020-03-26 21:28:56 +01:00
Beniamino Galvani
c878c48efb platform: sort IPv6 addresses from platform during sync
There is no guarantee that addresses returned from the cache are in
scope-priority order. Sort them.
2020-03-26 21:28:56 +01:00
Thomas Haller
6f9a478b7d tests: replace NMTST_SWAP() by new NM_SWAP() macro
NMTST_SWAP() used memcpy() for copying the value, while NM_SWAP() uses
a temporary variable with typeof(). I think the latter is preferable.

Also, the macro is essentially doing the same thing.
2020-03-26 21:28:56 +01:00
Thomas Haller
cec06138f1 shared: add NM_SWAP() macro 2020-03-26 21:28:56 +01:00
Thomas Haller
4fe46d9e20 build/meson: fix build by link nm-dispatcher with libnm-glib-aux.la
Fixes: a34b1f793e ('build: link nm-dispatcher with libnm-glib-aux.la')
2020-03-25 16:41:17 +01:00
Thomas Haller
380ecbc234 dispatcher: use nm_str_hash() for hash table in dispatcher
nm_str_hash() uses siphash24. We want to use that everywhere.
The only concern would be that it is slower. But if that's the concern,
then we would have many more performance critical places to care
about first.
2020-03-25 16:19:53 +01:00
Thomas Haller
a34b1f793e build: link nm-dispatcher with libnm-glib-aux.la
Our glib based code should also include our static utility library
libnm-glib-aux. This is our basic utility library that we want to
have around everywhere. Since we link statically, the linker will weed
out the unused stuff at compile time. So, there is no overhead, except
for the things that we actually use.
2020-03-25 16:14:52 +01:00
Thomas Haller
fbb65de32e rdisc: avoid static variable in receive_ra()
It's unnecessary and makes the function unnecessarily not thread safe.
Of course, also ndp_msg_opt_route_prefix() uses static variables, so
it's still not thread safe.

Fixes: c3a4656a68 ('rdisc: libndp implementation')
2020-03-25 11:16:50 +01:00
Thomas Haller
d1181533b8 rdisc: fix parsing ndp_msg_opt_dnssl_lifetime() from IPv6 RA
Fixes: c3a4656a68 ('rdisc: libndp implementation')
2020-03-25 11:16:16 +01:00
Thomas Haller
1704507c49 core: merge branch 'af/settings-add-matches' (part 1)
https://gitlab.freedesktop.org/afreof/NetworkManager/-/tree/af/settings-add-matches
2020-03-24 20:59:51 +01:00
Thomas Haller
f2fd1614f5 utils: use nm_utils_strsplit_set_full() in nm_utils_proc_cmdline_split()
We should handle kernel command line like systemd does, with its
ConditionKernelCommandLine= setting.

For example, it tokenizes words between various white space characters,
not only space. Use nm_utils_strsplit_set_full() for that.

Note that we currently don't yet have a tokenizer that supports
quotation, like systemd does. We should extend
nm_utils_strsplit_set_full() for that.
2020-03-24 20:59:36 +01:00
Thomas Haller
999c569585 shared: add NM_ASCII_WHITESPACES macro
NM_ASCII_SPACES contains the ASCII characters according to
g_ascii_isspace().

Add NM_ASCII_WHITESPACES which differs from NM_ASCII_SPACES by not
including "\f". In some cases, that character shall be excluded.
For example, this is what systemd uses as "WHITESPACE" define at
various places.

Also, reorder the spaces string so that plain space comes first. It is
expected that ' ' is much more frequently than newlines or tabs. While
the order here shouldn't matter, it seems preferably to order frequent
characters in front.
2020-03-24 20:43:55 +01:00
Adrian Freihofer
8069e5fd20 nm-core-utils: add nm_utils_proc_cmdline
Add a new function to read /proc/cmdline. The function caches the content.
2020-03-24 16:56:06 +01:00
Yuri Chornoivan
a30736fbd7 po: update Ukrainian (uk) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/448
2020-03-24 16:32:34 +01:00
Niklas Goerke
bddba4ca8b Add domain_match mode for wifi certificate domain comparison
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/308
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/437
2020-03-23 20:31:09 +01:00
Thomas Haller
e75d62ce76 systemd: merge branch systemd into master 2020-03-23 17:50:12 +01:00
Thomas Haller
46a1816034 systemd: update code from upstream (2020-03-23)
This is a direct dump from systemd git.

======

SYSTEMD_DIR=../systemd
COMMIT=cdc6c95737d26b1746b446dfe662872d593d23c6

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

git ls-files -z :/src/systemd/src/ \
                :/shared/systemd/src/ \
                :/shared/nm-std-aux/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_stdaux() {
    mkdir -p "./shared/nm-std-aux/"
    cp "$SYSTEMD_DIR/$1" "./shared/nm-std-aux/${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/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-dhcp-option.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_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/cgroup-util.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_random.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_syscall.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.c"
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/strxcpyx.c"
nm_copy_sd_shared "src/basic/strxcpyx.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/user-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"
nm_copy_sd_shared "src/shared/dns-domain.c"
nm_copy_sd_shared "src/shared/dns-domain.h"
nm_copy_sd_stdaux "src/basic/unaligned.h"
2020-03-23 16:39:32 +01:00
Thomas Haller
44fed3c340 core: avoid assertion failure in _settings_connection_flags_changed() without device
It seems not unexpected, that we get a flags-changed notification while
having no device. Handle it gracefully and avoid the assertion failure.

   #0  _g_log_abort (breakpoint=breakpoint@entry=1) at gmessages.c:583
   #1  g_logv (log_domain=0x55f3c86f0262 "NetworkManager", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7ffcbf88f1c0) at gmessages.c:1391
   #2  g_log (log_domain=log_domain@entry=0x55f3c86f0262 "NetworkManager", log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0x7f21e99adb27 "%s: assertion '%s' failed") at gmessages.c:1432
   #3  g_return_if_fail_warning (log_domain=log_domain@entry=0x55f3c86f0262 "NetworkManager", pretty_function=pretty_function@entry=0x55f3c875f290 <__func__.53083> "nm_device_reapply", expression=expression@entry=0x55f3c8752507 "NM_IS_DEVICE (self)") at gmessages.c:2809
   #4  nm_device_reapply (self=0x0, connection=connection@entry=0x55f3caab4e60, error=error@entry=0x7ffcbf88f308) at src/devices/nm-device.c:12107
   #5  _settings_connection_flags_changed (settings_connection=<optimized out>, self=0x55f3caabca70 [NMActRequest]) at src/nm-active-connection.c:960
   #9  <emit signal ??? on instance 0x55f3caaaf530 [NMSettingsConnection]> (instance=instance@entry=0x55f3caaaf530, signal_id=<optimized out>, detail=detail@entry=0) at gsignal.c:3447
   #6  g_closure_invoke (closure=0x55f3caa4c160, return_value=return_value@entry=0x0, n_param_values=1, param_values=param_values@entry=0x7ffcbf88f520, invocation_hint=invocation_hint@entry=0x7ffcbf88f4c0) at gclosure.c:804
   #7  signal_emit_unlocked_R (node=node@entry=0x55f3ca9dcf90, detail=detail@entry=0, instance=instance@entry=0x55f3caaaf530, emission_return=emission_return@entry=0x0, instance_and_params=instance_and_params@entry=0x7ffcbf88f520) at gsignal.c:3635
   #8  g_signal_emit_valist (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>, var_args=var_args@entry=0x7ffcbf88f6a0) at gsignal.c:3391
   #10 nm_settings_connection_set_flags_full (self=self@entry=0x55f3caaaf530 [NMSettingsConnection], mask=<optimized out>, value=<optimized out>) at src/settings/nm-settings-connection.c:2025
   #11 _connection_changed_process_all_dirty (update_reason=(NM_SETTINGS_CONNECTION_UPDATE_REASON_RESET_SYSTEM_SECRETS | NM_SETTINGS_CONNECTION_UPDATE_REASON_RESET_AGENT_SECRETS), sett_mask=<optimized out>, sett_flags=<optimized out>, connection=0x55f3caab4f80, sett_conn_entry=<optimized out>, self=0x55f3ca99c000 [NMSettings]) at src/settings/nm-settings.c:1099
   #12 _connection_changed_process_all_dirty (update_reason=(NM_SETTINGS_CONNECTION_UPDATE_REASON_RESET_SYSTEM_SECRETS | NM_SETTINGS_CONNECTION_UPDATE_REASON_RESET_AGENT_SECRETS), override_sett_flags=1, sett_mask=_NM_SETTINGS_CONNECTION_INT_FLAGS_PERSISTENT_MASK, sett_flags=<optimized out>, allow_add_to_no_auto_default=0, sett_conn_entry=<optimized out>, self=0x55f3ca99c000 [NMSettings]) at src/settings/nm-settings.c:1284
   #13 _connection_changed_process_all_dirty (self=self@entry=0x55f3ca99c000 [NMSettings], allow_add_to_no_auto_default=allow_add_to_no_auto_default@entry=0, sett_flags=sett_flags@entry=NM_SETTINGS_CONNECTION_INT_FLAGS_NONE, sett_mask=sett_mask@entry=NM_SETTINGS_CONNECTION_INT_FLAGS_NONE, override_sett_flags=override_sett_flags@entry=1, update_reason=update_reason@entry=(NM_SETTINGS_CONNECTION_UPDATE_REASON_RESET_SYSTEM_SECRETS | NM_SETTINGS_CONNECTION_UPDATE_REASON_RESET_AGENT_SECRETS)) at src/settings/nm-settings.c:1304
   #14 _plugin_connections_reload (self=self@entry=0x55f3ca99c000 [NMSettings]) at src/settings/nm-settings.c:1417
   #15 impl_settings_reload_connections (obj=0x55f3ca99c000 [NMSettings], interface_info=<optimized out>, method_info=<optimized out>, connection=<optimized out>, sender=<optimized out>, invocation=0x7f21d000c100 [GDBusMethodInvocation], parameters=0x55f3ca9e1f20) at src/settings/nm-settings.c:2822
   ...

https://bugzilla.redhat.com/show_bug.cgi?id=1816067
2020-03-23 13:31:09 +01:00
Thomas Haller
27c0d9d8b7 clients/tests: comment return code by signal in test output
Otherwise, we just see "returncode: -11", which isn't very clear.
By default, our test nmcli invocations should never exit by a signal.
Usually, when we encounter a signal, it indicates to a bug and a crash
during the test.

Print more information about the exit code.

    returncode: -11 (SIGNAL SIGSEGV)
2020-03-23 13:30:13 +01:00
Beniamino Galvani
c5365ca482 cli: merge branch 'bg/cli-remove-setting'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/440
2020-03-23 11:43:03 +01:00
Beniamino Galvani
2334a27692 cli: support setting removal 2020-03-23 11:42:57 +01:00
Beniamino Galvani
0d0c79d5ab libnm-core: slightly improve sriov setting documentation 2020-03-23 11:42:57 +01:00
Beniamino Galvani
78f1977ecd libnm-core: remove trailing dot from setting description
The trailing dot is already added when generating the man page.
2020-03-23 11:42:57 +01:00
Thomas Haller
52dbab7d07 all: use nm_clear_pointer() instead of g_clear_pointer()
g_clear_pointer() would always cast the destroy notify function
pointer to GDestroyNotify. That means, it lost some type safety, like

   GPtrArray *ptr_arr = ...

   g_clear_pointer (&ptr_arr, g_array_unref);

Since glib 2.58 ([1]), g_clear_pointer() is also more type safe. But
this is not used by NetworkManager, because we don't set
GLIB_VERSION_MIN_REQUIRED to 2.58.

[1] f9a9902aac

We have nm_clear_pointer() to avoid this issue for a long time (pre
1.12.0). Possibly we should redefine in our source tree g_clear_pointer()
as nm_clear_pointer(). However, I don't like to patch glib functions
with our own variant. Arguably, we do patch g_clear_error() in
such a manner. But there the point is to make the function inlinable.

Also, nm_clear_pointer() returns a boolean that indicates whether
anything was cleared. That is sometimes useful. I think we should
just consistently use nm_clear_pointer() instead, which does always
the preferable thing.

Replace:

   sed 's/\<g_clear_pointer *(\([^;]*\), *\([a-z_A-Z0-9]\+\) *)/nm_clear_pointer (\1, \2)/g' $(git grep -l g_clear_pointer) -i
2020-03-23 11:22:38 +01:00
Thomas Haller
073994ca42 all: use nm_clear_g_free() instead of g_clear_pointer()
I think it's preferable to use nm_clear_g_free() instead of
g_clear_pointer(, g_free). The reasons are not very strong,
but I think it is overall preferable to have a shorthand for this
frequently used functionality.

   sed 's/\<g_clear_pointer *(\([^;]*\), *\(g_free\) *)/nm_clear_g_free (\1)/g' $(git grep -l g_clear_pointer) -i
2020-03-23 11:05:34 +01:00
Thomas Haller
c50b4621d4 libnm: merge branch 'th/libnm-dbus-async-calls'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/439
2020-03-23 09:47:17 +01:00
Thomas Haller
431c349b47 libnm: enable macros for marking sync libnm methods as deprecated 2020-03-23 09:38:24 +01:00
Thomas Haller
7c2bcd4bc9 libnm: drop unused code 2020-03-23 09:38:23 +01:00
Thomas Haller
42edeb62a3 cli: use async method D-Bus for nmcli radio wifi on|off
Showcase nm_client_dbus_set_property().

Thereby, also print error messages and return an error if
the command fails.

Also, enable PolicyKit authentication (although, I think there are
some bugs with this still).
2020-03-23 09:38:23 +01:00
Thomas Haller
c6c15c2c25 cli: use async method D-Bus for nmcli networking on|off
Previously, we would call the synchronous nm_client_networking_set_enabled()
method. There were 3 problems:

1) nmcli ignored the return value, that means, if the request failed with
  access denied it would just silently pretend that it succeeded.

2) nmcli first called nmc_start_polkit_agent_start_try(), but when
  invoking the synchronous method, the main context is busy and a
  polkit request cannot possibly be handled.

3) nm_client_networking_set_enabled() is deprecated.

Fix all of these, by calling the D-Bus method directly.

Policykit authentication requests are only handled partly. There
seems to be an unrelated race/bug. Now it works sometimes.
2020-03-23 09:37:53 +01:00
Thomas Haller
d99d1dc265 cli: replace deprecated and synchronous nm_client_set_logging()
This is more a showcase for using nm_client_dbus_call(), than a
real use.

In this case, nmcli was mostly fine to just invoke the synchronous API
and not care about the problems that it had.

Still, replace it, and show the suggested alternative.
2020-03-23 09:33:52 +01:00
Thomas Haller
06da903bb6 libnm: advise using D-Bus instead of deprecated synchronous methods
With 1.22, various synchronous functions for invoking D-Bus methods were
deprecated. The reason was that D-Bus is fundamentally asynchronous, and
providing synchronous API in NMClient is inherently wrong. That is
because NMClient essentially is a cache of the D-Bus API, and invoking
g_dbus_connection_call_sync() messes up the order of events from D-Bus.
In particular, when the synchronous function completes, the content of
the cache does not yet reflect the change.

Since they got deprecated, the question is with what to replace them.

Instead of adding a (e.g.) nm_client_networking_set_enabled_async()
for nm_client_networking_set_enabled(), just expect the user to call
D-Bus directly.

D-Bus itself defines a reasonable API, and with GDBusConnection it
is fine (and convenient) to just call D-Bus operations directly.
Often libraries try to abstract D-Bus by providing convenience
wrappers around D-Bus API. I think that often is wrong and unnecessary.

Note that libnm's NMClient does a lot more than just wrapping simple
D-Bus calls. It provides a complete client-side cache of the D-Bus
interface. As such, what libnm's NMClient does is more than simple
wrappers around D-Bus. NMClient is a reasonable thing to do.

However, it is unnecessary to add API like nm_client_networking_set_enabled_async()
that only calls g_dbus_connection_call(). Don't pretend that we would need such
trivial wrappers in libnm.

Instead, recommend to use g_dbus_connection_call(). Or alternatively,
the convenience wrappers nm_client_dbus_call() and
nm_client_dbus_set_property().
2020-03-23 09:33:51 +01:00
Thomas Haller
a7b8c82ee2 libnm: add nm_client_dbus_set_property() API
Similar to nm_client_dbus_call(), but useful for setting a D-Bus
property on NetworkManager's D-Bus interface.

Note that we currently have various synchronous API for setting D-Bus
properties (like nm_client_networking_set_enabled()). Synchronous
API does not play well with the content of NMClient's cache, and was
thus deprecated. However, until now no async variant exists.

Instead of adding multiple async operations, I think it should be
sufficient to only add one nm_client_dbus_set_property() property.
It's still reasonably convenient to use for setting a property.
2020-03-23 09:33:01 +01:00
Thomas Haller
1a36bdbb2c libnm: add nm_client_dbus_call() API
Add an API for calling D-Bus methods arbitrary objects of
NetworkManager's API.

Of course, this is basically just a call to g_dbus_connection_call(),
using the current name owner, nm_client_get_dbus_connection() and
nm_client_get_main_context().

All of this could also be achieved without this new API. However,
nm_client_dbus_call() also gracefully handles if the current name
owner is %NULL.

It's a valid concern whether such API is useful, as the users already
have all pieces to do it themself. I think it is.
2020-03-23 09:32:04 +01:00
Thomas Haller
0f15d5aa40 shared: allow nm_dbus_connection_call_finish_variant_cb() with D-Bus methods that have no return value 2020-03-23 09:32:04 +01:00
Thomas Haller
61615781c5 libnm/doc: fix gtk-doc for deprecated markers in libnm 2020-03-23 09:32:04 +01:00
Thomas Haller
2686de2ede wifi: merge branch 'blocktrron/owe-tm'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/442
2020-03-22 11:08:57 +01:00
Thomas Haller
277044de10 core/wifi: minor cleanup in _bss_info_properties_changed()
Move local variables to inner scope.

Also, drop code comment that doesn't give additional information
beyond what is already plainly visible in source code.
2020-03-22 11:07:37 +01:00
Thomas Haller
7ccd2bb35e core/wifi: always set owe_transition_mode output in nm_wifi_utils_parse_ies()
... and rename output variable.
2020-03-22 11:07:24 +01:00
David Bauer
37e7fa38c2 nm-supplicant-interface: enable OWE security when transition mode is available
This pull requests sets the OWE flag for an open network advertising an
OWE enabled transition BSSID. This way, hostapd will automatically
connect to the OWE secured BSSID advertised in the transition mode
information element.

Signed-off-by: David Bauer <mail@david-bauer.net>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/442
2020-03-22 11:03:00 +01:00
Thomas Haller
11797f4ad4 supplicant: fix crash setting supplicant state down
When we receive a "InterfaceRemoved" signal, we will end up calling
set_state_down(). That emits a "state" change signal, which causes
NMDeviceWifi to unref the supplicant interface. This may already
give up the last reference, and we cleanup the supplicant state
(by again calling set_state_down()). When we return, set_state_down()
will crash because it operates on an already destroyed instance.

Avoid that by keeping a reference to the interface during set_state_down().

Fixes: b83f07916a ('supplicant: large rework of wpa_supplicant handling')

https://bugzilla.redhat.com/show_bug.cgi?id=1815058
2020-03-20 11:34:01 +01:00
Thomas Haller
c03f88575d cli: fix nmcli device wifi with no Wi-Fi devices available
Fixes: db396cea9d ('cli: rework do_device_wifi_list() to scan and print Wi-Fi list')
2020-03-20 10:38:09 +01:00
Antonio Cardace
8d6998cb77 nm-setting-bond: merge branch 'ac/fix_add_miimon'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/438
2020-03-19 17:26:32 +01:00
Antonio Cardace
97d3f1b4b9 nm-setting-bond: don't take default values into account when comparing options
This solves a bug exposed by the following cmds:
$ nmcli c add type bond ifname bond0 con-name bond0
$ nmcli c modify bond0 +bond.options miimon=100
$ nmcli -f bond.options c show bond0
bond.options:                           mode=balance-rr

Here we just added the option 'miimon=100', but it doesn't get saved in
because nm_settings_connection_set_connection() which is responsible for
actually updating the connection compares the new connection with old
one and if and only if the 2 are different the update is carried out.

The bug is triggered because when comparing, if default values are taken into
account, then having 'miimon=100' or not having it it's essentially the
same for compare(). While this doesn't cause a bond to have a wrong
setting when activated it's wrong from a user experience point of view
and thus must be fixed.

When this patch is applied, the above
commands will give the following results:
$ nmcli c add type bond ifname bond0 con-name bond0
$ nmcli c modify bond0 +bond.options miimon=100
$ nmcli -f bond.options c show bond0
bond.options:                           mode=balance-rr,miimon=100

Fix unit tests and also add a new case covering this bug.

https://bugzilla.redhat.com/show_bug.cgi?id=1806549
2020-03-19 17:26:08 +01:00
Antonio Cardace
fcbef9b6d3 ifcfg-rh: add 'timestamp' property before comparing a reread connection
Since ifcfg-rh doesn't write out to file the 'connection.timestamp' property
let's add it before comparing an updated connection with the plugin's reread
one otherwise the comparison operation would always fail.
The fix is not necessary for the keyfile plugin, because the reader/writer
correctly reads/writes the connection timestamp.
2020-03-19 17:26:08 +01:00