Commit graph

21454 commits

Author SHA1 Message Date
Beniamino Galvani
542e340f01 supplicant: don't set PMF when the supplicant doesn't support it
When the supplicant does not support PMF we wrongly set
'ieee80211w=0', but since the option is not recognized the connection
fails. Don't set it when unsupported.

Fixes: a9ab50efb1
(cherry picked from commit 58c4cd9cc9)
2019-01-17 11:02:57 +01:00
Beniamino Galvani
d0dd120ab4 supplicant: fix ready_count assignment
Fix a wrong backport.

Fixes: 1110e0bcae
2019-01-14 15:16:09 +01:00
Beniamino Galvani
49853fa7c1 dns: merge branch 'bg/dns-child-restart-issue105'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/105
(cherry picked from commit 240e2bd9f8)
2019-01-14 10:46:09 +01:00
Beniamino Galvani
5ef8f456ad dns: fail the plugin when the rate limiter hits
If the child is respawning too fast, consider the plugin failed so
that upstream servers are written to resolv.conf until the plugin gets
restarted after the delay.

(cherry picked from commit e45636659b)
2019-01-14 10:45:59 +01:00
Beniamino Galvani
7a025027a5 dns: fix updating resolv.conf after dnsmasq process dies
When the dnsmasq process dies, two events are generated:

(1) a NM_DNS_PLUGIN_FAILED signal in nm-dns-dnsmasq.c:name_owner_changed()
(2) a NM_DNS_PLUGIN_CHILD_QUIT signal in nm-dns-plugin.c:from watch_cb()

Event (1) is handled by updating resolv.conf with upstream servers,
(2) by restarting the child process.

The order in which the two signals are received is not deterministic,
so when (1) comes after (2) the manager leaves upstream servers in
resolv.conf even if a dnsmasq instance is running.

When dnsmasq disappears from D-Bus and we know that the process is not
running, we should not emit a FAILED signal because the disappearing
is caused by the process termination, and that event is already
handled by the manager.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/105
(cherry picked from commit f2a2012733)
2019-01-14 10:45:55 +01:00
Beniamino Galvani
5a831af656 clients: merge branch 'bg/cli-dns-options-rh1665649'
https://bugzilla.redhat.com/show_bug.cgi?id=1665649
(cherry picked from commit 9b0c1ef5d0)
2019-01-14 10:45:07 +01:00
Beniamino Galvani
d5700563cb clients: remove the same dns-option before adding it
nmcli connection modify t ipv4.dns-options ndots:2
 nmcli connection modify t +ipv4.dns-options ndots:4

should set dns-options to 'ndots:4', so we must remove other
occurences of the same option before adding it, otherwise the setting
refuses to set the same option again.

(cherry picked from commit b11a20ded0)
2019-01-14 10:44:45 +01:00
Beniamino Galvani
2bd646f333 clients: fix appending to dns-property variable
Appending to the ipvx.dns-options property:

  nmcli connection modify con +ipv4.dns-options rotate

currently is buggy because it resets the list to contain only
'rotate'. The setter function should not clear the list.

https://bugzilla.redhat.com/show_bug.cgi?id=1665649
(cherry picked from commit bcb91f4f65)
2019-01-14 10:44:41 +01:00
Beniamino Galvani
3b63f08456 clients: unify IPv4 and IPv6 accessors for dns-search, dns-options
(cherry picked from commit 1f32e417a8)
2019-01-14 10:44:39 +01:00
Beniamino Galvani
1110e0bcae supplicant: set optional PMF using global supplicant property
wpa_supplicant is going to change the global default for PMF from 0
(disabled) to 1 (optional) [1], so NM code needs to be adjusted to
work with all wpa_supplicant versions. Furthermore, it is better to
set optional PMF using the 'Pmf' property instead of the 'ieee80211w'
configuration option because the former better handles missing support
in driver [2].

Note that each interface in wpa_supplicant has its own copy of global
configuration and so 'global' options must still be set on each
interface. So, let's set Pmf=1 when each interface gets created and
override it with ieee80211w={0,2} if needed during association.

[1] http://lists.infradead.org/pipermail/hostap/2018-November/039009.html
[2] http://lists.infradead.org/pipermail/hostap/2019-January/039215.html

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/104
(cherry picked from commit a9ab50efb1)
2019-01-14 10:43:13 +01:00
Francesco Giudici
530d438388 merge: branch 'fg/assume_bridge-rh1593939'
Improve assuming bridges on startup.

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

https://github.com/NetworkManager/NetworkManager/pull/266

(cherry picked from commit 46726ecdde)
2019-01-10 10:13:17 +01:00
Francesco Giudici
ec0e52cdc8 device: when assuming a bridge ignore stp options if stp is disabled
When STP is disabled, the bridge parameters 'priority', 'forward-delay',
'hello-time' and 'max-age' are irrelevant.
We already skip them when loading a connection profile from a ifcfg file.
Do the same when generating a connection from a configured device, in
order to possibly assume the connection.

(cherry picked from commit abc40618f1)
2019-01-10 10:12:39 +01:00
Francesco Giudici
8d0b71fdbc device: use bool instead of gboolean in the bridge options struct
just to save some bytes of memory (gboolean --> typef gint)

(cherry picked from commit ede6b65abf)
2019-01-10 10:12:25 +01:00
Francesco Giudici
6a0f828405 device: always enforce bridge properties limits
...also when the connection is created at NetworkManager
startup to map an already configured bridge.
Ensure the device has configuration values that fall inside
NetworkManager boundaries, otherwise map the value with a default.

(cherry picked from commit 30d9744534)
2019-01-10 10:12:10 +01:00
Francesco Giudici
5a49f7ee77 core: move bridge port min/max/default values to core-internal
We have bridge min/max/default values in core-internal. Do the same
for bridge port ones.
We will soon use those values to enforce limits when assuming a
bridge port configuration.

(cherry picked from commit 0f6fe2a38a)
2019-01-10 10:11:56 +01:00
Francesco Giudici
ec0edc76b5 core: remove NM_SETTING_PARAM_INFERRABLE flag from bridge-port.path-cost
In NetworkManager we have a default port path-cost equal to 100.
In the linux kernel the default port cost depends upon the interface
speed: 2 for 10Gb, 4 for 1Gb, 19 for 100Mb and 100 for 10Mb (or when the
interface speed is not available, like current virtio_net driver).
Allow NetworkManager to assume bridge port connections also when the
path-cost differs: this will allow us to assume bridge ports created
outside NetworkManager (e.g. in initrd) that will likely have a different
"cost" value.

(cherry picked from commit cad905fce2)
2019-01-10 10:11:38 +01:00
Thomas Haller
422680fe87 dhcp: merge branch 'th/dhcp-client-id-infiniband-rh1658057' (partial backport)
- fix DHCP client-id generatation on infiniband devices

- as part of this branch, "master" branch also changed the default "ipv4.dhcp-client-id"
  setting for the internal DHCP plugin. This change of default was not
  backported to nm-1-14 branch at this point.

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

https://github.com/NetworkManager/NetworkManager/pull/263

(cherry picked from commit e844984a34)
2019-01-08 08:05:44 +01:00
Thomas Haller
4415ec5988 dhcp: move nm_utils_dhcp_client_id_mac() to "nm-core-utils.c"
We will need it outside of "src/devices/nm-device.c".

(cherry picked from commit 2ef9a089eb)
2019-01-08 08:01:21 +01:00
Thomas Haller
282a0c4a69 core/trivial: rename nm_utils_detect_arp_type_from_addrlen() to nm_utils_arp_type_detect_from_hwaddrlen()
Rename the function so that the function name's prefix is
the topic what this is about: arp-type.

(cherry picked from commit 3bce451c60)
2019-01-08 07:43:28 +01:00
Thomas Haller
c10868c7ff dhcp/trivial: add comment about requiring DHCP client-id for infiniband
(cherry picked from commit 6f0cb0bf4f)
2019-01-08 07:43:24 +01:00
Thomas Haller
ba132ab58e dhcp: fix generating MAC based client-id for infiniband
For infiniband, only the last 8 bytes for the 20 bytes hardware address
are relevant. At least, with respect to the settings

  - ipv4.dhcp-client-id=mac
  - ipv4.dhcp-client-id=perm-mac
  - ipv6.dhcp-duid=ll
  - ipv6.dhcp-duid=llt
  - ipv6.dhcp-duid=stable-ll
  - ipv6.dhcp-duid=stable-llt

This is also what ISC dhclient on Fedora/RHEL does ([1], [2]).

[1] https://bugzilla.redhat.com/show_bug.cgi?id=660681
[2] 3ccf3c8d81/f/dhcp-lpf-ib.patch

https://bugzilla.redhat.com/show_bug.cgi?id=1658057
(cherry picked from commit 4523a376cc)
2019-01-08 07:42:27 +01:00
Beniamino Galvani
fd3658e25f cli: fix cleanup after activation from editor
progress_activation_editor_cb() is called multiple times every 120
milliseconds and it must free resources only the last time.

Fixes: f0a2686545

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/51
(cherry picked from commit d091cbdc2f)
2019-01-02 08:55:00 +01:00
Thomas Haller
87baa2678a dhcp6: don't enforce DUID content for sd_dhcp6_client_set_duid()
There are various functions to set the DUID of a DHCPv6 client.
However, none of them allows to set arbitrary data. The closest is
sd_dhcp6_client_set_duid(), which would still do validation of the
DUID's content via dhcp_validate_duid_len().

Relax the validation and only log a debug message if the DUID
does not validate.

Note that dhcp_validate_duid_len() already is not very strict. For example
with DUID_TYPE_LLT it only ensures that the length is suitable to contain
hwtype and time. It does not further check that the length of hwaddr is non-zero
or suitable for hwtype. Also, non-well-known DUID types are accepted for
extensibility. Why reject certain DUIDs but allowing clearly wrong formats
otherwise?

The validation and failure should happen earlier, when accepting the
unsuitable DUID. At that point, there is more context of what is wrong,
and a better failure reason (or warning) can be reported to the user. Rejecting
the DUID when setting up the DHCPv6 client seems not optimal, in particular
because the DHCPv6 client does not care about actual content of the
DUID and treats it as opaque blob.

Also, NetworkManager (which uses this code) allows to configure the entire
binary DUID in binary. It intentionally does not validate the binary
content any further. Hence, it needs to be able to set _invalid_ DUIDs,
provided that some basic constraints are satisfied (like the maximum length).

sd_dhcp6_client_set_duid() has two callers: both set the DUID obtained
from link_get_duid(), which comes from configuration.
`man networkd.conf` says: "The configured DHCP DUID should conform to
the specification in RFC 3315, RFC 6355.". It does not not state that
it MUST conform.

Note that dhcp_validate_duid_len() has another caller: DHCPv4's
dhcp_client_set_iaid_duid_internal(). In this case, continue with
strict validation, as the callers are more controlled. Also, there is
already sd_dhcp_client_set_client_id() which can be used to bypass
this check and set arbitrary client identifiers.

ab4a88bc29
(cherry picked from commit d65ee3bb18)
2018-12-21 20:46:18 +01:00
Thomas Haller
a46745a36a dhcp: don't enforce hardware address length for sd_dhcp_client_set_client_id()
sd_dhcp_client_set_client_id() is the only API for setting a raw client-id.
All other setters are more restricted and only allow to set a type 255 DUID.

Also, dhcp4_set_client_identifier() is the only caller, which already
does:

                r = sd_dhcp_client_set_client_id(link->dhcp_client,
                                                 ARPHRD_ETHER,
                                                 (const uint8_t *) &link->mac,
                                                 sizeof(link->mac));

and hence ensures that the data length is indeed ETH_ALEN.

Drop additional input validation from sd_dhcp_client_set_client_id(). The client-id
is an opaque blob, and if a caller wishes to set type 1 (ethernet) or type 32
(infiniband) with unexpected address length, it should be allowed. The actual
client-id is not relevant to the DHCP client, and it's the responsibility of the
caller to generate a suitable client-id.

For example, in NetworkManager you can configure all the bytes of the
client-id, including such _invalid_ settings. I think it makes sense,
to allow the user to fully configure the identifier. Even if such configuration
would be rejected, it would be the responsibility of the higher layers (including
a sensible error message to the user) and not fail later during
sd_dhcp_client_set_client_id().

Still log a debug message if the length is unexpected.

bfda0d0f09
(cherry picked from commit 0d5fec5741)
2018-12-21 20:46:18 +01:00
Thomas Haller
56f5edcbd3 dhcp: fix sd_dhcp_client_set_client_id() for infiniband addresses
Infiniband addresses are 20 bytes (INFINIBAND_ALEN), but only the last
8 bytes are suitable for putting into the client-id.

This bug had no effect for networkd, because sd_dhcp_client_set_client_id()
has only one caller which always uses ARPHRD_ETHER type.

I was unable to find good references for why this is correct ([1]). Fedora/RHEL
has patches for ISC dhclient that also only use the last 8 bytes ([2], [3]).
RFC 4390 (Dynamic Host Configuration Protocol (DHCP) over InfiniBand) [4] does
not discuss the content of the client-id either.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1658057#c29
[2] https://bugzilla.redhat.com/show_bug.cgi?id=660681
[3] 3ccf3c8d81/f/dhcp-lpf-ib.patch
[4] https://tools.ietf.org/html/rfc4390

b9d8071458
(cherry picked from commit 24a62f90c7)
2018-12-21 20:46:18 +01:00
Beniamino Galvani
710406e746 device: ensure IP configuration is restored when link goes up
When the link is up and goes down link_changed_cb() schedules
device_link_changed() to be run later. If the function is dispatched
when the link is already up again, it does not detect that the link
was down.

Fix this by storing in the device state that we saw the link down so
that device_link_changed() can properly restore the IP configuration.

https://bugzilla.redhat.com/show_bug.cgi?id=1636715
https://github.com/NetworkManager/NetworkManager/pull/264
(cherry picked from commit 7bd193ef30)
2018-12-21 17:57:59 +01:00
Aleksander Morgado
1445b5b296 wwan: rework when settings/device are blocked for autoconnection
The reasons to block autoconnection at settings level are not the same
as the ones to block autoconnection at device level.

E.g. if the SIM-PIN is wrong, you may want to block autoconnection
both at settings level (as the PIN configured in settings is wrong)
and at device level (so that no other setting is tried automatically).

For some other reasons, you may want to block autoconnection only at
setting level (e.g. wrong APN).

And for some other reasons you may want to block autoconnection at
device level only (e.g. SIM missing), so that the autoconnection
blocking is removed when the device goes away. This is especially
important with SIM hotplug events processed by ModemManager, as a
device without SIM will be removed from MM when a new SIM is
inserted, so that a completely new object is exposed in MM with the
newly detected SIM.

https://github.com/NetworkManager/NetworkManager/pull/259
(cherry picked from commit 90e9695af5)
2018-12-14 14:30:05 +01:00
Thomas Haller
0d980e76b1 dhcp: merge branch 'th/dhcp-infiniband-client-id'
https://bugzilla.redhat.com/show_bug.cgi?id=1658057

https://github.com/NetworkManager/NetworkManager/pull/262

(cherry picked from commit f22492f8fc)
2018-12-14 14:16:02 +01:00
Thomas Haller
42c07a033d dhcp: support generating DHCP client-id/duid for infiniband
https://bugzilla.redhat.com/show_bug.cgi?id=1658057
(cherry picked from commit 672852c4d3)
2018-12-14 14:15:45 +01:00
Thomas Haller
17e7eba7a3 core: add nm_utils_detect_arp_type_from_addrlen() helper
and use it in "nm-dhcp-systemd.c".

(cherry picked from commit 6e48e99be4)
2018-12-14 14:15:44 +01:00
Beniamino Galvani
e4fa047126 ifcfg-rh: fix reading SR-IOV settings
Fixes: d48f389cbf
(cherry picked from commit 0819563e01)
2018-12-13 18:24:47 +01:00
Aleksander Morgado
7c6dba0b43 devices,bluetooth: fix default CDMA number setting
https://github.com/NetworkManager/NetworkManager/pull/260

Fixes: 215306f5a1
(cherry picked from commit 87bed48974)
2018-12-13 17:01:16 +01:00
Thomas Haller
961cdf97ad device: disable rp_filter handling
Don't let NetworkManager change rp_filter sysctl [1]. By default, various
distributions set rp_filter rather strict. That works badly, in common cases
where the user connects multiple interfaces to the same IP network (for
example, using Wi-Fi and ethernet in your home network). It also confuses
connectivity checking. For that reason, NetworkManager would loosen the
rp_filter setting.

However, that was not configurable and users who really wanted a strict
setting could not prevent NetworkManager from doing it ([2], [3], [4]).

Hence it was decided, that a better solution is for NetworkManager not
to do anything about rp_filter. Instead, distibutions should not enable
it strictly (or at least, only for certain setups where it makes sense
-- if it ever makes sense) ([5], [6]);

Disble this behavior for the moment. In the future, the code will be
removed entirely.

[1] https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1492472
[4] https://bugzilla.redhat.com/show_bug.cgi?id=1593194
[3] https://bugzilla.redhat.com/show_bug.cgi?id=1651097
[5] https://bugzilla.redhat.com/show_bug.cgi?id=1653824
[6] https://github.com/systemd/systemd/pull/10971

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1651097
(cherry picked from commit b1082aa9a7)
2018-12-13 14:25:25 +01:00
Beniamino Galvani
95d9fd387b settings: apply agent-owned secrets from the new connection on update
When updating a connection passing agent-owned secret, they are lost
from @reread_connection after the settings-plugin persists the
connection. Therefore we need to cache and reapply them separately to
the connection so that they can be saved to secret agents later.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/82
(cherry picked from commit a3383726dc)
2018-12-13 11:22:54 +01:00
Thomas Haller
87095393e0 device: fix compile error in _set_State_full() for missing cast
src/devices/nm-device.c: In function '_set_state_full':
    src/devices/nm-device.c:14766:19: error: assignment from incompatible pointer type [-Werror]
       if (   (s_sriov = nm_device_get_applied_setting (self, NM_TYPE_SETTING_SRIOV))
                       ^

Fixes: 6ae1f64351
2018-12-13 07:20:25 +01:00
Beniamino Galvani
6506916319 merge: branch 'bg/sriov-fixes'
Some fixes related to SR-IOV support.

https://github.com/NetworkManager/NetworkManager/pull/258
(cherry picked from commit b6259f7056)
2018-12-12 15:48:12 +01:00
Beniamino Galvani
ce44056410 platform: sriov: write new values when we can't read old ones
Fixes: 7df3333879
(cherry picked from commit 1e41495d9a)
2018-12-12 15:38:35 +01:00
Beniamino Galvani
f33954f628 meson: add check on settings docs
Move the autotools check on settings docs to a shell script and call
it from meson too.

(cherry picked from commit 81bc218e6d)
2018-12-12 15:38:33 +01:00
Beniamino Galvani
edb6a21b6d man: add SR-IOV nmcli example
Add an example on how to configure SR-IOV to the nmcli examples man
page.

https://bugzilla.redhat.com/show_bug.cgi?id=1651979
(cherry picked from commit f606124b62)
2018-12-12 15:38:27 +01:00
Beniamino Galvani
9ff5e3b2a6 core: use NMTernary for SR-IOV autoprobe-drivers
(cherry picked from commit e01a7c1154)
2018-12-12 15:38:08 +01:00
Beniamino Galvani
9deca176f8 ifcfg-rh: fix persisting sriov setting
The writer should write all properties of the sriov setting when the
setting exists without additional logic. Likewise, the reader should
instantiate a sriov setting when any sriov key is present and blindly
set properties from keys.

The old code did not always preserve the presence of a sriov setting
after a write/read cycle.

Fixes: c02d1c488f
(cherry picked from commit d48f389cbf)
2018-12-12 15:33:13 +01:00
Beniamino Galvani
6ae1f64351 device: reset SR-IOV VFs on deactivation
If the connection has a sriov setting we configure SR-IOV VFs on
activation. We should also clear resources when the connection
deactivates.

(cherry picked from commit 529533a50c)
2018-12-12 15:33:11 +01:00
Beniamino Galvani
ca45433f4f device: configure static number of VFs in unavailable state
Don't configure the static number of VFs when the device is realized
because the device could still be unmanaged. Instead, do it when the
device becomes managed.

(cherry picked from commit 75024e11b3)
2018-12-12 15:33:09 +01:00
Beniamino Galvani
20f38e09ec libnm-core: slightly improve SR-IOV documentation
Describe how to specify multiple VFs and which attributes are
supported, so that this information is available in the nm-settings
manual page.

Also, clarify that SR-IOV parameters are managed only when the setting
is present.

https://bugzilla.redhat.com/show_bug.cgi?id=1651979
(cherry picked from commit 3de25bbc97)
2018-12-12 15:32:43 +01:00
Beniamino Galvani
082bb02fa0 cli: strictly validate SR-IOV attributes
Report an error when the user tries to add an unknown attribute
instead of silently accepting (and ignoring) it.

Note that this commit also changes the behavior of public API
nm_utils_sriov_vf_from_str() to return an error when an unknown
attribute is found. I think the previous behavior was buggy as wrong
attributes were simply ignored without any way for the user to know.

Fixes: a9b4532fa7
(cherry picked from commit 769e0726a8)
2018-12-12 14:54:26 +01:00
Beniamino Galvani
67994f0e6f udev: remove unneeded NULL checks
self->monitor cannot be NULL there.

(cherry picked from commit 3e4b30b2b1)
2018-12-12 14:54:23 +01:00
Beniamino Galvani
19b7a4c167 udev: increase receive buffer size
With the default 128KiB buffer size it is easy to lose events. For
example when 64 interfaces appear at the same time, we lose events for
the last 16. Increase the buffer size to 4MiB.

https://bugzilla.redhat.com/show_bug.cgi?id=1651578
(cherry picked from commit 5780a2893b)
2018-12-12 14:54:22 +01:00
Thomas Haller
dc18a00a18 core: merge branch 'th/secret-key-to-host-id'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/61

(cherry picked from commit ba1a7c1d21)
2018-12-12 14:41:17 +01:00
Thomas Haller
62722347c5 core: never fail reading host-id timestamp and never change it
The timestamp of the host-id is the timestamp of the secret_key file.
Under normal circumstances, reading the timestamp should never fail,
and reading it multiple times should always yield the same result.

If we unexpectedly fail to read the timestamp from the file we want:

- log a warning, so that the user can find out what's wrong. But
  do so only once.

- we don't want to handle errors or fail operation due to a missing
  timestamp. Remember, it's not supposed to ever fail, and if it does,
  just log a warning and proceed with a fake timestamp instead. In
  that case something is wrong, but using a non-stable, fake timestamp
  is the least of the problems here.
  We already have a stable identifier (the host-id) which we can use to
  generate a fake timestamp. Use it.

In case the user would replace the secret_key file, we also don't want
that accessing nm_utils_host_id_get_timestamp*() yields different
results. It's not implemented (nor necessary) to support reloading a
different timestamp. Hence, nm_utils_host_id_get_timestamp() should
memoize the value and ensure that it never changes.

(cherry picked from commit a68d027ba4)
2018-12-12 14:40:55 +01:00
Thomas Haller
164d796cf8 core: split initializing host-id singleton out of nm_utils_host_id_get()
(cherry picked from commit e9887d4816)
2018-12-12 14:40:55 +01:00