Commit graph

12650 commits

Author SHA1 Message Date
Thomas Haller
d50856b5c6 manager: drop devices_inited field in NManagerPrivate for devices_inited_id
It is redundant. Drop it.

Also, we don't need to cancel and reschedule the idle source in
nm_manager_start(). First of all, it really shouldn't be pending.
Second, contrary to a timer, when an idle source is already pending,
then the pending one will run at the right time.
2020-02-14 11:56:44 +01:00
Thomas Haller
de62da297e all: drop explicit casts from _GET_PRIVATE() macro calls
The _GET_PRIVATE() macros are all implemented based on
_NM_GET_PRIVATE(). That macro tries to be more type safe and uses
_Generic() to do the right thing. Explicitly casting is not only
unnecessary, it defeats these (static) type checks.

Don't do that.
2020-02-14 11:04:46 +01:00
Thomas Haller
d165787b54 device/trivial: add FIXME comment about simplifying deactivate_async() 2020-02-14 10:10:26 +01:00
Thomas Haller
f0bc4aa525 device: move supplicant_timeout_id into supplicant struct in NMDeviceEthernetPrivate
The supplicant struct is there to group related variables.

Move supplicant_timeout_id there.
2020-02-14 09:48:37 +01:00
Thomas Haller
c23c2e2f94 device: reorder fields in NMDeviceEthernetPrivate struct 2020-02-14 09:48:37 +01:00
Thomas Haller
098c0d5092 device: inline "struct Supplicant" to where it is used 2020-02-14 09:48:37 +01:00
Thomas Haller
984e94f01d supplicant: expose nm_supplicant_driver_to_string() helper function
Will be useful later.
2020-02-14 09:48:37 +01:00
Thomas Haller
cd31437024 shared: drop _STATIC variant of macros that define functions
Several macros are used to define function. They had a "_STATIC" variant,
to define the function as static.

I think those macros should not try to abstract entirely what they do.
They should not accept the function scope as argument (or have two
variants per scope). This also because it might make sense to add
additional __attribute__(()) to the function. That only works, if
the macro does not pretend to *not* define a plain function.

Instead, embrace what the function does and let the users place the
function scope as they see fit.

This also follows what is already done with

    static NM_CACHED_QUARK_FCN ("autoconnect-root", autoconnect_root_quark)
2020-02-13 17:17:07 +01:00
Thomas Haller
487141d4a8 shared: add entry_cmd argument to NM_UTILS_STRING_TABLE_LOOKUP_DEFINE*() macro
This extra argument allows to tweak whether to assert for the input argument name.
2020-02-13 10:46:34 +01:00
Antonio Cardace
904050dd2d nm-logging: fix stack-use-after-scope error detected by asan
asan error:

==6291==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7ffe6af12880 at pc 0x7fc8dd3321cd bp 0x7ffe6af11be0 sp 0x7ffe6af11388
READ of size 15 at 0x7ffe6af12880 thread T0
    #0 0x7fc8dd3321cc  (/lib64/libasan.so.5+0x4e1cc)
    #1 0x7fc8dcebcf29 in sd_journal_sendv ../src/journal/journal-send.c:226
    #2 0x74d834 in _nm_log_impl ../src/nm-logging.c:778
    #3 0x42485c in main ../src/main.c:379
    #4 0x7fc8dca1b1a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
    #5 0x427e3d in _start (/work/NetworkManager/build/src/NetworkManager+0x427e3d)

Address 0x7ffe6af12880 is located in stack of thread T0 at offset 736 in frame
    #0 0x74c26f in _nm_log_impl ../src/nm-logging.c:663

  This frame has 9 object(s):
    [48, 56) 's_log_domains' (line 744)
    [80, 88) 'l_log_domains' (line 745)
    [112, 128) 'tv' (line 666)
    [144, 168) 'args' (line 664)
    [208, 240) 'g_copy' (line 670)
    [272, 312) 'cur_log_state_copy' (line 669)
    [352, 392) 'iov_free_data' (line 730)
    [432, 672) 'iov_data' (line 728)
    [736, 1024) 's_log_domains_buf' (line 743) <== Memory access at offset 736 is inside this variable
2020-02-12 16:21:47 +01:00
Thomas Haller
8e636186c0 core: for WireGuard devices use a default dns-priority of 50 (like for VPNs) 2020-02-12 11:55:30 +01:00
Thomas Haller
7d87d2b8da device: add nm_device_is_vpn() function 2020-02-12 11:55:30 +01:00
Thomas Haller
c69d703017 all: use g_ascii_strcasecmp() instead of the locale dependent strcasecmp()
In all the cases, we don't want to perform locale dependent comparison.

  $ sed -i 's/\<strcasecmp\>/g_ascii_\0/g' $(git grep -w -l strcasecmp -- ':(exclude)shared/systemd/' )
2020-02-11 15:23:06 +01:00
Beniamino Galvani
45521b1b38 dhcp: nettools: move to failed state if event dispatch fails 2020-02-11 09:26:07 +01:00
Beniamino Galvani
554e9be5b0 team: ignore bus name appearance when killing teamd
If we are currently killing teamd, we are not interested in knowing
when it becomes ready.
2020-02-11 09:17:11 +01:00
Beniamino Galvani
e94d76382c team: ignore bus name appearance if we can't determine process id
If the GetConnectionUnixProcessID() call fails, the process that
registered on the bus has died and we should ignore the name
appearance event.
2020-02-11 09:17:11 +01:00
Thomas Haller
8a4fecbf65 wifi: cleanup property setters in "wifi/nm-wifi-p2p-peer.c" 2020-02-10 19:11:50 +01:00
Thomas Haller
cc002ed3c1 wifi: move nm_wifi_utils_parse_ies() to "src/nm-core-utils.h"
We will need it in "src/supplicant".
2020-02-10 19:11:50 +01:00
Thomas Haller
05ff735ec0 wifi: move nm_wifi_utils_level_to_quality() to "src/nm-core-utils.h"
It will be used outside of Wi-Fi device plugin. Namely, NMSupplicantInterface
needs to convert the signal strength from supplicant to percent.
2020-02-10 19:11:50 +01:00
Thomas Haller
837e71a374 supplicant: move defines for supplicant D-Bus API to header 2020-02-10 19:11:50 +01:00
Thomas Haller
bf9e016a13 supplicant: use nm_utils_error_is_cancelled() instead of g_error_matches() 2020-02-10 19:11:50 +01:00
Thomas Haller
2a831a9eae supplicant: drop unused detection for credreq 2020-02-10 19:11:50 +01:00
Thomas Haller
2685079c63 supplicant: drop unused NM_SUPPLICANT_INTERFACE_CREDENTIALS_REQUEST signal 2020-02-10 19:11:50 +01:00
Thomas Haller
c5f58619c7 supplicant: remove unused nm_supplicant_interface_credentials_reply()
Also, it is a synchronous D-Bus call. Get rid of the unused function.
2020-02-10 19:11:50 +01:00
Thomas Haller
3228fcbe9a supplicant: define wpas_state_string_to_enum() via NM_UTILS_STRING_TABLE_LOOKUP_DEFINE()
We frequently have code that converts a string to number/enum.
Use a preferred implementation via the NM_UTILS_STRING_TABLE_LOOKUP_DEFINE()
macro.

Also, this does binary search, so in most cases it's (slightly) faster.
2020-02-10 19:11:50 +01:00
Thomas Haller
6cb728e977 supplicant: use nm_utils_gbytes_to_variant_ay() in nm_supplicant_manager_set_wfd_ies() 2020-02-10 19:11:50 +01:00
Thomas Haller
c5e0bae8b4 supplicant: track supplicant interface instances in manager via embedded CList 2020-02-10 19:11:50 +01:00
Thomas Haller
0df15330ae supplicant/trivial: give WPAS defines an NM prefix
Defines in our header files should all have an NM specific prefix.

Rename.

Also rename the related defines in the source file. Usually declarations
in a source file should not have an NM prefix. But here they have for
consistency.
2020-02-10 19:11:50 +01:00
Thomas Haller
8eb1bfa87f supplicant: rework handling of capabilities (features) to use capabilities enumeration
We keep adding capabilities. Tracking them individually via boolean (or
ternary) properties is cumbersome.

Instead, use an enum NMSupplCapType and a corresponding bitmask
NMSupplCapMask. The latter can track whether a capability is detected,
detected to be absent or not detected (unknown).
2020-02-10 19:11:50 +01:00
Thomas Haller
02e5fade55 supplicant: add enum for supplicant capabilities (features)
We should handle features/capabilities more generically.
Add an enum type for that. It will be used next.

Also, wpa_supplicant calls this "Capabilities", not features.
Use that name.
2020-02-10 19:11:50 +01:00
Thomas Haller
1cc65fff1d supplicant: remove unused NM_SUPPLICANT_INTERFACE_GROUP_FORMATION_FAILURE signal 2020-02-10 19:11:50 +01:00
Thomas Haller
49931d1637 core: forward declare opaque NMRefString typedef 2020-02-10 19:11:50 +01:00
Thomas Haller
8c23586a77 shared: drop nm_utils_dbus_normalize_object_path() in favor of nm_dbus_path_not_empty()
They do the same thing. Unify and drop one.
2020-02-10 19:11:50 +01:00
Thomas Haller
8b63b229dd shared/trivial: rename time related functions to use "nsec"/"msec" abbreviation instead of "ns"/"ms"
The "ns" abbreviation doesn't look too nice. We mostly use "nsec" at other
places. Rename.
2020-02-10 19:11:50 +01:00
Thomas Haller
53f6858a27 all: add nm_utils_error_is_cancelled() and nm_utils_error_is_cancelled_or_disposing()
Most callers would pass FALSE to nm_utils_error_is_cancelled(). That's
not very useful. Split the two functions and have nm_utils_error_is_cancelled()
and nm_utils_error_is_cancelled_is_disposing().
2020-02-10 19:11:50 +01:00
Thomas Haller
08f86ce04d platform: use C99 static array index in parameter of nm_platform_if_indextoname()
It gives the compiler a possibility to warn about some misuses of the
function.
2020-02-10 19:11:50 +01:00
Thomas Haller
d892a35395 platform: fix GCC warning about zero-length array in nmp_utils_ethtool_get_permanent_address()
GCC 10 complains about accesses to elements of zero-length arrays that
overlap other members of the same object:

  src/platform/nm-platform-utils.c: In function ‘nmp_utils_ethtool_get_permanent_address’:
  src/platform/nm-platform-utils.c:854:29: error: array subscript 0 is outside the bounds of an interior zero-length array ‘__u8[0]’ {aka ‘unsigned char[0]’} [-Werror=zero-length-bounds]
    854 |  if (NM_IN_SET (edata.e.data[0], 0, 0xFF)) {
  ./shared/nm-glib-aux/nm-macros-internal.h:731:20: note: in definition of macro ‘_NM_IN_SET_EVAL_N’

Fix this warning.
2020-02-10 11:39:01 +01:00
Thomas Haller
16e1e44c5e platform: fix GCC warning about zero-length array in ethtool_get_stringset()
GCC 10 complains about accesses to elements of zero-length arrays that
overlap other members of the same object:

 src/platform/nm-platform-utils.c: In function ‘ethtool_get_stringset’:
 src/platform/nm-platform-utils.c:355:27: error: array subscript 0 is outside the bounds of an interior zero-length array ‘__u32[0]’ {aka ‘unsigned int[0]’} [-Werror=zero-length-bounds]
   355 |  len = sset_info.info.data[0];
       |        ~~~~~~~~~~~~~~~~~~~^~~
 In file included from src/platform/nm-platform-utils.c:12:
 /usr/include/linux/ethtool.h:647:8: note: while referencing ‘data’
   647 |  __u32 data[0];
       |        ^~~~

Fix this warning.
2020-02-10 11:39:01 +01:00
Thomas Haller
0931c4f2ea Revert "platform: fix GCC warning about zero-lenght array (2)"
This reverts commit 5076fc0ca0.
2020-02-10 11:26:59 +01:00
Thomas Haller
1fd7e45139 Revert "platform: fix GCC warning about zero-lenght array (1)"
I think this solution is not right, because "char buf" is not guaranteed
to have the correct alignment. Revert, and solve it differently.

This reverts commit 6345a66153.
2020-02-10 11:26:59 +01:00
Beniamino Galvani
623a1e1f99 ovs: wait that link disappears before continuing with deactivation
When we deactivate a virtual device, we usually schedule the deletion
of the link in an idle handler. That action will be executed at a
later time when the device is already in the disconnected state.

Similarly, for ovs interfaces we send the deletion command to the
ovsdb and then proceed to the disconnected state.

However, in the first case there is the guarantee that the link will
be deleted at some point, while for ovs interfaces it may happen that
ovs decides to reuse the same link if there is an addition
queued. Since reusing the same link confuses NM, let's implement
deactivate_async() for ovs-interfaces and wait that the link actually
goes away before proceeding.

https://bugzilla.redhat.com/show_bug.cgi?id=1782701
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/402
2020-02-05 22:31:21 +01:00
Beniamino Galvani
f3baa7b1d5 ifcfg-rh: add missing 'extern' keyword
Add missing 'extern' keyword to fix the following error caused by GCC
10 defaulting to -fno-common:

 src/settings/plugins/ifcfg-rh/.libs/libnms-ifcfg-rh-core.a(libnms_ifcfg_rh_core_la-shvar.o):/root/NetworkManager/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h:36: multiple definition of `nms_ifcfg_well_known_keys';
 src/settings/plugins/ifcfg-rh/.libs/libnm_settings_plugin_ifcfg_rh_la-nms-ifcfg-rh-plugin.o:/root/NetworkManager/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h:36: first defined here
2020-02-03 11:00:34 +01:00
Beniamino Galvani
5076fc0ca0 platform: fix GCC warning about zero-lenght array (2)
GCC 10 complains about accesses to elements of zero-length arrays that
overlap other members of the same object:

  src/platform/nm-platform-utils.c: In function ‘nmp_utils_ethtool_get_permanent_address’:
  src/platform/nm-platform-utils.c:854:29: error: array subscript 0 is outside the bounds of an interior zero-length array ‘__u8[0]’ {aka ‘unsigned char[0]’} [-Werror=zero-length-bounds]
    854 |  if (NM_IN_SET (edata.e.data[0], 0, 0xFF)) {
  ./shared/nm-glib-aux/nm-macros-internal.h:731:20: note: in definition of macro ‘_NM_IN_SET_EVAL_N’

Fix this warning.
2020-02-03 11:00:34 +01:00
Beniamino Galvani
6345a66153 platform: fix GCC warning about zero-lenght array (1)
GCC 10 complains about accesses to elements of zero-length arrays that
overlap other members of the same object:

 src/platform/nm-platform-utils.c: In function ‘ethtool_get_stringset’:
 src/platform/nm-platform-utils.c:355:27: error: array subscript 0 is outside the bounds of an interior zero-length array ‘__u32[0]’ {aka ‘unsigned int[0]’} [-Werror=zero-length-bounds]
   355 |  len = sset_info.info.data[0];
       |        ~~~~~~~~~~~~~~~~~~~^~~
 In file included from src/platform/nm-platform-utils.c:12:
 /usr/include/linux/ethtool.h:647:8: note: while referencing ‘data’
   647 |  __u32 data[0];
       |        ^~~~

Fix this warning.
2020-02-03 11:00:34 +01:00
Beniamino Galvani
c11ac34f4c all: remove wrong CURL option initialization
curl_multi_setopt() accepts CURLMOPT_* options, not CURLOPT_*
ones. Found by GCC 10:

clients/cloud-setup/nm-http-client.c:700:38: error: implicit conversion from ‘enum <anonymous>’ to ‘CURLMoption’ [-Werror=enum-conversion]
  700 |    curl_multi_setopt (priv->mhandle, CURLOPT_VERBOSE, 1);

Fixes: 69f048bf0c ('cloud-setup: add tool for automatic IP configuration in cloud')
2020-02-01 11:38:08 +01:00
Beniamino Galvani
3d03900e91 platform: skip VRF test if kernel support is missing
Fixes: 7c73c6a038 ('platform: add VRF support')
2020-01-31 15:45:04 +01:00
Beniamino Galvani
d8e1f4c8ef ndisc: remove upper bound for IPv6 autoconfiguration timeout
As it is possible to configure an arbitrarily large DHCP timeout, it
should be possible to also set a large timeout for IPv6
autoconfiguration. Currently the timeout can only be changed via
sysctl. Leave the lower bound because the default kernel sysctl value
is 3 * 4 = 12 seconds and so without the lower limit the default
timeout would change from 30 to 12 seconds for every user, which seems
a big change and could possibly break users' setup.

https://bugzilla.redhat.com/show_bug.cgi?id=1795957
2020-01-30 15:23:04 +01:00
Beniamino Galvani
df75c21b4d device: accept new leases in NM_DEVICE_IP_STATE_DONE
If the current lease expires, we start the grace period in which the
clients starts again from the INIT DHCP state (i.e. sending DISCOVER
messages). If it is able to obtain a new lease, it must be accepted or
otherwise the client will not renew it.
2020-01-30 15:23:04 +01:00
Beniamino Galvani
a4ddb56923 dhcp: introduce EXTENDED state for renewals
Currently the DHCP client reports the BOUND state not only when the
lease is obtained initially but also when it is renewed. Having a
different state for the renewal will be used by NMDevice in the next
patch to determine whether the lease needs to be accept()ed or not.
2020-01-30 15:23:04 +01:00
Beniamino Galvani
aee78ca788 dhcp: derive the grace period duration from the timeout property
Currently the duration of the DHCP grace period (in which we try to
acquire a new lease after expiration) is hardcoded to 480
seconds. That value seems arbitrary and too long for the default
configuration. Since we already have a property that allows the user
to configure how long NM should try to get the lease initially, it
makes sense to use it also for retries after lease expirations.

In particular, setting the ipvx.dhcp-timeout to a high value extends
also the grace period to a very long time, potentially forever.
2020-01-30 15:23:04 +01:00