1. 12 Feb, 2019 1 commit
  2. 23 Apr, 2018 1 commit
  3. 13 Mar, 2018 1 commit
    • Thomas Haller's avatar
      core/dbus: rework creating numbered D-Bus export path by putting counter into class · 57ab9fd6
      Thomas Haller authored
      I dislike the static hash table to cache the integer counter for
      numbered paths. Let's instead cache the counter at the class instance
      itself -- since the class contains the information how the export
      path should be exported.
      
      However, we cannot use a plain integer field inside the class structure,
      because the class is copied between derived classes. For example,
      NMDeviceEthernet and NMDeviceBridge both get a copy of the NMDeviceClass
      instance. Hence, the class doesn't contain the counter directly, but
      a pointer to one counter that can be shared between sibling classes.
      57ab9fd6
  4. 12 Mar, 2018 1 commit
    • Thomas Haller's avatar
      core/dbus: rework D-Bus implementation to use lower layer GDBusConnection API · 297d4985
      Thomas Haller authored
      Previously, we used the generated GDBusInterfaceSkeleton types and glued
      them via the NMExportedObject base class to our NM types. We also used
      GDBusObjectManagerServer.
      
      Don't do that anymore. The resulting code was more complicated despite (or
      because?) using generated classes. It was hard to understand, complex, had
      ordering-issues, and had a runtime and memory overhead.
      
      This patch refactors this entirely and uses the lower layer API GDBusConnection
      directly. It replaces the generated code, GDBusInterfaceSkeleton, and
      GDBusObjectManagerServer. All this is now done by NMDbusObject and NMDBusManager
      and static descriptor instances of type GDBusInterfaceInfo.
      
      This adds a net plus of more then 1300 lines of hand written code. I claim
      that this implementation is easier to understand. Note that previously we
      also required extensive and complex glue code to bind our objects to the
      generated skeleton objects. Instead, now glue our objects directly to
      GDBusConnection. The result is more immediate and gets rid of layers of
      code in between.
      Now that the D-Bus glue us more under our control, we can address issus and
      bottlenecks better, instead of adding code to bend the generated skeletons
      to our needs.
      
      Note that the current implementation now only supports one D-Bus connection.
      That was effectively the case already, although there were places (and still are)
      where the code pretends it could also support connections from a private socket.
      We dropped private socket support mainly because it was unused, untested and
      buggy, but also because GDBusObjectManagerServer could not export the same
      objects on multiple connections. Now, it would be rather straight forward to
      fix that and re-introduce ObjectManager on each private connection. But this
      commit doesn't do that yet, and the new code intentionally supports only one
      D-Bus connection.
      Also, the D-Bus startup was simplified. There is no retry, either nm_dbus_manager_start()
      succeeds, or it detects the initrd case. In the initrd case, bus manager never tries to
      connect to D-Bus. Since the initrd scenario is not yet used/tested, this is good enough
      for the moment. It could be easily extended later, for example with polling whether the
      system bus appears (like was done previously). Also, restart of D-Bus daemon isn't
      supported either -- just like before.
      
      Note how NMDBusManager now implements the ObjectManager D-Bus interface
      directly.
      
      Also, this fixes race issues in the server, by no longer delaying
      PropertiesChanged signals. NMExportedObject would collect changed
      properties and send the signal out in idle_emit_properties_changed()
      on idle. This messes up the ordering of change events w.r.t. other
      signals and events on the bus. Note that not only NMExportedObject
      messed up the ordering. Also the generated code would hook into
      notify() and process change events in and idle handle, exhibiting the
      same ordering issue too.
      No longer do that. PropertiesChanged signals will be sent right away
      by hooking into dispatch_properties_changed(). This means, changing
      a property in quick succession will no longer be combined and is
      guaranteed to emit signals for each individual state. Quite possibly
      we emit now more PropertiesChanged signals then before.
      However, we are now able to group a set of changes by using standard
      g_object_freeze_notify()/g_object_thaw_notify(). We probably should
      make more use of that.
      
      Also, now that our signals are all handled in the right order, we
      might find places where we still emit them in the wrong order. But that
      is then due to the order in which our GObjects emit signals, not due
      to an ill behavior of the D-Bus glue. Possibly we need to identify
      such ordering issues and fix them.
      
      Numbers (for contrib/rpm --without debug on x86_64):
      
      - the patch changes the code size of NetworkManager by
        - 2809360 bytes
        + 2537528 bytes (-9.7%)
      
      - Runtime measurements are harder because there is a large variance
        during testing. In other words, the numbers are not reproducible.
        Currently, the implementation performs no caching of GVariants at all,
        but it would be rather simple to add it, if that turns out to be
        useful.
        Anyway, without strong claim, it seems that the new form tends to
        perform slightly better. That would be no surprise.
      
        $ time (for i in {1..1000}; do nmcli >/dev/null || break; echo -n .;  done)
        - real    1m39.355s
        + real    1m37.432s
      
        $ time (for i in {1..2000}; do busctl call org.freedesktop.NetworkManager /org/freedesktop org.freedesktop.DBus.ObjectManager GetManagedObjects > /dev/null || break; echo -n .; done)
        - real    0m26.843s
        + real    0m25.281s
      
      - Regarding RSS size, just looking at the processes in similar
        conditions, doesn't give a large difference. On my system they
        consume about 19MB RSS. It seems that the new version has a
        slightly smaller RSS size.
        - 19356 RSS
        + 18660 RSS
      297d4985
  5. 03 Jan, 2017 1 commit
  6. 23 Nov, 2016 1 commit
  7. 04 Oct, 2016 1 commit
    • Thomas Haller's avatar
      core: refactor private data in "src" · 4d37f7a1
      Thomas Haller authored
      - use _NM_GET_PRIVATE() and _NM_GET_PRIVATE_PTR() everywhere.
      
      - reorder statements, to have GObject related functions (init, dispose,
        constructed) at the bottom of each file and in a consistent order w.r.t.
        each other.
      
      - unify whitespaces in signal and properties declarations.
      
      - use NM_GOBJECT_PROPERTIES_DEFINE() and _notify()
      
      - drop unused signal slots in class structures
      
      - drop unused header files for device factories
      4d37f7a1
  8. 19 Feb, 2016 1 commit
    • Thomas Haller's avatar
      all: cleanup includes and let "nm-default.h" include "config.h" · 8bace23b
      Thomas Haller authored
      - All internal source files (except "examples", which are not internal)
        should include "config.h" first. As also all internal source
        files should include "nm-default.h", let "config.h" be included
        by "nm-default.h" and include "nm-default.h" as first in every
        source file.
        We already wanted to include "nm-default.h" before other headers
        because it might contains some fixes (like "nm-glib.h" compatibility)
        that is required first.
      
      - After including "nm-default.h", we optinally allow for including the
        corresponding header file for the source file at hand. The idea
        is to ensure that each header file is self contained.
      
      - Don't include "config.h" or "nm-default.h" in any header file
        (except "nm-sd-adapt.h"). Public headers anyway must not include
        these headers, and internal headers are never included after
        "nm-default.h", as of the first previous point.
      
      - Include all internal headers with quotes instead of angle brackets.
        In practice it doesn't matter, because in our public headers we must
        include other headers with angle brackets. As we use our public
        headers also to compile our interal source files, effectively the
        result must be the same. Still do it for consistency.
      
      - Except for <config.h> itself. Include it with angle brackets as suggested by
        https://www.gnu.org/software/autoconf/manual/autoconf.html#Configuration-Headers
      8bace23b
  9. 10 Nov, 2015 1 commit
    • Thomas Haller's avatar
      core: fix wrongly exporting object before instance is fully constructed · 8a8ecc46
      Thomas Haller authored
      Exporting the object already in the *_init() function will later
      break because the object is not yet fully initialized at that point.
      
      Add a convenient flag so that the NMExportedObject parent implementation
      automatically can export itself. This saves the derived class from
      overwriting the constructed() method.
      
      Also add an assertion to catch such bugs.
      8a8ecc46
  10. 10 Aug, 2015 1 commit
  11. 05 Aug, 2015 1 commit
  12. 24 Jul, 2015 4 commits
    • Dan Winship's avatar
      core: port NMDhcp4Config/NMDhcp6Config to GVariant · 94078a13
      Dan Winship authored
      In the gdbus port, the :options properties will be GVariant-valued
      (and thus immutable), so having APIs that let you repeatedly modify
      them would make things complicated. Since we actually only ever set
      all the options at once, just change the APIs to do that, rather than
      setting the options one-by-one.
      
      Since nm-dispatcher already works in terms of GVariant, it makes
      things simpler there if NMDhcp[46]Config can return its options as a
      GVariant. And since we'll need it to be a GVariant internally later
      anyway, just port everything to GVariant now, and convert it to a
      GHashTable for dbus-glib only in get_property().
      94078a13
    • Dan Winship's avatar
      core: move D-Bus export/unexport into NMExportedObject · c1dd3b6e
      Dan Winship authored
      Move D-Bus export/unexport handling into NMExportedObject and remove
      type-specific export/get_path methods (export paths are now specified
      at the class level, and NMExportedObject handles the counters for all
      exported types automatically).
      
      Since all exportable objects now use the same get_path() method, we
      can also add some helper methods to simplify get_property()
      implementations for object-path and object-path-array properties.
      c1dd3b6e
    • Dan Winship's avatar
      core: add an NMExportedObject base class · 6fcc1dee
      Dan Winship authored
      Add NMExportedObject, make it the base class of all D-Bus-exported
      types, and move the nm-properties-changed-signal logic into it. (Also,
      make NMSettings use the same properties-changed code as everything
      else, which it was not previously doing, presumably for historical
      reasons).
      
      (This is mostly just shuffling code around at this point, but
      NMExportedObject will be more important in the gdbus port, since
      gdbus-codegen doesn't do a very good job of supporting objects that
      export multiple interfaces [as each NMDevice subclass does, for
      example], so we will need more glue/helper code in NMExportedObject
      then.)
      6fcc1dee
    • Dan Winship's avatar
      all: rename nm-glib-compat.h to nm-glib.h, use everywhere · 3452ee2a
      Dan Winship authored
      Rather than randomly including one or more of <glib.h>,
      <glib-object.h>, and <gio/gio.h> everywhere (and forgetting to include
      "nm-glib-compat.h" most of the time), rename nm-glib-compat.h to
      nm-glib.h, include <gio/gio.h> from there, and then change all .c
      files in NM to include "nm-glib.h" rather than including the glib
      headers directly.
      
      (Public headers files still have to include the real glib headers,
      since nm-glib.h isn't installed...)
      
      Also, remove glib includes from header files that are already
      including a base object header file (which must itself already include
      the glib headers).
      3452ee2a
  13. 13 Nov, 2014 1 commit
    • Dan Winship's avatar
      all: consistently include config.h · 3bfb163a
      Dan Winship authored
      config.h should be included from every .c file, and it should be
      included before any other include. Fix that.
      
      (As a side effect of how I did this, this also changes us to
      consistently use "config.h" rather than <config.h>. To the extent that
      it matters [which is not much], quotes are more correct anyway, since
      we're talking about a file in our own build tree, not a system
      include.)
      3bfb163a
  14. 01 Aug, 2014 2 commits
    • Dan Winship's avatar
      libnm: rename NetworkManager.h and NetworkManagerVPN.h · 3ddce748
      Dan Winship authored
      "NetworkManager.h"'s name (and non-standard capitalization) suggest
      that it's some sort of high-level super-important header, but it's
      really just low-level D-Bus stuff. Rename it to "nm-dbus-interface.h"
      and likewise "NetworkManagerVPN.h" to "nm-vpn-dbus-interface.h"
      3ddce748
    • Dan Winship's avatar
      libnm, core, cli, tui: fix the capitalization of various types · 3ac0f528
      Dan Winship authored
      GLib/Gtk have mostly settled on the convention that two-letter
      acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
      become initial-caps-only (eg, "Tcp").
      
      NM was inconsistent, with most long acronyms using initial caps only
      (Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
      PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
      three-or-more-letter-long acronyms (and update nmcli and nmtui for the
      libnm changes).
      3ac0f528
  15. 19 Jun, 2014 1 commit
  16. 20 May, 2013 2 commits
  17. 08 Apr, 2013 1 commit
    • Dan Williams's avatar
      core: use wrappers for DBus object registration/unregistration · 3c7f267f
      Dan Williams authored
      When providing a service on the bus daemon and a private connection,
      we'll need to track objects so we can register them with the
      private connection too.  Thus all registration/unregistration
      calls have to go through the NMDBusManager, not straight to
      dbus-glib.
      3c7f267f
  18. 11 May, 2011 1 commit
  19. 25 Feb, 2009 1 commit
    • Dan Williams's avatar
      core: ensure superclass' finalize method is called · f648c269
      Dan Williams authored
      Fixes a crash with PropertyChanged signals (triggered when using wifi + vpn and
      rmmod-ing the driver) where properties_changed_info_destroy() wouldn't get
      called on object destruction becuase the GObject finalize method never got
      called for the DHCP4Config and IP4Config objects.
      f648c269
  20. 03 Nov, 2008 1 commit
  21. 07 Aug, 2008 1 commit
    • Dan Williams's avatar
      2008-08-07 Dan Williams <dcbw@redhat.com> · 881370ab
      Dan Williams authored
      	* include/NetworkManager.h
      		- Add the DHCP4Config D-Bus interface
      
      	* libnm-glib/Makefile.am
      	  libnm-glib/nm-dhcp4-config.c
      	  libnm-glib/nm-dhcp4-config.h
      		- Handle DHCP4 config objects exported by NM over D-Bus
      
      	* libnm-glib/nm-device.c
      	  libnm-glib/nm-device.h
      		- Add a 'dhcp4-config' property
      
      	* libnm-glib/libnm-glib-test.c
      		- Print out DHCP4 config for devices
      		- Fix some crashes when no connections are active
      
      	* src/nm-device-interface.c
      	  src/nm-device.c
      	  src/nm-dhcp4-config.c
      	  src/nm-dhcp4-config.h
      		- Treat dhcp4-config object as an object path at the D-Bus interface so
      			that when it doesn't exist we can proxy it as "/" which dbus-glib
      			doesn't let us do when the property type is G_TYPE_OBJECT
      
      
      
      git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3905 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
      881370ab
  22. 17 Jul, 2008 1 commit
    • Dan Williams's avatar
      2008-07-17 Dan Williams <dcbw@redhat.com> · edda4463
      Dan Williams authored
      	* introspection/Makefile.am
      	  introspection/nm-device.xml
      	  introspection/nm-dhcp4-config.xml
      		- Add bits for the DHCP4Config property of the device, and the DHCP4Config
      			itself
      	* src/nm-device-interface.c
      	  src/nm-device-interface.h
      		- Add the DHCP4Config property
      
      	* src/nm-device.c
      		- Keep track of DHCP4 options via a new DHCP4Config property and notify
      			D-Bus clients when it changes
      
      	* src/nm-dhcp4-config.c
      	  src/nm-dhcp4-config.h
      		- Simple object to store DHCP4 options, export them over D-Bus, and
      			notify when they change
      
      	* src/dhcp-manager/nm-dhcp-manager.c
      	  src/dhcp-manager/nm-dhcp-manager.h
      		- (nm_dhcp_manager_set_dhcp4_config, copy_dhcp4_config_option): copy and
      			filter server-returned DHCP options into an NMDHCP4Config object
      
      
      
      git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3829 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
      edda4463