NetworkManager/libnm
Thomas Haller 13f6f3a410 libnm: rework team handling of JSON config
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
2019-05-23 18:09:49 +02:00
..
tests build/meson: introduce libnm/liblibnm.la as static library for libnm/libnm.la 2019-05-22 20:04:08 +02:00
generate-plugin-docs.pl docs: misc. typos pt2 2018-09-17 11:26:13 +02:00
generate-setting-docs.py libnm: rework team handling of JSON config 2019-05-23 18:09:49 +02:00
libnm.pc.in libnm,pkg-config: provide a variable with VPN service directory 2015-08-19 15:13:11 +02:00
libnm.ver all: support bridge vlan ranges 2019-04-18 09:39:28 +02:00
meson.build build/meson: introduce libnm/liblibnm.la as static library for libnm/libnm.la 2019-05-22 20:04:08 +02:00
NetworkManager.h libnm,cli: add NMSettingWireGuard 2019-02-22 11:00:10 +01:00
nm-access-point.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-access-point.h all: don't use gchar/gshort/gint/glong but C types 2018-07-11 12:02:06 +02:00
nm-active-connection.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-active-connection.h libnm: add NMActivationStateFlags 2017-10-05 11:50:31 +02:00
nm-autoptr.h libnm,cli: add NMSettingWireGuard 2019-02-22 11:00:10 +01:00
nm-checkpoint.c all: fix misspellings 2019-01-24 17:19:44 +01:00
nm-checkpoint.h libnm: add checkpoint support 2017-11-09 10:12:30 +01:00
nm-client.c libnm: fix dns-configuration property type 2019-03-15 11:15:37 +01:00
nm-client.h Add polkit action for Wi-Fi scans 2019-02-21 13:49:17 +01:00
nm-dbus-helpers.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-dbus-helpers.h shared: move "nm-dbus-compat.h" header to "nm-std-aux/nm-dbus-compat.h" 2019-04-18 18:59:09 +02:00
nm-device-6lowpan.c libnm: add support form 6LoWPAN devices 2018-06-26 16:21:55 +02:00
nm-device-6lowpan.h libnm: add support form 6LoWPAN devices 2018-06-26 16:21:55 +02:00
nm-device-adsl.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-device-adsl.h include: use double-quotes to include our own headers 2017-03-09 14:12:35 +01:00
nm-device-bond.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-device-bond.h include: use double-quotes to include our own headers 2017-03-09 14:12:35 +01:00
nm-device-bridge.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-device-bridge.h include: use double-quotes to include our own headers 2017-03-09 14:12:35 +01:00
nm-device-bt.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-device-bt.h include: use double-quotes to include our own headers 2017-03-09 14:12:35 +01:00
nm-device-dummy.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-device-dummy.h libnm: add 'hw-address' property to NMDeviceDummy 2017-06-30 22:04:03 +02:00
nm-device-ethernet.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-device-ethernet.h include: use double-quotes to include our own headers 2017-03-09 14:12:35 +01:00
nm-device-generic.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-device-generic.h include: use double-quotes to include our own headers 2017-03-09 14:12:35 +01:00
nm-device-infiniband.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-device-infiniband.h include: use double-quotes to include our own headers 2017-03-09 14:12:35 +01:00
nm-device-ip-tunnel.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-device-ip-tunnel.h ip-tunnel: add support for tunnel flags 2018-01-05 18:25:08 +01:00
nm-device-macsec.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-device-macsec.h include: use double-quotes to include our own headers 2017-03-09 14:12:35 +01:00
nm-device-macvlan.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-device-macvlan.h include: use double-quotes to include our own headers 2017-03-09 14:12:35 +01:00
nm-device-modem.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-device-modem.h include: use double-quotes to include our own headers 2017-03-09 14:12:35 +01:00
nm-device-olpc-mesh.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-device-olpc-mesh.h include: use double-quotes to include our own headers 2017-03-09 14:12:35 +01:00
nm-device-ovs-bridge.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-device-ovs-bridge.h libnm: add accessors for ovs port/bridge slaves 2018-07-10 13:12:07 +02:00
nm-device-ovs-interface.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-device-ovs-interface.h libnm: add support for ovs-interface devices 2017-10-30 17:40:08 +01:00
nm-device-ovs-port.c libnm,core: fix device TYPE for Wi-Fi P2P devices 2019-02-26 09:14:13 +01:00
nm-device-ovs-port.h libnm: add accessors for ovs port/bridge slaves 2018-07-10 13:12:07 +02:00
nm-device-ppp.c device: add NMDevicePPP 2017-08-05 08:03:15 +02:00
nm-device-ppp.h device: add NMDevicePPP 2017-08-05 08:03:15 +02:00
nm-device-private.h libnm: use the o.fd.DBus.ObjectManager API for object management 2016-11-10 16:48:48 +01:00
nm-device-team.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-device-team.h include: use double-quotes to include our own headers 2017-03-09 14:12:35 +01:00
nm-device-tun.c libnm: fix memleak for NMDeviceTun:hw-address 2019-02-19 09:33:05 +01:00
nm-device-tun.h include: use double-quotes to include our own headers 2017-03-09 14:12:35 +01:00
nm-device-vlan.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-device-vlan.h include: use double-quotes to include our own headers 2017-03-09 14:12:35 +01:00
nm-device-vxlan.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-device-vxlan.h include: use double-quotes to include our own headers 2017-03-09 14:12:35 +01:00
nm-device-wifi-p2p.c libnm,core: fix device TYPE for Wi-Fi P2P devices 2019-02-26 09:14:13 +01:00
nm-device-wifi-p2p.h wifi-p2p: drop WiFi-P2P "group-owner" property from D-Bus API and libnm 2019-02-21 15:34:55 +01:00
nm-device-wifi.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-device-wifi.h wifi: expose LastScan as milliseconds not seconds 2018-06-15 16:23:30 +02:00
nm-device-wimax.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-device-wimax.h all: don't use gchar/gshort/gint/glong but C types 2018-07-11 12:02:06 +02:00
nm-device-wireguard.c libnm: fix leak for NMDeviceWireGuard's public_key 2018-08-06 08:34:27 +02:00
nm-device-wireguard.h libnm: introduce NMDeviceWireGuard 2018-08-06 08:34:27 +02:00
nm-device-wpan.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-device-wpan.h libnm: add support for WPAN devices 2018-06-26 16:21:55 +02:00
nm-device.c shared: move udev helper to separate directory "shared/nm-udev-aux" 2019-04-18 18:58:28 +02:00
nm-device.h libnm: add nm_lldp_neighbor_get_attr_value() 2019-03-27 10:17:39 +01:00
nm-dhcp-config.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-dhcp-config.h include: use double-quotes to include our own headers 2017-03-09 14:12:35 +01:00
nm-dhcp4-config.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-dhcp4-config.h build: refine the NETWORKMANAGER_COMPILATION define 2018-01-08 12:38:53 +01:00
nm-dhcp6-config.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-dhcp6-config.h build: refine the NETWORKMANAGER_COMPILATION define 2018-01-08 12:38:53 +01:00
nm-dns-manager.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-dns-manager.h build: refine the NETWORKMANAGER_COMPILATION define 2018-01-08 12:38:53 +01:00
nm-enum-types.c.template build: use template files for enum types' sources generation 2017-12-18 11:25:06 +01:00
nm-enum-types.h.template build: use template files for enum types' sources generation 2017-12-18 11:25:06 +01:00
nm-ip-config.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-ip-config.h include: use double-quotes to include our own headers 2017-03-09 14:12:35 +01:00
nm-ip4-config.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-ip4-config.h build: refine the NETWORKMANAGER_COMPILATION define 2018-01-08 12:38:53 +01:00
nm-ip6-config.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-ip6-config.h build: refine the NETWORKMANAGER_COMPILATION define 2018-01-08 12:38:53 +01:00
nm-libnm-utils.c all: goodbye libnm-glib 2019-04-16 15:52:27 +02:00
nm-libnm-utils.h libnm/utils: extend the product fixup phrase list 2018-02-23 19:47:19 +01:00
nm-manager.c shared: build helper "libnm-libnm-core-{intern|aux}.la" library for libnm-core 2019-04-18 18:59:09 +02:00
nm-manager.h all: return output dictionary from "AddAndActivate2" 2019-01-14 11:56:18 +01:00
nm-object-private.h build: refine the NETWORKMANAGER_COMPILATION define 2018-01-08 12:38:53 +01:00
nm-object.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-object.h docs: misc. typos pt2 2018-09-17 11:26:13 +02:00
nm-remote-connection-private.h build: refine the NETWORKMANAGER_COMPILATION define 2018-01-08 12:38:53 +01:00
nm-remote-connection.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-remote-connection.h libnm/remote-connection: add filename property 2018-06-11 15:06:49 +02:00
nm-remote-settings.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-remote-settings.h build: refine the NETWORKMANAGER_COMPILATION define 2018-01-08 12:38:53 +01:00
nm-secret-agent-old.c libnm: don't use strlen() for checking for non-empty string 2019-03-25 09:12:32 +01:00
nm-secret-agent-old.h include: use double-quotes to include our own headers 2017-03-09 14:12:35 +01:00
nm-types.h wifi-p2p: rename Wi-Fi P2P 2019-02-01 17:02:57 +01:00
nm-vpn-connection.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-vpn-connection.h libnm/nm-vpn-connection: un-deprecate the NMVpnStateReason use in a header 2017-03-20 14:51:11 +01:00
nm-vpn-editor.c all: cleanup includes and let "nm-default.h" include "config.h" 2016-02-19 17:53:25 +01:00
nm-vpn-editor.h all: replace non-leading tabs with spaces 2018-02-07 13:32:04 +01:00
nm-vpn-plugin-old.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-vpn-plugin-old.h include: use double-quotes to include our own headers 2017-03-09 14:12:35 +01:00
nm-vpn-service-plugin.c all: use nm_clear_g_dbus_connection_signal() helper 2019-05-12 09:56:36 +02:00
nm-vpn-service-plugin.h libnm: add nm_vpn_service_plugin_shutdown() API 2018-01-16 14:39:09 +01:00
nm-wifi-p2p-peer.c all: codespell fixes 2019-03-11 12:03:46 +01:00
nm-wifi-p2p-peer.h wifi-p2p: rename Wi-Fi P2P 2019-02-01 17:02:57 +01:00
nm-wimax-nsp.c all: drop unnecessary includes of <errno.h> and <string.h> 2019-02-12 08:50:28 +01:00
nm-wimax-nsp.h include: use double-quotes to include our own headers 2017-03-09 14:12:35 +01:00