Commit Graph

12390 Commits

Author SHA1 Message Date
Thomas Haller
86097cc2e8 libnm: fix return value for nm_remote_settings_reload_connections*() to ignore server result
Note that the server always returns TRUE for the boolean return value
of ReloadConnections. Hence, this should not change in behavior, because
the server would never have returned FALSE.

However, change behavior of the API. It's odd that the function might
return %FALSE without setting the error output. It's also not clear
what the boolean value of the "ReloadConnections" D-Bus would mean
anyway.
2019-10-16 08:56:00 +02:00
Beniamino Galvani
eb3e932b6a ifcfg-rh: drop trailing dot from error messages 2019-10-15 08:34:31 +02:00
Beniamino Galvani
8afce75bf3 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.
2019-10-15 08:34:31 +02:00
Beniamino Galvani
8763e6da9c 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.
2019-10-15 08:34:31 +02:00
Beniamino Galvani
5b4f4a4c30 supplicant: export authentication state
Add a property to the supplicant to indicate the current state of the
authentication process.
2019-10-15 08:34:31 +02:00
Beniamino Galvani
292ba430a0 ifcfg-rh: refactor reading 802.1X phase2 auth method
Refactor reading the phase2 authentication method for 802.1X.
Previously the reader only considered the first item of the
space-separated list; but since the 802.1x setting can hold distinct
phase2-auth and phase2-autheap properties - both mapped to the same
ifcfg-rh variable - we should parse the whole list. We only emit a
warning when multiple methods of the same type are found to avoid
breaking existing manually written ifcfg files.

Moreover, the reader implemented different checks for each of the
outer tunneled methods (PEAP, TTLS and FAST); drop those checks and
accept whatever the 802.1X setting also consider as valid. Note that
some combinations that are in principle valid, like PEAP + EAP-MD5,
were dropped before.
2019-10-15 08:33:46 +02:00
Thomas Haller
10c63f167d core: don't use pointer value for pending action string in active-connection
The pending action gets logged. We should not log plain pointer
values because they may be used to defeat ASLR.

Instead, construct the pending action using the "version_id". This
number is also unique, and suits sufficiently well. With debug logging
you can still grep the log for the corresponding active-connection (and
anyway it's obvious from the context).
2019-10-14 16:37:16 +02:00
Thomas Haller
1e5206414a device: don't delay startup complete for pending-actions "autoconf", "dhcp4" and "dhcp6"
These "pending-actions" only have one purpose: to mark the device
as busy and thereby delay "startup complete" to be reached. That
in turn delays "NetworkManager-wait-online" service.

Of course, "NetworkManager-wait-online" waits for some form of readiness
and is not extensively configurable (e.g. you cannot exclude devices from
being waited). However, the intent is to wait that all devices are "settled".
That means among others, that the timeouts waiting for carrier and Wi-Fi scan
results passed, and devices either don't have a connection profile to autoactivate,
or they autoactivated profiles and are in state "connected".

A major point here is that the device is considered ready, once it
reaches the state "connected". Note that if you configure both IPv4 and
IPv6 addressing modes, than "ipv4.may-fail=yes" and "ipv6.may-fail=yes"
means, that the device is considered fully activated once one address
family completes. Again, this is not very configurable, but by setting
"ipv6.may-fail=no", you can require that the device has indeed IPv6
addressing completed.

Now, the determining factor for declaring "startup complete" is whether the
device is in state "connected". That may or may not mean that DHCPv4,
autoconf or DHCPv6 completed, as it depends on a overall state of the
device. So, it is wrong to have distinct pending actions for these operations.

Remove them.

This fixes that we wrongly would wait too long before declaring startup
complete. But it is also a change in behavior.
2019-10-14 11:35:40 +02:00
Beniamino Galvani
ec28f5b343 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
2019-10-10 15:08:16 +02:00
Beniamino Galvani
4875745bc0 macvlan: update MTU according to parent's one 2019-10-10 15:08:16 +02:00
Beniamino Galvani
438a0a9ad5 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
2019-10-10 15:08:16 +02:00
Beniamino Galvani
5cf57f4522 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.
2019-10-10 15:08:16 +02:00
Beniamino Galvani
6455a4e528 device: expand comment on MTU selection 2019-10-10 15:08:16 +02:00
Beniamino Galvani
353c7c95c1 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
2019-10-10 15:08:16 +02:00
Beniamino Galvani
b58e4d311d 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
2019-10-10 14:47:21 +02:00
Beniamino Galvani
e36c297fd8 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
2019-10-09 13:04:41 +02:00
Thomas Haller
5a24ad53ad device: order assert before logging in concheck_cb() 2019-10-03 15:32:32 +02:00
Ilya Shipitsin
e8588d0c6f src/devices/nm-device.c: resolve possible null pointer dereference
found by cppcheck

[src/devices/nm-device.c:3032] -> [src/devices/nm-device.c:3025]: (warning) Either the condition '!handle' is redundant or there is possible null pointer dereference: handle.

https://github.com/NetworkManager/NetworkManager/pull/352
2019-10-03 15:12:34 +02:00
Thomas Haller
3b69f02164 all: unify format of our Copyright source code comments
```bash

readarray -d '' FILES < <(
  git ls-files -z \
    ':(exclude)po' \
    ':(exclude)shared/c-rbtree' \
    ':(exclude)shared/c-list' \
    ':(exclude)shared/c-siphash' \
    ':(exclude)shared/c-stdaux' \
    ':(exclude)shared/n-acd' \
    ':(exclude)shared/n-dhcp4' \
    ':(exclude)src/systemd/src' \
    ':(exclude)shared/systemd/src' \
    ':(exclude)m4' \
    ':(exclude)COPYING*'
  )

sed \
  -e 's/^\(--\|#\| \*\) *\(([cC]) *\)\?Copyright \+\(\(([cC])\) \+\)\?\(\(20\|19\)[0-9][0-9]\) *[-–] *\(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/\1 C1pyright#\5 - \7#\9/' \
  -e 's/^\(--\|#\| \*\) *\(([cC]) *\)\?Copyright \+\(\(([cC])\) \+\)\?\(\(20\|19\)[0-9][0-9]\) *[,] *\(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/\1 C2pyright#\5, \7#\9/' \
  -e 's/^\(--\|#\| \*\) *\(([cC]) *\)\?Copyright \+\(\(([cC])\) \+\)\?\(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/\1 C3pyright#\5#\7/' \
  -e 's/^Copyright \(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/C4pyright#\1#\3/' \
  -i \
  "${FILES[@]}"

echo ">>> untouched Copyright lines"
git grep Copyright "${FILES[@]}"

echo ">>> Copyright lines with unusual extra"
git grep '\<C[0-9]pyright#' "${FILES[@]}" | grep -i reserved

sed \
  -e 's/\<C[0-9]pyright#\([^#]*\)#\(.*\)$/Copyright (C) \1 \2/' \
  -i \
  "${FILES[@]}"

```

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/298
2019-10-02 17:03:52 +02:00
Lubomir Rintel
a5ca504b5b bluetooth: don't set the ifindex after the device has been activated
The Bluetooth DUN device's NMModem would signal the reset of ifindex to zero
when it's disconnected and the NMDeviceBt would accordingly update the
bluetooth device's ip ifindex. This is not okay since commit ab4578302d
('device: refactor nm_device_set_ip_ifindex() and set_ip_iface()') which,
although claiming to be a refactoring, made such use of
nm_device_set_ip_ifindex() illegal. Resetting the ifindex is anyway not
necessary, since it's taken care of _cleanup_generic_post().

Let's leave the ifindex alone once the device is activated, in a manner
analogous to what NMDeviceModem.

Fixes: ab4578302d ('device: refactor nm_device_set_ip_ifindex() and set_ip_iface()')
Fixes: 78ca2a70c7 ('device: don't set invalid ip-iface'):
2019-10-02 11:29:53 +02:00
Beniamino Galvani
5307b1ed73 wifi: guess metered flag based on Network Cost information element
Network Cost [1] is a vendor-specific information element defined by
Microsoft and used to advertise the cost of Wi-Fi networks to clients.

We can use it together with the ANDROID_METERED mechanism to
automatically set the metered flag on the device.

[1] https://docs.microsoft.com/en-us/windows-hardware/drivers/mobilebroadband/network-cost-information-element

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/200
2019-10-01 13:37:50 +02:00
Iñigo Martínez
42a8533d5f meson: Remove devices tests' meson build files
The devices tests' meson build files include only the build of a
single executable file and its execution as a test unit.

This has been moved to the devices' main meson build files so this
files can be removed.
2019-10-01 09:49:33 +02:00
Iñigo Martínez
05c7a77022 meson: Add missing "nm-bt-test" helper program
In 878d4963e a new `nm-bt-test` helper program was added. However,
although `autotools` build steps were included, meson build steps
were not.

This add meson's build steps.
2019-10-01 09:49:33 +02:00
Iñigo Martínez
2172b885b4 meson: Improve the wwan test build file
The test unit name string is used in different place so it has been
replaced by a variable.

The `nm-service-providers.c` source file is appended by using a
`files` generated object.
2019-10-01 09:49:33 +02:00
Iñigo Martínez
7e1aacaef2 meson: Remove tests related to check_so_symbols
These tests are already working since 19a718bc1 so `FIXME` comments
are not needed anymore.
2019-10-01 09:49:33 +02:00
Iñigo Martínez
509706b62b meson: Avoid the creation of an extra variable
An extra variable is used for sources of
`libnm-settings-plugin-ifupdown` module. However, it only contains
one source file and using it directly avoiding the creation of the
extra variable doesn't hurt readibility.
2019-10-01 09:49:33 +02:00
Iñigo Martínez
146348199e meson: Remove unused variable 2019-10-01 09:49:33 +02:00
Iñigo Martínez
a010fcb5f7 meson: Move network-config directory creation to main install file
The `ifcfg-rh` meson build file installs a new post install script
to create the `network-config` directory.

This has been moved to the main post install file so it's easier to
find because all post install steps are together and it avoids and
extra post install script execution.
2019-10-01 09:49:33 +02:00
Iñigo Martínez
f5f9c071ba meson: Improve ifcfg-rh plugin build
The file has been fixed to be consistent with the rest of the files.
The data files to be installed have been grouped together. The
sourc files has been listed vertically and the link target in
`nm-settings-plugin-ifcfg-rh` does not use an array anymore.
2019-10-01 09:49:33 +02:00
Iñigo Martínez
4e5b1e257e meson: Improve nm-initrd-generator target
The set of link targets used when building `nm-initrd-generator`
target has been grouped together.
2019-10-01 09:49:33 +02:00
Iñigo Martínez
c4dc02c9bd meson: Avoid the use of unnecessary array
The linker flags used when building `libnm_wwan` target uses an
array even when it only uses one value.

When using only one value the array is unnecessary so it has been
removed.
2019-10-01 09:49:33 +02:00
Iñigo Martínez
dababfa59e meson: Improve ppp build file
The set of c_flags used when building `ppp` targets has been grouped
together. Used dependencies have also been reviewed and removed
the unnecessary one.
2019-10-01 09:49:33 +02:00
Iñigo Martínez
23bd02110c meson: Rename the compiler flags variable
Renamed the variable holding the compiler flags to be consistent
with different meson ports.

This naming pattern improves the use of different compiler flags
in environments with multiple languages.
2019-10-01 09:49:33 +02:00
Iñigo Martínez
780585952d meson: Use variable for test program name
The name of the `monitor` test program is duplicated. A variable
has been used to avoid using the same string twice.
2019-10-01 09:49:33 +02:00
Iñigo Martínez
31f1516760 meson: Improve the src build file
The targets that involve the use of the `NetworkManager` library,
built in the `src` build file have been improved by applying a set
of changes:

- Indentation has been fixed.
- Set of objects used in targets have been grouped together.
- Aritificial dependencies used to group dependencies and custom
  compiler flags have been removed and their use replaced with
  proper dependencies and compiler flags to avoid any confussion.
2019-10-01 09:49:33 +02:00
Iñigo Martínez
1066ddb3a1 meson: Improve the systemd build file
The `systemd` build file has been improved by grouping together all
the objects used in the building of the `libnm-systemd-core`
library.
2019-10-01 09:49:33 +02:00
Iñigo Martínez
f427f4771e meson: Improve the libnm-core build file
The `libnm-core` build file has been improved by applying a set of
changes:

- Indentation has been fixed to be consistent.
- Library variable names have been changed to `lib{name}` pattern
  following their filename pattern.
- `shared` prefix has been removed from all variables using it.
- Dependencies have been reviewed to store the necessary data.
- The use of the libraries and dependencies created in this file
  has been reviewed through the entire source code. This has
  required the addition or the removal of different libraries and
  dependencies in different targets.
- Some files used directly with the `files` function have been moved
  to their nearest path build file because meson stores their full
  path seamessly and they can be used anywhere later.
2019-10-01 09:49:33 +02:00
Iñigo Martínez
70a34c54fe meson: Use dependency for nm-default header
The `nm-default.h` header is used widely in the code by many
targets. This header includes different headers and needs different
libraries depending the compilation flags.

A new set of `*nm_default_dep` dependencies have been created to
ease the inclusion of different directorires and libraries.

This allows cleaner build files and avoiding linking unnecessary
libraries so this has been applied allowing the removal of some
dependencies involving the linking of unnecessary libraries.
2019-10-01 09:49:33 +02:00
Iñigo Martínez
c74e428342 meson: Improve the shared build file
The `shared` build file has been improved by applying a set of
changes:

- Indentation has been fixed to be consistent.
- Unused libraries and dependencies have been removed.
- Dependencies have been reviewed to store the necessary data.
- Set of objects used in targets have been grouped together.
- Header files have been removed from sources lists as it's
  unnecessary.
- Library variable names have been changed to `lib{name}` pattern
  following their filename pattern.
- `shared` prefix has been removed from all variables using it.
- `version_header` its related configuration `version_conf`
  variables have been renamed to `nm_version_macro*` following
  its input and final file names.
2019-10-01 09:49:33 +02:00
Iñigo Martínez
82e79e40a5 meson: Avoid the use of source_root and build_root methods
The way some directory paths are defined has also been changed to
avoid the use of the `source_root` and `build_root` functions
because they are discouraged[0]

[0] https://wiki.gnome.org/Initiatives/GnomeGoals/MesonPorting
2019-10-01 09:49:33 +02:00
Thomas Haller
abff46cacf all: manually drop code comments with file description 2019-10-01 07:50:52 +02:00
Beniamino Galvani
3c4f70c5c2 dhcp: systemd: support DHCPv6 prefix delegation
Add support to the internal DHCP client for requesting a prefix and
distributing it to interfaces with 'shared' IPv6 mode.

The systemd-networkd API currently allows to request only a single
prefix and so there will be issues when the number of downstream
interfaces is greater than the number of /64 subnets available in the
returned prefix; but this is still an improvement over the previous
situation when no prefix was requested at all.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/247
2019-09-30 16:15:13 +02:00
Beniamino Galvani
5f284e1574 device: fix wrong string compare in _commit_mtu()
Fixes: e6628fa27c ('ipv6: add 'disabled' method')

https://bugzilla.redhat.com/show_bug.cgi?id=1753128
2019-09-27 13:39:43 +02:00
Beniamino Galvani
f868b509fb team: delete port configuration on release
If we set a port configuration upon enslaving, delete it when the port
is released.

https://bugzilla.redhat.com/show_bug.cgi?id=1755406
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/293
2019-09-27 13:33:36 +02:00
Beniamino Galvani
64a9dd3804 device: don't reapply IP config on link up for disconnected devices
Only reapply the IP configuration on link up if the IP state is CONF
or DONE. Previously we also reapplied it when the device was
disconnected (IP state NONE) and this could lead to a situation where
an incomplete config was applied; then we intersected the desired
configuration with the external - incomplete - one, causing the
removal of part of desired configuration (for example the default
route).

Fixes: d0b16b9283 ('device: unconditionally reapply IP configuration on link up')

https://bugzilla.redhat.com/show_bug.cgi?id=1754511
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/291
2019-09-27 13:27:19 +02:00
Thomas Haller
eea783d129 initrd: make "argv" argument of nmi_cmdline_reader_parse() a const strv 2019-09-27 09:20:06 +02:00
Thomas Haller
eea8ee2321 initrd/tests: check for the parsed values in detail for rd.znet test 2019-09-27 09:20:06 +02:00
Thomas Haller
19604cb126 initrd: avoid modifying the argv argument in nmi_cmdline_reader_parse()
While nmi_cmdline_reader_parse() only has one caller, which indeed has the
argv parameter at hand and doesn't care it to be modified, I think it
is ugly.

Arguments preferably are strictly either input or output arguments,
with input arguments not being modified by the call.
2019-09-27 09:20:06 +02:00
Thomas Haller
783fe28465 initrd: avoid assertion inparse_rd_znet() and cleanup
- nm_setting_wired_add_s390_option() asserts that a "value" argument
  is given. Check that the string contains a '=' where we can split.

- pass the requested NM_SETTING_WIRED_SETTING_NAME type to get_conn().
  Otherwise, @s_wired might be %NULL, resulting in an assertion.
  I do wonder whether this always retrieves a connection of the
  appropriate type for modification, or whether a profile could
  be returned that was created for a different purpose. But that
  isn't changed.

- avoid "g_strcmp0 (nettype, "ctc") != 0". I find it unexpected, that we add the
  3rd subchannel component, if the nettype is "ctc" (intuitively, I'd expect it
  to be the opposite). The reasons for this are not documented, but I
  presume it is correct.
  Anyway, using streq() makes this slightly more clear to me, as with
  strcmp() I would wonder whether this was just a typo while with
  streq() I'd be more confident that this is indeed intended.

- don't initialize local variables unnecessarily. The compiler would
  warn if we would forget about this. Also, don'\''t use { } for a
  one-line block.
2019-09-27 09:18:43 +02:00
Dan Horák
df07539105 nm-initrd-generator - add test for rd.znet 2019-09-27 09:17:57 +02:00