Commit graph

24713 commits

Author SHA1 Message Date
Thomas Haller
02ba767496 device: allow setting "arp_validate" with supported bond modes
arp_validate is allowed for several bonding modes, at least since commit [1].

The validation was too strict. Just use set_bond_attr() directly, that
already correctly encodes whether to set the value or not.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=13ac34a8866e31b31db6237c73aa558aff84d765

(cherry picked from commit d9d51dd42d)
2020-02-19 17:30:15 +01:00
Beniamino Galvani
987c1d282a Revert "core: create virtual device on settings changes in idle handler"
When AddConnection() or Update() terminate, the (unrealized) virtual
device should be already be available, otherwise an activation attempt
of that connection can fail.

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

This reverts commit c163207b07.

(cherry picked from commit efc04b1285)
2020-02-19 10:06:21 +01:00
Thomas Haller
0c8046574e ifcfg: fix writer when changing OVS slave to clear previous settings
We need to reset the OVS_PORT and OVS_PORT_UUID variables.
Otherwise, clearing the slave type doesn't work.

On master this is solved differently, by automatically clearing all
variables that are not explicitly set.

Reproducer:

    nmcli con del t-eth1
    nmcli con add type ethernet autoconnect no ifname eth1 master port0 con-name t-eth1 slave-type ovs-port
    echo "
    remove ovs-interface
    remove connection.master
    remove connection.slave-type
    print
    save
    quit
    " | nmcli c edit t-eth1
    nmcli con show t-eth1 | grep 'ovs\|slave-type'

Fixes: 1440fe6a88 ('ifcfg: don't forget master of ovs interfaces')

https://bugzilla.redhat.com/show_bug.cgi?id=1804167
2020-02-18 18:37:45 +01:00
Antonio Cardace
6e12b31d1f release: bump version to 1.22.9 (development) 2020-02-18 16:49:55 +01:00
Antonio Cardace
fa6c656473 release: bump version to 1.22.8 2020-02-18 16:48:01 +01:00
Antonio Cardace
24977b55c8 release: update NEWS 2020-02-18 16:46:35 +01:00
Thomas Haller
82237a3344 shared/trivial: add code comment to nm_utils_ifname_valid_kernel()
(cherry picked from commit eb74d5f65f)
2020-02-18 13:28:49 +01:00
Thomas Haller
9bbb021b4f shared: check for valid UTF-8 in nm_utils_ifname_valid()
The interface name might come from the command line or from a filename
(like during nm_vpn_wireguard_import()). It's not clear that this
is valid UTF-8. Asserting against that requires the caller to ensure
that the encoding is valid. That is cumbersome, especially since we anyway
check. Just report a regular error.

(cherry picked from commit 82fb8b00b4)
2020-02-18 13:28:48 +01:00
Antonio Cardace
88d0d80d09 nm-shared-utils: relax ovs ifname check to accept any (non-space) ASCII printable char
quoting 'man ovs-vswitchd.conf.db':
"The name must be alphanumeric and must not contain forward or backward
slashes."

OVS actually accepts a wider range of chars (all printable UTF-8 chars),
NetworkManager restricts this to ASCII char as it's a safer option for
now since OVS is not well documented on this matter.

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

Fixes: e7d72a14f6 ('libnm-core: use different ifname validation function for OVS bridges, ports and interfaces')
(cherry picked from commit ed5a647ad1)
2020-02-18 13:12:59 +01:00
Beniamino Galvani
53b878818c ovs: merge branch 'bg/ovs-deactivate-async-pt2'
https://bugzilla.redhat.com/show_bug.cgi?id=1787989
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/412
(cherry picked from commit e24fd88494)
2020-02-17 19:08:48 +01:00
Beniamino Galvani
c4eb0c6852 ovs: discard link updates when deactivating
When the ovs interface gets deactivated, it is released from the
master port and we call nm_device_update_from_platform_link (dev,
NULL) to ignore any later event for the interface. This is important
especially because it sets a zero ifindex on the interface and so,
later when the link disappears, we don't unmanage the device but
directly remove it.

However, since ovs commands are queued, the link could appear during
the deactivation and we need to ignore such events. Add a new device
method can_update_from_platform_link() for such purpose.

(cherry picked from commit e9fc1dea43)
2020-02-17 19:08:21 +01:00
Beniamino Galvani
2e5e409bf2 ovs: rework asynchronous deactivation of ovs interfaces
Tracking the deletion of link by ifindex is difficult because the
ifindex of the device is updated through delayed (idle) calls in
NMDevice and so there is the possibility that at a certain time the
device ifindex is not in sync with platform state. It seems simpler to
watch instead the interface name. The ugly thing is that the interface
name can be changed externally, but if users do that on an activating
device they are looking for trouble.

Also change the deactivate code to deal with the scenario where we
already created the interface in the ovsdb but the link didn't show up
yet. To ensure a proper cleanup we must wait that the link appears and
then goes away; however the link may never appear if vswitchd sees
only the last state in ovsdb, and so we must use a ugly timeout to
avoid waiting forever.

https://bugzilla.redhat.com/show_bug.cgi?id=1787989
(cherry picked from commit 9c49f8a879)
2020-02-17 19:08:20 +01:00
Beniamino Galvani
644151b07a n-dhcp4: request previous address after expiration
If the lease expires and the client start again sending a discover,
request the previous address.

(cherry picked from commit 3286918bd9)
2020-02-17 19:07:36 +01:00
Thomas Haller
b1dcfcb7b7 shared: fix returning out_len from nm_utils_hash_values_to_array()
The only affected caller is nm_modem_manager_get_modems(), which
is used by NMDeviceBt for DUN connections. This is rather bad.

Fixes: 4154d9618c ('bluetooth: refactor BlueZ handling and let NMBluezManager cache ObjectManager data')
Fixes: e688e70b37 ('shared: add nm_utils_hash_values_to_array() helper')
(cherry picked from commit 037507f790)
2020-02-17 17:55:52 +01:00
Antonio Cardace
4200d0a85b Merge branch 'ac/ovs_ifname_length' into 'master'
[ac/ovs ifname length]

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/408

(cherry picked from commit 63eabe0dbf)
2020-02-17 17:34:49 +01:00
Antonio Cardace
a44fa6c689 libnm-core: use different ifname validation function for OVS bridges, ports and interfaces
OVS bridges and ports do not have the length limitation of 15 bytes, the
only requirements are that all chars must be alphanumeric and not be
forward or backward slashes.

For OVS interfaces only 'patch' types do not have the length limit, all
the other types do (according to whether they have a corresponding
kernel link or not).

Add related unit test.

https://bugzilla.redhat.com/show_bug.cgi?id=1788432
(cherry picked from commit e7d72a14f6)
2020-02-17 17:31:31 +01:00
Antonio Cardace
1a4b59a7c3 nm-setting-ovs-interface: remove unneeded check on 'self'
'self' is guaranteed of being not-NULL since we have the
assertion 'g_return_val_if_fail (NM_IS_SETTING_OVS_INTERFACE (self),FALSE);'
at the beginning of the function.

(cherry picked from commit 15e87b80f3)
2020-02-17 17:28:15 +01:00
Antonio Cardace
30d329567c libnm-core: add assertion for valid 'error' argument in nm_utils_is_valid_iface_name()
(cherry picked from commit 72f7ad75dc)
2020-02-17 17:28:15 +01:00
Antonio Cardace
c3b0f1d4f5 all: use nm_utils_ifname_valid_kernel() instead of nm_utils_is_valid_iface_name()
nm_utils_is_valid_iface_name() is a public API of libnm-core, let's use
our internal API.

$ sed -i 's/\<nm_utils_is_valid_iface_name\>/nm_utils_ifname_valid_kernel/g' $(git grep -l nm_utils_is_valid_iface_name)

(cherry picked from commit 6e9a36ab9f)
2020-02-17 17:28:14 +01:00
Antonio Cardace
2cf568bd8f nm-shared-utils: add nm_utils_ifname_valid*() to shared utils
Move the body of nm_utils_is_valid_iface_name() to
nm_utils_ifname_valid_kernel() so that it's shared between NM and
clients.

(cherry picked from commit 550f538564)
2020-02-17 17:26:47 +01:00
Antonio Cardace
5fb293cfc6 nmcli: remove interface length check in nmcli
nmcli should not perform checks on the interface name length,
this kind of operations should only be performed by the NetworkManager
daemon and not be duplicated inside cli applications.

(cherry picked from commit 15a8595575)
2020-02-17 17:25:52 +01:00
Antonio Cardace
816aacc4c2 nm-device-factory: remove ifname check as it prevents activating OVS connections
(cherry picked from commit 0cac094c93)
2020-02-17 17:25:52 +01:00
Antonio Cardace
e52fccb0d0 nm-dhcp-client: use nm_assert() to check ifname
so that it gets compiled out in production builds, this check is
carried out anyway when the connection is created.

(cherry picked from commit 9e27252c27)
2020-02-17 17:25:52 +01:00
Thomas Haller
91b2be2e1b all: merge branch 'th/ra-timeout'
https://bugzilla.redhat.com/show_bug.cgi?id=1801158

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/414

(cherry picked from commit 4c993f6bbb)
2020-02-17 15:12:30 +01:00
Thomas Haller
8d04ae1e84 version: add NM_VERSION_1_22_8/NM_AVAILABLE_IN_1_22_8 macros 2020-02-17 15:06:10 +01:00
Thomas Haller
f259b4b6c0 ndisc: implement "ipv6.ra-timeout" property
(cherry picked from commit 9dde86d02c)
2020-02-17 15:06:10 +01:00
Thomas Haller
1f4c8a0f54 ndisc: rename NM_NDISC_RA_TIMEOUT signal to NM_NDISC_RA_TIMEOUT_SIGNAL
We will add a property NM_NDISC_RA_TIMEOUT for which this name is better
suited. The problem is really that our convention for object properties
and signals defines have no prefix to indicate whether it's a property
or a signal.

Rename.

(cherry picked from commit 10f0253f2e)
2020-02-17 15:06:10 +01:00
Thomas Haller
7c86bc9c97 ndisc: improve logging message with nm_ndisc_start() and minor cleanup
(cherry picked from commit b2e30b3c9a)
2020-02-17 15:06:10 +01:00
Thomas Haller
c1b640da2d libnm,cli,ifcfg-rh: add ipv6.ra-timeout configuration option
(cherry picked from commit de4aeb34e3)
2020-02-17 15:06:10 +01:00
Thomas Haller
8985917c9e cli: add support for "ipv6.dhcp-timeout" property
It was internally supported, but not by nmcli.

(cherry picked from commit 0d8f55a1cb)
2020-02-17 15:06:10 +01:00
Thomas Haller
60ef3a3e59 ifcfg-rh: belatedly add support for "ipv6.dhcp-timeout" setting
(cherry picked from commit 843c546b84)
2020-02-17 15:06:10 +01:00
Thomas Haller
fe6c3f0867 ifcfg-rh: fix potential crash with variadic argument make_ip6_setting()
It is undefined behavior and can lead to crashes or memory corruption.
In practice, this only had an issue on Big Endian systems.

Fixes: fdbf4ae5e6 ('ifcfg-rh: add IPV4_DHCP_TIMEOUT key for ipv4.dhcp-timeout property')
(cherry picked from commit 9b82d29f5f)
2020-02-17 15:06:10 +01:00
Thomas Haller
7751f853c3 ifcfg-rh: inline unnecessary function write_ip6_setting_dhcp_hostname()
If a function is only called once, it may not help to simplify the code
but make it more complicated. It would only simplify the code, if it
had a clear, distinct purpose. That isn't the case here. Also, the
IPv4 writer doesn't have such a function either. Drop and inline it.

(cherry picked from commit d06092acbd)
2020-02-17 15:06:10 +01:00
Thomas Haller
2ed1a6803e device: don't schedule grace timeout if dhcp-timeout is infinity
It feels wrong to schedule a timeout with G_MAXUINT32, if we actually
disabled the timeout. Of course, in practice there should be little
difference.

(cherry picked from commit 4c101f36ec)
2020-02-17 15:06:10 +01:00
Thomas Haller
bd02523b6b device/trivial: rename get_dhcp_timeout() virtual function to have a unique name
This is C, we have almost no IDE support. And ctags/cscope is much more
helpful if we use unique names.

Don't use the get_dhcp_timeout() name, because that is already used in
"src/devices/nm-device.c" already. Rename.

(cherry picked from commit be4129bb2d)
2020-02-17 15:06:10 +01:00
Thomas Haller
fb1b8de4d7 libnm/doc: explain values for dhcp-timeout setting
(cherry picked from commit e34db042af)
2020-02-17 15:06:10 +01:00
Antonio Cardace
a2a2bf5206 man: fix missing tag
(cherry picked from commit 1ccdce0c1d)
2020-02-17 14:35:15 +01:00
Antonio Cardace
83d5368a19 man: add dnsmasq option documentation on added dns servers
(cherry picked from commit 7ef684b1b3)
2020-02-17 14:35:09 +01:00
Thomas Haller
501893c4bc man: document connectivity.enabled option in NetworkManager.conf manual
(cherry picked from commit 655e1aa97f)
2020-02-17 14:34:59 +01:00
Thomas Haller
99caa0c28f doc: clarify default values for ipv4.mdns and ipv4.llmnr settings
LLMNR and mDNS settings can have their global default value configured
in "NetworkManager.conf".

Global default values should work the way that all regular values of the property
can be configured explicitly in the connection profile. The special "default" value
only indicates to allow lookup of the global default, but it should not have a
meaning of its own.

Note that if mDNS/LLMNR settings are left unspecified, we will set the
argument to SetLinkMulticastDNS() and SetLinkLLMNR() functions to "",
which means that systemd-resolved decides on a default. Also, depending
on the DNS plugin, the default value differs. This is all fine however.
In this case, the ultimate default value depends on other things (like
the DNS plugin), but each possible value is in fact explicitly
configurable. We also do that for "ipv6.ip6-privacy".

Anyway, cleanup the documentation a bit and try to better explain what
the default is.

(cherry picked from commit 3d07708f59)
2020-02-17 13:47:25 +01:00
Beniamino Galvani
3a43575539 libnm-core: fix documentation of dns-priority property
Clarify that VPNs are considered first in case of same priority, and
also that it's the *best* default route that matters.

(cherry picked from commit bf4b53d453)
2020-02-12 11:10:20 +01:00
Beniamino Galvani
2be04221de dhcp: merge branch 'bg/nettools-request-free'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/409
(cherry picked from commit 2e53fd4561)
2020-02-11 09:28:39 +01:00
Beniamino Galvani
9a1bbef1b4 dhcp: nettools: move to failed state if event dispatch fails
(cherry picked from commit 45521b1b38)
2020-02-11 09:28:27 +01:00
Beniamino Galvani
14aadaadf2 n-dhcp4: avoid double free of NDhcp4Outgoing
n_dhcp4_c_connection_start_request() should take ownership of the
request only on success. On failure the request is freed by the
caller.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/355
(cherry picked from commit 43016d6ebd)
2020-02-11 09:28:26 +01:00
Beniamino Galvani
0bd30d8da0 team: merge branch 'bg/team-race-rh1798947'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/410
https://bugzilla.redhat.com/show_bug.cgi?id=1798947
(cherry picked from commit a119dac998)
2020-02-11 09:21:46 +01:00
Beniamino Galvani
a0c209b653 team: ignore bus name appearance when killing teamd
If we are currently killing teamd, we are not interested in knowing
when it becomes ready.

(cherry picked from commit 554e9be5b0)
2020-02-11 09:21:35 +01:00
Beniamino Galvani
77635adb50 team: ignore bus name appearance if we can't determine process id
If the GetConnectionUnixProcessID() call fails, the process that
registered on the bus has died and we should ignore the name
appearance event.

(cherry picked from commit e94d76382c)
2020-02-11 09:21:33 +01:00
Thomas Haller
dbd7083881 libnm: merge branch 'th/libnm-active-connection-delay-ready'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/405

(cherry picked from commit 2d3a1af5d6)
2020-02-10 19:04:46 +01:00
Thomas Haller
60877600c5 libnm: hide NMActiveConnection until NMRemoteConnection is ready
Generally, libnm's NMClient cache only wants to expose NMObjects that
are fully initalized. Most objects don't require anything special,
except NMRemoteConnection which waits for the GetSettings() call to complete.

NMObjects reference each other. For example, NMActiveConnection
references NMDevice and NMRemoteConnection. There is a desire that an
object is only ready, if the objects that it references are ready too.
In practice that is not done, because usually every objects references
other objects, that means all objects would be declared as non-ready
as long as any of them is still initializing. That does not seem
desirable. Instead, most objects (except NMRemoteConnection and now
NMActiveConnection) are considered ready and visible, once their first
notification completes. In case the objects reference any object that is
not yet ready, the references is NULL (but the source object is visible
already). This is also done this way, to cope with cycles where
objects reference each other. In practice, such cycles should not be
exposed by NetworkManager. However, libnm should be robust against that.

This has the undesired effect that when you call AddAndActivate(), then
the NMActiveConnection might already be visible while its
NMRemoteConnection isn't. That means, ac.get_connection() will
initially return NULL, until the remote connection becomes ready.
Also add a special handling that NMActiveConnection waits for their
NMRemoteConnection to be ready, before being ready itself.

Fixes: ce0e898fb4 ('libnm: refactor caching of D-Bus objects in NMClient')
(cherry picked from commit 425412a363)
2020-02-10 19:04:46 +01:00
Thomas Haller
ef09aac69b libnm: minor cleanup of libnm trace logging
(cherry picked from commit 6b745e0725)
2020-02-10 19:04:46 +01:00