• Thomas Haller's avatar
    libnm: rework team handling of JSON config · 13f6f3a4
    Thomas Haller authored
    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
    13f6f3a4
Name
Last commit
Last update
..
tests Loading commit data...
NetworkManager.h Loading commit data...
generate-plugin-docs.pl Loading commit data...
generate-setting-docs.py Loading commit data...
libnm.pc.in Loading commit data...
libnm.ver Loading commit data...
meson.build Loading commit data...
nm-access-point.c Loading commit data...
nm-access-point.h Loading commit data...
nm-active-connection.c Loading commit data...
nm-active-connection.h Loading commit data...
nm-autoptr.h Loading commit data...
nm-checkpoint.c Loading commit data...
nm-checkpoint.h Loading commit data...
nm-client.c Loading commit data...
nm-client.h Loading commit data...
nm-dbus-helpers.c Loading commit data...
nm-dbus-helpers.h Loading commit data...
nm-device-6lowpan.c Loading commit data...
nm-device-6lowpan.h Loading commit data...
nm-device-adsl.c Loading commit data...
nm-device-adsl.h Loading commit data...
nm-device-bond.c Loading commit data...
nm-device-bond.h Loading commit data...
nm-device-bridge.c Loading commit data...
nm-device-bridge.h Loading commit data...
nm-device-bt.c Loading commit data...
nm-device-bt.h Loading commit data...
nm-device-dummy.c Loading commit data...
nm-device-dummy.h Loading commit data...
nm-device-ethernet.c Loading commit data...
nm-device-ethernet.h Loading commit data...
nm-device-generic.c Loading commit data...
nm-device-generic.h Loading commit data...
nm-device-infiniband.c Loading commit data...
nm-device-infiniband.h Loading commit data...
nm-device-ip-tunnel.c Loading commit data...
nm-device-ip-tunnel.h Loading commit data...
nm-device-macsec.c Loading commit data...
nm-device-macsec.h Loading commit data...
nm-device-macvlan.c Loading commit data...
nm-device-macvlan.h Loading commit data...
nm-device-modem.c Loading commit data...
nm-device-modem.h Loading commit data...
nm-device-olpc-mesh.c Loading commit data...
nm-device-olpc-mesh.h Loading commit data...
nm-device-ovs-bridge.c Loading commit data...
nm-device-ovs-bridge.h Loading commit data...
nm-device-ovs-interface.c Loading commit data...
nm-device-ovs-interface.h Loading commit data...
nm-device-ovs-port.c Loading commit data...
nm-device-ovs-port.h Loading commit data...
nm-device-ppp.c Loading commit data...
nm-device-ppp.h Loading commit data...
nm-device-private.h Loading commit data...
nm-device-team.c Loading commit data...
nm-device-team.h Loading commit data...
nm-device-tun.c Loading commit data...
nm-device-tun.h Loading commit data...
nm-device-vlan.c Loading commit data...
nm-device-vlan.h Loading commit data...
nm-device-vxlan.c Loading commit data...
nm-device-vxlan.h Loading commit data...
nm-device-wifi-p2p.c Loading commit data...
nm-device-wifi-p2p.h Loading commit data...
nm-device-wifi.c Loading commit data...
nm-device-wifi.h Loading commit data...
nm-device-wimax.c Loading commit data...
nm-device-wimax.h Loading commit data...
nm-device-wireguard.c Loading commit data...
nm-device-wireguard.h Loading commit data...
nm-device-wpan.c Loading commit data...
nm-device-wpan.h Loading commit data...
nm-device.c Loading commit data...
nm-device.h Loading commit data...
nm-dhcp-config.c Loading commit data...
nm-dhcp-config.h Loading commit data...
nm-dhcp4-config.c Loading commit data...
nm-dhcp4-config.h Loading commit data...
nm-dhcp6-config.c Loading commit data...
nm-dhcp6-config.h Loading commit data...
nm-dns-manager.c Loading commit data...
nm-dns-manager.h Loading commit data...
nm-enum-types.c.template Loading commit data...
nm-enum-types.h.template Loading commit data...
nm-ip-config.c Loading commit data...
nm-ip-config.h Loading commit data...
nm-ip4-config.c Loading commit data...
nm-ip4-config.h Loading commit data...
nm-ip6-config.c Loading commit data...
nm-ip6-config.h Loading commit data...
nm-libnm-utils.c Loading commit data...
nm-libnm-utils.h Loading commit data...
nm-manager.c Loading commit data...
nm-manager.h Loading commit data...
nm-object-private.h Loading commit data...
nm-object.c Loading commit data...
nm-object.h Loading commit data...
nm-remote-connection-private.h Loading commit data...
nm-remote-connection.c Loading commit data...
nm-remote-connection.h Loading commit data...
nm-remote-settings.c Loading commit data...
nm-remote-settings.h Loading commit data...
nm-secret-agent-old.c Loading commit data...
nm-secret-agent-old.h Loading commit data...
nm-types.h Loading commit data...
nm-vpn-connection.c Loading commit data...
nm-vpn-connection.h Loading commit data...
nm-vpn-editor.c Loading commit data...
nm-vpn-editor.h Loading commit data...
nm-vpn-plugin-old.c Loading commit data...
nm-vpn-plugin-old.h Loading commit data...
nm-vpn-service-plugin.c Loading commit data...
nm-vpn-service-plugin.h Loading commit data...
nm-wifi-p2p-peer.c Loading commit data...
nm-wifi-p2p-peer.h Loading commit data...
nm-wimax-nsp.c Loading commit data...
nm-wimax-nsp.h Loading commit data...