Commit graph

26437 commits

Author SHA1 Message Date
Charlie Getzen
e7d2ea95ba
man: update nmcli.xml wording
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/582
2020-07-21 09:14:16 +02:00
Beniamino Galvani
116c49fceb merge: branch 'bg/sleep-unmanaged-rh1855563'
https://bugzilla.redhat.com/show_bug.cgi?id=1855563
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/580
2020-07-21 09:01:09 +02:00
Beniamino Galvani
725fed01cf policy: block connection from autoconnect in case of failed dependency
A connection that fails due to dependency-failed is not able to
reconnect until the master connection activates again; when this
happens, the master clears the blocked reason for all its slaves in
activate_slave_connections() and tries to reconnect them. For this to
work, the slave should be marked as blocked when it fails with
dependency-failed.
2020-07-21 09:00:53 +02:00
Beniamino Galvani
fe2d93980b manager: fix race condition when resuming from sleep
If the device state change (to disconnected or unmanaged) triggered by
a sleep event happens after the wake, the devices becomes wrongly
unmanaged and it's necessary to manually manage it again, or restart
NM.

During the wake event we should disconnect the device_sleep_cb()
callback for all devices because we don't want to react to state
changes anymore; in particular we don't need to detect when the device
becomes disconnected to unmanage it.
2020-07-21 09:00:52 +02:00
Thomas Haller
e73bd2cf5f
cloud-setup: always replace addresses, routes and rules in _nmc_mangle_connection()
If the list of addresses, routes and rules is empty, we still want to mangle
the applied connection, to also have an empty list.

nm-cloud-setup has certain expectations. For example, that the static addresses,
routes and rules of the active connection is entirely under the control of the
tool. For example, so it usually replaces the lists entirely. It also should do
that, if the new list is empty.

Maybe, one day there could be more complex merging strategies, where the user could
also add static addresses, routes, or rules to the profile, and nm-cloud-setup
would preserve them. However, that is not implemented, nor is it clear how exactly
that would work.
2020-07-20 19:02:57 +02:00
Thomas Haller
6f29ed9f3f
device: fix setting %NULL iface in nm_device_update_from_platform_link()
Fixes: f004e7b1a7 ('device: mark ifindex/iface fields of NMDevicePrivate as const')
2020-07-20 16:11:48 +02:00
Thomas Haller
cb4fb0ac06
core: use nm_streq*() instead of strcmp() in "nm-device.c" and "nm-manager.c" 2020-07-20 13:55:22 +02:00
Thomas Haller
f004e7b1a7
device: mark ifindex/iface fields of NMDevicePrivate as const
"nm-device.c" is large and complicated. It's hard to find relevant places
that modify the ifindex,ip_ifindex,iface,ip_iface fields.

Mark them as const, to make that easier.
2020-07-19 12:38:17 +02:00
Thomas Haller
3f140afdfc
all: add trailing semicolon to NM_DEFINE_SINGLETON_REGISTER() 2020-07-19 12:15:41 +02:00
Thomas Haller
ba42189bb9
all: add trailing semicolon to NM_UTILS_LOOKUP_DEFINE()/NM_GOBJECT_PROPERTIES_DEFINE*() 2020-07-19 12:12:58 +02:00
Thomas Haller
b17e3cf707
all: add trailing semicolon to NM_AUTO_DEFINE_FCN_*() uses 2020-07-19 12:01:56 +02:00
Thomas Haller
8bd2673484
shared: add _NM_DUMMY_STRUCT_FOR_TRAILING_SEMICOLON define
Will be used next.
2020-07-19 11:37:23 +02:00
Thomas Haller
e4877b9ca2
shared: make nm_utils_strdup_reset() self-assignment safe
There is no need to write code that has such trivial flaws.

  val = g_strdup ("aaaa");
  nm_utils_strdup_reset (&val, &val[1]);
2020-07-19 11:31:17 +02:00
Beniamino Galvani
74a36168bb po: RHEL 8.3 translations - fr,ja,zh-CN 2020-07-17 15:59:09 +02:00
Beniamino Galvani
0911d2a4ee core: fix check on master active-connection failure
The previous check was never satisfied, as the device is assigned to
the active-connection and realized early. Instead, check the
master_ready flag, which tells if the master is ready and, therefore,
if the slave has already been added to the master.

Before this commit, in some cases a device didn't detect that the
master failed and kept waiting forever.

https://bugzilla.redhat.com/show_bug.cgi?id=1845018
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/568
2020-07-17 08:56:28 +02:00
Thomas Haller
3e475e5cd1
contrib/rpm: prefer keyfile settings plugin from Fedora 33 and newer
This change is for Fedora 33 and newer. For now, also enable it for RHEL
9 and newer, but it must still be decided whether that will be done
there as well.

https://mail.gnome.org/archives/networkmanager-list/2020-May/msg00002.html
https://fedoraproject.org/wiki/Changes/NetworkManager_keyfile_instead_of_ifcfg_rh
https://lists.fedoraproject.org/archives/list/devel-announce@lists.fedoraproject.org/thread/OLOU27DAON2TYGTAVZ35GZE2BEIN42U3/
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/OLOU27DAON2TYGTAVZ35GZE2BEIN42U3/
https://pagure.io/fesco/issue/2432

https://bugzilla.redhat.com/show_bug.cgi?id=1857391
2020-07-16 12:28:03 +02:00
Beniamino Galvani
26e97fcd0d team: perform cleanup immediately when connecting to teamd fails
When NM fails to connect to teamd during an activation, it sets the
device state to FAILED. Eventually the device will become DISCONNECTED
and will call the ->deactivate() method that will perform the cleanup
of timers, teamd process and teamdctl instance.

However, in this way, when the device is DISCONNECTED timers are still
armed and can be triggered in the wrong state. Instead, perform the
cleanup immediately on failure.

https://bugzilla.redhat.com/show_bug.cgi?id=1856723
2020-07-16 09:36:26 +02:00
Thomas Haller
e2fba6c4b3
libnm: trace log the call and the completion event for D-Bus methods 2020-07-15 12:39:50 +02:00
Thomas Haller
16d5dff596
libnm: support "stdout" flag for LIBNM_CLIENT_DEBUG for logging to stdout
Trace logging from libnm is verbose. So, by default we print trace
messages to stderr. However, that means that messages printed to stdout
are not in sync with the trace logging.

That means, if the libnm application prints messages to stdout, and
you'd like to correlate them with trace messages, it is difficult.

Add an option to allow printing trace messages to stdout.

  $ LIBNM_CLIENT_DEBUG=trace,stdout nmcli

Possibly redirecting stderr to stdout might also work around the
ordering issue. However, it's not entirely clear how buffering of
the file streams affects this.
2020-07-15 11:53:20 +02:00
Thomas Haller
39264bdb13
libnm: add trace logging for D-Bus calls
libnm-dbus: <trace> [394618.09943] nmclient[97de7f355f14dfa9]: call D-Bus method on :1.17: /org/freedesktop/NetworkManager/Settings/17, org.freedesktop.NetworkManager.Settings.Connection.GetSettings -> (a{sa{sv}}) (())
2020-07-15 11:20:47 +02:00
Antonio Cardace
1b1a764445
core: merge branch 'ac/vrf_local_route_fix'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/579
2020-07-15 11:00:28 +02:00
Antonio Cardace
d342af1925
core: fix generation of dependent local routes for VRFs
When using VRF devices we must pre-generate dependent local
routes in the VRF's table otherwise they will be incorrectly added
to the local table instead.

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

Fixes: a199cd2a7d ('core: add dependent local routes configured by kernel')
2020-07-15 10:57:49 +02:00
Thomas Haller
f0a39b517e
bond: avoid setting "active_slave" option without interface enslaved
Kernel will reject setting "active_slave", if the interface is not enslaved or not
up. We already handle that by setting the option whenever we enslave an interface.
However, we also must not set it initially, otherwise we get an ugly error log message:

    NetworkManager[939]: <debug> [1594709143.7459] platform-linux: sysctl: setting net:/sys/class/net/bond99/bonding/active_slave to eth1 (current value is )
    NetworkManager[939]: <error> [1594709143.7459] platform-linux: sysctl: failed to set bonding/active_slave to eth1: (22) Invalid argument
    NetworkManager[939]: <warn>  [1594709143.7460] device (bond99): failed to set bonding attribute active_slave to eth1
    ...
    kernel: bond99: (slave eth1): Device is not bonding slave
    kernel: bond99: option active_slave: invalid value (eth1)

See-also: https://bugzilla.redhat.com/show_bug.cgi?id=1856640

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/577
2020-07-14 19:13:39 +02:00
Sayed Shah
e3cd3b73ed
cloud-setup: don't require delimiter in 'nmcs_utils_hwaddr_normalize'
Azure gives MAC address without delimiter. So, make the normalize function
more liberal so that it can accept this format.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/576
2020-07-14 19:10:29 +02:00
Thomas Haller
aa4cb0e5eb
contrib: improve code comments to release.sh scripts 2020-07-13 23:54:34 +02:00
Thomas Haller
7b14686ae2
release: bump version to 1.27.1 (development) 2020-07-13 23:40:48 +02:00
Thomas Haller
5542275672
contrib: add "major-post" step for release.sh script 2020-07-13 23:28:05 +02:00
Thomas Haller
8582a5f356
release: bump version to 1.26.0 2020-07-13 20:11:58 +02:00
Thomas Haller
ca75400f00
NEWS: update
(cherry picked from commit c2f7428bc0)
2020-07-13 20:10:39 +02:00
Thomas Haller
c2f7428bc0
NEWS: update 2020-07-13 19:09:00 +02:00
Thomas Haller
c3b04c4fd9
contrib: support "major" release in release.sh script 2020-07-13 18:05:32 +02:00
Thomas Haller
a802192f75
NEWS: update 2020-07-13 18:02:20 +02:00
Beniamino Galvani
b76f7cc555
NEWS: update
(cherry picked from commit 2a9f5f25b2)
2020-07-13 18:02:20 +02:00
Thomas Haller
8c2f8169aa
libnm: fix -Werror=maybe-uninitialized warning _setting_bond_validate_option()
Fixes: e96051d734 ('libnm: cleanup validating bond option "arp_ip_target"')
(cherry picked from commit 826c83ce41)
2020-07-13 17:41:36 +02:00
Thomas Haller
826c83ce41
libnm: fix -Werror=maybe-uninitialized warning _setting_bond_validate_option()
Fixes: e96051d734 ('libnm: cleanup validating bond option "arp_ip_target"')
2020-07-13 17:40:40 +02:00
Thomas Haller
2e780878f0
cli: fix leak in do_device_modify() and minor cleanup
(cherry picked from commit 5deb71625d)
2020-07-13 17:20:48 +02:00
Thomas Haller
fd9e7d6167
cli: fix accessing argv with zero elements in nmc_process_connection_properties()
Without this, `nmcli device modify "$DEVICE"` leads to a crash. At least
since commit c5d45848dd ('cli: mark argv argument for command line
parsing as const'), when this happens.

That is, because it passes a NULL strv array with argc being set to
zero. nmc_process_connection_properties() is not supposed to access
the array, if there are no elements there.

Fixes: c5d45848dd ('cli: mark argv argument for command line parsing as const')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/492
(cherry picked from commit 09c94bc24f)
2020-07-13 17:20:47 +02:00
Thomas Haller
5deb71625d
cli: fix leak in do_device_modify() and minor cleanup 2020-07-13 17:16:28 +02:00
Thomas Haller
09c94bc24f
cli: fix accessing argv with zero elements in nmc_process_connection_properties()
Without this, `nmcli device modify "$DEVICE"` leads to a crash. At least
since commit c5d45848dd ('cli: mark argv argument for command line
parsing as const'), when this happens.

That is, because it passes a NULL strv array with argc being set to
zero. nmc_process_connection_properties() is not supposed to access
the array, if there are no elements there.

Fixes: c5d45848dd ('cli: mark argv argument for command line parsing as const')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/492
2020-07-13 17:15:56 +02:00
Frazer Clews
2fba8a3ece
cloud-setup: fix nmcs_utils_poll argument ordering
the order of the arguments in the header and C file did not match

Fixes: 69f048bf0c ('cloud-setup: add tool for automatic IP configuration in cloud')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/574
(cherry picked from commit 16abfca78a)
2020-07-13 13:18:12 +02:00
Frazer Clews
16abfca78a
cloud-setup: fix nmcs_utils_poll argument ordering
the order of the arguments in the header and C file did not match

Fixes: 69f048bf0c ('cloud-setup: add tool for automatic IP configuration in cloud')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/574
2020-07-13 13:13:58 +02:00
Thomas Haller
4168c19e04
shared: move nm_close(), nm_auto_close, nm_steal_fd(), nm_steal_int() to nm-std-aux 2020-07-12 13:05:13 +02:00
Thomas Haller
6225ace76f
bond: merge branch 'th/bond-normalize'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/570

(cherry picked from commit ecba921920)
2020-07-11 15:07:49 +02:00
Thomas Haller
a55b514477
tui: fix default values for bond options in nmtui
When configuring miimon settings, the updelay/downdelay fields with
value zero may not be stored in the setting.

For example:

- have a profile with "mode=balance-rr,arp_interval=11,arp_ip_target=10.10.10.1,miimon=10"
  Switch the link monitoring mode to "MII" and press <OK>. Previously,
  the change of the link monitoring did not update the settings, and
  nothing was changed.

- when loading settings, initialize all fields with the values from the
  settings, regardless whether they are currently visible or not.
  Otherwise, if you edit a profile with
  "mode=balance-rr,arp_interval=11,arp_ip_target=10.10.10.1,miimon=10"
  and switch link monitoring mode to "MII", the miimon setting was not
  initialized to 10.

- accept empty bond settings, for example for updelay. In that case,
  initialize the text input to "0". Likewise, when the text entry is
  empty, set the bond option to the respective default.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/488
(cherry picked from commit 61d4bc62e0)
2020-07-11 15:07:48 +02:00
Thomas Haller
b3775325af
libnm: add _nm_setting_bond_mode_from_string() to nm-libnm-core-intern
(cherry picked from commit a0b22b5b40)
2020-07-11 15:07:48 +02:00
Thomas Haller
131794b57b
tui: fix alternating miimon/arp_interval settings for bond options in nmtui
(cherry picked from commit 211d799817)
2020-07-11 15:07:47 +02:00
Thomas Haller
9d918e556f
cli: fix alternating miimon/arp_interval settings for bond options in nmcli
Before 1.24, nm_setting_bond_add_option() would clear
miimon/arp_interval settings when the respective other was set.

That was no longer done, with the effect that enabling (for example)
miimon on a bond profile that has arp_interval enabled, sets both
conflicting options.

That is not a severe problem, because the profile still validates.
However, at runtime only one of the settings can be actually configured.

Fix that, by restoring the previous behavior for the client. But note
that this time it's implemented in the client, and not in libnm's
nm_setting_bond_add_option().

(cherry picked from commit b55578bf6e)
2020-07-11 15:07:47 +02:00
Thomas Haller
0c75899d3e
bond: log only skipped bond options if they are set in the profile
(cherry picked from commit 3a25b3bfc7)
2020-07-11 15:07:46 +02:00
Thomas Haller
96edc84b4d
libnm,core: fix handling miimon and arp_interval as conflicting kernel options
We use sysfs API for setting bond options. Note that the miimon and
arp_interval settings conflict each other, and whenever setting one
of these sysfs values, the other one gets reset. That means,
NetworkManager needs to mediate and handle a profile which has both
these options set.

Before 1.24, the libnm API nm_setting_bond_add_option() API would mangle
the content of the bond settings, to clear the respective other fields
when setting miimon/arp_interval. That also had the effect that the
settings plugins, weren't able to read such (conflicting) settings
back from disk (but they would write them to disk). If a keyfile
specified both miimon and arp_interval keys, then it would depend on
their order in the keyfile which wins.
It is wrong that a libnm property setter mangles the option in such a way,
especially, because you still could set the NM_SETTING_BOND_OPTIONS
property directly and bypass this. So, since 1.24, you can create
profiles that have conflicting options.

Also, we can now not start to reject such settings as invalid, because that
would be an API break. Instead, just make sure that when one of the
settings is set, that the other one consistently gets deactivated.

Also, before 1.24 already, NMDeviceBond would mediate whether to either set
miimon or arp_interval settings. Despite that the keyfile reader would
mangle the settings, it would also prefer miimon over arp_interval,
if both were set.

This mechanism was broken since we switch to _bond_get_option_normalized()
for that. As a consequence, NetworkManager would try to set both the
conflicting options. Fix that.

(cherry picked from commit 4aa46328ca)
2020-07-11 15:07:46 +02:00
Thomas Haller
491cd1d2cd
libnm: don't fail assertion for _bond_get_option_normalized() with invalid bond mode
_bond_get_option_normalized() gets called with code paths that don't
assume a valid options hash. That means, the bond mode might be invalid
and we should fail an assertion.

(cherry picked from commit 1543f8a1a1)
2020-07-11 15:07:46 +02:00