Commit graph

26196 commits

Author SHA1 Message Date
Antonio Cardace
ad64da5e85
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')
(cherry picked from commit d342af1925)
2020-07-15 11:49:41 +02:00
Thomas Haller
e48c908e8c
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
(cherry picked from commit f0a39b517e)
2020-07-14 19:14:37 +02:00
Thomas Haller
3e6c85d908
release: bump version to 1.26.1 (development) 2020-07-13 20:11:59 +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
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
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
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
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
Thomas Haller
45c95e9314
device/bond: rework setting of arp_ip_target bond options
- the arp_ip_target option in the settings might not have normalized
  IP addresses or duplicates. If there would be duplicates, setting
  them twice would fail with EINVAL. Hence, first normalize them
  and make them unique.

- if what we want to set is identical to what is already set, don't
  do anything.

(cherry picked from commit 6a923a5d57)
2020-07-11 15:07:45 +02:00
Thomas Haller
c284f3c7fa
libnm: cleanup validating bond option "arp_ip_target"
We already have meta data for all bond options. For example,
"arp_ip_target" has type NM_BOND_OPTION_TYPE_IP.

Also, verify() already calls nm_setting_bond_validate_option() to validate
the option. Doing a second validation below is redundant (and done
inconsistently).

Validate the setting only once.

Also beef up the validation and use nm_utils_bond_option_arp_ip_targets_split()
to parse the IP addresses. This now strips extra whitespace and (as
before) removes empty entries.

(cherry picked from commit e96051d734)
2020-07-11 15:07:45 +02:00
Thomas Haller
2f43cde20d
libnm: add nm_utils_bond_option_arp_ip_targets_split() helper
Note yet used. The way how we split the option is relevant at various
places. The code should use the same helper function.

(cherry picked from commit 4ee0e8f075)
2020-07-11 15:07:45 +02:00
Thomas Haller
b5e5356ad5
shared: assert that nm_utils_strsplit_set_full() returns non-empty strv array
(cherry picked from commit f78e0bf246)
2020-07-11 15:07:45 +02:00
Beniamino Galvani
446ad4a03d merge: branch 'bg/sriov-reset-on-failure'
https://bugzilla.redhat.com/show_bug.cgi?id=1819587
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/457

(cherry picked from commit 6ca98f5b04)
2020-07-10 10:26:58 +02:00
Beniamino Galvani
ef9f26a1bf device: reset SR-IOV parameters on activation failure
SR-IOV parameters are reset when deactivating a connection; do the
same also on failure.

https://bugzilla.redhat.com/show_bug.cgi?id=1819587
(cherry picked from commit 4d6ea18de4)
2020-07-10 10:26:58 +02:00
Beniamino Galvani
b140adc40d device: allow queuing SR-IOV operation from a callback
Keep priv->sriov.pending set during the callback set so that it
becomes possible to insert a new operation from the callback itself.

(cherry picked from commit 74ccda8a71)
2020-07-10 10:26:57 +02:00
Beniamino Galvani
01997b2550 device: clear queued sriov operation on dispose
When dispose() is called, there can't be any pending operation because
they keep a reference to the device. Instead, there can be a a queued
operation not yet executed. Destroy it.

(cherry picked from commit 6fcb077a98)
2020-07-10 10:26:57 +02:00
Beniamino Galvani
ed849eadc1 platform: do not rely on the presence of sriov_totalvfs sysfs file
The file doesn't exist for all interfaces that support SR-IOV. In
particular, netdevsim devices support SR-IOV but don't expose the
file.

(cherry picked from commit 63a932b851)
2020-07-10 10:26:57 +02:00
Beniamino Galvani
2572f7c821 initrd: generate ipv6.method=auto for ip=dhcp6
When a 'ip=auto6' option is passed to kernel, the old dracut network
module only sets accept_ra in kernel and wait for the address to
appear. Instead, with a 'ip=dhcp6' option it starts 'dhclient -6',
leaving accept_ra to the initial value (that is already 1). So
'ip=dhcp6' in practice does kernel IPv6 autoconf and DHCPv6 at the
same time, without honoring the 'Managed' flag of the router
advertisement.

It seems that the only reason to have distinct 'auto6' and 'dhcp6'
options was that network module did not support starting DHCPv6 only
when necessary based on the M flag of the RA; so the user had to
specify if DHCPv6 was needed or not.

Given that 1) NM is smarter and can start DHCPv6 only when needed by
RA; 2) DHCPv6 alone only gets a /128 address without a prefix route
and so it's not useful; then it makes sense to generate a connection
with 'ipv6.method=auto' for both 'ip=auto6' and 'ip=dhcp6'.

https://bugzilla.redhat.com/show_bug.cgi?id=1854323
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/571
(cherry picked from commit ca3d0a8f06)
2020-07-09 14:48:29 +02:00
Antonio Cardace
a199cd2a7d
core: add dependent local routes configured by kernel
Pre-generate routes in the local table that are configured
by kernel when an ip-address is assigned to an interface.

This helps NM taking into account routes that are not to be deleted
when a connection is reapplied (or deactivated) on an interface instead of only
ignoring (when pruning) IPv6 routes having metric 0 and routes belonging
to the local table having 'kernel' as proto.

https://bugzilla.redhat.com/show_bug.cgi?id=1821787
(cherry picked from commit 3e5fc04df3)
2020-07-09 11:42:05 +02:00
Thomas Haller
e407cf6ca4
platform: skip metric-0 IPv6 routes in nm_platform_ip_route_sync()
@routes are the list of routes we want to configure. This contains
routes from DHCP and manual routes in the profile. It also contains
externally present routes, including the metric=0 routes in the local
table.

Trying to add an IPv6 route with metric zero adds instead a route with
metric 1024.

Usually, we wouldn't do that, because that route was present externally,
so it possibly is still present (in the platform cache) during sync and
we skip the addition. However, there is a race where the external route
might just disappear and we'd add a route with metric 1024.

Avoid that.

(cherry picked from commit a83622f7d0)
2020-07-09 11:42:05 +02:00
Antonio Cardace
cc412891d0
nm-device: change route table sync mode behaviour
NM will now sync all tables when a connection has specified
at least 1 local route in 'ipv[4|6].routes' to correctly
reconcile local routes when reapplying connections on a device.

If the connection has no local routes only the main table will be
taken into account preserving the previous NM's behaviour.

https://bugzilla.redhat.com/show_bug.cgi?id=1821787
(cherry picked from commit c5496f7372)
2020-07-09 11:42:05 +02:00
Antonio Cardace
4486c25077
platform: do not prune kernel added routes
IPv6 routes having metric 0 and routes having rt_source == kernel
are entirely managed by kernel, NM should not try to remove them.

https://bugzilla.redhat.com/show_bug.cgi?id=1821787
(cherry picked from commit 9ecc27f6d3)
2020-07-09 11:42:05 +02:00
Antonio Cardace
aefca972b6
core: add dependent multicast route configured by kernel for IPv6
Pre-generate the device multicast route in the local table that are configured
by kernel when an ipv6-address is assigned to an interface.

This helps NM taking into account routes that are not to be deleted
when a connection is reapplied on an interface.

https://bugzilla.redhat.com/show_bug.cgi?id=1821787
(cherry picked from commit cd89026c5f)
2020-07-09 11:42:04 +02:00
Antonio Cardace
f61e9a0011
platform: parse route type from netlink messages
https://bugzilla.redhat.com/show_bug.cgi?id=1821787
(cherry picked from commit 04878193f7)
2020-07-09 11:42:04 +02:00
Antonio Cardace
9120cfaf9c
utils: add 'unspecified' to nm_utils_route_type2str()
https://bugzilla.redhat.com/show_bug.cgi?id=1821787
(cherry picked from commit e3e7bdf96e)
2020-07-09 11:42:04 +02:00
Antonio Cardace
6e73e27622
platform: always display route type when calling nmp_object_to_string()
https://bugzilla.redhat.com/show_bug.cgi?id=1821787
(cherry picked from commit d67ad4c86b)
2020-07-09 11:42:00 +02:00
Beniamino Galvani
72d66fffac ppp: fix taking control of link generated by kernel
NetworkManager can't control the name of the PPP interface name
created by pppd; so it has to wait for the interface to appear and
then rename it. This happens in nm_device_take_over_link() called by
nm-device-ppp.c:ppp_ifindex_set() when pppd tells NM the ifindex of
the interface that was created.

However, sometimes the initial interface name is already correct, for
example when the connection.interface-name is ppp0 and this is the
first PPP interface created.

When this happens, nm_device_update_from_platform_link() is called on
the NMDevicePPP and it sets the device ifindex. Later, when pppd
notifies NM, nm_device_take_over_link() fails because the ifindex is
already set:

 nm_device_take_over_link: assertion 'priv->ifindex <= 0' failed

Make nm_device_take_over_link() more robust to cope with this
situation.

https://bugzilla.redhat.com/show_bug.cgi?id=1849386
(cherry picked from commit 75bc21c4cf)
2020-07-08 15:07:44 +02:00
Thomas Haller
2ced21c5b7
core: fix treating route metric zero of IPv6 routes special
Userspace cannot add IPv6 routes with metric 0. Trying to do that, will
be coerced by kernel to route metric 1024. For IPv4 this is different,
and metric zero is commonly allowed.

However, kernel itself can add IPv6 routes with metric zero:

  # ip -6 route show table local
  local fe80::2029:c7ff:fec9:698a dev v proto kernel metric 0 pref medium

That means, we must not treat route metric zero special for most cases.
Only, when we want to add routes (based on user configuration), we must
coerce a route metric of zero to 1024.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/563
(cherry picked from commit 1b408e243d)
2020-07-07 16:15:41 +02:00
Beniamino Galvani
db1363fcec initrd: merge branch 'bg/initrd-bootif'
https://bugzilla.redhat.com/show_bug.cgi?id=1853277
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/562
(cherry picked from commit fbac6217b1)
2020-07-06 09:59:56 +02:00
Beniamino Galvani
0cb5bec7ae initrd: write the hostname to stdout with --stdout
Don't try to open /run/NetworkManager/initrd when called with
--stdout, but instead write the hostname to the standard output.

Fixes: ff70adf873 ('initrd: save hostname to a file in /run')
(cherry picked from commit 5fa97d7796)
2020-07-06 09:59:33 +02:00
Beniamino Galvani
b8246ea367 initrd: fix generating default BOOTIF= connection
There is a bug when parsing a BOOTIF= without any existing
connection. The generated connection doesn't have wired setting and
later we try to access it:

 # nm-initrd-generator --stdout -- BOOTIF=01-50-50-00-9f-21-21
  (nm-initrd-generator:1546): libnm-CRITICAL **: ((libnm-core/nm-setting-wired.c:205)): assertion '<dropped>' failed
  (nm-initrd-generator:1546): GLib-GObject-CRITICAL **: g_object_set: assertion 'G_IS_OBJECT (object)' failed

Fix this.

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

Fixes: 25a2b6e14f ('initrd: rework command line parsing')
(cherry picked from commit 3023c70e4e)
2020-07-06 09:59:28 +02:00
Beniamino Galvani
5a0be027a8 initrd: fix generation of MTU and cloned-mac-address for masters
Setting a MTU or a cloned MAC for bonds/bridges/teams fails with:

 # nm-initrd-generator -- bond=bond0:eno1,eno2:mode=802.3ad
    ip=192.168.1.5::192.168.1.254:255.255.255.0:MyServer:bond0:none::01:02:03:04:05:06
    bootdev=bond0 nameserver=192.168.1.1

 <warn> cmdline-reader: 'bond' does not support setting cloned-mac-address

Fix this.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/460
(cherry picked from commit 79f70bf5d6)
2020-07-06 09:58:22 +02:00
Beniamino Galvani
f819a7cabf ovs: merge branch 'bg/ovs-mac-pt2'
https://bugzilla.redhat.com/show_bug.cgi?id=1852106
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/557
(cherry picked from commit 15492e6c50)
2020-07-06 09:52:11 +02:00
Beniamino Galvani
791a888cad device: don't reset the MAC without ifindex
nm_device_cleanup() can be called when the device no longer has an
ifindex. In such case, don't try to reset the MAC address as that
would lead to an assertion failure.

(cherry picked from commit 77b6ce7d04)
2020-07-06 09:51:34 +02:00
Beniamino Galvani
60d10b146d ovs: also set cloned MAC address via netlink
We already set the MAC of OVS interfaces in the ovsdb. Unfortunately,
vswitchd doesn't create the interface with the given MAC from the
beginning, but first creates it with a random MAC and then changes it.

This causes a race condition: as soon as NM sees the new link, it
starts IP configuration on it and (possibly later) vswitchd will
change the MAC.

To avoid this, also set the desired MAC via netlink before starting IP
configuration.

https://bugzilla.redhat.com/show_bug.cgi?id=1852106
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/483
(cherry picked from commit 47ec3d14d4)
2020-07-06 09:51:31 +02:00
Beniamino Galvani
7548c29a89 ovs: set MAC address on the bridge for local interfaces
When a user creates a ovs-interface with the same name of the parent
ovs-bridge, openvswitch considers the interface as the "local
interface" [1] and assigns the MAC address of the bridge to the
interface [2].

This is confusing for users, as the cloned MAC property is ignored in
some cases, depending on the ovs-interface name.

Instead, detect when the interface is local and set the MAC from the
ovs-interface connection in the bridge table.

[1] https://github.com/openvswitch/ovs/blob/v2.13.0/vswitchd/vswitch.xml#L2546
[2] https://github.com/openvswitch/ovs/blob/v2.13.0/vswitchd/bridge.c#L4744

(cherry picked from commit 5d4c8521a3)
2020-07-06 09:51:29 +02:00
Beniamino Galvani
5321490180 device: restart DHCP only for devices that are active or activating
do_sleep_wake() tries to restart DHCP for all devices, even ones that
are disconnecting. When a device is disconnecting, it still has a DHCP
client instance but we shouldn't restart it because it makes no sense;
and especially, the device could be already removed.

https://bugzilla.redhat.com/show_bug.cgi?id=1852612
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/561
(cherry picked from commit 2c50438987)
2020-07-06 09:39:53 +02:00
Thomas Haller
838777a891
ndisc/tests: fix assertion in "test-ndisc-fake.c"
First I wanted to fix

  test:ERROR:../src/ndisc/tests/test-ndisc-fake.c:373:test_preference_changed_cb: assertion failed (_a->timestamp == (data->timestamp1 + 3)): (9 == 10)

but that leads to a different failure:

  test:ERROR:../src/ndisc/tests/test-ndisc-fake.c:375:test_preference_changed_cb: assertion failed (_a->lifetime == (9)): (10 == 9)

Instead, the start and end times must match exact (in their duration),
we only allow them to be shifted by up to one second.

Fixes: 8209095ee1 ('ndisc/tests: relax the assertion in "test-ndisc-fake.c"')
(cherry picked from commit b2f03544a7)
2020-07-03 20:41:43 +02:00
Thomas Haller
75177f6967
ndisc/tests: relax the assertion in "test-ndisc-fake.c"
test:ERROR:../src/ndisc/tests/test-ndisc-fake.c:373:test_preference_changed_cb: assertion failed (_a->timestamp == (data->timestamp1 + 3)): (9 == 10)

(cherry picked from commit 8209095ee1)
2020-07-03 20:41:42 +02:00
Thomas Haller
0847ede1e3
cli: suppress "(unknown)" output in terse mode for device properties HWADDR and DRIVER
$ nmcli -f GENERAL.HWADDR device show ovsport0
  GENERAL.HWADDR: (unknown)

but:

  $ nmcli -f GENERAL.HWADDR --terse device show ovsport0
  GENERAL.HWADDR:

This is an API change of nmcli.

(cherry picked from commit 2a1e621704)
2020-07-03 15:09:26 +02:00
Thomas Haller
c624fa684c
cli: add nmc_meta_generic_get_str_i18n_null() helper
(cherry picked from commit 05a84be550)
2020-07-03 15:09:20 +02:00