Commit graph

26127 commits

Author SHA1 Message Date
Antonio Cardace
8581038450
nmcs-main: support adding additional routes
This allows a provider to only add additional routes to the applied profile

https://bugzilla.redhat.com/show_bug.cgi?id=1821787
(cherry picked from commit 75a84677ca)
2020-06-28 17:40:21 +02:00
Antonio Cardace
23c11af7f5
nmcs-http: add param to GET API to set custom HTTP headers
https://bugzilla.redhat.com/show_bug.cgi?id=1821787
(cherry picked from commit 053bce438b)
2020-06-28 17:40:21 +02:00
Antonio Cardace
c8965f906e
main: remove unused argument
(cherry picked from commit 1095cef9a1)
2020-06-28 17:40:21 +02:00
Antonio Cardace
1f27c36288
nmcs: fix indentation
(cherry picked from commit d46da9072a)
2020-06-28 17:40:21 +02:00
Antonio Cardace
0d22e6b2fe
nm-shared-utils: add util to parse out lines from a string
https://bugzilla.redhat.com/show_bug.cgi?id=1821787
(cherry picked from commit aa5959a595)
2020-06-28 17:40:20 +02:00
Antonio Cardace
20a6fa7d1b
nmcs: add error message when a HTTP request times out
https://bugzilla.redhat.com/show_bug.cgi?id=1821787
(cherry picked from commit 3bd30f6064)
2020-06-28 17:40:20 +02:00
Antonio Cardace
b7d53f0d3a
nmcs-http: remove the timeout once expired
libcurl's documentation for CURLMOPT_TIMERFUNCTION requires the
application to install a non-repeating timer.

https://curl.haxx.se/libcurl/c/CURLMOPT_TIMERFUNCTION.html

So let's remove the GSource once expired.

Fixes: 69f048bf0c ('cloud-setup: add tool for automatic IP configuration in cloud')
(cherry picked from commit e09bd2339a)
2020-06-28 17:40:20 +02:00
Antonio Cardace
f5487645d8
nmcs-http: fix multiple HTTP request bug
Since just a single pointer is used to store the socket's GSource
if more than 1 consecutive request was done through the same
HTTP provider the 2nd request would clear the GSource associated to
the second request causing the 1st HTTP request to never complete
and end up in a expired timeout.

Use a hashtable instead so we can correctly track all requests.

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

Fixes: 69f048bf0c ('cloud-setup: add tool for automatic IP configuration in cloud')
(cherry picked from commit 427fbc85f0)
2020-06-28 17:40:13 +02:00
Beniamino Galvani
2b5ba370a6 device: clean up exported IP6 config when flushing addresses
After flushing addresses and routes, it's also necessary to update the
exported IP6 configuration.

https://bugzilla.redhat.com/show_bug.cgi?id=1848888
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/551

Fixes: e302f5ff77 ('device: flush IP configuration of slaves during activation')
(cherry picked from commit 071104124b)
2020-06-28 17:00:03 +02:00
Thomas Haller
af3c8bcb45
core,libnm: merge branch 'th/kernel-cmdline-match'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/550

(cherry picked from commit d18d75f89c)
2020-06-26 13:33:42 +02:00
Thomas Haller
3ced486f41
libnm/match: extend syntax for match patterns with '|', '&', '!' and '\\'
For simple matches like match.interface-name, match.driver, and
match.path, arguably what we had was fine. There each element
(like "eth*") is a wildcard for a single name (like "eth1").

However, for match.kernel-command-line, the elements match individual
command line options, so we should have more flexibility of whether
a parameter is optional or mandatory. Extend the syntax for that.

- the elements can now be prefixed by either '|' or '&'. This makes
  optional or mandatory elements, respectively. The entire match
  evaluates to true if all mandatory elements match (if any) and
  at least one of the optional elements (if any).
  As before, if neither '|' nor '&' is specified, then the element
  is optional (that means, "foo" is the same as "|foo").

- the exclamation mark is still used to invert the match. If used
  alone (like "!foo") it is a shortcut for defining a mandatory match
  ("&!foo").

- the backslash can now be used to escape the special characters
  above. Basically, the special characters ('|', '&', '!') are
  stripped from the start of the element. If what is left afterwards
  is a backslash, it also gets stripped and the remainder is the
  pattern. For example, "\\&foo" has the pattern "&foo" where
  '&' is no longer treated specially. This special handling of
  the backslash is only done at the beginning of the element (after
  the optional special characters). The remaining string is part
  of the pattern, where backslashes might have their own meaning.

This change is mostly backward compatible, except for existing matches
that started with one of the special characters '|', '&', '!', and '\\'.

(cherry picked from commit 824ad6275d)
2020-06-26 13:33:41 +02:00
Thomas Haller
1149dff6a1
core/tests: add unit test for nm_utils_kernel_cmdline_match_check()
(cherry picked from commit fa56e52a4f)
2020-06-26 13:33:41 +02:00
Thomas Haller
8d30c11e0c
core: move matching of kernel command line to separate function
(cherry picked from commit e0f4817148)
2020-06-26 13:33:41 +02:00
Thomas Haller
5b7d39f8e1
docs: fix escaping XML in "tools/generate-docs-nm-settings-docs-gir.py"
The gtk-doc text that the tool receives is not XML, it's a plain text.
When setting the plain text as XML attribute, we need to properly escape
it. The previous XML escape code was naive, and didn't cover for a
plain ampersand.

(cherry picked from commit 1641cc1d03)
2020-06-26 13:33:41 +02:00
Thomas Haller
c590f3c071
shared: return non-const pointer from nm_str_buf_get_str()
It's more convenient in certain cases. The user is allowed
to modified the content of the returned buffer.

(cherry picked from commit de4df9f529)
2020-06-26 10:31:07 +02:00
Thomas Haller
bf9ea4ea71
shared: avoid copying empty string in nm_str_buf_append_printf()
(cherry picked from commit 081650eb67)
2020-06-26 10:31:06 +02:00
Beniamino Galvani
27c84a505c libnm: fix wrong assertion in nm_client_check_connectivity_finish()
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/476

Fixes: b44d883d92 ('libnm: implement nm_client_check_connectivity_async() by using GDBusConnection directly')
(cherry picked from commit d0a2eb8f05)
2020-06-25 14:13:53 +02:00
Beniamino Galvani
a1de36d917 libnm: omit nm_device_*_get_hw_address() from introspection output
When the get_hw_address() method is called on a device object through
GObject-introspection, the device-specific
(e.g. nm_device_ethernet_get_hw_address()) C function is called
instead of the more generic nm_device_get_hw_address().

Those device-specific functions were deprecated in commit 067a3d6c08
('nm-device: expose via D-Bus the 'hw-address' property') and so libnm
will print out deprecation warnings like:

 DeprecationWarning: NM.DeviceEthernet.get_hw_address is deprecated

Omit the device-specific function from the introspection output so
that the generic function will be called instead.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/544
(cherry picked from commit 3124a05d83)
2020-06-25 11:05:11 +02:00
Beniamino Galvani
13eb192966 initrd: merge branch 'bg/initrd-ipv6'
https://bugzilla.redhat.com/show_bug.cgi?id=1848943
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/548
(cherry picked from commit 4efd4e0a61)
2020-06-24 14:55:11 +02:00
Beniamino Galvani
440a0b4078 initrd: set ipv6.method=auto when the autoconfiguration field is 'none'
The 7th field of:

 ip=<client-IP>:[<peer>]:<gateway-IP>:<netmask>:<client_hostname>:<interface>:{none|off|dhcp|on|any|dhcp6|auto6|ibft}:[:[<mtu>][:<macaddr>]]

specifies which kind of autoconfiguration to do. 'none' and 'off' mean
static addresses.

The old network module of dracut used to leave kernel IPv6
autoconfiguration enabled when IPv4 static addresses were
configured. With NM, this corresponds to enabling IPv6 auto method.

https://bugzilla.redhat.com/show_bug.cgi?id=1848943
(cherry picked from commit a39eb9ac14)
2020-06-24 14:54:50 +02:00
Beniamino Galvani
0e15a5e1be initrd: generate connections with IPv6 method 'auto' instead of 'ignore'
When the initrd generator creates a connection with IPv6 method
'ignore', the kernel will do IPv6 autoconfiguration on the
interface. However, it is preferable to let NetworkManager configure
the interface directly instead of relying on kernel. Therefore, change
the IPv6 method to 'auto'. Note that we still set ipv6.may-fail to
'yes' so that a failure during IPv6 autoconfiguration doesn't bring
down the interface.

(cherry picked from commit f6d654b18f)
2020-06-24 14:54:49 +02:00
Thomas Haller
a259e10946
shared,core: merge branch 'th/strsplit-quoted-kernel-cmdline'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/549

(cherry picked from commit 827dfacf0f)
2020-06-24 09:02:18 +02:00
Thomas Haller
254528acb6
core: use nm_utils_strsplit_quoted() for splitting the kernel command line
The kernel command line supports escaping and quoting (at least,
according to systemd's parser, which is our example to follow).

Use nm_utils_strsplit_quoted() which supports that.

(cherry picked from commit 27041e9f05)
2020-06-24 09:02:17 +02:00
Thomas Haller
5d2b609e7e
shared: add nm_utils_strsplit_quoted()
We want to parse "/proc/cmdline". That is space separated with support
for quoting and escaping. Our implementation becomes part of stable
behavior, and we should interpret the kernel command line the same way
as the system does. That means, our implementation should match
systemd's.

(cherry picked from commit 10779d545a)
2020-06-24 09:02:17 +02:00
Thomas Haller
61a37bdf13
tests: add nmtst_extract_first_word_all() for testing
We usually don't want to use internal API of systemd for our own
purposes. Here, we will use it to check our implementation against
systemd's. Add an accessor to extract_first_word() for testing.

(cherry picked from commit 2a6ecf2128)
2020-06-24 09:02:17 +02:00
Thomas Haller
4c443ec269
shared: add nm_str_buf_append_c_repeated() helper
(cherry picked from commit a2142e884b)
2020-06-24 09:02:16 +02:00
Thomas Haller
3ed95f308f
shared: make NM_STR_BUF_INIT() an inline function
In the previous form, NM_STR_BUF_INIT() was a macro. That makes sense,
however it's not really possible to make that a macro without evaluating
the reservation length multiple times. That means,

    NMStrBuf strbuf = NM_STR_BUF_INIT (nmtst_get_rand_uint32 () % 100, FALSE);

leads to a crash. That is unfortunate, so instead make it an inline
function that returns a NMStrBut struct. Usually, we avoid functions
that returns structs, but here we do it.

(cherry picked from commit c6809df4cd)
2020-06-24 09:02:16 +02:00
Thomas Haller
5216e5c012
shared: allow empty NMStrBuf buffers with un-allocated memory
Previously, for simplicity, NMStrBuf did not support buffers without any
data allocated. However, supporting that has very little
overhead/complexity, so do it.

Now you can initialize buffers to have no data allocated, and when
appending data, it will automatically grow.

(cherry picked from commit 83c79bc7a8)
2020-06-24 09:01:41 +02:00
Thomas Haller
1d1098f638
libnm: avoid deprecation warning about NMUtilsPredicateStr
NMUtilsPredicateStr got introduced in 1.26.0 API. However, marking the typedef
to be available only in 1.26, causes a compiler warning when using the header:

    /usr/include/libnm/nm-setting.h:372:39: error: ‘NMUtilsPredicateStr’ is deprecated: Not available before 1.26 [-Werror=deprecated-declarations]
      372 |                                       NMUtilsPredicateStr predicate);
          |                                       ^~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors

Avoid that. It's not a problem in practice, because all users of the typedef
are functions that are marked to be available in 1.26 themselves.

(cherry picked from commit 8a13b02d96)
2020-06-22 13:27:19 +02:00
Thomas Haller
6ae1f0e459
libnm: return NULL for boxed strv properties of NMSettingMatch
The API does not allow to distinguish between an unset (NULL) or empty
strv array. For example, nm_setting_match_get_paths() never returns
%NULL, but returns an empty strv array.

On the other hand, the GObject properties of type G_TYPE_STRV have a
default value of %NULL. That means, also the getter should map both
unset and empty to %NULL.

Note that this is a change in behavior w.r.t. 1.24.0 API, where
match.interface-name property would return an empty strv array.
Regrading the other API, this is no change because it is new API
and we will fix it before 1.26.0 release.

(cherry picked from commit 62263e706f)
2020-06-22 12:18:26 +02:00
Thomas Haller
092ab227d5
shared: add nm_strvarray_get_strv_non_empty() helper
(cherry picked from commit d69f057a65)
2020-06-22 12:18:21 +02:00
Beniamino Galvani
3951396de7 settings: fix assertion when updating default wired connection
The connection is expected to have the NM_GENERATED flag, since it has
a default wired device.

Fixes: d35d3c468a ('settings: rework tracking settings connections and settings plugins')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/471
(cherry picked from commit 4aefad5673)
2020-06-22 09:55:04 +02:00
Thomas Haller
28644556e1
shared: fix string truncation in nm_str_buf_append_printf()
If g_vsnprintf() returns that it wants to write 5 characters, it
really needs space for 5+1 characters. If we have 5 characters
available, it would have written "0123\0", which leaves the buffer
broken.

Fixes: eda47170ed ('shared: add NMStrBuf util')
(cherry picked from commit fd34fe50a2)
2020-06-21 22:34:16 +02:00
Yuri Chornoivan
cdd50a0402
po: update Ukrainian (uk) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/543
(cherry picked from commit 38d291f229)
2020-06-19 10:18:22 +02:00
Beniamino Galvani
b1e00a5805 ifcfg-rh: fix memory leak reading tc filters
Fixes: 902bbfdb18 ('ifcfg-rh: add tc support')
(cherry picked from commit 88e8f2829e)
2020-06-18 17:53:21 +02:00
Beniamino Galvani
5e5f7574b4 supplicant: fix memory leak
Fixes: b83f07916a ('supplicant: large rework of wpa_supplicant handling')
(cherry picked from commit e12d32bf56)
2020-06-18 17:53:19 +02:00
Beniamino Galvani
85535ba8ae libnm-core: fix memory leak in match setting
Fixes: 808e837149 ('all: add "path" property to the match setting')
(cherry picked from commit 92208ebd1f)
2020-06-18 14:28:47 +02:00
Beniamino Galvani
26f1074d9d cli: fix reference count handling in hotspot error path
The connection is automatically unreferenced when the function
returns.

Fixes: 9c5ea0917d ('devices: reuse the hotspot connection if we find appropriate one'):
(cherry picked from commit 3ecfd13ded)
2020-06-18 14:28:46 +02:00
Thomas Haller
8ee194ae52
build: fix detecting use of pregenerated docs in "configure.ac"
Without it, we fail to use the pregenerated gtk-doc files.

Fixes: 8a78b15c9b ('docs: merge branch 'th/nm-settings-manual'')
(cherry picked from commit 56b15ca0b6)
2020-06-16 00:04:37 +02:00
Thomas Haller
d7ff630425
release: bump version to 1.25.90 (1.26-rc1) 2020-06-15 17:12:41 +02:00
Thomas Haller
f9e14805e6
firewalld: allow access to SSH in "nm-shared" firewalld zone
SSH seems one of the few really trusted processes. It is even
allowed for the public zone. Allow it in "nm-shared" zone too.
2020-06-15 16:49:14 +02:00
Sayed Shah
be822b52e6
all: reformat python files with python black
Part of !537.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/537
2020-06-15 16:40:38 +02:00
Beniamino Galvani
b6febb0fd0 NEWS: update 2020-06-15 16:02:53 +02:00
Thomas Haller
edfe9fa9a2
glib: always re-implement g_steal_pointer()
g_steal_pointer() is marked as GLIB_AVAILABLE_STATIC_INLINE_IN_2_44,
that means we get a deprecated warning. Avoid that. We anyway
re-implement the macro so that we can use it before 2.44 and so
that it always does the typeof() cast.
2020-06-15 15:56:30 +02:00
Thomas Haller
c56c6e8faa
build: ensure man directory exists for "man/nm-settings-docs-*.xml"
It would seem that the proper dependency is "man/.dirstamp". But that just
doesn't work. Use "man/common.ent" instead. If you figure out how to
convince autotools to make .dirstamp working, send a patch.
2020-06-15 15:34:16 +02:00
Thomas Haller
84a68972df
lldp: merge branch 'th/lldp-mud-url'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/539
2020-06-15 15:05:31 +02:00
Thomas Haller
d0ce1eb351
lldp: omit empty "object-id" for LLDP management address
It seems common that the object-id might be empty. Omit the
field in that case.
2020-06-15 15:05:25 +02:00
Thomas Haller
dc08b42f45
lldp: expose "mud-url" LLDP attribute for the MUD usage description
See-also: https://github.com/systemd/systemd/pull/15234
See-also: c4f8796bf8/tests/lldp_mudurl.pcap
2020-06-15 15:05:22 +02:00
Thomas Haller
4043f82790
lldp: cleanup converting binary LLDP fields to string
Introduce and use format_string() helper to convert the binary fields
to string.

This is like systemd's parse_string() function.
2020-06-15 15:02:53 +02:00
Beniamino Galvani
6e02622f57 Revert "manager: change autoconnect-slaves logic for already active slaves"
The commit breaks many nmstate CI tests. It also breaks the
autoconnect-slaves functionality: if the master gets reactivated and
the slave was active, the slave is not reconnected.

A different solution is needed for the original issue.

This reverts commit 024e983c8e.
2020-06-15 09:51:25 +02:00