summaryrefslogtreecommitdiff
path: root/libnm
Commit message (Collapse)AuthorAgeFilesLines
* libnm/modem: add APN getterlr/modem-propertiesLubomir Rintel2019-06-053-0/+41
|
* libnm/modem: add network id getterLubomir Rintel2019-06-053-0/+42
|
* libnm/modem: add device id getterLubomir Rintel2019-06-053-0/+59
|
* libnm: rework team handling of JSON configThomas Haller2019-05-231-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Completely refactor the team/JSON handling in libnm's NMSettingTeam and NMSettingTeamPort. - team handling was added as rh#1398925. The goal is to have a more convenient way to set properties than constructing JSON. This requires libnm to implement the hard task of parsing JSON (and exposing well-understood properties) and generating JSON (based on these "artificial" properties). But not only libnm. In particular nmcli and the D-Bus API must make this "simpler" API accessible. - since NMSettingTeam and NMSettingTeamPort are conceptually the same, add "libnm-core/nm-team-utils.h" and NMTeamSetting that tries to handle the similar code side-by-sdie. The setting classes now just delegate for everything to NMTeamSetting. - Previously, there was a very fuzzy understanding of the provided JSON config. Tighten that up, when setting a JSON config it regenerates/parses all other properties and tries to make the best of it. When modifying any abstraction property, the entire JSON config gets regenerated. In particular, don't try to merge existing JSON config with the new fields. If the user uses the abstraction API, then the entire JSON gets replaced. For example note that nm_setting_team_add_link_watcher() would not be reflected in the JSON config (a bug). That only accidentally worked because client would serializing the changed link watcher to GVariant/D-Bus, then NetworkManager would set it via g_object_set(), which would renerate the JSON, and finally persist it to disk. But as far as libnm is concerned, nm_setting_team_add_link_watcher() would bring the settings instance in an inconsistent state where JSON and the link watcher property disagree. Setting any property must immediately update both the JSON and the abstraction API. - when constucting a team setting from D-Bus, we would previously parse both "config" and abstraction properties. That is wrong. Since our settings plugins only support JSON, all information must be present in the JSON config anyway. So, when "config" is present, only the JSON must be parsed. In the best case, the other information is redudant and contributes nothing. In the worse case, they information differs (which might happen if the client version differs from the server version). As the settings plugin only supports JSON, it's wrong to consider redundant, differing information from D-Bus. - we now only convert string to JSON or back when needed. Previously, setting a property resulted in parsing several JSON multiple times (per property). All operations should now scale well and be reasonably efficient. - also the property-changed signals are now handled correctly. Since NMTeamSetting knows the current state of all attributes, it can emit the exact property changed signals for what changed. - we no longer use libjansson to generate the JSON. JSON is supposed to be a machine readable exchange format, hence a major goal is to be easily handled by applications. While parsing JSON is not so trivial, writing a well-known set of values to JSON is. The advantage is that when you build libnm without libjansson support, then we still can convert the artificial properties to JSON. - Requiring libjansson in libnm is a burden, because most of the time it is not needed (as most users don't create team configurations). With this change we only require it to parse the team settings (no longer to write them). It should be reasonably simple to use a more minimalistic JSON parser that is sufficient for us, so that we can get rid of the libjansson dependency (for libnm). This also avoids the pain that we have due to the symbol collision of libjansson and libjson-glib. https://bugzilla.redhat.com/show_bug.cgi?id=1691619
* build/meson: introduce libnm/liblibnm.la as static library for libnm/libnm.laThomas Haller2019-05-222-31/+49
| | | | Same as done for autotools.
* libnm/tests: rename libnm's "test-general" to "test-libnm"Thomas Haller2019-05-192-3/+3
|
* all: use nm_clear_g_dbus_connection_signal() helperThomas Haller2019-05-121-5/+2
| | | | | | | | | I also like this because it's non-obvious that subscription IDs from GDBusConnection are "guint" (contrary to signal handler IDs which are "gulong"). So, by using this API you get a compiler error when using the wrong type. In the past, when switching to nm_clear_g_signal_handler() this uncovered multiple bugs where the wrong type was used to hold the ID.
* all: use nm_dbus_connection_signal_subscribe_name_owner_changed()Thomas Haller2019-05-121-10/+6
| | | | ... and nm_dbus_connection_call_get_name_owner().
* build/meson: rename "nm_core_dep" to "libnm_core_dep"Thomas Haller2019-04-182-4/+4
| | | | | The library is called "libnm_core". So the dependency should be called "libnm_core_dep", like in all other cases.
* shared: build helper "libnm-libnm-core-{intern|aux}.la" library for libnm-coreThomas Haller2019-04-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "libnm-core" implements common functionality for "NetworkManager" and "libnm". Note that clients like "nmcli" cannot access the internal API provided by "libnm-core". So, if nmcli wants to do something that is also done by "libnm-core", , "libnm", or "NetworkManager", the code would have to be duplicated. Instead, such code can be in "libnm-libnm-core-{intern|aux}.la". Note that: 0) "libnm-libnm-core-intern.la" is used by libnm-core itsself. On the other hand, "libnm-libnm-core-aux.la" is not used by libnm-core, but provides utilities on top of it. 1) they both extend "libnm-core" with utlities that are not public API of libnm itself. Maybe part of the code should one day become public API of libnm. On the other hand, this is code for which we may not want to commit to a stable interface or which we don't want to provide as part of the API. 2) "libnm-libnm-core-intern.la" is statically linked by "libnm-core" and thus directly available to "libnm" and "NetworkManager". On the other hand, "libnm-libnm-core-aux.la" may be used by "libnm" and "NetworkManager". Both libraries may be statically linked by libnm clients (like nmcli). 3) it must only use glib, libnm-glib-aux.la, and the public API of libnm-core. This is important: it must not use "libnm-core/nm-core-internal.h" nor "libnm-core/nm-utils-private.h" so the static library is usable by nmcli which couldn't access these. Note that "shared/nm-meta-setting.c" is an entirely different case, because it behaves differently depending on whether linking against "libnm-core" or the client programs. As such, this file must be compiled twice.
* shared: move "nm-dbus-compat.h" header to "nm-std-aux/nm-dbus-compat.h"Thomas Haller2019-04-181-1/+1
|
* shared: move most of "shared/nm-utils" to "shared/nm-glib-aux"Thomas Haller2019-04-182-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | From the files under "shared/nm-utils" we build an internal library that provides glib-based helper utilities. Move the files of that basic library to a new subdirectory "shared/nm-glib-aux" and rename the helper library "libnm-core-base.la" to "libnm-glib-aux.la". Reasons: - the name "utils" is overused in our code-base. Everything's an "utils". Give this thing a more distinct name. - there were additional files under "shared/nm-utils", which are not part of this internal library "libnm-utils-base.la". All the files that are part of this library should be together in the same directory, but files that are not, should not be there. - the new name should better convey what this library is and what is isn't: it's a set of utilities and helper functions that extend glib with funcitonality that we commonly need. There are still some files left under "shared/nm-utils". They have less a unifying propose to be in their own directory, so I leave them there for now. But at least they are separate from "shared/nm-glib-aux", which has a very clear purpose.
* shared: move udev helper to separate directory "shared/nm-udev-aux"Thomas Haller2019-04-181-1/+1
| | | | | | | | We built (among others) two libraries from the sources in "shared/nm-utils": "libnm-utils-base.la" and "libnm-utils-udev.la". It's confusing. Instead use directories so there is a direct correspondence between these internal libraries and the source files.
* all: support bridge vlan rangesBeniamino Galvani2019-04-181-1/+1
| | | | | | | | | | | | In some cases it is convenient to specify ranges of bridge vlans, as already supported by iproute2 and natively by kernel. With this commit it becomes possible to add a range in this way: nmcli connection modify eth0-slave +bridge-port.vlans "100-200 untagged" vlan ranges can't be PVIDs because only one PVID vlan can exist. https://bugzilla.redhat.com/show_bug.cgi?id=1652910
* all: goodbye libnm-glibLubomir Rintel2019-04-166-143/+0
| | | | | | | | | | | | | | | | | | | | | | | 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
* core/qdisc: add support for attributesLubomir Rintel2019-04-121-0/+3
|
* Revert "all: goodbye libnm-glib"Lubomir Rintel2019-04-036-0/+143
| | | | | | We need this for a little little longer :( This reverts commit 1de8383ad9fdfc8f552117e5d109bdfa7005634b.
* libnm: add API to NMSettingIPConfig for routing rulesThomas Haller2019-03-271-0/+5
|
* libnm: add NMIPRoutingRule APIThomas Haller2019-03-271-1/+45
| | | | | | | | | | | | 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).
* libnm/lldp: cleanup asserting for valid NMLldpNeighbor agumentbg/lldp-enh-rh1652211Thomas Haller2019-03-271-12/+19
| | | | | | | | | 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).
* libnm/lldp: fix leak and bug in nm_lldp_neighbor_dup()Thomas Haller2019-03-271-1/+7
| | | | | | | | | | | 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.
* libnm: add nm_lldp_neighbor_get_attr_value()Beniamino Galvani2019-03-273-0/+24
| | | | | The function provides access to the GVariant representing a LLDP attribute.
* libnm: make attribute name const in LLDP API functionsBeniamino Galvani2019-03-272-6/+6
| | | | | | 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.
* libnm-core: add bridge vlan conversion utilsBeniamino Galvani2019-03-261-0/+2
|
* libnm-core: add vlans property to bridge settingBeniamino Galvani2019-03-261-0/+6
|
* libnm-core: add vlans property to bridge-port settingBeniamino Galvani2019-03-261-0/+19
|
* all: add vlan-filtering and vlan-default-pvid bridge propertiesBeniamino Galvani2019-03-261-0/+6
|
* libnm: don't use strlen() for checking for non-empty stringThomas Haller2019-03-251-2/+1
| | | | | | It's well understood that these are NUL terminated strings. We don't need strlen() to check that the strings aren't empty.
* all: goodbye libnm-glibLubomir Rintel2019-03-196-143/+0
| | | | | | | | | | | | | | | | | | | | | | | 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
* libnm: fix dns-configuration property typeBeniamino Galvani2019-03-151-8/+3
| | | | | | | Fixes: a8d600525643 ('libnm: implement support for DNS manager properties') https://bugzilla.redhat.com/show_bug.cgi?id=1689055 (cherry picked from commit d867837d05a808ff90756a41a96f778846522465)
* all: codespell fixesLubomir Rintel2019-03-111-1/+1
| | | | | | | Codespel run with the same arguments as described in commit 58510ed56679 ('docs: misc. typos pt2'). (cherry picked from commit bf0c4e6ac2855088e3962693886bb6ab71856f7b)
* libnm: Fix reporting of unknown device typesBenjamin Berg2019-03-071-2/+2
| | | | | | | | | | | 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 a6a185ba00c6218d9b1ace6e3bd6b57347198246)
* core,wifi-p2p: Fix Wi-Fi P2P device typeBenjamin Berg2019-03-071-0/+3
| | | | | | | | | | 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 8d9365a973025976a15e5e7adb26a6f791957b7c)
* libnm: rename and expose nm_utils_base64secret_decode() in libnmThomas Haller2019-03-071-0/+1
| | | | | | | | | | | | | | | | | | | 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 e46ba0186720bfe5e31dcad9a5001a415deb9ce6)
* nm: Fix syntax on introspection annotationsMarco Trevisan (TreviƱo)2019-03-072-3/+3
| | | | | | | | 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 73005fcf5b957a4cf7f8244da85ade0214db7606)
* wireguard: add "peer-routes" setting for WireGuard profilesThomas Haller2019-03-051-0/+1
| | | | | | | | 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 d719ad31f096583c501af3bea01a01ffd72337d5)
* wireguard: add "mtu" setting for WireGuard profilesThomas Haller2019-03-051-0/+1
| | | | | | This adds new API for 1.16.0 and is an ABI break since 1.16-rc1. (cherry picked from commit d5e93ae613fd355351bdf37530cae3d3dfb4e5ba)
* libnm,core: fix device TYPE for Wi-Fi P2P devicesThomas Haller2019-02-262-0/+8
| | | | | | | | | | | | 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 8f6a8d051731333d94da6f2c43c72a1fd9aed9ff)
* all/trivial: fix whitespace/indentationThomas Haller2019-02-221-3/+3
|
* libnm: add NMWireGuardPeer and libnm support for peersThomas Haller2019-02-221-0/+31
|
* libnm,cli: add NMSettingWireGuardThomas Haller2019-02-223-0/+8
| | | | | | | | | | | | | | 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).
* libnm: fix leak in nm_client_add_and_activate_connection{2,_async}()Thomas Haller2019-02-222-7/+13
| | | | | | | | Detected via valgrind: $ ./tools/run-nm-test.sh -m -v libnm/tests/test-nm-client -p /libnm/active-connections Fixes: fbb038af5e5d675c994de26da676edfd8e73ffbe
* wifi-p2p: drop WiFi-P2P "group-owner" property from D-Bus API and libnmThomas Haller2019-02-213-45/+0
| | | | | | | | | 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
* Add polkit action for Wi-Fi scansJonathan Kang2019-02-212-1/+5
| | | | | | | | | | | | | | | | | | 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
* Remove WFD IEs property from P2P deviceBenjamin Berg2019-02-211-34/+0
| | | | | | | 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.
* core/setting-wifi-p2p: Add WFD IEs property to P2P settingsBenjamin Berg2019-02-211-0/+1
| | | | | | 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.
* libnm: fix leaking checkpoints from NMManagerThomas Haller2019-02-191-0/+2
| | | | Fixes: c3efedf54bc64fd130849096849540ed1294df55
* libnm: fix memleak for NMDeviceTun:hw-addressThomas Haller2019-02-191-0/+1
| | | | Fixes: 337304f19df43eaa6c76a7571094ccc9dc99a4c5
* libnm: fix duplicate free in nm_client_checkpoint_rollback()Thomas Haller2019-02-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | #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: c3efedf54bc64fd130849096849540ed1294df55
* all: cache errno in local variable before using itThomas Haller2019-02-121-1/+0
|