Commit Graph

24036 Commits

Author SHA1 Message Date
Thomas Haller
5131cc4245 core: add and use NM_MANAGER_GET macro
For our singleton getters we usually have such a macro. See NM_PLATFORM_GET
and NM_SETTINGS_GET.

Add such a macro for NMManager and use it.
2019-09-22 16:05:50 +02:00
Thomas Haller
d048050c2d shared: add more nm_dbus_connection_call_*() and nm_dbus_connection_signal_subscribe_*() helpers 2019-09-22 16:05:50 +02:00
Thomas Haller
c73b5c1be0 shared,all: add and use DBUS_INTERFACE_OBJECT_MANAGER define 2019-09-22 16:05:50 +02:00
Thomas Haller
e688e70b37 shared: add nm_utils_hash_values_to_array() helper 2019-09-22 16:05:50 +02:00
Thomas Haller
2667a46874 shared: add nm_auto_remove_source cleanup macro 2019-09-22 16:05:50 +02:00
Thomas Haller
6a9ab7bb30 shared: add nm_auto_unref_io_channel cleanup macro 2019-09-22 16:05:50 +02:00
Thomas Haller
b911cc17d8 shared: support nm_g_slice_free_fcn() for sizes of 32 bytes 2019-09-22 16:05:50 +02:00
Thomas Haller
d19a403faa libnm/test: add unit test with consistency checks about NMSetting type info
Add test for checking the meta data for expected consistency.

This is also useful if you want to check something about the meta data
programatically.

For example, if you have the question which (if any) properties
are GObject based but also implement a to_dbus_fcn() function. Then you
can extend this code with some simple printf debugging to get a list of
those.

Or, if you want to find how many NMSettInfoProperty instances are in
static data (e.g. to determine how much memory is used). You can easily
modify this code to count them (and find 447 properties). Out of these,
326 are plain GObject based properties. Meaning, we could refactor the
code to create smaller NMSettInfoProperty instances for those, saving
thus (326 * 4 * sizeof (gpointer)) bytes (10K).

Such questions are interesting when refactoring the code.
2019-09-21 22:01:29 +02:00
Thomas Haller
bf8118b829 libnm: merge branch 'th/libnm-dbus-rework-1'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/258
2019-09-21 14:59:59 +02:00
Thomas Haller
30ce0079a8 libnm: drop unused property setter NM_DEVICE_MANAGED
NM_DEVICE_MANAGED was intended to work like NM_DEVICE_AUTOCONNECT:
namely it would call the D-Bus property setter synchronously.

But such behavior is horrendous, we certainly don't want blocking calls
during a property getter.

Luckily this one instance was unused and never worked as the property
was marked as G_PARAM_READABLE. Just drop the setter.
2019-09-21 14:58:26 +02:00
Thomas Haller
7db00be6b7 libnm: inline NMManager's get_permissions_sync()
Synchrnous initialization is problmatic and needs cleanup.

get_permissions_sync() is an internal function, that has only one
caller. We need to keep track of functions that make synchronous D-Bus
calls. Move the synchronous call into the caller, so that it's clearer
who calls such API.
2019-09-21 14:58:26 +02:00
Thomas Haller
0f9157f07b libnm: drop _nm_dbus_is_connection_private()
Currently, we don't use private sockets. We are always connected
to D-Bus.
2019-09-21 14:58:26 +02:00
Thomas Haller
be3712f6fb libnm: drop nm_dbus_new_connection() helper API
We don't need a wrapper around g_bus_get*(). Just use
it directly.

I guess in the past this had some use when we were using
a private socket too. Those days are gone. If we are going
to re-introduce private socket support, then we probably should
come up with a better solution.
2019-09-21 14:58:26 +02:00
Thomas Haller
908fadec96 shared: add NMRefString
I'd like to refactor libnm's caching. Note that cached D-Bus objects
have repeated strings all over the place. For example every object will
have a set of D-Bus interfaces (strings) and properties (strings) and an
object path (which is referenced by other objects). We can save a lot of
redundant strings by deduplicating/interning them. Also, by interning
them, we can compare them using pointer equality.

Add a NMRefString implementation for this.

Maybe an alternative name would be NMInternedString or NMDedupString, because
this string gets always interned. There is no way to create a NMRefString
that is not interned. Still, NMRefString name sounds better. It is ref-counted
after all.

Notes:

 - glib has GQuark and g_intern_string(). However, such strings cannot
   be unrefered and are leaked indefinitely. It is thus unsuited for
   anything but a fixed set of well-known strings.

 - glib 2.58 adds GRefString, but we cannot use that because we
   currently still use glib 2.40.
   There are some differences:

     - GRefString is just a typedef to char. That means, the glib API
       exposes GRefString like regular character strings.
       NMRefString intentionally does that not. This makes it slightly
       less convenient to pass it to API that expects "const char *".
       But it makes it clear to the reader, that an instance is in fact
       a NMRefString, which means it indicates that the string is
       interned and can be referenced without additional copy.

     - GRefString can be optionally interned. That means you can
       only use pointer equality for comparing values if you know
       that the GRefString was created with g_ref_string_new_intern().
       So, GRefString looks like a "const char *" pointer and even if
       you know it's a GRefString, you might not know whether it is
       interned. NMRefString is always interned, and you can always
       compare it using pointer equality.

  - In the past I already proposed a different implementation for a
    ref-string. That made different choices. For example NMRefString
    then was a typedef to "const char *", it did not support interning
    but deduplication (without a global cache), ref/unref was not
    thread safe (but then there was no global cache so that two threads
    could still use the API independently).

The point is, there are various choices to make. GRefString, the
previous NMRefString implementation and the one here, all have pros and
cons. I think for the purpose where I intend NMRefString (dedup and
efficient comparison), it is a preferable implementation.

Ah, and of course NMRefString is an immutable string, which is a nice
property.
2019-09-21 14:58:26 +02:00
Thomas Haller
dd33b3a14e shared: add nm_auto_unlock_g_mutex and NM_G_MUTEX_LOCKED() helper macros 2019-09-21 14:52:31 +02:00
Lubomir Rintel
e1cda0150c wifi: fix the supplicant config test
Oopsie, forgot to adjust the test for change in roaming signal strength
threshold.

Fixes: 24bbceed9b ('wifi: roam more aggressively'):
2019-09-20 16:24:40 +02:00
Beniamino Galvani
b57f8d93e2 tui: wifi: support WPA3-Personal (SAE) 2019-09-20 13:18:19 +02:00
Beniamino Galvani
84a86ce55f libnm-core: support SAE when determining AP compatibility
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/172
2019-09-20 13:18:18 +02:00
Kristian Klausen
24bbceed9b wifi: roam more aggressively
-80dBm is a very weak signal and we should roam sooner.
iwd[1] and iOS[2] default to -70dBm, Android[3] default to -73dBm.
So lets change the roaming threshold to -70dBm.

[1] https://git.kernel.org/pub/scm/network/wireless/iwd.git/commit/?id=45a51613c4c24067fe0e35b4c084a50124282b36
[2] https://support.apple.com/en-us/HT203068
[3] 68a4599a37/core/res/res/values/config.xml (609)
    dacacbf69d/service/java/com/android/server/wifi/ScoringParams.java (218)
    dacacbf69d/service/java/com/android/server/wifi/ScoringParams.java (325)
    ee0920fb68/service/java/com/android/server/wifi/WifiNetworkSelector.java (149)

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/201
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/278
2019-09-20 12:57:16 +02:00
Lubomir Rintel
d4fd1ea4ca introspection: fix documentation for Wimax(Hardware)?Enabled
These properties don't do anything. They just exist for compatibility
reasons.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/274
2019-09-20 12:51:20 +02:00
Lubomir Rintel
25fadf8f92 cli: add kill switch indication to "nmcli" output
There is some guess work done on the client side. Perhaps the
o.fd.NM.Device could be extended to indicate which kill switch is the
device disabled by. This could be good enough for now though.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/271/commits
2019-09-20 12:49:21 +02:00
Beniamino Galvani
a7dd935d87 Merge branch 'bg/dhcp-keep'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/243
https://bugzilla.redhat.com/show_bug.cgi?id=1688329
2019-09-18 09:31:57 +02:00
Beniamino Galvani
9c123cdd3f device: keep client running after activation failure
If DHCPv4 fails but IPv6 succeeds it makes sense to continue trying
DHCP so that we will eventually be able to get an address if the DHCP
server comes back. Always keep the client running; it will be only
terminated when the connection is brought down.

https://bugzilla.redhat.com/show_bug.cgi?id=1688329
2019-09-18 09:29:51 +02:00
Beniamino Galvani
8b5bf6e4d1 device: accept lease only after addresses are configured
In the accept() callback, the nettools client creates a UDP socket
with the received address as source, so the address must be already
configured on the interface.

Also, handle errors returned by nm_dhcp_client_accept().

Fixes: 401fee7c20 ('dhcp: support notifying the client of the result of DAD')
2019-09-18 09:29:51 +02:00
Beniamino Galvani
687d0dd95e n-dhcp4: arm timers in bound state
Arm timers when the bound state is reached, otherwise the lease is
never renewed.

https://github.com/nettools/n-dhcp4/pull/4
2019-09-18 09:29:51 +02:00
Beniamino Galvani
686c6b0032 merge: branch 'bg/cli-general-reload'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/265
2019-09-17 09:34:44 +02:00
Beniamino Galvani
5afcf9c045 cli: add 'general reload' command
Add 'nmcli general reload [flags]' command to reload NM configuration
and perform other updates.
2019-09-17 09:31:34 +02:00
Beniamino Galvani
fd8d5a0c7a cli: don't create a NMClient for the 'connection reload' command
It is a waste of resources instantiating a NMClient, filling the
object cache and then throwing everything away without using it. This
can take seconds on slow systems with many objects. Since the
ReloadConnections doesn't need anything from the cache, just execute
the D-Bus method call directly.
2019-09-17 09:31:34 +02:00
Beniamino Galvani
07e838567e libnm: add nm_client_reload()
Introduce libnm API to reload NM configuration through the Reload()
D-Bus method.
2019-09-17 09:31:34 +02:00
Beniamino Galvani
c1c970f1b1 libnm: export reload flags
Flags to the manager Reload() method are stable API but not exposed in
a public header. Export them.
2019-09-17 09:30:18 +02:00
Beniamino Galvani
a2e6e7f2a9 systemd: use busctl instead of dbus-send
While dbus-send may not be installed, busctl is shipped with systemd
and so it should be always available.
2019-09-17 09:29:34 +02:00
Beniamino Galvani
c177a38e88 supplicant: add FT-SAE key-mgmt to verification list
FT-SAE is missing in the supplicant configuration verification list,
causing an activation failure when using SAE and the supplicant
supports FT.

Fixes: d17a0a0905 ('supplicant: allow fast transition for WPA-PSK and WPA-EAP')
2019-09-16 16:21:35 +02:00
Francesco Giudici
98885f7732 merge: branch 'fg/nettools_dhcp_options_II'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/213
2019-09-13 18:45:04 +02:00
Francesco Giudici
07b3ecbb7a dhcp: nettools: drop useless "options" GHashTable checks 2019-09-13 18:44:32 +02:00
Francesco Giudici
86973eae1f dhcp: nettools: add utf8 checking on the wpad option
and assert values exported as dhcp options are utf8 compliant
2019-09-13 18:44:32 +02:00
Francesco Giudici
3a10c47786 dhcp: nettools: drop the 'iface' parameter when no more used
Drop it from the functions for extracting the dhcp options from the
lease: it was just used for the logging, but now we log all the options
once, at the end of the process.
2019-09-13 18:44:32 +02:00
Francesco Giudici
6945ecb804 dhcp: nettools: drop plugin logging of the lease options
as these are already logged in common dhcp-client code. Moreover, now
the log level of the lease options will move from INFO to DEBUG.
2019-09-13 18:44:32 +02:00
Francesco Giudici
fff39e4a88 dhcp: internal: drop plugin logging of the lease options
as these are already logged in common dhcp-client code.
2019-09-13 18:44:32 +02:00
Francesco Giudici
862177f6b6 dhcp: log the dhcp options got in the lease once for all plugin
Each plugin logged the options: just do that on dhcp state change and do
in common code.
Log the options at INFO level for all the plugins. This partially reverts
the effects on the internal plugin of the commit:
97ce488f5f ('dhcp/internal: decrease logging level when
retrieving dhcp options')
2019-09-13 18:44:32 +02:00
Francesco Giudici
dbd9ed1c62 dhcp: nettools: retrieve and expose the private dhcp options 2019-09-13 18:44:32 +02:00
Francesco Giudici
cded6d5184 dhcp: nettools: retrieve and expose the expiry time
also fix the lease time: it should be the time in seconds that the lease
lasts
2019-09-13 18:44:32 +02:00
Beniamino Galvani
8cd8a5fbed wifi: allow reapply when the seen-bssids property changed
wifi.seen-bssid is a synthetic read-only property that lists all the
bssids seen for that connection; it should be ignored during a
reapply.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/243
2019-09-13 14:26:21 +02:00
Francesco Giudici
15035e2b0d meson: fix build_clean.sh -w meson -w test
Fixes: 6e5385a4eb ('wwan/tests: test service-providers.xml parser')
2019-09-13 12:59:03 +02:00
Robert Ancell
41593d0787 libnm: Add missing autoptr macros for classes
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/270
2019-09-13 12:15:01 +02:00
Lubomir Rintel
4af856a71b build: make test-service-providers depend on nm-core-enum-types.h
Fixes build:

  In file included from ../src/devices/wwan/nm-service-providers.c:10:
  In file included from ../shared/nm-default.h:279:
  ../libnm-core/nm-core-types.h:14:10: fatal error: 'nm-core-enum-types.h' file not found
  #include "nm-core-enum-types.h"
           ^
  1 error generated.
  make[2]: *** [src/devices/wwan/src_devices_wwan_tests_test_service_providers-nm-service-providers.o] Error 1
2019-09-11 16:42:59 +02:00
Lubomir Rintel
455f6dcbdc build/debian: install mobile-broadband-provider-info 2019-09-11 14:54:34 +02:00
Lubomir Rintel
beab85520a merge: branch 'lr/gsm-default-apn'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/98
2019-09-11 14:34:48 +02:00
Lubomir Rintel
7c53930ceb wwan/modem-broadband: add capability to look up default APN/username/password
This allows the GSM connection to Just Work most of the time, as in:
"nmcli d connect ttyUSB0".
2019-09-11 14:32:05 +02:00
Lubomir Rintel
0d44b640fc wwan/modem-broadband: get rid of g_assert*()
Though there is no known way to reach these, it may well happen that
this is going to prevent some hard crashes.
2019-09-11 14:32:05 +02:00
Lubomir Rintel
6e5385a4eb wwan/tests: test service-providers.xml parser
Just a handful of unit tests.
2019-09-11 14:32:05 +02:00