Commit graph

26129 commits

Author SHA1 Message Date
Beniamino Galvani
d0a2eb8f05 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')
2020-06-25 14:11:36 +02:00
Beniamino Galvani
3124a05d83 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
2020-06-25 11:03:23 +02:00
Beniamino Galvani
4efd4e0a61 initrd: merge branch 'bg/initrd-ipv6'
https://bugzilla.redhat.com/show_bug.cgi?id=1848943
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/548
2020-06-24 10:38:58 +02:00
Beniamino Galvani
a39eb9ac14 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
2020-06-24 10:37:31 +02:00
Beniamino Galvani
f6d654b18f 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.
2020-06-24 10:37:31 +02:00
Thomas Haller
827dfacf0f
shared,core: merge branch 'th/strsplit-quoted-kernel-cmdline'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/549
2020-06-24 08:40:17 +02:00
Thomas Haller
27041e9f05
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.
2020-06-23 00:42:37 +02:00
Thomas Haller
10779d545a
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.
2020-06-23 00:42:37 +02:00
Thomas Haller
2a6ecf2128
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.
2020-06-22 23:09:05 +02:00
Thomas Haller
a2142e884b
shared: add nm_str_buf_append_c_repeated() helper 2020-06-22 21:33:59 +02:00
Thomas Haller
c6809df4cd
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.
2020-06-22 21:20:03 +02:00
Thomas Haller
8a13b02d96
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.
2020-06-22 13:24:43 +02:00
Thomas Haller
62263e706f
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.
2020-06-22 11:59:21 +02:00
Thomas Haller
d69f057a65
shared: add nm_strvarray_get_strv_non_empty() helper 2020-06-22 11:57:25 +02:00
Beniamino Galvani
4aefad5673 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
2020-06-22 09:38:12 +02:00
Thomas Haller
fd34fe50a2
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')
2020-06-21 12:41:53 +02:00
Thomas Haller
83c79bc7a8
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.
2020-06-20 19:22:04 +02:00
Thomas Haller
8ba4537b24
all: merge branch 'th/stdict-values'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/531
2020-06-19 18:07:16 +02:00
Thomas Haller
bb6c2d7371
libnm: ensure stable behavior in _nm_ip_route_attribute_validate_all()
Check the attributes in a defined, stable order. This is necessary,
so that consistently the same error gets reported.
2020-06-19 17:14:10 +02:00
Thomas Haller
19b6d38932
libnm: use nm_utils_named_values_from_strdict() in "nm-setting-tc-config.c" 2020-06-19 17:07:27 +02:00
Thomas Haller
83146b3ec2
libnm: add missing since gtk-doc for nm_tc_action_get_attribute_names() 2020-06-19 17:07:27 +02:00
Thomas Haller
fff812e255
shared: refactor nm_utils_strdict_to_variant_ass() to use nm_utils_named_values_from_strdict()
It is pretty much the same code this way, but shorter.
2020-06-19 17:07:26 +02:00
Thomas Haller
cdb38df7e5
shared,core: rename and move function to nm_utils_strdict_to_variant_asv() 2020-06-19 17:07:26 +02:00
Thomas Haller
91d6461761
ifcfg-rh: use nm_utils_named_values_from_strdict() in write_secrets() 2020-06-19 17:07:26 +02:00
Thomas Haller
ee9e1ceefc
shared: avoid allocating temporary buffer for nm_utils_named_values_from_strdict()
Iterating hash tables gives an undefined order. Often we want to have
a stable order, for example when printing the content of a hash or
when converting it to a "a{sv}" variant.

How to achieve that best? I think we should only iterate the hash once,
and not require additional lookups. nm_utils_named_values_from_strdict()
achieves that by returning the key and the value together. Also, often
we only need the list for a short time, so we can avoid heap allocating
the list, if it is short enough. This works by allowing the caller to
provide a pre-allocated buffer (usually on the stack) and only as fallback
allocate a new list.
2020-06-19 17:07:25 +02:00
Thomas Haller
4d6b96b48f
shared: make NMUtilsNamedValue.value_ptr non const
If the value pointer is const, it is commonly inconvenient and requires
a cast. Requiring casts on a common base does not increase type safety,
but is annoying.
2020-06-19 17:07:19 +02:00
Thomas Haller
d64eb7201e
build: merge branch 'ss/python-improvements'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/540
2020-06-19 12:59:13 +02:00
Thomas Haller
8c3ee4e857
gitlab-ci: enable python black check in gitlab-ci 2020-06-19 12:58:52 +02:00
Thomas Haller
70f3ad6785
gitlab-ci: run checkpatch test against fedora:32 target 2020-06-19 12:47:15 +02:00
Thomas Haller
c537852231
build: optionally skip python black check by setting NMTST_SKIP_PYTHON_BLACK=1 2020-06-19 12:46:20 +02:00
Sayed Shah
9f77d26ad0
build: create check for python black
If python black is install then it would check the
formating of all of the python files and test the for it.
Otherwise, it would just simply ignore the python black
if python black is not installed.
2020-06-19 12:34:40 +02:00
Yuri Chornoivan
38d291f229
po: update Ukrainian (uk) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/543
2020-06-19 10:17:11 +02:00
Beniamino Galvani
88e8f2829e ifcfg-rh: fix memory leak reading tc filters
Fixes: 902bbfdb18 ('ifcfg-rh: add tc support')
2020-06-18 17:45:45 +02:00
Beniamino Galvani
e12d32bf56 supplicant: fix memory leak
Fixes: b83f07916a ('supplicant: large rework of wpa_supplicant handling')
2020-06-18 17:45:43 +02:00
Beniamino Galvani
92208ebd1f libnm-core: fix memory leak in match setting
Fixes: 808e837149 ('all: add "path" property to the match setting')
2020-06-18 14:26:00 +02:00
Beniamino Galvani
3ecfd13ded 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'):
2020-06-18 14:25:58 +02:00
Antonio Cardace
3e21357888
platform: merge branch 'ac/local_route'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/526
2020-06-16 10:46:25 +02:00
Antonio Cardace
7781f78435
setting-ip-config: validate route attributes in verify()
It's better to verify these route attributes so that the user can be
notified early if something is not supported or invalid.

The downside is that some incorrect profiles (with invalid route attributes)
that previously would work since this commit will not anymore as
the incorrect bits don't get ignored but rejected instead.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/407
https://bugzilla.redhat.com/show_bug.cgi?id=1821787
2020-06-16 10:01:26 +02:00
Antonio Cardace
5d0d13f570
platform: add support for local routes
Also update unit tests.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/407
https://bugzilla.redhat.com/show_bug.cgi?id=1821787
2020-06-16 10:01:22 +02:00
Thomas Haller
56b15ca0b6
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'')
2020-06-16 00:04:02 +02:00
Thomas Haller
b378524507
release: bump version to 1.27.0 (development) 2020-06-15 17:13:38 +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