Commit graph

26800 commits

Author SHA1 Message Date
Beniamino Galvani
613f74b545 initrd: merge branch 'bg/initrd-mac-iface'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/632
2020-09-24 10:55:13 +02:00
Thomas Haller
c17468665d
l3cfg: merge branch 'th/l3cfg-10'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/629
2020-09-24 09:44:45 +02:00
Thomas Haller
7141537097
l3cfg/tests: add unit test for NML3Cfg 2020-09-24 09:44:04 +02:00
Thomas Haller
3695949151
l3cfg/device: drop NML3Cfg references from NMDevice for now
Adding NML3Cfg support is a large effort that is done in parallel.
While already parts of the code is merged, it is not actually used
yet. Remove the parts from NMDevice that interact with NML3Cfg
before we actually start using it.

The point is that we might want to do a release before switching
over to the new way. For that release, we should not have the unused
code in NMDevice.

This patch will later be restored and extended.
2020-09-24 09:44:03 +02:00
Thomas Haller
441de0f0f8
l3cfg: fix leaking l3_config_datas array in NML3Cfg
But also take a reference whenever we have any configurations
registered. Registering a configuration means to automatically
keep the instance alive.

Any user must take care to unregister again when it no longer requires
the configuration.
2020-09-24 09:44:02 +02:00
Thomas Haller
042112ea2d
l3cfg: various fixes for l3cfg 2020-09-24 09:44:01 +02:00
Thomas Haller
d627ec7075
platform/tests: add nmtstp_platform_ip_addresses_assert() test helper 2020-09-24 09:44:00 +02:00
Thomas Haller
9f91e0b26d
platform/tests: add nmtstp_platform_ip_address_find() test util 2020-09-24 09:43:59 +02:00
Thomas Haller
e232ce93d0
platform: add NM_PLATFORM_IP[46]_ADDRESS_INIT() helper macros 2020-09-24 09:43:58 +02:00
Thomas Haller
6efd4e2efa
tests: use in_addr_t type for IPv4 addresses in test helpers 2020-09-24 09:43:58 +02:00
Thomas Haller
adb78bd471
tests: mark static variables in test helpers as thread local
We should avoid static variables in general, but for test helpers they
are often convenient.

Mark them as thread local to make them safer to use. The only downsides
may only be some runtime overhead, which is negligible for unit tests.
2020-09-24 09:43:57 +02:00
Thomas Haller
23a6965ce2
l3cfg: add nm_l3_config_data_log() function 2020-09-24 09:43:56 +02:00
Thomas Haller
7ff1beabdb
l3cfg: let l3cfg emit signal on idle handler for platform changes
Currently all NMDevice instance register to the platform change signals,
then if a signal for their IP ifindex appears, they schedule a task on
an idle handler. That is wasteful.

NML3Cfg already gets a notification on an idle handler and can just re-emit
it to the respective listeners.

With this, there is only one subscriber to the platform signals (NMNetns)
which then multiplexes the signals to the right NML3Cfg instances, and
further.
2020-09-24 09:43:55 +02:00
Thomas Haller
000ad171e3
l3cfg: add nm_l3cfg_has_commited_ipv6_pending_dad() function
This will be used for tracking IPv6 addresses that still have DAD pending.
Currently, NMDevice does it differently (see "dad6").
2020-09-24 09:43:55 +02:00
Thomas Haller
dbfb7fe2d7
l3cfg: add nm_l3_config_data_lookup_address_6() helper 2020-09-24 09:43:54 +02:00
Thomas Haller
62f2c5a879
platform: refactor nm_platform_ip6_address_get() function to accept pointer instead of "struct in6_addr"
While C is fine with accepting structs as function arguments,
we usually don't do that for IPv6 addresses. Accept a pointer
instead.
2020-09-24 09:43:54 +02:00
Thomas Haller
1215b6cc30
l3cfg: track both the commited and the currently merged l3cd instance
The caller may want to know the merge NML3ConfigData as it would be used
for the next commit, without already committing it.

Track both the NML3ConfigData instance that is merged from the
registered items, and the one that was used the last time during
commit.
2020-09-24 09:43:54 +02:00
Thomas Haller
79913fb446
l3cfg: allow %NULL argument for nm_l3_config_data_ref()
It's often convenient not to require the caller to check for
%NULL. On the other hand, there are cases where having a %NULL instance
is a bug, so gracefully accepting %NULL might hide bugs.

Still, change it.
2020-09-24 09:43:53 +02:00
Thomas Haller
1b79b33206
shared: add NM_PRINT_FMT_QUOTED2() helper macro 2020-09-24 09:43:53 +02:00
Thomas Haller
417737934e
license: add Daniel to RELICENSE.md
https://mail.gnome.org/archives/networkmanager-list/2020-September/msg00010.html
2020-09-24 09:35:00 +02:00
Thomas Haller
0ad2d4d96d
libnm, shared: merge branch 'th/hwaddr-cleanup' 2020-09-23 13:58:05 +02:00
Thomas Haller
2fdc713e92
libnm: relax asserting argument for nm_utils_hwaddr_len()
nm_utils_hwaddr_len() isn't very useful. It's documented to
only accept two possible input values (ARPHRD_ETHER and ARPHRD_INFINIBAND)
for which the respective return values are well known.

In particular, asserting that the input value is one of the two values
means it becomes harder to extend the function (and make it more useful).
Because, then the user would need to call:

     #if NM_VERSION > NM_VERSION_1_XX
     len = nm_utils_hwaddr_len (ARPHDR_FOO);
     #else
     len = 0
     #endif

and then it would introduce an unnecessary run time dependency on
NM_VERSION_1_XX.

Instead, just document to return 0 if the value is not supported.
2020-09-23 13:57:38 +02:00
Thomas Haller
2d360d8293
cloud-setup: add code comment to nmcs_utils_hwaddr_normalize() 2020-09-23 13:57:38 +02:00
Thomas Haller
dea59122e7
shared: move nm_utils_hwaddr_ntoa_buf() to shared/ as _nm_utils_hwaddr_ntoa()
The name is better as it mirrors nm_utils_hwaddr_aton(). Also, move
it to shared/ so it can be reused (and inlined).
2020-09-23 13:57:37 +02:00
Thomas Haller
74c03da086
shared: move _nm_utils_hwaddr_aton() to shared/
_nm_utils_hwaddr_aton() is only a wrapper around nm_utils_hexstr2bin_full().
But it abstracts the "right" parameters for what we consider a valid MAC
address and what not. As such, this function is useful.

Move it to "shared/" and replace the dupicate macro hwaddr_aton() with
it.
2020-09-23 13:57:04 +02:00
Thomas Haller
d5d45c8ce6
libnm: cleanup nm_utils_hwaddr_canonical() and nm_utils_hwaddr_valid()
- only call hwaddr_aton() once per function. Also, pass it sizeof(buf)
  as buffer size, it seems more correct.

- the only downside is that we now would always first parse up to 20
  characters, before comparing the requested length. Previously, a
  MAC address that was too long was rejected earlier (and the parsing
  aborted earlier). But that is a tiny overhead, also we expect that
  in common cases the MAC addresses are in fact of the right size,
  then there is no difference.
2020-09-23 13:54:32 +02:00
Thomas Haller
dc3a477884
all/style: remove duplicate semicolon (";;") in sources 2020-09-23 12:43:47 +02:00
Thomas Haller
20ce16cc7b
license: add Kjartan to RELICENSE.md
https://mail.gnome.org/archives/networkmanager-list/2020-September/msg00008.html
2020-09-23 12:32:56 +02:00
Beniamino Galvani
364c7c278a initrd: fix parsing IPv6 prefix length
The generator didn't accept prefix lengths > 32 for IPv6:

$ src/initrd/nm-initrd-generator --stdout -- ip=[fd01::1]:::40::ens0
 <warn>  [1600851580.7875] cmdline-reader: Invalid IP mask: 40

https://bugzilla.redhat.com/show_bug.cgi?id=1879795
2020-09-23 11:00:19 +02:00
Thomas Haller
b8811d97a4
all: require a semicolon after NM_CACHED_QUARK_FCN() 2020-09-23 10:55:17 +02:00
Beniamino Galvani
f223644291 initrd: accept mac address as interface specifier
The interface can be specified either by name or MAC address:

ip=192.0.2.2:::::eth0
ip=192.0.2.2:::::00-11-22-33-44-55

https://bugzilla.redhat.com/show_bug.cgi?id=1879795
2020-09-23 10:29:24 +02:00
Antonio Cardace
41147c4d17
clang-format: proposed style 2020-09-23 09:07:10 +02:00
Thomas Haller
bad4065d67
contrib/release: implement "rc1" release mode 2020-09-23 08:58:47 +02:00
Thomas Haller
e8e5c12480
libnm: hide nm_setting_ip_config_next_valid_dns_option() function from headers
nm_setting_ip_config_next_valid_dns_option() API was added in libnm 1.2, but
it was never exported in the ABI of libnm. It thus was unusable, and any user
trying to link against it would have been unable to do so.

Hide the API now entirely. It doesn't seem a very nice API. If we want to
allow the user to validate option names, we should expose such a function
to validate an option (not to fetch the next valid option from a
profile).

Fixes: 019943bb5d ('libnm-core: add dns-options property to NMSettingIPConfig')
2020-09-22 18:04:11 +02:00
Thomas Haller
e8dd19bb01
shared: extend nm_utils_hexstr2bin_full() to require hexdigits in pairs
nm_utils_hexstr2bin_full() is our general hexstr to binary parsing
method. It uses (either mandatory or optional) delimiters. Before,
if delimiters are in use, it would accept individual hexdigits.
E.g. "a:b" would be accepted as "0a:0b:.

Add an argument that prevents accepting such single digits.
2020-09-22 17:40:41 +02:00
letmestudy
798cf37621
po: correct Chinese translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/628
2020-09-21 12:59:21 +02:00
Thomas Haller
f0ec4bb59a
license: add SUSE LLC to RELICENSE.md
This also includes the contributions made by Ximian (bought
by Novell) and by Novell.

https://mail.gnome.org/archives/networkmanager-list/2020-September/msg00000.html
2020-09-18 15:47:04 +02:00
Thomas Haller
86f2ea66f5
l3cfg: merge branch 'th/l3cfg-9'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/626
2020-09-18 15:26:49 +02:00
Thomas Haller
5e84143378
core: assert that nm_dbus_utils_get_property() returns a variant of the expected type
g_dbus_gvalue_to_gvariant() doesn't check/assert that the value has the
right variant signature, if the value is already a GVariant.

Add an assertion.
2020-09-18 15:26:40 +02:00
Thomas Haller
51b7d351fa
core: fix D-Bus type for "org.freedesktop.NetworkManager.Capabilities" property
Fixes: 297d4985ab ('core/dbus: rework D-Bus implementation to use lower layer GDBusConnection API')
2020-09-18 15:26:39 +02:00
Thomas Haller
0a579fd16e
device: return same singleton variant for NM_DEVICE_IP4_ADDRESS property
All our devices will return the same value on D-Bus: a "u" variant with zero value.
Since NMDBusObject caches all the property values, we can share the instance.
2020-09-18 15:26:38 +02:00
Thomas Haller
479de883b3
shared: add m_g_variant_singleton_u_0()
We anyway cache our variants for the properties of NMDBusObject instances.
If such a variant is well known to be always the same, there is no need
to allocate a new instance every time. In particular, because GVariant
is an immutable and ref counted type.

Add a singleton getter for a "u" variant with numeric value 0.
2020-09-18 15:26:37 +02:00
Thomas Haller
72d6062cb0
device: break deprecated "Ip4Address" D-Bus property of Device interface
The "Ip4Address" property of "org.freedesktop.NetworkManager.Device"
interface is deprecated since version 0.9.9.1 (2013). Also, the property
is not exposed by libnm and generally not useful.

Drop the code to maintain it. The property still exists but always
returns 0 (0.0.0.0).
2020-09-18 15:26:21 +02:00
Thomas Haller
535fb95745
l3cd/ndisc: add nm_ndisc_data_to_l3cd() helper
NML3ConfigData is a simple container structure that contains no logic.
Also, DHCP code already is intimately related to NMIP[46]Config (for
now, later that will be NML3ConfigData).

It makes sense that NMNDisc is aware of NML3ConfigData and knows how to
conver the RA data into an l3cd instance.
2020-09-15 18:58:50 +02:00
Thomas Haller
d69b8ecd34
l3cfg: add nm_l3_config_data_clear_searches() API 2020-09-15 18:58:49 +02:00
Thomas Haller
b850cea874
l3cfg: add nm_l3_config_data_{get,set}_ip6_mtu() API 2020-09-15 18:07:24 +02:00
Thomas Haller
9802c89972
l3cfg: add nm_l3_config_data_{get,set}_ndisc_*() API 2020-09-15 17:45:35 +02:00
Thomas Haller
ef26ed3092
l3cfg: fix handling of mtu during nm_l3_config_data_merge()
Fixes: 25d404dadb ('l3cfg: add more API to NML3ConfigData')
2020-09-15 16:06:33 +02:00
Thomas Haller
81d7009956
l3cfg: track ip6_privacy (use_tempaddr) in NML3ConfigData
NMDevice currently configures use_tempaddr sysctl itself. Later,
NML3Cfg should do that, so we need to keep track of that as part
of the configuration.
2020-09-15 16:06:32 +02:00
Thomas Haller
be5f7ab7c9
device/ndisc: explicitly call nm_ndisc_stop() during addrconf6_cleanup() 2020-09-15 15:37:19 +02:00