Commit graph

12291 commits

Author SHA1 Message Date
Thomas Haller
fff235e3a5 device/wifi: fix memleak parsing SSID arguments for "RequestScan"
Oddly enough, valgrind was not complaining about this leak...

Fixes: 87b2d783b6 ('core: accept 'ssids':aay option in RequestScan() dictionary parameter')
(cherry picked from commit 5ed1edc02a)
(cherry picked from commit 568c19f07d)
2020-01-08 13:22:27 +01:00
Beniamino Galvani
cbb1ad1ba7 manager: create a virtual device only if the connection can autoconnect
The autoconnection for virtual devices currently works in two
phases. First we detect that there is suitable profile that can
autoconnect and we realize the device. Then, when the device becomes
'disconnected', autoconnect kicks in and starts the activation.

However, if autoconnect is blocked for a device, currently we do step
1 without step 2, leaving a stale interface around. Fix this by also
checking that autoconnect is not blocked during step 1.

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/360
(cherry picked from commit 6c716912eb)
(cherry picked from commit 944ff9f9dc)
2019-12-24 09:21:46 +01:00
Beniamino Galvani
bfece9d4fc dhcp: nettools: fix parsing of search domains option
'first' was never modified and so the dot was never added.

Fixes: 6adade6f21 ('dhcp: add nettools dhcp4 client')

https://bugzilla.redhat.com/show_bug.cgi?id=1783981
(cherry picked from commit 9aa00a8a14)
(cherry picked from commit ea22135384)
2019-12-17 14:36:23 +01:00
Beniamino Galvani
a3ed90bdbc device: don't reapply IP configuration if the ifindex is missing
Assertions will fail in ip_config_merge_and_apply() if the device
doesn't have an ifindex. Reproducible with:

 $ nmcli connection add type ovs-bridge ifname ovs0 ipv4.method disabled ipv6.method disabled
 Connection 'ovs-bridge-ovs0' (1d5e794b-10ad-4b2b-aa7c-5ca7e34b0a55) successfully added

 $ nmcli device reapply ovs0
 Error: Reapplying connection to device '(null)' (/org/freedesktop/NetworkManager/Devices/16) failed: Remote peer disconnected

 $ journalctl -u NetworkManager -e
 ...
 NetworkManager[73824]: nm_ip4_config_add_dependent_routes: assertion 'ifindex > 0' failed
 systemd[1]: NetworkManager.service: Main process exited, code=dumped, status=5/TRAP
 ...

(cherry picked from commit 6d6e1402dc)
(cherry picked from commit f1d4853927)
2019-12-14 21:08:27 +01:00
Beniamino Galvani
65d37a3bfa ovs: check state before starting ip configuration after link change
When the link becomes available, check that the device is in the
ip-config state before starting ip configuration. Also, reset the
'waiting_for_interface' flag when the device deactivates.

https://bugzilla.redhat.com/show_bug.cgi?id=1781165
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/358
(cherry picked from commit 0738c10445)
(cherry picked from commit 3381299562)
2019-12-14 21:08:26 +01:00
Beniamino Galvani
74649429df manager: forbid autoactivation of parent when it is blocked by user request
If a device is being autoactivated and requires a parent that is
blocked due to user request, the autoactivation attempt should fail
because NM shouldn't overrule the user decision.

https://bugzilla.redhat.com/show_bug.cgi?id=1765566
(cherry picked from commit f2dbf8fbc0)
(cherry picked from commit 61d431a9e8)
2019-12-11 13:55:32 +01:00
Beniamino Galvani
0064401e35 device: always allow reapply of MTU from wired setting
Many device types take the MTU value from the wired setting; usually
they don't implement the can_reapply_change() method and so the MTU
can't be changed with the Reapply() API.

Instead of implementing the method for all such devices to support the
same property (adding a lot of duplicated code), add a check in
NMDevice to allow the reapply of MTU when we recognize that the device
uses the MTU from the wired setting.

Device types can still decide to implement can_reapply_change() and
support whatever properties they want, even from the wired setting.

(cherry picked from commit 9339d3310e)
(cherry picked from commit 1191eba15a)
2019-12-11 13:54:35 +01:00
Beniamino Galvani
4134023a29 infiniband: allow reapply of MTU
(cherry picked from commit ceeefa82c5)
(cherry picked from commit 1aedf60244)
2019-12-11 13:54:32 +01:00
Thomas Haller
ee032f79df settings: assert that we don't leak error variable in impl_settings_load_connections()
(cherry picked from commit e0569ee575)
(cherry picked from commit 7e8a5d98e3)
2019-12-09 09:55:51 +01:00
Thomas Haller
aa545d5b58 settings: fix use after free in keyfile's load_connections()
Fixes: d35d3c468a ('settings: rework tracking settings connections and settings plugins')
(cherry picked from commit eb642fecdf)
(cherry picked from commit 6d37f690ad)
2019-12-09 09:55:49 +01:00
Beniamino Galvani
8274cc1353 device: don't transition assumed devices to FAILED before ACTIVATED
If the activation of an assumed device fails, we first set the device
state to FAILED and then to ACTIVATED. In the FAILED state, the active
connection transitions to DEACTIVATED and clears its device pointer;
hence we end up with an inconsistent state which causes assertion
failures in other parts of the code (for example, get_best_ip_config()
assumes that the device of the best active connection is not NULL).

Don't first transition to FAILED and then to ACTIVATED, just set the
latter.

https://bugzilla.redhat.com/show_bug.cgi?id=1737774
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/351
(cherry picked from commit 93e9010b75)
(cherry picked from commit 366b90db87)
2019-12-05 17:14:31 +01:00
Beniamino Galvani
80bb91d8e6 manager: don't activate device if the parent is missing
In multiple places we currently proceed to creating a virtual device
even if the connection specifies a parent device which is
missing. This can be easily reproduced with:

  nmcli con add type vxlan ifname vxlan1 \
                vxlan.parent not-exists \
                id 43 remote 172.25.1.1

which creates a vxlan1 interface without activating any
connection. Add a check to prevent this.

https://bugzilla.redhat.com/show_bug.cgi?id=1774074
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/344
(cherry picked from commit a73efb059f)
2019-11-29 11:13:27 +01:00
Thomas Haller
b67983c387 ifcfg: various cleanup in ifcfg writer
svUnsetValue (ifcfg, KEY);
    if (condition)
         svSetValue* (ifcfg, KEY, ...);

is not good. It requires first clearing the value, before setting
it again.

Various cleanup to fix such uses.

(cherry picked from commit 5028206ec4)
2019-11-22 14:40:32 +01:00
Thomas Haller
d0572b6602 ifcfg: add support for "802-1x.system-ca-certs" setting
(cherry picked from commit 2a4fb75d3b)
2019-11-22 14:40:32 +01:00
Thomas Haller
f449ace2f1 ifcfg: add svSetValueBoolean_cond_true() helper
(cherry picked from commit 87af96a9d6)
2019-11-22 14:40:32 +01:00
Beniamino Galvani
8e2ad6f0c3 ethernet: wait for carrier before starting supplicant
After we set link parameters (auto-negotiation, speed, duplex) in
stage1, the carrier can go down for several seconds because the
Ethernet PHY needs to renegotiate the link. Wait that carrier goes up
before starting the supplicant or the EAPoL start packet can be lost
causing an authentication failure.

https://bugzilla.redhat.com/show_bug.cgi?id=1759797
(cherry picked from commit 838e5b87c2)
2019-11-21 10:22:47 +01:00
Beniamino Galvani
5a8ea69209 device: check for disconnected state before activating NMActRequest
When a new activation request comes and the device is currently
activated, we move the device state to 'deactivating' and wait that it
reaches 'disconnected' before starting the new activation request.

In the meantime, a carrier change could happen but still we have to
wait that device finishes any pending deactivation.

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/339
(cherry picked from commit 4b4f18e77b)
2019-11-21 10:10:06 +01:00
Beniamino Galvani
b366234a3a ovs: allow changing mac address of bridges and interfaces
Allow changing the cloned MAC address for OVS bridges and
interfaces. The MAC address set on the bridge is propagated by ovs to
the local interface (the one with the same name as the bridge), while
all other internal interfaces use the address defined in the interface
connection.

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/321
(cherry picked from commit 101e65d2bb)
2019-11-20 11:12:12 +01:00
Beniamino Galvani
ad17cfff24 ovs: fix memory leak
(cherry picked from commit 508c7679cf)
2019-11-20 11:10:53 +01:00
Lubomir Rintel
e51a4ae806 initrd/tests: put the bootif=no next to the other bootif tests
A cosmetical improvement.

(cherry picked from commit cdfa3d3428)
2019-11-18 13:44:06 +01:00
Lubomir Rintel
964f8aab6d dracut/cmdline: don't combine BOOTIF with on with a name or a MAC address
This fixes the dracut test suite.

(cherry picked from commit 45548bc670)
2019-11-18 13:44:06 +01:00
Lubomir Rintel
d240c14478 initrd/cmdline: split add_conn() from get_conn()
No change in behavior. Will be useful when we'll want to unconditionally
add new connection without the matching behavior.

(cherry picked from commit e1a068e93c)
2019-11-18 13:44:06 +01:00
Lubomir Rintel
b03a632c3d initrd: don't overwrite just any connection's name with bootdev= argument
It is really not clear what the user could have meant by specifying a
bootdev= argument, and we deal with it just by ensuring a device with
that name whould come up.

We therefore pick a default connection if there's one (that is a
conneciton that we create if the device name is unspecified, as in
"ip=auto"), otherwise we create a new one.

(cherry picked from commit 30f8154319)
2019-11-18 13:44:06 +01:00
Lubomir Rintel
d7101d8342 initrd: default bridge name to br0 as opposed to bridge0
For compatibility. The dracut.cmdline(7) manual says:

  Bridge without parameters assumes bridge=br0:eth0

(cherry picked from commit f581756af6)
2019-11-18 13:44:06 +01:00
Lubomir Rintel
e19138b94c manager: assume DHCP if we see a lease on taking over an initramfs connection
In general, we aren't really able to tell, but when we see a lease file
we're pretty sure that DHCP is what was going on.

https://bugzilla.redhat.com/show_bug.cgi?id=1771792
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/335

Fixes: f2fe6c03ee ('manager: don't treat the initramfs-configured DHCP connections as generated')
(cherry picked from commit 7a84388a9b)
2019-11-18 13:44:06 +01:00
Lubomir Rintel
3a133e2826 dhcp/nettools: add siaddr to lease options
This is so that we end up with a next-server option analogous to what
dhclient helper sends us. Dracut uses this for networked boots.

(cherry picked from commit c1104a5cc2)
2019-11-18 13:44:06 +01:00
Lubomir Rintel
68841b76a6 systemd: add siaddr to lease options
This is so that we end up with a next-server option analogous to what
dhclient helper sends us. Dracut uses this for networked boots.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/329
(cherry picked from commit e475ac7567)
2019-11-18 13:44:06 +01:00
Frank Deng
e1acd336bb utils: alow matching ipv6 new method 'disable'
Make nm_utils_match_connection() match 'ignore' connections with
connections that are generated to have ipv6.method of 'disable'.
Perhaps the ipv6 was disabled globally.

[lkundrak@v3.sk: commit message fixup]

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/336
(cherry picked from commit 87c9583282)
2019-11-18 13:44:06 +01:00
Beniamino Galvani
d1c7c381e4 ipv6: disable kernel handling of RAs (accept_ra)
With accept_ra set to 1, kernel sends its own router solicitation
messages and parses the advertisements. This duplicates what NM
already does in userspace and has unwanted consequences like [1] and
[2].

The only reason why accept_ra was re-enabled in the past was to apply
RA parameters like ReachableTime and RetransTimer [3]; but now NM
supports them and so accept_ra can be turned off again.

Also, note that previously the option was set in
addrconf6_start_with_link_ready(), and so this was done only when the
method was 'auto'. Instead, now we clear it for all methods except
'ignore'.

[1] https://mail.gnome.org/archives/networkmanager-list/2019-June/msg00027.html
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1734470
[3] https://bugzilla.redhat.com/show_bug.cgi?id=1068673

(cherry picked from commit 5a534529e2)
2019-11-15 16:17:41 +01:00
Beniamino Galvani
08fdea122d ipv6: set neighbor parameters from RAs
IPv6 router advertisement messages contain the following parameters
(RFC 4861):

 - Reachable time: 32-bit unsigned integer.  The time, in
   milliseconds, that a node assumes a neighbor is reachable after
   having received a reachability confirmation.  Used by the Neighbor
   Unreachability Detection algorithm.  A value of zero means
   unspecified (by this router).

 - Retrans Timer: 32-bit unsigned integer.  The time, in milliseconds,
   between retransmitted Neighbor Solicitation messages.  Used by
   address resolution and the Neighbor Unreachability Detection
   algorithm.   A value of zero means unspecified (by this router).

Currently NM ignores them; however, since it leaves accept_ra=1, the
kernel parses RAs and applies those parameters for us [1].

In the next commit kernel handling of RAs will be disabled, so let NM
set those neighbor-related parameters.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/ipv6/ndisc.c?h=v5.2#n1353

(cherry picked from commit 5f0c6f8d3b)
2019-11-15 16:17:33 +01:00
Beniamino Galvani
49857ed279 device: fix setting MTU from connection when limited by parent
We try to set only one time the MTU from the connection to not
interfere with manual user changes.

If at some point the parent interface changes temporarily MTU to a
lower value (for example, because the connection was reactivated), the
kernel will also lower the MTU on child interface and we will not
update it ever again.

Add a workaround to this. If we detect that the MTU we want to set
from connection is higher that the allowed one, go into a state where
we follow the parent MTU until it is possible to set again the desired
MTU. This is a bit ugly, but I can't think of any nicer way to do it.

https://bugzilla.redhat.com/show_bug.cgi?id=1751079
(cherry picked from commit ec28f5b343)
2019-11-11 10:56:43 +01:00
Beniamino Galvani
9133ba9003 macvlan: update MTU according to parent's one
(cherry picked from commit 4875745bc0)
2019-11-11 10:56:42 +01:00
Beniamino Galvani
c58ce8945d macsec: update MTU according to parent's one
A MACsec connection doesn't have an ordering dependency with its
parent connection and so it's possible that the parent gets activated
later and sets a greater MTU than the original one.

It is reasonable and useful to keep the MACsec MTU configured by
default as the maximum allowed by the parent interface, that is the
parent MTU minus the encapsulation overhead (32). The user can of
course override this by setting an explicit value in the
connection. We already do something similar for VLANs.

https://bugzilla.redhat.com/show_bug.cgi?id=1723690
(cherry picked from commit 438a0a9ad5)
2019-11-11 10:56:39 +01:00
Beniamino Galvani
73597864bb device: introduce generic function to inherit MTU from parent
Introduce a generic function to set a MTU based on parent's one. Also
define a device-specific @mtu_parent_delta value that specifies the
difference from parent MTU that should be set by default. For VLAN it
is zero but other interface types (for example MACsec) require a
positive value due to encapsulation overhead.

(cherry picked from commit 5cf57f4522)
2019-11-11 10:56:36 +01:00
Beniamino Galvani
37720d856a device: expand comment on MTU selection
(cherry picked from commit 6455a4e528)
2019-11-11 10:56:34 +01:00
Beniamino Galvani
f35783c3fb device: reset ip6_mtu on cleanup
ip6_mtu contains the MTU received through IPv6 autoconfiguration; it
should be reset when the connection is deactivated.

https://bugzilla.redhat.com/show_bug.cgi?id=1753128
(cherry picked from commit 353c7c95c1)
2019-11-11 10:50:13 +01:00
Beniamino Galvani
c36da8b990 acd: poll the acd fd after starting the announcements
In nm_acd_manager_announce_addresses() we should not only start the
probes but also add the acd file descriptor to the main loop.
Otherwise, a timer is armed to send the announcements but it never
fires and no announcements are sent.

Fixes: d9a4b59c18 ('acd: adapt NM code and build options')

https://bugzilla.redhat.com/show_bug.cgi?id=1767681
(cherry picked from commit 14992ab9cd)
2019-11-06 16:39:29 +01:00
Beniamino Galvani
91ea7737fd ethernet: honor the 802-1x.optional property
If the 802.1X authentication fails and 802-1x.optional is set,
continue with activation. In this case, subscribe to the auth-state
supplicant property so that any dynamic IP method can be restarted
when the authentication succeeds. This is because upon authentication
the switch could have changed the VLAN we are connected to.

(cherry picked from commit 8afce75bf3)
2019-11-06 11:46:05 +01:00
Beniamino Galvani
90671a30b7 all: add 802-1x.optional property
Introduce a 802-1x.optional boolean property that can be used to
succeed the connection even after an authentication timeout or
failure.

(cherry picked from commit 8763e6da9c)
2019-11-06 11:46:04 +01:00
Beniamino Galvani
2c9912d812 supplicant: export authentication state
Add a property to the supplicant to indicate the current state of the
authentication process.

(cherry picked from commit 5b4f4a4c30)
2019-11-06 11:46:02 +01:00
Thomas Haller
e59f6f593f device/trivial: rename local variable for device in "nm-device-{ethernet,macvlan}.c"
This variable is commonly called "device", not "dev". Rename.

(cherry picked from commit f42ced162f)
2019-11-06 11:46:00 +01:00
Lubomir Rintel
4c7d12cb29 initrd/tests: test that we generate the s390 interface names correctly
(cherry picked from commit 927ae6d927)
2019-11-04 16:24:42 +01:00
Dan Horák
56026dd3dd initrd: handle rd.znet with legacy interface names
Handle rd.znet with legacy interface names too, the index for eth or ctc
corresponds to the position on the command line.

(cherry picked from commit 22e388d90e)
2019-11-04 16:24:40 +01:00
Dan Horák
72fcf35cb6 initrd: prepare interface in rd.znet only if persistent interface names are enabled
When processing the rd.znet option set the interface name only in case when
the persistent interface names feature isn't disabled via net.ifnames=0

[lkundrak@v3.sk: minor tweaks to the net.ifnames=0 parsing]

(cherry picked from commit c7423dca89)
2019-11-04 16:24:39 +01:00
Dan Horák
31d44a28e1 initrd/tests: use a valid combination of device and interface name for testing
(cherry picked from commit c27f5030e9)
2019-11-04 16:24:39 +01:00
Dan Horák
deff651704 initrd: use proper interface when adding s390 specific details
The current solution for s390 specific details relies on an interface to
exist before adding the s390 details. It means the ip= option must precede
the rd.znet= option. Also only a single interface can be configured. With
this change the s390 details are put to the right interface and properly
named interface is created if it hasn't existed yet.

(cherry picked from commit adcc52c3da)
2019-11-04 16:24:38 +01:00
Lubomir Rintel
9e6706edb7 iwd: unbreak iwd-1.0
The upstream apparently thought it's a great idea to change the agent
manager path. This fixes things for those unfortunate enough to run
IWD.

(cherry picked from commit 186d22a963)
2019-11-03 13:06:04 +01:00
Lubomir Rintel
8a668d0983 iwd: add some missing error handling
g_dbus_object_manager_get_interface() can happily return NULL and we
need to check for that.

(cherry picked from commit 59923ad85d)
2019-11-03 13:06:03 +01:00
Beniamino Galvani
58ffded2d0 dhcp: include conditionals from existing dhclient configuration
Since commit 159ff23268 ('dhcp/dhclient-utils: skip over
dhclient.conf blocks') we skip blocks enclosed in lines containing '{'
and '}' because NM should ignore 'lease', 'alias' and other
declarations. However, conditional statements seem useful and should
not be skipped.

https://bugzilla.redhat.com/show_bug.cgi?id=1758550
(cherry picked from commit b58e4d311d)
2019-10-10 14:53:01 +02:00
Beniamino Galvani
299fbc0888 supplicant: allow PMF with SAE
PMF can be used with SAE, allow it. Actually, it is required according
to WPA3 specifications but there are implementations that don't
require it (hostapd can be configured in a such way); so let's not
make it mandatory for WPA3.

Fixes: 6640fb4b36 ('supplicant: add support for SAE key management')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/257
(cherry picked from commit e36c297fd8)
2019-10-09 13:09:42 +02:00