Commit graph

23027 commits

Author SHA1 Message Date
Lubomir Rintel
5a565659fa 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
(cherry picked from commit 2952953a48)
2019-07-24 08:45:37 +02:00
Lubomir Rintel
be01ba6d98 initrd/tests: ensure that nameserver= setting affects the correct connection
(cherry picked from commit 39d5c8c12f)
2019-07-24 08:45:37 +02:00
Lubomir Rintel
0d9a62c25e 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.

(cherry picked from commit 6da2058237)
2019-07-24 08:45:37 +02:00
Lubomir Rintel
24c3a0c88f initrd/tests: ensure we accept a prefix in place of an IPv4 mask
(cherry picked from commit 77540b2a7c)
2019-07-24 08:45:37 +02:00
Lubomir Rintel
fe803a577c 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
(cherry picked from commit 390d79079e)
2019-07-24 08:45:37 +02:00
Lubomir Rintel
c0b2950282 initrd: remove an accidental backspace
(cherry picked from commit 920e59016f)
2019-07-24 08:45:37 +02:00
Lubomir Rintel
d023155894 initrd: fix error reporting on bad netmask
It says the address is bad, but what is wrong is the mask.

(cherry picked from commit 4b097e314e)
2019-07-24 08:45:37 +02:00
Thomas Haller
57048338ee platform/netlink: mark nested netlink attribute with NLA_F_NESTED
Kernel 5.2 is adding stricter checking for netlink messages.
In particular, for certain API it checks now that NLA_F_NESTED flag is
set for nested attributes ([1]).

Note that libnl3 does not ever set this flag, and since our netlink
implementation is copied from there, certain netlink messages are now
rejected as invalid.

On the other hand, libmnl always adds this flag ([2]). So we should do that
as well.

In particular, this affects the WireGuard netlink API causing request
from NetworkManager to be rejected ([3]).

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b424e432e770d6dd572765459d5b6a96a19c5286
[2] https://git.netfilter.org/libmnl/tree/src/attr.c?id=5937dfcb0185f5cb9cf275992ea701ec4e619d9c#n535
[3] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/212

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/210
(cherry picked from commit 7811d1c187)
2019-07-23 14:45:09 +02:00
Marco Trevisan (Treviño)
64ed96fb5f device: free temporary typename with iface variable
To create a disambiguated name for some Bluetooth devices we use its type name
with iface, however this value is allocated but never free'd when passed to
g_strdup_printf.

So use instead a temporary variable and free it once done.

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

Fixes: 8bbda5cdff
(cherry picked from commit b621aba5c2)
2019-07-22 08:31:17 +02:00
Thomas Haller
f6088582bb libnm,core: support more "arp_validate" bond options
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/networking/bonding.txt?id=22051d9c4a57d3b4a8b5a7407efc80c71c7bfb16#n306

https://bugzilla.redhat.com/show_bug.cgi?id=1730793
(cherry picked from commit b8e9a62f2a)
2019-07-18 14:20:38 +02:00
Thomas Haller
09f37d5bd4 device: fix reapplying changes to connection ID and UUID
4 properties are not really relevant for an already activated connection
or it makes not sense to change them. These are connection.id, connection.uuid,
connection.autoconnect and connection.stable-id.

For convenience, we allow to reapply these. This way, one can take
a different setting (e.g. with a different connection.id or
connection.uuid) and reapply them, but such changes are silently
ignored.

However this was done wrongly. Instead of reverting the change to the new
applied connection, we would change the input connection.

This is bad, for example with

  nmcli connection up uuid cb922f18-e99a-49c6-b200-1678b5070a82
  nmcli connection modify cb922f18-e99a-49c6-b200-1678b5070a82 con-name "bogus"
  nmcli device reapply eth0

the last re-apply would reset the settings-connection's connection ID to
what was before, while accepting the new name on the applied-connection
(while it should have been rejected).

Fixes: bf3b3d444c ('device: avoid changing immutable properties during reapply')

(cherry picked from commit adb51c2a7f)
2019-07-18 12:20:39 +02:00
Thomas Haller
44e4ed1e95 core: fix mangling static IPv6 routes in nm_ip6_config_merge_setting()
https://bugzilla.redhat.com/show_bug.cgi?id=1727193

Fixes: 433d2f8659 ('core: merge IPv4 and IPv6 version of _nm_ip_config_merge_route_attributes()')
(cherry picked from commit a8fa015a4e)
2019-07-09 14:35:05 +02:00
Beniamino Galvani
4150dd8c43 ifcfg-rh: fix memory leak reading infiniband setting
(cherry picked from commit c045267837)
2019-07-04 11:55:20 +02:00
Beniamino Galvani
5ca888d693 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
(cherry picked from commit 17f4a1e794)
2019-07-03 17:59:00 +02:00
Beniamino Galvani
9fe7ef6ca3 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'):
(cherry picked from commit 420554a72e)
2019-06-27 17:14:52 +02:00
Beniamino Galvani
7f239eff44 device: set IPv6 token only when necessary
Setting the IPv6 token triggers a new router solicitation from kernel
and so we should avoid when not strictly necessary.

https://mail.gnome.org/archives/networkmanager-list/2019-May/msg00004.html
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/179
(cherry picked from commit e4ce9bd7af)
2019-06-26 09:17:41 +02:00
Beniamino Galvani
52c886a6d7 cli: fix crash on autocompletion
@connections is NULL when doing autocompletion. Fixes the following:

 $ nmcli --complete-args con monitor ""
  help
  id
  uuid
  path
  filename
  ...
  Segmentation fault (core dumped)

Fixes: 4b3297271e ('cli: rework connection handling for multiple results')

https://bugzilla.redhat.com/show_bug.cgi?id=1716948
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/177
(cherry picked from commit 6a3bb90ad4)
2019-06-20 10:43:58 +02:00
Beniamino Galvani
591837d6f5 device: fix matching parent device by connection UUID
We must compare the UUID with the one on the *parent* device.

Also, simplify the checks to only return TRUE at the end of function.

Fixes: 27c281ac5a ('device: deduplicate match_parent()')

https://bugzilla.redhat.com/show_bug.cgi?id=1716438
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/176
(cherry picked from commit 3c54b5eb2b)
2019-06-20 10:40:56 +02:00
Beniamino Galvani
45d47a680b connectivity: merge branch 'bg/concheck-issue181'
Don't start connectivity check on unconfigured devices.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/181
(cherry picked from commit 4dce38c37f)
2019-06-20 10:28:48 +02:00
Thomas Haller
aa055239a2 Revert "Coerce connectivity "LIMITED" to "NONE" when device is disconnected"
NMConnectivity can now distinguish between LIMITED and NONE connectivity
and it does so based on whether IP addresses and routes are configured.

Previously, NMConnectivity would not differenciate between limited and
no connectivity, which is why NMDevice added some additional logic on top
to coerce LIMITED to NONE (if the device is not logically connected).

But note that the connectivity state (whether a network is reachable on
an interface) depends on what is configured in kernel and whether the
internet is reachable on that interface. It does not depend on the
logical device state.

On the other hand, whether the device is configured in a manner to have
connectivity depends on the logical state of the device (as NetworkManager
is configuring the device).

So, in many cases, the logical state and the connectivity state agree now,
but for the right reasons.

This reverts commit 4c4dbcb78d.

(cherry picked from commit 5a416a9da1)
2019-06-20 10:28:28 +02:00
Thomas Haller
a842280dbe connectivity: make platform argument to nm_connectivity_check_start() optional
The platform is used to detect whether to skip the connectivity check right away.
It should be an optional argument, so one could avoid this pre-check.

(cherry picked from commit b626baa313)
2019-06-20 10:28:26 +02:00
Thomas Haller
3c2886f447 connectivity: simplify passing result to idle handler
(cherry picked from commit 19c957f091)
2019-06-20 10:28:24 +02:00
Thomas Haller
28540a8eb8 connectivity: remove unused error varialbe in _idle_cb()
(cherry picked from commit 4001aee370)
2019-06-20 10:28:23 +02:00
Beniamino Galvani
7f937ecece device: don't start connectivity check on unconfigured devices
If the interface has no carrier, no addresses or no routes there is no
point in starting a connectivity check on it because it will fail.
Moreover, doing the check on a device without routes causes the
addition of a negative entry in the ARP table for each of the
addresses associated with the connectivity check host; this can lead
to poor network performances.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/181
(cherry picked from commit 91d447df19)
2019-06-20 10:28:21 +02:00
Beniamino Galvani
28c3692023 libnm-core: fix conversion to json of team watcher flags
Team watcher flags are boolean objects: persist them as such and not
as strings.

Fixes: e59878ce19
https://bugzilla.redhat.com/show_bug.cgi?id=1720153
2019-06-17 09:33:33 +02:00
Beniamino Galvani
3423629ff0 cli: don't wait for connection change on update failure
When saving a connection, we wait the connection-changed signal before
proceeding to ensure that the remote connection is up to date.
However, no signal is emitted if the update fails and so we shouldn't
wait for it.

Fixes: a370faeb59 ('cli: wait for changed signal after updating a connection'):

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/124
https://bugzilla.redhat.com/show_bug.cgi?id=1702203
(cherry picked from commit 2d347e7e17)
2019-06-14 17:22:08 +02:00
Alfonso Sánchez-Beato
3caa065709 core/pppd-plugin: wait to recover port settings before notifying death
pppd restores the previous settings for the serial port it uses right
before exiting. It is especially important to do so because otherwise
ModemManager is not able to recover the port as it can receive a hangup
event from the port due to CLOCAL not being restored.  However, there is
currently a race condition that produces this issue. This is because
when PHASE_DEAD is notified, pppd still has not restored the port
settings - it does that a bit later, in the die() function.

This patch delays notifying PHASE_DEAD until when the exitnotify() hook
is called by pppd: when this happens the port settings have already been
restored.

There were previously efforts to fix this in commit fe090c34b7, so
PHASE_DEAD was used instead of PHASE_DISCONNECT to notify MM that the
port was disconnected, but that still early to ensure that the port
settings are restored.

The MM traces seen when the bug is triggered are:

ModemManager[2158]: <warn>  (ttyACM1): could not re-acquire serial port lock: (5) Input/output error
ModemManager[2158]: <warn>  Couldn't load Operator Code: 'Cannot run sequence: 'Could not open serial device ttyACM1: it has been forced close'

https://mail.gnome.org/archives/networkmanager-list/2019-June/msg00014.html

(cherry picked from commit a251712a72)
2019-06-14 13:32:57 +02:00
Beniamino Galvani
5221af1123 tui: add only some options to new bond connections
Instead of adding every known option to new bond connections, only add
the ones supported by UI.

https://bugzilla.redhat.com/show_bug.cgi?id=1715720
(cherry picked from commit b247950c6f)
2019-06-11 18:36:30 +02:00
Beniamino Galvani
e94127432c libnm-core: change unsupported modes for arp_ip_targets bond option
If the mode is one of '802.3ad', 'tlb' or 'alb' and the connection has
both 'arp_interval' and 'arp_ip_target' options, during normalization
we remove 'arp_interval' because unsupported in the current mode. The
connection then becomes invalid because 'arp_ip_target' requires
'arp_interval'.

Since 'arp_interval' and 'arp_ip_target' are mutually dependent, the
latter should also be unsupported for those bonding modes.

https://bugzilla.redhat.com/show_bug.cgi?id=1718173
(cherry picked from commit fa0f87fef7)
2019-06-11 18:36:29 +02:00
Beniamino Galvani
14cfffa64c device: reset cached route tables when starting new activation
The values cached in the device may be stale when we start a new
activation because in a disconnected state we might have called
ip_config_merge_and_apply() which cached the main table value.

(cherry picked from commit 5be69ba794)
2019-06-11 15:38:53 +02:00
Thomas Haller
a7322eaa5d libnm: belatedly expose nm_ethtool_optname_is_feature() in libnm
Also, plan right away to backport this symbol all the way back to
1.14.8. As such, we only need to add it once, with the right linker
version "libnm_1_14_8".

But still, the symbols first appears on a major release 1.20.0.

(cherry picked from commit a4c1489507)
2019-06-11 15:05:03 +02:00
Thomas Haller
7f5ee67a19 version: add NM_AVAILABLE_IN_1_18_2 macro 2019-06-11 15:05:03 +02:00
Thomas Haller
2a2a66b4d5 cli: fix resetting default value for GObject property
This matters for properties that don't have 0/NULL/FALSE as
default value and when setting an empty property with

  $ nmcli connection modify "$PROFILE" setting.property ''

Fixes: 3c82db710f ('cli: reset default value of properties via set_fcn()')
(cherry picked from commit 403f207fe5)
2019-05-31 15:56:13 +02:00
Ludek Janda
548bacd24e po: RHEL 7.7 translations - fr,ja,zh-CN
[lkundrak@v3.sk: make update-po]
2019-05-28 14:21:46 +02:00
Lubomir Rintel
9de7c0542c po: update-po 2019-05-28 14:21:06 +02:00
Beniamino Galvani
eb9dec78ee ifcfg-rh: merge branch 'bg/802-1x-client-cert-rh1705054'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/148
https://bugzilla.redhat.com/show_bug.cgi?id=1705054
(cherry picked from commit 7502fb0f5e)
2019-05-28 13:22:03 +02:00
Beniamino Galvani
51896e1e6b ifcfg-rh: use PKCS #12 private key also as client cert in reader
Before commit e3ac45c026 the reader set the private key in the
setting using the libnm function, which also set the key as client
certificate if it was in PKCS #12 format.

After the commit, existing connections with a PKCS #12 private key but
without a client certificate became invalid. Restore the old behavior.

Fixes: e3ac45c026 ('ifcfg-rh: don't use 802-1x certifcate setter functions')
(cherry picked from commit 9a410fc312)
2019-05-28 13:21:38 +02:00
Beniamino Galvani
c28db67a78 ifcfg-rh: don't check for 802.1x private key or client cert in reader
Let the setting check it in verify().

(cherry picked from commit d9b3b2b8ce)
2019-05-28 13:21:36 +02:00
Beniamino Galvani
5a5cd8d05d ifcfg-rh: write client certificate even if it is pkcs12
The writer should only persist properties without too much additional
logic, which should be instead embedded in the setting itself.

(cherry picked from commit a995244e9b)
2019-05-28 13:21:33 +02:00
Beniamino Galvani
bb5038defc ifcfg-rh: preserve existence of wired setting
Currently the plugin doesn't preserve the existence of a wired setting
because the writer saves only variables with non-default values and,
especially, the reader always creates the setting.

Fix this; now the writer writes HWADDR even if empty when the setting
is present; the reader creates the setting when at least one property
is found.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/166
https://bugzilla.redhat.com/show_bug.cgi?id=1703960
(cherry picked from commit d6a51ced40)
2019-05-28 11:35:03 +02:00
Beniamino Galvani
e14cc0d424 core: merge branch 'bg/add-activate-fail-rh1667874'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/144
https://bugzilla.redhat.com/show_bug.cgi?id=1667874
(cherry picked from commit 95cc384377)
2019-05-20 14:58:09 +02:00
Beniamino Galvani
767204e315 device: don't wait udev for devices created by us
If we created a software interface it is because we already decided
that it should be managed, and so there is no point in waiting udev to
check that the interface is not udev-unmanaged.

We still wait udev for software interfaces created externally.

(cherry picked from commit 58db61545d)
2019-05-20 14:55:55 +02:00
Beniamino Galvani
21ee2f50e8 manager: relax condition when checking for duplicate ACs
An active connection started by user could be queued in state UNKNOWN
which means the device hasn't started activating yet. Eventually it
will, and we don't want to cancel the user activation because of an
internal autoconnection attempt.

(cherry picked from commit d33c995d45)
2019-05-20 14:55:52 +02:00
Beniamino Galvani
bd372bab2f device: use variable for platform in realize_start_setup()
(cherry picked from commit 831f079e55)
2019-05-20 14:55:50 +02:00
Beniamino Galvani
bd113fe72e team: don't kill teamd for external devices
The teamd instance must not be killed if the device was externally
activated.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/158
https://bugzilla.redhat.com/show_bug.cgi?id=1693142
(cherry picked from commit 008a4b4215)
2019-05-20 14:55:30 +02:00
Lubomir Rintel
fc69cf4cfe manager: don't allow femoving a device without traversing proper states
There was a special case for ensuring that the device's configuration
doesn't disappear when some factory is too late at recognizing the
device is just a component of another one.

It was always a bad idea. If the device already had an active
connection (such as for a generated default wired connection), it would
remain around, with a dangling reference to the device.

This effectively reverts commit 5ad69cb29b ('core: remove child devices
without deconfiguring them (bgo #738479)'). It's okay to do so, because
we now wouldn't deconfigure the device upon its removal anyway.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/151/
(cherry picked from commit ff2d0f5add)
2019-05-20 13:46:04 +02:00
Patrick J. Volkerding
065e810424 hostname-manager: use fqdn for persistent hostname on Slackware
This will be the default for Slackware 15.0 and on.

This should be safe for both master and 1.12.x stable branch, as
no existing Slackware releases are expected to run NM-1.12.x or
later.

Signed-off-by: Robby Workman <rworkman@slackware.com>

https://mail.gnome.org/archives/networkmanager-list/2019-May/msg00011.html

(cherry picked from commit e1df17e0ac)
2019-05-19 10:48:09 +02:00
Thomas Haller
6d9030acb6 device/trivial: add comment about lifetime of "kind" in tc_commit()
In general, all fields of public NMPlatform* structs must be
plain/simple. Meaning: copying the struct must be possible without
caring about cloning/duplicating memory.
In other words, if there are fields which lifetime is limited,
then these fields cannot be inside the public part NMPlatform*.

That is why

  - "NMPlatformLink.kind", "NMPlatformQdisc.kind", "NMPlatformTfilter.kind"
    are set by platform code to an interned string (g_intern_string())
    that has a static lifetime.

  - the "ingress_qos_map" field is inside the ref-counted struct NMPObjectLnkVlan
    and not NMPlatformLnkVlan. This field requires managing the lifetime
    of the array and NMPlatformLnkVlan cannot provide that.

See also for example NMPClass.cmd_obj_copy() which can deep-copy an object.
But this is only suitable for fields in NMPObject*. The purpose of this
rule is that you always can safely copy a NMPlatform* struct without
worrying about the ownership and lifetime of the fields (the field's
lifetime is unlimited).

This rule and managing of resource lifetime is the main reason for the
NMPlatform*/NMPObject* split. NMPlatform* structs simply have no mechanism
for copying/releasing fields, that is why the NMPObject* counterpart exists
(which is ref-counted and has a copy and destructor function).

This is violated in tc_commit() for the "kind" strings. The lifetime
of these strings is tied to the setting instance.

We cannot intern the strings (because these are arbitrary strings
and interned strings are leaked indefinitely). We also cannot g_strdup()
the strings, because NMPlatform* is not supposed to own strings.

So, just add comments that warn about this ugliness.

The more correct solution would be to move the "kind" fields inside
NMPObjectQdisc and NMPObjectTfilter, but that is a lot of extra effort.

(cherry picked from commit f2ae994b23)
2019-05-15 14:07:08 +02:00
Thomas Haller
ea7de52d77 device: don't rely on nm_platform_link_get_ifindex() returning 0
While nm_platform_link_get_ifindex() is documented to return 0 if the device
is not found, don't rely on it. Instead, check that a valid(!) ifindex was
returned, and only then set the ifindex. Otherwise leave it at zero. There
is of course no difference in practice, but we generally treat invalid ifindexes
as <= 0, so it's not immediately clear what nm_platform_link_get_ifindex()
returns to signal no device.

(cherry picked from commit 9eefe27a1c)
2019-05-15 14:07:08 +02:00
Thomas Haller
a0161aa977 device/trivial: add space between macro name and arguments and vertically align lines
Also calling macros we commonly put a space between the macro name and
the parenthesis.

Also align the parameters. Otherwise it's hard to read for me.

(cherry picked from commit 9399297a82)
2019-05-15 14:07:08 +02:00