Commit graph

26789 commits

Author SHA1 Message Date
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
Thomas Haller
b8811d97a4
all: require a semicolon after NM_CACHED_QUARK_FCN() 2020-09-23 10:55:17 +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
Thomas Haller
6ce482c526
device/ndisc: add nm_ndisc_stop() method
It is bad style to rely on the last unref of an object for stopping
the operation. With a ref-counted object you should never rely on
anybody else still having (or not having) a reference. Hence, you
should not rely on stopping the ND during the last unref.

Add an explicit nm_ndisc_stop() function.
2020-09-15 15:36:19 +02:00
Thomas Haller
e8eaaa78d1
device/ndisc: let calling code determine the used RA timeout for NMNDisc
Previously, if we passed ra_timeout 0 to NMNDisc, then it would
calculate the effective timeout based on the router-solicitations
and the router-solicitation-interval.

The caller may want to know the used timeout, to also run its own timers
with the same timeout. Hence, it cannot leave this automatism internal
to NMNDisc.
2020-09-15 15:08:03 +02:00
Thomas Haller
f6692367b1
libnm: mark static buffer for nm_utils_inet[46]_ntop() as thread local
I think the convenience feature about omitting the output buffer is
undesirable. Anyway, try to make it safer by using a thread local
buffer.
2020-09-15 15:08:03 +02:00
Thomas Haller
f295e1313a
core: use _nm_utils_inet4_ntop() instead of nm_utils_inet4_ntop()
nm_utils_inet4_ntop() is public API of libnm. Also, it accepts a
%NULL buffer to use a static buffer. That is error prone and we
should not use such convenience behavior for our own code.
2020-09-15 15:08:02 +02:00
Thomas Haller
026389fc1f
supplicant: fix crash in _scan_notify_allowed() when supplicant disconnects
When stopping wpa_supplicant, I got an assertion failure:

  #0  g_logv (log_domain=0x55f8e4a43013 "NetworkManager", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=<optimized out>) at ../glib/gmessages.c:1377
  #1  0x00007f2d33245233 in g_log (log_domain=log_domain@entry=0x55f8e4a43013 "NetworkManager", log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0x7f2d332976ff "%s: assertion '%s' failed") at ../glib/gmessages.c:1415
  #2  0x00007f2d33245a2d in g_return_if_fail_warning (log_domain=log_domain@entry=0x55f8e4a43013 "NetworkManager", pretty_function=pretty_function@entry=0x55f8e4acc1e0 <__func__.14> "nm_supplicant_interface_get_state", expression=expression@entry=0x55f8e4acb450 "NM_IS_SUPPLICANT_INTERFACE (self)") at ../glib/gmessages.c:2771
  #3  0x000055f8e49ab3f2 in nm_supplicant_interface_get_state (self=0x0) at src/supplicant/nm-supplicant-interface.c:2581
  #4  0x00007f2d1f7307a4 in _scan_notify_allowed (self=self@entry=0x55f8e5199cf0 [NMDeviceWifi], do_kickoff=do_kickoff@entry=NM_TERNARY_FALSE) at src/devices/wifi/nm-device-wifi.c:514
  #5  0x00007f2d1f730ed3 in supplicant_iface_state (self=0x55f8e5199cf0 [NMDeviceWifi], new_state=<optimized out>, old_state=NM_SUPPLICANT_INTERFACE_STATE_COMPLETED, disconnect_reason=<optimized out>, is_real_signal=<optimized out>) at src/devices/wifi/nm-device-wifi.c:2492
  #6  0x00007f2d32339af0 in ffi_call_unix64 () at ../src/x86/unix64.S:76
  #7  0x00007f2d323392ab in ffi_call (cif=cif@entry=0x7ffcaf6c3120, fn=fn@entry=0x7f2d1f731920 <supplicant_iface_state_cb>, rvalue=<optimized out>, avalue=avalue@entry=0x7ffcaf6c3050) at ../src/x86/ffi64.c:525
  #12 0x00007f2d3334ac63 in <emit signal ??? on instance 0x55f8e4f49bb0 [NMSupplicantInterface]> (instance=instance@entry=0x55f8e4f49bb0, signal_id=<optimized out>, detail=detail@entry=0) at ../gobject/gsignal.c:3554
      #8  0x00007f2d3333238d in g_cclosure_marshal_generic (closure=closure@entry=0x55f8e521eb10, return_gvalue=return_gvalue@entry=0x0, n_param_values=n_param_values@entry=4, param_values=param_values@entry=0x7ffcaf6c3320, invocation_hint=invocation_hint@entry=0x7ffcaf6c32a0, marshal_data=marshal_data@entry=0x0) at ../gobject/gclosure.c:1500
      #9  0x00007f2d3333188a in g_closure_invoke (closure=0x55f8e521eb10, return_value=return_value@entry=0x0, n_param_values=4, param_values=param_values@entry=0x7ffcaf6c3320, invocation_hint=invocation_hint@entry=0x7ffcaf6c32a0) at ../gobject/gclosure.c:810
      #10 0x00007f2d33344423 in signal_emit_unlocked_R (node=node@entry=0x7f2d200066c0, detail=detail@entry=0, instance=instance@entry=0x55f8e4f49bb0, emission_return=emission_return@entry=0x0, instance_and_params=instance_and_params@entry=0x7ffcaf6c3320) at ../gobject/gsignal.c:3742
      #11 0x00007f2d3334aaf9 in g_signal_emit_valist (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>, var_args=var_args@entry=0x7ffcaf6c34f0) at ../gobject/gsignal.c:3498
  #13 0x000055f8e49a880b in _emit_signal_state (disconnect_reason=0, old_state=NM_SUPPLICANT_INTERFACE_STATE_COMPLETED, new_state=<optimized out>, self=0x55f8e4f49bb0 [NMSupplicantInterface]) at src/supplicant/nm-supplicant-interface.c:1083
  #14 set_state_down (self=0x55f8e4f49bb0 [NMSupplicantInterface], force_remove_from_supplicant=0, reason=0x55f8e4acd918 "InterfaceRemoved signal from wpa_supplicant") at src/supplicant/nm-supplicant-interface.c:1083
  #15 0x000055f8e49acb0b in _supp_iface_remove_one (self=0x55f8e51990c0 [NMSupplicantManager], supp_iface=0x55f8e4f49bb0 [NMSupplicantInterface], force_remove_from_supplicant=0, reason=0x55f8e4acd918 "InterfaceRemoved signal from wpa_supplicant") at src/supplicant/nm-supplicant-manager.c:1067
  #16 0x000055f8e49accec in _dbus_interface_removed_cb (connection=<optimized out>, sender_name=0x7f2d20038f20 ":1.4741", object_path=<optimized out>, signal_interface_name=<optimized out>, signal_name=<optimized out>, parameters=<optimized out>, user_data=0x55f8e51990c0) at src/supplicant/nm-supplicant-manager.c:902
  #17 0x00007f2d33483c0f in emit_signal_instance_in_idle_cb (data=data@entry=0x7f2d20034750) at ../gio/gdbusconnection.c:3777
  #18 0x00007f2d3323945b in g_idle_dispatch (source=source@entry=0x7f2d20038db0, callback=0x7f2d33483b90 <emit_signal_instance_in_idle_cb>, user_data=0x7f2d20034750) at ../glib/gmain.c:5755
  #19 0x00007f2d3323d78f in g_main_dispatch (context=0x55f8e4ee31e0) at ../glib/gmain.c:3309
  #20 g_main_context_dispatch (context=0x55f8e4ee31e0) at ../glib/gmain.c:3974
  #21 0x00007f2d3323db18 in g_main_context_iterate (context=0x55f8e4ee31e0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/gmain.c:4047
  #22 0x00007f2d3323de33 in g_main_loop_run (loop=0x55f8e4ec4d20) at ../glib/gmain.c:4241
  #23 0x000055f8e4755a3b in main (argc=<optimized out>, argv=<optimized out>) at src/main.c:456

Fixes: 7500e90b53 ('wifi: rework scanning of Wi-Fi device')
2020-09-15 15:00:14 +02:00
Sayed Shah
518187e8db platform: add support for mcast_hash_max netlink attribute for bridges
Adding the mcast_hash_max property. The value must be the power of 2.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/624
2020-09-15 13:41:29 +02:00
Thomas Haller
88425e569f
device: merge branch 'th/device-track-shared-ips'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/625
2020-09-15 12:01:52 +02:00
Thomas Haller
3338ea0530
device: track used shared-ips via NMNetns
Note that when NetworkManager tries to allocate more than 256 networks,
then previously the allocation would fail. We no longer fail, but log an
error and reuse the last address (10.42.255.1/24).

It's simpler to have code that cannot fail, because it's often hard to
handle failure properly. Also, if the user would configure two shared
profiles that explicitly use the same subnet, we also wouldn't fail. Why
not? Is that not a problem as well? If it is not, there is no need to
fail in this case. If it is a problem, then it would be much more
important to handle this case otherwise -- since it's more likely to
activate two profiles that accidentally use the same subnet than
activating 257+ shared profiles.
2020-09-14 17:30:59 +02:00
Thomas Haller
3fcfb53c4b
core: add nm_netns_shared_ip_reserve() API
Add a better way of tracking the shared IP addresses that are in use.
This will replace NMDevice's usage of a global hash table. For one, the
API is more formalized with reserve() and release() functions.
Also, it ties the used IP addresses to the netns, which would be more
correct (in the future when we may support more netns).
2020-09-14 17:28:10 +02:00
Thomas Haller
991999489a
contrib/build: reword howto for "release.sh" script 2020-09-14 16:11:54 +02:00
Beniamino Galvani
7f8426538b release: bump version to 1.27.3 (development) 2020-09-14 15:23:59 +02:00