Commit graph

810 commits

Author SHA1 Message Date
Lubomir Rintel
5801f89f4d all: goodbye libnm-glib
This removes libnm-glib, libnm-glib-vpn, and libnm-util for good.
The it has been replaced with libnm since NetworkManager 1.0, disabled
by default since 1.12 and no up-to-date distributions ship it for years
now.

Removing the libraries allows us to:

* Remove the horrible hacks that were in place to deal with accidental use
  of both the new and old library in a single process.
* Relief the translators of maintenance burden of similar yet different
  strings.
* Get rid of known bad code without chances of ever getting fixed
  (libnm-glib/nm-object.c and libnm-glib/nm-object-cache.c)
* Generally lower the footprint of the releases and our workspace

If there are some really really legacy users; they can just build
libnm-glib and friends from the NetworkManager-1.16 distribution. The
D-Bus API is stable and old libnm-glib will keep working forever.

https://github.com/NetworkManager/NetworkManager/pull/308
2019-04-16 15:52:27 +02:00
Lubomir Rintel
65831ee84c core/qdisc: add support for attributes 2019-04-12 18:04:04 +02:00
Lubomir Rintel
b027723e00 Revert "all: goodbye libnm-glib"
We need this for a little little longer :(

This reverts commit 1de8383ad9.
2019-04-03 08:52:38 +02:00
Thomas Haller
6e6d1e070c libnm: add API to NMSettingIPConfig for routing rules 2019-03-27 16:23:30 +01:00
Thomas Haller
7fb23b0a62 libnm: add NMIPRoutingRule API
Add NMIPRoutingRule API with a few basic rule properties. More
properties will be added later as we want to support them.

Also, add to/from functions for string/GVariant representations.
These will be needed to persist/load/exchange rules.

The to-string format follows the `ip rule add` syntax, with the aim
to be partially compatible. Full compatibility is not possible though,
for various reasons (see code comment).
2019-03-27 16:23:30 +01:00
Thomas Haller
5b51a1a9f7 libnm/lldp: cleanup asserting for valid NMLldpNeighbor agument
At a few places we checked whether neighbor->attrs was non-NULL.
That is not necessary, unless we'd like to catch some dangling/invalid
pointers. The attrs hash is always set otherwise.

Instead of just dropping the check, add a NM_IS_LLDP_NEIGHBOR() macro
(inline function).
2019-03-27 10:47:24 +01:00
Thomas Haller
8db0319198 libnm/lldp: fix leak and bug in nm_lldp_neighbor_dup()
For one, just reassigning copy->attrs leaks the previous
hash table. Fix that.

Also, NMLldpNeighbor instances are not immutable. I think that
is an uglyness, and it would be preferable that they can be sealed.
A sealed object could safely share/ref the internal hash-table. However,
as it is, we cannot just have two NMLldpNeighbor instances share the
same hash-table. Do a full copy.
2019-03-27 10:47:24 +01:00
Beniamino Galvani
937796f6ea libnm: add nm_lldp_neighbor_get_attr_value()
The function provides access to the GVariant representing a LLDP
attribute.
2019-03-27 10:17:39 +01:00
Beniamino Galvani
8cdc011cd1 libnm: make attribute name const in LLDP API functions
Add the const qualifier to the attribute name in LLDP API functions so
that const strings and string literals are accepted. This change is
backwards compatible for existing users of the API.
2019-03-27 10:17:39 +01:00
Beniamino Galvani
cf71860183 libnm-core: add bridge vlan conversion utils 2019-03-26 17:18:29 +01:00
Beniamino Galvani
a680bedf94 libnm-core: add vlans property to bridge setting 2019-03-26 17:18:29 +01:00
Beniamino Galvani
1e5b0788bc libnm-core: add vlans property to bridge-port setting 2019-03-26 17:18:29 +01:00
Beniamino Galvani
96fab7b462 all: add vlan-filtering and vlan-default-pvid bridge properties 2019-03-26 17:18:29 +01:00
Thomas Haller
395738900f libnm: don't use strlen() for checking for non-empty string
It's well understood that these are NUL terminated strings.
We don't need strlen() to check that the strings aren't
empty.
2019-03-25 09:12:32 +01:00
Lubomir Rintel
1de8383ad9 all: goodbye libnm-glib
This removes libnm-glib, libnm-glib-vpn, and libnm-util for good.
The it has been replaced with libnm since NetworkManager 1.0, disabled
by default since 1.12 and no up-to-date distributions ship it for years
now.

Removing the libraries allows us to:

* Remove the horrible hacks that were in place to deal with accidental use
  of both the new and old library in a single process.
* Relief the translators of maintenance burden of similar yet different
  strings.
* Get rid of known bad code without chances of ever getting fixed
  (libnm-glib/nm-object.c and libnm-glib/nm-object-cache.c)
* Generally lower the footprint of the releases and our workspace

If there are some really really legacy users; they can just build
libnm-glib and friends from the NetworkManager-1.16 distribution. The
D-Bus API is stable and old libnm-glib will keep working forever.

https://github.com/NetworkManager/NetworkManager/pull/308
2019-03-19 17:15:15 +01:00
Beniamino Galvani
47f1c931ee libnm: fix dns-configuration property type
Fixes: a8d6005256 ('libnm: implement support for DNS manager properties')

https://bugzilla.redhat.com/show_bug.cgi?id=1689055
(cherry picked from commit d867837d05)
2019-03-15 11:15:37 +01:00
Lubomir Rintel
4251f4e476 all: codespell fixes
Codespel run with the same arguments as described in
commit 58510ed566 ('docs: misc. typos pt2').

(cherry picked from commit bf0c4e6ac2)
2019-03-11 12:03:46 +01:00
Benjamin Berg
6b2aaba6df libnm: Fix reporting of unknown device types
nm_device_get_device_type would report the device type as it was send on
DBus, while fetching the property would mean that only a known device
types is reported.

Make both results consistent by coercing in nm_device_get_device_type
rather than when setting the property.

(cherry picked from commit a6a185ba00)
2019-03-07 22:26:20 +01:00
Benjamin Berg
2d547059dc core,wifi-p2p: Fix Wi-Fi P2P device type
The device type was set to the GType rather than a new value in the
NMDeviceType enum.

Add the corresponding enum entry, fix the device type and set the
routing priority to the same value as generic devices.

(cherry picked from commit 8d9365a973)
2019-03-07 22:26:20 +01:00
Thomas Haller
0d178a968d libnm: rename and expose nm_utils_base64secret_decode() in libnm
A NetworkManager client requires an API to validate and decode
a base64 secret -- like it is used by WireGuard. If we don't have
this as part of the API, it's inconvenient. Expose it.

Rename it from _nm_utils_wireguard_decode_key(), to give it a more
general name.

Also, rename _nm_utils_wireguard_normalize_key() to
nm_utils_base64secret_normalize(). But this one we keep as internal
API. The user will care more about validating and decoding the base64
key. To convert the key back to base64, we don't need a public API in
libnm.

This is another ABI change since 1.16-rc1.

(cherry picked from commit e46ba01867)
2019-03-07 22:22:39 +01:00
Marco Trevisan (Treviño)
b5bbf8edc2 nm: Fix syntax on introspection annotations
Various annotations were added using multiple colons, while only one has
to be added or g-ir-introspect will consider them part of the description

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/94
(cherry picked from commit 73005fcf5b)
2019-03-07 10:09:23 +01:00
Thomas Haller
2d34d06e5f wireguard: add "peer-routes" setting for WireGuard profiles
This setting is not yet implemented.

This adds new API for 1.16.0 and is an ABI break since 1.16-rc1.

(cherry picked from commit d719ad31f0)
2019-03-05 12:23:59 +01:00
Thomas Haller
89d40d6579 wireguard: add "mtu" setting for WireGuard profiles
This adds new API for 1.16.0 and is an ABI break since 1.16-rc1.

(cherry picked from commit d5e93ae613)
2019-03-05 12:23:59 +01:00
Thomas Haller
ab80bf8f87 libnm,core: fix device TYPE for Wi-Fi P2P devices
Don't use "wifip2p" for the type description.

    $ nmcli device
    DEVICE             TYPE      STATE         CONNECTION
    wlan0              wifi      connected     x
    p2p-dev-wlan0      wifip2p   disconnected  --

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/87
(cherry picked from commit 8f6a8d0517)
2019-02-26 09:14:13 +01:00
Thomas Haller
79af876e0e all/trivial: fix whitespace/indentation 2019-02-22 16:28:12 +01:00
Thomas Haller
e148ec07d5 libnm: add NMWireGuardPeer and libnm support for peers 2019-02-22 11:00:10 +01:00
Thomas Haller
b521f426ab libnm,cli: add NMSettingWireGuard
For now only add the core settings, no peers' data.

To support peers and the allowed-ips of the peers is more complicated
and will be done later. It's more complicated because these are nested
lists (allowed-ips) inside a list (peers). That is quite unusual and to
conveniently support that in D-Bus API, in keyfile format, in libnm,
and nmcli, is a effort.
Also, it's further complicated by the fact that each peer has a secret (the
preshared-key). Thus we probably need secret flags for each peer, which
is a novelty as well (until now we require a fixed set of secrets per
profile that is well known).
2019-02-22 11:00:10 +01:00
Thomas Haller
fefb965cfe libnm: fix leak in nm_client_add_and_activate_connection{2,_async}()
Detected via valgrind:

  $ ./tools/run-nm-test.sh -m -v libnm/tests/test-nm-client -p /libnm/active-connections

Fixes: fbb038af5e
2019-02-22 08:14:01 +01:00
Thomas Haller
b7d4ad8547 wifi-p2p: drop WiFi-P2P "group-owner" property from D-Bus API and libnm
It's not yet implemented server-side.

Until it is clear that we need this property and until it is implemented,
drop it again from public API.

See-also: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/80#note_118004
2019-02-21 15:34:55 +01:00
Jonathan Kang
243af16c5b Add polkit action for Wi-Fi scans
Previously, Wi-Fi scans uses polkit action
"org.freedesktop.NetworkManager.network-control". This is introduced
in commit 5e3e19d0. But in a system with restrict polkit rules, for
example "org.freedesktop.NetworkManager.network-control" was set as
auth_admin. When you open the network panel of GNOME Control Center, a
polkit dialog will keep showing up asking for admin password, as GNOME
Control Center scans the Wi-Fi list every 15 seconds.

Fix that by adding a new polkit action
"org.freedesktop.NetworkManager.wifi.scan" so that distributions can
add specific rule to allow Wi-Fi scans.

[thaller@redhat.com: fix macro in "shared/nm-common-macros.h"]

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/68
2019-02-21 13:49:17 +01:00
Benjamin Berg
3d12dbc0a7 Remove WFD IEs property from P2P device
While this can be considered a property of the P2P device, the API will
require setting it through the settings when activating a connection. As
such, having a (read only) property on the device is not very useful, so
remove it again.
2019-02-21 10:10:20 +01:00
Benjamin Berg
8ed7aef26d core/setting-wifi-p2p: Add WFD IEs property to P2P settings
This is a protocol specific extension to Wi-Fi frames which need to be
set in certain conditions. The P2P device will use this to update the
corresponding wpa_supplicant property.
2019-02-21 10:10:20 +01:00
Thomas Haller
10600bdb69 libnm: fix leaking checkpoints from NMManager
Fixes: c3efedf54b
2019-02-19 09:33:05 +01:00
Thomas Haller
41ea9fffbb libnm: fix memleak for NMDeviceTun:hw-address
Fixes: 337304f19d
2019-02-19 09:33:05 +01:00
Thomas Haller
25a3825b51 libnm: fix duplicate free in nm_client_checkpoint_rollback()
#0  0x00007fffea7481e5 in _g_log_abort (breakpoint=1) at gmessages.c:554
    #1  0x00007fffea74951d in g_logv (log_domain=0x7fffea78e00e "GLib", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffcbb0)
        at gmessages.c:1371
    #2  0x00007fffea7496f3 in g_log
        (log_domain=log_domain@entry=0x7fffea78e00e "GLib", log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0x7fffea798320 "%s: assertion '%s' failed")
        at gmessages.c:1413
    #3  0x00007fffea749f2d in g_return_if_fail_warning
        (log_domain=log_domain@entry=0x7fffea78e00e "GLib", pretty_function=pretty_function@entry=0x7fffea799d40 <__func__.4759> "g_atomic_ref_count_dec", expression=expression@entry=0x7fffea799ca1 "g_atomic_int_get (arc) > 0") at gmessages.c:2762
    #4  0x00007fffea754c12 in g_atomic_ref_count_dec (arc=arc@entry=0x5555558c5280) at grefcount.c:260
    #5  0x00007fffea7302c6 in g_hash_table_unref (hash_table=0x5555558c5240) at ghash.c:1101
    #6  0x00007fffea4b6dbc in clear_op_res (simple=0x55555587ed90 [GSimpleAsyncResult]) at gsimpleasyncresult.c:248
    #7  0x00007fffea4b6dbc in g_simple_async_result_finalize (object=0x55555587ed90 [GSimpleAsyncResult]) at gsimpleasyncresult.c:268
    #8  0x00007fffea67b949 in g_object_unref (_object=<optimized out>) at gobject.c:3346
    #9  0x00007fffea67b949 in g_object_unref (_object=0x55555587ed90) at gobject.c:3238
    #10 0x00007fffe95dea2d in checkpoint_rollback_cb (object=<optimized out>, result=<optimized out>, user_data=0x55555587ed90) at libnm/nm-manager.c:1584
    #11 0x00007fffea4ca834 in g_task_return_now (task=0x5555558b5c80 [GTask]) at gtask.c:1148
    #12 0x00007fffea4cb196 in g_task_return (task=0x5555558b5c80 [GTask], type=<optimized out>) at gtask.c:1206
    #13 0x00007fffea5096bb in reply_cb (connection=<optimized out>, res=<optimized out>, user_data=0x5555558b5c80) at gdbusproxy.c:2596
    #14 0x00007fffea4ca834 in g_task_return_now (task=0x5555558b5d50 [GTask]) at gtask.c:1148
    #15 0x00007fffea4cb196 in g_task_return (task=0x5555558b5d50 [GTask], type=<optimized out>) at gtask.c:1206
    #16 0x00007fffea4fdd4a in g_dbus_connection_call_done (source=<optimized out>, result=0x5555558b5e20, user_data=0x5555558b5d50) at gdbusconnection.c:5715
    #17 0x00007fffea4ca834 in g_task_return_now (task=0x5555558b5e20 [GTask]) at gtask.c:1148
    #18 0x00007fffea4ca86d in complete_in_idle_cb (task=task@entry=0x5555558b5e20) at gtask.c:1162
    #19 0x00007fffea73e97b in g_idle_dispatch (source=0x7fffdc04eb90, callback=0x7fffea4ca860 <complete_in_idle_cb>, user_data=0x5555558b5e20) at gmain.c:5620
    #20 0x00007fffea74206d in g_main_dispatch (context=0x5555557c8410) at gmain.c:3182
    #21 0x00007fffea74206d in g_main_context_dispatch (context=context@entry=0x5555557c8410) at gmain.c:3847
    #22 0x00007fffea742438 in g_main_context_iterate (context=0x5555557c8410, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3920
    #23 0x00007fffea742762 in g_main_loop_run (loop=0x55555584ed00) at gmain.c:4116

Fixes: c3efedf54b
2019-02-19 09:33:05 +01:00
Thomas Haller
047998f80a all: cache errno in local variable before using it 2019-02-12 08:50:28 +01:00
Thomas Haller
a3370af3a8 all: drop unnecessary includes of <errno.h> and <string.h>
"nm-macros-interal.h" already includes <errno.h> and <string.h>.
No need to include it everywhere else too.
2019-02-12 08:50:28 +01:00
Thomas Haller
db98070214 build/meson: add dependency of libnm to libnm-core
We need to build libnm-core first. Especially, because libnm
sources require the "libnm-core/nm-core-enum-types.h" header
to be generated first.

Add a missing dependency.
2019-02-06 13:36:22 +01:00
Thomas Haller
052734a8d3 build/meson: cleanup of libnm/meson.build
"libnm/fake-typelib/meson.build" modifies the variable "sources",
which is defined by the outer "libnm/meson.build" file.

That is confusing. If a variable is not only used within one "meson.build"
file alone, it should have a unique name. Rename the variable to
"libnm_utils_sources".

Also avoid local variable "deps" which is only used at one place.
2019-02-06 13:35:26 +01:00
Thomas Haller
d25ed0820c all: don't use "static inline" in source files
For static functions inside a module, the compiler determines on its own
whether to inline the function.

Also, "inline" was used at some places that don't immediatly look like
candidates for inlining. It was most likely a copy&paste error.
2019-02-06 09:31:00 +01:00
Benjamin Berg
60691d76ad libnm: Add async start/stop routines for P2P find operations
These were dropped earlier as new sync API must not be the primary way
of calling new routines in libnm.

In this particular case the DBus calls are simple and unlikely to fail.
Most users should use the normal async API and call the finish routine.
However, if the API user is not interested in the result, then they can
simply set the callback to NULL to ignore it.

[thaller@redhat.com: added options argument to start-find method]
2019-02-05 13:55:13 +01:00
Thomas Haller
c67ebc8abf build/meson: add intermediate shared/nm-utils base library
Like also done for autotools, create and use intermediate libraries
from "shared/nm-utils/".

Also, replace "shared_dep" by "shared_nm_utils_base_dep". We don't
need super fine-grained selection of what we link. We can always
link in "shared/libnm-utils-base.a", and let the linker throw away
unsed parts.
2019-02-05 09:53:24 +01:00
Thomas Haller
d52fd81b91 libnm/secret-agent/trivial: rename internal init-data structure
No "NM" prefix for internal structure.
2019-02-05 08:34:23 +01:00
Thomas Haller
43b3e19c88 libnm/secret-agent: use cleanup attribute in NMSecretAgentOldPrivate
Refactor memory handling to use cleanup attribute.
2019-02-05 08:34:23 +01:00
Thomas Haller
ee9e980814 libnm/secret-agent: reorder fields in NMSecretAgentOldPrivate
And don't waste 4 bytes per boolean.
2019-02-05 08:34:23 +01:00
Thomas Haller
b9a7f1974b libnm/secret-agent: use CList instead of GSList for tracking requests
Always always when we want a linked list, CList is a better choice than
GSList. It's more convenient to use and is more efficient.

Also, use GSlice allocator for GetSecretRequest data.
2019-02-05 08:34:23 +01:00
Thomas Haller
72f90a8fbc clients/secret-agent: fix cancel_get_secrets() implementation
The callback must be invoked, as also documented.

Otherwise, the tracked info gets leaked.

Let NMSecretAgentOld (the caller) be a bit resilient against
bugs in the client, and avoid a crash by prematurely remove
the request-info from the pending list. That does not fully
workaround the bug (it leads to a leak), but at least it does
not cause other "severe" issues.

The leak was present earlier as well.
2019-02-05 08:34:23 +01:00
Thomas Haller
fb4a188350 libnm/secret-agent: refactor GObject properties in NMSecretAgentOld
Use NM_GOBJECT_PROPERTIES_DEFINE() and _notify() and get rid of
the extra tab for indentation.
2019-02-05 08:34:13 +01:00
Thomas Haller
99ae86d824 libnm/secret-agent: reorder code 2019-02-05 08:34:07 +01:00
Thomas Haller
7fb18004b3 libnm/trival: fix indention in "libnm/nm-secret-agent-old.c" 2019-02-05 08:22:01 +01:00