Commit Graph

1956 Commits

Author SHA1 Message Date
Thomas Haller
801c41a11c build: make path to polkit-agent-helper-1 binary configurable
Add new configure option to set the path to "polkit-agent-helper-1".

The path cannot be obtained from pkg-config and `pkg-config
--variable=prefix polkit-agent-1` is not good enough.

On Fedora, the path is "/usr/lib/polkit-1/polkit-agent-helper-1".
On Debian Buster, the path is "/usr/lib/policykit-1/polkit-agent-helper-1"
On Debian Sid, the path is "/usr/libexec/polkit-agent-helper-1" (but
currently it is also symlinked from "/usr/lib/policykit-1/polkit-agent-helper-1".
2021-02-12 11:34:24 +01:00
Thomas Haller
d0552e00d0 cloud-setup/tests: add test for nmcs_setting_ip_replace_ipv4_addresses() 2021-02-10 18:35:13 +01:00
Thomas Haller
7e8809a9c5 cloud-setup/tests: add unit test for nm-cloud-setup 2021-02-10 18:23:44 +01:00
Thomas Haller
bbd36be44a cloud-setup: fix replacing IPv4 addresses during update
If previously the profile would track two addresses ("10.116.1.130/24",
"10.116.1.65/24"), and during an update the second address was removed
(leaving "10.116.1.130/24"), then the addresses of the profile were
wrongly not changed.

The effect is that removing a secondary IP address might not take
effect.

Fix that.

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

Fixes: 69f048bf0c ('cloud-setup: add tool for automatic IP configuration in cloud')
2021-02-10 18:23:44 +01:00
Thomas Haller
94a75c8cd6 cloud-setup: build intermediate library "libnm-cloud-setup-core.a"
Next we'll add unit tests, hence we need to link against the code
but we don't want to compile it twice.
2021-02-10 18:23:44 +01:00
Andrew Zaborowski
ba7a13789f setting-8021x: Fix descriptions for phase2-auth & phase2-autheap
phase2-auth applies for EAP-TTLS and EAP-PEAP but the interpretation is
different for one than for the other, clarify the difference.
phase2-auth is for the non-EAP inner methods of EAP-TTLS but is also for
the EAP inner methods of EAP-PEAP.  EAP-PEAP doesn't use phase2-autheap
and doesn't support any non-EAP methods.

Given how complicated EAP configuration is it's likely that people just
use example configurations rather than look at the docs.  The example
configuration in man/nm-settings-keyfile.xsl is correct in using PEAP
together with phase2-auth=mschapv2.

[thaller@redhat.com: regenerate documentation files]
2021-02-09 17:09:31 +01:00
Thomas Haller
b13a2b27e9 all: move shared/nm-meta-setting.[hc] to libnm-core and clients
"shared/nm-meta-setting.[hc]" contains meta data about settings.
As such it is similarly used by libnm-core (as internal API) and
by clients (as extension of public API of libnm). However, it must
be compiled twice, because while it defines in both cases a
NMMetaSettingInfo type, these types are different between internal and
public API.
Hence, the files must also be compiled twice (and differently), once
against libnm-core and once against the client helper library.

Previously, the file was under "shared/", but there it's a bit odd
it doesn't clearly belong anywhere.

There are two goals here:

 - copy the file to the two places where it is used. We also have
   a "check-tree" unit test that ensures those files don't diverge in
   the future.

 - we no longer require CFLAGS set during built. Instead, the sources
   should control the build. For that we have new (simple) headers
   "nm-meta-setting-base.h" that define the right behavior for the
   impl files.

There is still an ugliness (among several): the files must be named the
same for libnm-core and clients/common. Preferably, all our sources have
unique names, but that is not possible with this scheme (without
introducing other ugliness). To mitigate that, include the files only at
one exact place.
2021-02-09 12:38:19 +01:00
Thomas Haller
606612ea59 all: add "libnm/nm-default-client.h" as replacement for "nm-default.h" 2021-02-09 12:38:17 +01:00
Thomas Haller
5f47a2d44d build/meson: cleanup clients/***/meson.build 2021-02-09 12:38:16 +01:00
Thomas Haller
ab2dcc3289 meson/build: fix c_args for libnmc
This used c_flags, which was previously defined by dispatcher/meson.build,
something unrelated entirely.
2021-02-09 12:38:16 +01:00
Thomas Haller
0177cb9ade clients/tests: better explain how to configure localized tests 2021-02-08 16:38:54 +01:00
Thomas Haller
f72278eff7 ethtool: add more offload features that kernel supports
New features:

 - ethtool.feature-macsec-hw-offload
 - ethtool.feature-rx-gro-list
 - ethtool.feature-rx-udp-gro-forwarding
 - ethtool.feature-tls-hw-rx-offload
 - ethtool.feature-tx-gso-list
 - ethtool.feature-tx-tunnel-remcsum-segmentation

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/735
2021-02-08 15:11:11 +01:00
Thomas Haller
684019d6f1 cloud-setup: add Documentation link to "nm-cloud-setup.service" 2021-02-02 18:13:02 +01:00
Thomas Haller
150c18130e cloud-setup: add comment to "nm-cloud-setup.service" about drop-in files 2021-02-02 18:09:27 +01:00
Thomas Haller
3389192703 libnm/docs: explain that edns0/trust-ad is automatically added to DNS options
Since commit f91a8ef332 ('dns: add edns0 and trust-ad options when
using local resolver') we automatically set these options.

Document it.
2021-01-26 17:04:28 +01:00
Beniamino Galvani
92c494f290 all: change default value of hostname.only-from-default to false
Currently, is retrieved by default only from the device with the
default route. This is done so that in presence of multiple
connections the choice is deterministic.

However, this limitation seems confusing for users, that expect to get
an hostname even for non-default devices. Change the default and allow
any device to obtain the hostname.

Note that when there is a default route, NM still prefers that device
and so the behavior doesn't change.

The only change in behavior is that when there is no default route and
the machine doesn't have a static hostname, NM will try to get
hostname from DHCP or reverse DNS.

https://bugzilla.redhat.com/show_bug.cgi?id=1766944
2021-01-18 16:29:55 +01:00
Thomas Haller
874bd8994e libnm,shared: move nm-ethtool helper to "libnm-base"
We want to use this by "shared/nm-platform", which should have
no dependency on "libnm-core".

Move "libnm-core/nm-ethtool-utils.h" to "libnm/nm-ethtool-utils.h" so
that it is only used by libnm. This file contains the defines for
the option names.

Also, symlink "libnm/nm-ethtool-utils.h" as "shared/nm-base/nm-ethtool-utils-base.h".
We want to use the same defines also internally. Since they are both
public API (must be in libnm) and should be in "shared/nm-base", this
is the way.
2021-01-15 11:32:41 +01:00
Thomas Haller
19242f56d7 libnm: split ethtool option names to a new header "libnm-core/nm-ethtool-utils.h"
We want to use these defines for option names also in "shared/nm-base"
(and in turn in "shared/nm-platform), which cannot include "libnm-core".

However, they are also public API of libnm.

To get this done, in a first step, move these defines to a new header
"libnm-core/nm-ethtool-utils.h".

Since now the name "nm-ethtool-utils.h" is taken, also rename
nm-libnm-core-intern files.
2021-01-15 11:32:39 +01:00
Thomas Haller
800e226334 device: add "ipv4.dhcp-client-id=ipv6-duid" property for RFC4361
RFC4361 intends to set the same IAID/DUID for both DHCPv4 and DHCPv6.
Previously, we didn't have a mode for that.

Of course, you could always set "ipv4.dhcp-client-id" and
"ipv6.dhcp-duid" to (the same) hex string, but there was no
automatic mode. Instead we had:

- "ipv4.dhcp-client-id=duid" which sets the client ID to a stable,
  generated DUID. However, there was no option so that the same
  DUID/IAID would be automatically used for DHCPv6.

- there are various special values for "ipv6.dhcp-duid" which generate
  a stable DUIDs. However, those values did not work for
  "ipv4.dhcp-client-id".

Solve that by adding "ipv4.dhcp-client-id=ipv6-duid" which indicates to use
the DUID from DHCPv6's "ipv6.dhcp-duid" setting. As IAID it will prefer "ipv4.dhcp-iaid"
(if set), but fallback to "ipv6.dhcp-iaid".

https://tools.ietf.org/html/rfc4361

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/618

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/718
2021-01-11 18:59:01 +01:00
Thomas Haller
7c6adf8032 clients: fix compiler warning in _do_test_parse_passwd_file()
Since "_i" is int type and G_N_ELEMENTS() is size_t, the compiler
can warn

    error: comparison of unsigned expression in '< 0' is always false [-Werror=type-limits]

Avoid the warning by casting.
2021-01-08 19:06:44 +01:00
Thomas Haller
8128f791c9 cloud-setup: assign incremental iface_idx for Azure,GCP get_config() result
We use the iface_idx for example to determine the routing table,
by using table 30400+iface_idx.

While the HTTP API for Azure has a index, it does not mean that we
should use that index as-is for our purpose.

Instead, treat those indexes separately and ensure that the
iface_idx that we return is numbering the interfaces starting
from zero.
2021-01-08 16:32:50 +01:00
Thomas Haller
e81b442d8b cloud-setup: fail get_config() for Azure on invalid prefix
While it's not clear whether we should be strict or forgiving
when fetching the HTTP meta data, we should be consistent.

On a parse error of the IP addresses we fail. Hence also
fail on a parse error for the subnet.
2021-01-08 16:32:49 +01:00
Thomas Haller
fc8315cd94 cloud-setup: use nmcs_utils_ipaddr_normalize_bin() in Azure provider 2021-01-08 16:32:49 +01:00
Thomas Haller
288b38e719 cloud-setup: use nmcs_utils_ipaddr_normalize_gbytes() in GCP provider 2021-01-08 16:32:49 +01:00
Thomas Haller
30e1f73347 cloud-setup: add nmcs_utils_ipaddr_normalize*() helper 2021-01-08 16:32:49 +01:00
Thomas Haller
f0faf2e1a1 cloud-setup: handle unknown interaces in get_config() for GCP/Azure
The API of mcs_provider_get_config() allows to explicitly request
for certain interfaces (MAC addresses), but it also allows to fetch
any.

That means, the result dictionary will be pre-populated with the
MAC addresses that were requested, but if we encounter an unknown
interface, then that is not a reason to fail.
2021-01-08 16:32:48 +01:00
Thomas Haller
511b4ab411 cloud-setup: add and use nmcs_utils_hwaddr_normalize_gbytes()
Previously we would call

    nmcs_utils_hwaddr_normalize(g_bytes_get_data(response, NULL), -1);

which treats the data in response as NUL terminated. That is not
entirely wrong, because the HTTP request's response is guaranteed
to have a NUL termination at the end. However, it doesn't seam to good
either.

For one, we already have the length. Use it. But also, if the response
contains any NUL bytes in the middle, then this would wrongly only
consider the first line. We should not accept "00:11:22:33:44:55\0bogus"
as valid.

While at it, reject NUL characters from nmcs_utils_hwaddr_normalize() --
except one NUL at the end.
2021-01-08 16:32:48 +01:00
Thomas Haller
2ba984a80a cloud-setup: strip whitespace from nmcs_utils_hwaddr_normalize()
This function should be accepting, and not reject leading/trailing
white space.
2021-01-08 16:32:48 +01:00
Thomas Haller
494819bbbf cloud-setup: move common code for get_config() to base class and improve cancellation
First note that all three provider implementations are very similar.
That is why NMCSProvider's implementation does already some work that
is common to all implementations. For example, it provides the
NMCSProviderGetConfigTaskData structure to help tracking the data of
the request.

Also note that the GCP/Azure implementations didn't handle the
cancellation correctly. They always would pass

    g_task_get_cancellable(get_config_data->task)

to the asynchronous requests. That is the GCancellable provider by the
caller. That is fine when there is only one async operation ongoing. But
that is not the case, we have parallel HTTP requests.
Then, when an error happened, the overall get_config() operations fails
and the still pending requests should all be aborted. However, we must
not cancel the GCancellable of the user (because that is not owned by us).
The correct solution is to use an internal cancellable in those cases.

Anyway. Since all of this is similar, we can extend the base class
to handle things for us. This also gets the cancellation right by having
a "get_config_data->intern_cancellable".
2021-01-08 16:32:48 +01:00
Thomas Haller
5fb2f7e717 cloud-setup/trivial: rename "response_data" variable
We have three implementations of providers, that all do something similar.
Name the variable with the HTTP response GBytes the same everywhere.
2021-01-08 15:24:43 +01:00
Thomas Haller
9afdbb97ea cloud-setup/trivial: rename variables "config_data" to "get_config_data"
The code is not entirely straight forward. Consistent naming
is hence important.

In "nmcs-provider-ec2.c", variables of this kind are called
"get_config_data". That also matches to the type of the data
(NMCSProviderGetConfigTaskData).

Rename the variables to make naming consistent. Also, I find the
longer name to be clearer.
2021-01-08 15:24:43 +01:00
scootergrisen
5e70e802e0 nmcli: change "--help" to "help"
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/706
2021-01-07 09:38:15 +01:00
Thomas Haller
977ea352a0 all: update deprecated SPDX license identifiers
These SPDX license identifiers are deprecated ([1]). Update them.

[1] https://spdx.org/licenses/

  sed \
     -e '1 s%^/\* SPDX-License-Identifier: \(GPL-2.0\|LGPL-2.1\)+ \*/$%/* SPDX-License-Identifier: \1-or-later */%' \
     -e '1,2 s%^\(--\|#\|//\) SPDX-License-Identifier: \(GPL-2.0\|LGPL-2.1\)+$%\1 SPDX-License-Identifier: \2-or-later%' \
     -i \
     $(git grep -l SPDX-License-Identifier -- \
         ':(exclude)shared/c-*/' \
         ':(exclude)shared/n-*/' \
         ':(exclude)shared/systemd/src' \
         ':(exclude)src/systemd/src')
2021-01-05 09:46:21 +01:00
Antonio Cardace
ff6cb8f528 wifi: merge branch 'ac/wpa3eap_suiteb192'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/709
2020-12-22 18:30:34 +01:00
Antonio Cardace
e874ccc917 wifi: add WPA-EAP-SUITE-B-192 support
Add a new key management option to support WPA3 Enteprise wifi
connection.

Only supported with wpa_supplicant for the time being.

Signed-off-by: Antonio Cardace <acardace@redhat.com>
2020-12-22 18:28:56 +01:00
Thomas Haller
0fca809bfd all: explicit include <linux/if_{ether,infiniband,vlan}.h> as needed
Currently libnm headers include <linux/if_{ether,infiniband,vlan}.h>.
These are public headers, that means we drag in the linux header to all
users of <NetworkManager.h>.

Often the linux headers work badly together with certain headers from libc.
Depending on the libc version, you have to order linux headers in the right
order with respect to libc headers.

We should do better about libnm headers. As a first step, assume that
the linux headers don't get included by libnm, and explicitly include
them where they are needed.
2020-12-22 16:33:33 +01:00
Fernando Fernandez Mancera
cf89e428af nmtui: fix listing veth devices on nmtui
When activating a connection using nmtui, veth connections where not
being listed. This patches fixes this and they are now being listed.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2020-12-21 11:29:32 +01:00
Thomas Haller
7f4a7bf433 all: remove unnecessary <netinet/ether.h> includes
<netinet/ether.h> with musl defines ethhdr struct, which conflicts
with <linux/if_ether.h>. The latter is included by "nm-utils.h",
so this is a problem.

Drop includes of "netinet/ether.h" that are not necessary.
2020-12-13 16:56:51 +01:00
Thomas Haller
be8a3f9902 cloud-setup: simplify cancellation in _get_config_fetch_cancelled_cb()
If we call g_cancellable_connect() on a GCancellable that is already
cancelled, then the callback is invoked synchronously. We need to
handle that.

However, we can slightly simplify the code. There is no change in
behavior, but we can always let the cancelled callback return the
result.
2020-12-11 17:36:37 +01:00
Thomas Haller
422ab25626 cloud-setup: in EC2's _get_config_task_maybe_return() cancel internal requests on any error
"iface_data->cancellable" is an internal cancellable for the parallel
HTTP requests. Once we encounter a failure, those requests are all
obsolete and must be cancelled.
2020-12-11 17:36:37 +01:00
Thomas Haller
399c04e810 cloud-setup: fix handling cancellation of internal GET operation for EC2 provider
There are two GCancellable at work: one is provided by the user
during nmcs_provider_get_config(), and one is used internally for the
individual HTTP GET requests.

In _get_config_fetch_done_cb(), if the error reason is "cancelled",
then it means that our internal iface_data->cancellable was cancelled.
Probably because an error happend (like a timeout or the user cancelled
the external GCancellable).

In that case, we must not report that the task completed with a
cancellation, because we need to preserve the error that was the
original cause.
2020-12-11 17:36:37 +01:00
Fernando Fernandez Mancera
cd0cf9229d veth: add support to configure veth interfaces
NetworkManager is now able to configure veth interfaces throught the
NMSettingVeth. Veth interfaces only have "peer" property.

In order to support Veth interfaces in NetworkManager the design need
to pass the following requirements:

 * Veth setting only has "peer" attribute.
 * Ethernet profiles must be applicable to Veth interfaces.
 * When creating a veth interface, the peer will be managed by
   NetworkManager but will not have a profile.
 * Veth connection can reapply only if the peer has not been modified.
 * In order to modify the veth peer, NetworkManager must deactivate the
   connection and create a new one with peer modified.

In general, it should support the basis of veth interfaces but without
breaking any existing feature or use case. The users that are using veth
interfaces as ethernet should not notice anything changed unless they
specified the veth peer setting.

Creating a Veth interface in NetworkManager is useful even without the
support for namespaces for some use cases, e.g "connecting one side of
the veth to an OVS bridge and the other side to a Linux bridge" this is
done when using OVN kubernetes [1][2]. In addition, it would provide
persistent configuration and rollback support for Veth interfaces.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1885605
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1894139

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2020-11-27 10:12:36 +01:00
Thomas Haller
ff71bbdc42 Revert "dns: change default DNS priority of VPNs to -50"
Revert this change. One problem is that none of the current GUIs
(nm-connection-editor, gnome-control-center, plasma-nm) expose the
dns-priority option. So, users tend to have their profile value set to
0. Changing the default means for them not only a change in behavior,
but its hard to fix via the GUI.

Also, what other call DNS leaks, is Split DNS to some. Both uses make
sense, but have conflicting goals. The default cannot accommodate both
at the same time.

Also, with split DNS enabled (dnsmasq, systemd-resolved), the concern
for DNS leaks is smaller. Imagine:

  Wi-Fi profile with ipv4.dns-priority (effectively) 100, domain "example.com".
  VPN profile with ipv4.dns-priority (effectively) 50 and a default route.

That is a common setup that one gets by default (and what probably many
users have today). In such a case with split DNS enabled, the Wi-Fi's DNS
server only sees requests for "*.example.com". So, it does not leak
everything.

Hence, revert this change before 1.28.0 release to the earlier behavior.

This reverts commit af13081bec.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/688
2020-11-23 18:53:52 +01:00
Thomas Haller
8dc28e4b5e cli: replace if-else-if construct in nmc_process_connection_properties() by continue
The if-else-if constuct spans many lines and it is not easy to see that
there is no common action after the if-else-if construct.

Instead, at the end of each if-block, just "continue" the loop. This
is similar to a "return-early" apprach and it mean you don't need
to think what happens at the end of the if-block.
2020-11-18 09:56:53 +01:00
Thomas Haller
1d6c2601b0 cli: don't fail nmcli con modify $PROFILE remove $SETTING for non-existing setting
Removing a setting that is not present should not be an error. The user
asked that the profile doesn't have the requested setting, and that
should succeed (even if that results in no actual change).

Consider when you want to make a hotspot profile "open". That implies
to remove the "wifi-sec" and "802-1x" settings. But you may
not check before whether the profile is already open, and whether
it already has those settings. We should just allow

  $ nmcli connection modify "$PROFILE" remove wifi-sec remove 802-1x

to succeed, regardless whether this changes anything or not.

Likewise, if you do

  $ nmcli connection modify "$PROFILE" con-name foo
  $ nmcli connection modify "$PROFILE" con-name foo

then the second command doesn't fail with "the name is
already \"foo\"". It just succeeds.
2020-11-18 09:56:16 +01:00
Thomas Haller
d0ec501163 cli: assert that valid_parts are set for base types 2020-11-17 22:19:29 +01:00
Thomas Haller
9ebeeb6bf2 cli: fix shell completion for connection.type to show "ovs-{dpkg,patch}"
nmcli --complete-args connection add type ''

would not show "ovs-{dpdk,patch}", because the conditions about what
makes a base type are not consistent with what NMSettingConnection's
verify() does.

Fix that.
2020-11-17 22:19:29 +01:00
Beniamino Galvani
abd002642f all: add hostname setting
Add a new setting that contains properties related to how NM should
get the hostname from the connection.
2020-11-16 16:43:39 +01:00
Thomas Haller
6100b52e5c libnm: add NMSettingOvsExternalIDs 2020-11-09 17:53:15 +01:00
Thomas Haller
62411390e2 build: rename "tools/check-settings-docs.sh" to "check-compare-generated.sh"
It's a better name, because the script merely compiles files and
is not specific to "settings-docs.h".
2020-11-03 15:41:39 +01:00