summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* checkpoint: minor cleanup of device_checkpoint_create()th/checkpointThomas Haller2018-03-301-13/+10
| | | | | | | | | | | | - indent with spaces for wrapped line - drop g_return_val_if_fail(). It really shouldn't happen, and if it does, we can just continue and will hit g_critical() warnings below, when using the variables. - get the NMActRequest instance first, and from there the applied and settings connection. Not the other way around. nm_device_get_settings_connection() and nm_device_get_applied_connection() are just convenience functions to get the fields from act_request.
* examples: improve checkpoint.py for python/giThomas Haller2018-03-291-48/+100
| | | | | | | | - make python2 and python3 compatible - support Checkpoint create flags (requires recent libnm for GI of flags) - support adjust-rollback-timeout command - print elapsed time in show output
* examples: add python utils for examplesThomas Haller2018-03-292-0/+74
| | | | | | | | | | | | | We need common operations from the python scripts. For example, to print the boot-time. Move such utils to a separate nmex.py file ("ex" for example). This file should contain helper functions that are pure python (or, if the have requirements, load them only on demand, so that examples that need those have additional dependencies). It should also be simple to extract individual helpers from nmex, so that the user can take an example, merge parts of nmex.py in, and modify it to his needs.
* checkpoint: allow resetting the rollback timeout via D-BusThomas Haller2018-03-2912-4/+302
| | | | | | | | | | | | | | | | | | | | | | This allows to adjust the timeout of an existing checkpoint. The main usecase of checkpoints, is to have a fail-safe when configuring the network remotely. By allowing to reset the timeout, the user can perform a series of actions, and keep bumping the timeout. That way, the entire series is still guarded by the same checkpoint, but the user can start with short timeout, and re-adjust the timeout as he goes along. The libnm API only implements the async form (at least for now). Sync methods are fundamentally wrong with D-Bus, and it's probably not needed. Also, follow glib convenction, where the async form doesn't have the _async name suffix. Also, accept a D-Bus path as argument, not a NMCheckpoint instance. The libnm API should not be more restricted than the underlying D-Bus API. It would be cumbersome to require the user to lookup the NMCheckpoint instance first, especially since libnm doesn't provide an efficient or convenient lookup-by-path method. On the other hand, retrieving the path from a NMCheckpoint instance is always possible.
* checkpoint: generate GIR information for NMCheckpointCreateFlagsThomas Haller2018-03-292-2/+3
| | | | | | | Note that this changes API for checkpoint_create_async() in Python via GIR. Previously it would require an integer argument, now a flags argument. But this API is still unstable, it will be introduced with 1.12.
* checkpoint: refactor setting error for lookup checkpoint failureThomas Haller2018-03-292-15/+11
| | | | | This changes the error reason in nm_checkpoint_manager_rollback() from NM_MANAGER_ERROR_FAILED to NM_MANAGER_ERROR_INVALID_ARGUMENTS.
* checkpoint: allow overlapping checkpointsThomas Haller2018-03-294-30/+78
| | | | | | | | | | | | | | | | | | | | Introduce a new flag NM_CHECKPOINT_CREATE_FLAG_ALLOW_OVERLAPPING that allows the creation of overlapping checkpoints. Before, and by default, checkpoints that reference a same device conflict, and creating such a checkpoint failed. Now, allow this. But during rollback automatically destroy all overlapping checkpoints that were created after the checkpoint that is about to rollback. With this, you can create a series of checkpoints, and rollback them individually. With the restrictin, that if you once rolled back to an older checkpoint, you no longer can roll"forward" to a younger one. What is also new here, is that the checkpoint might be automatically destroyed by NetworkManager before the timeout expires. When the user later would try to manually destroy/rollback such a checkpoint, it would fail because the checkpoint no longer exists.
* checkpoint: don't let nm_checkpoint_new() failThomas Haller2018-03-293-14/+12
| | | | | | | We already do error checking in nm_checkpoint_manager_create(). No need to split it in two places. Let all error conditions be handled by nm_checkpoint_manager_create() first, and then once we decide all is good, nm_checkpoint_new() can no longer fail.
* checkpoint: let each checkpoint schedule its own timeoutThomas Haller2018-03-293-66/+65
| | | | | Instead of having NMCheckpointManager schedule one timeout for all, let each NMCheckpoint do it itself.
* checkpoint: simplify device_checkpoint_create() to never failThomas Haller2018-03-291-11/+8
| | | | It never failed already. Don't pretend it could.
* checkpoint: rework timeout tracking for checkpointsThomas Haller2018-03-291-7/+14
| | | | | | | | | | Instead of scheduling one timeout only, let each checkpoint instance individually schedule a timeout. This has some overhead, but glib is supposed to make scheduling many timers efficient. Otherwise, glib should be fixed. This simplifies in my opinion the code, because it's up to each checkpoint to maintain it's own timeout.
* checkpoint: don't explicitly track checkpoints in a GHashTableThomas Haller2018-03-293-72/+76
| | | | | We already have a GHashTable for exported objects. We can use that if we want to look up by path efficiently.
* checkpoint: refactor nm_checkpoint_manager_create() to simplify creating ↵Thomas Haller2018-03-291-26/+18
| | | | | | | | device list If no device paths are given, we can take the devices directly. We don't need to first create a list of paths, and then look them up by path again to add them to the list.
* checkpoint: skip unrealized devices in nm_checkpoint_manager_create()Thomas Haller2018-03-291-0/+5
| | | | We already do it for the case where no paths are provided.
* checkpoint/trivial: rename local variable @checkpoint_pathThomas Haller2018-03-292-19/+19
| | | | | path is long enough and (in this context) it consistently references the checkpoint "path".
* checkpoint/trivial: rename nm_checkpoint_manager_unref() to ↵Thomas Haller2018-03-293-3/+4
| | | | | | | | | | | | | | | | | | | | | | nm_checkpoint_manager_free() NMCheckpointManager was added and is not ref-countable, because it is not needed. I still often like for such objects (that are not ref-countable), that their destroy function is called "unref". Both for consistency, and also if we would later add ref-counting to the object. However, NMCheckpointManager keeps a pointer to NMManager. So, when NMManager gets destroyed, it *MUST* destroy the NMCheckpointManager. It cannot accept that the checkpoint manager outlives NMManager, but the "unref" name suggests that somebody else might have still a reference to this object keeping it alive. That is not the case. Rename so that this is clear. I would name it nm_checkpoint_manager_destroy(), but "destroy" already has a meaning for NMCheckpoint instances, so use "free".
* checkpoint: embed CList in NMCheckpoint instanceThomas Haller2018-03-294-48/+51
| | | | | | | | We don't need an external CheckpointItem, just to wrap the CList instance. Embed it directly in NMCheckpoint. Sure, that exposes the checkpoints_lst field in the (internal) header file, hiding the private member less.
* libnm: fix crash creating checkpoint during find_checkpoint_info()Thomas Haller2018-03-291-10/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that the D-Bus signals in server are reordered, creating a checkpoint in libnm crashes: $ examples/python/gi/checkpoint.py create 4 #0 0x00007ffff6d011ee in __strcmp_sse2_unaligned () at /lib64/libc.so.6 #1 0x00007fffeb611c90 in find_checkpoint_info (manager=manager@entry=0x5555559e5110 [NMManager], path=0x7fffdc0092f0 "/org/freedesktop/NetworkManager/Checkpoint/6") at libnm/nm-manager.c:153 #2 0x00007fffeb611d8f in checkpoint_added (manager=0x5555559e5110 [NMManager], checkpoint=checkpoint@entry=0x555555a122d0 [NMCheckpoint]) at libnm/nm-manager.c:1194 #3 0x00007fffef7db929 in g_cclosure_marshal_VOID__OBJECTv (closure=0x5555559e4b30, return_value=<optimized out>, instance=<optimized out>, args=<optimized out>, marshal_data=<optimized out>, n_params=<optimized out>, param_types=0x5555559e2fc0) at gmarshal.c:2102 #4 0x00007fffef7d8976 in _g_closure_invoke_va (closure=0x5555559e4b30, return_value=0x0, instance=0x5555559e5110, args=0x7fffffffc1c8, n_params=1, param_types=0x5555559e2fc0) at gclosure.c:867 #5 0x00007fffef7f3ff4 in g_signal_emit_valist (instance=instance@entry=0x5555559e5110, signal_id=signal_id@entry=97, detail=0, var_args=var_args@entry=0x7fffffffc1c8) at gsignal.c:3300 #6 0x00007fffef7f4b48 in g_signal_emit_by_name (instance=instance@entry=0x5555559e5110, detailed_signal=detailed_signal@entry=0x7fffffffc310 "checkpoint-added") at gsignal.c:3487 #7 0x00007fffeb6156d1 in deferred_notify_cb (data=0x5555559e5110) at libnm/nm-object.c:219 #8 0x00007fffeb615ae7 in object_property_maybe_complete (self=0x5555559e5110 [NMManager]) at libnm/nm-object.c:555 #9 0x00007fffeb615e5d in object_created (obj=<optimized out>, path=<optimized out>, user_data=<optimized out>) at libnm/nm-object.c:576 #10 0x00007fffeb61648b in handle_object_array_property (pi=<optimized out>, value=0x7fffdc075070, property_name=0x7fffeb67f117 "checkpoints", self=0x5555559e5110 [NMManager]) at libnm/nm-object.c:671 #11 0x00007fffeb61648b in handle_property_changed (self=self@entry=0x5555559e5110 [NMManager], dbus_name=<optimized out>, value=<optimized out>) at libnm/nm-object.c:740 #12 0x00007fffeb6166e9 in properties_changed (proxy=<optimized out>, changed_properties=<optimized out>, invalidated_properties=<optimized out>, user_data=0x5555559e5110) at libnm/nm-object.c:772 ... That is, because NetworkManager now first emits signals that the checkpoint object was created, before answering the D-Bus request. That makes more sense, but leads to this crash. The ugliness of how libnm handles object visibility is considerable. libnm hides objects until they are fully initialized. So, when the async create-checkpoint operation returns, the object might not yet be ready to be exposed. We need to delay the result. It would be better if the API would simply return the created path.
* libnm: minor cleanup of nm_manager_get_device_by_path()Thomas Haller2018-03-291-5/+3
|
* device/trival: rename NMIwdManagerPrivate.nm_manager field to "manager"Thomas Haller2018-03-291-9/+9
| | | | | | Similar cases of such a field are name "manager". Also, internal names shall not have an "nm" prefix, contrary to names in a header file, which shall have such a prefix.
* core: add macro for iterating CList of devices of NMManagerThomas Haller2018-03-296-33/+36
| | | | | | I find it slightly nicer and explict. Also, the list elements are strictly speaking private, we should better not explicitly use them outside of NMManager/NMDevice. The macro hides this.
* core: drop unused nm_dbus_utils_g_value_set_object_path_array() functionThomas Haller2018-03-292-32/+0
|
* checkpoint: rework getting NM_CHECKPOINT_DEVICES propertyThomas Haller2018-03-291-7/+3
|
* core: add nm_dbus_utils_g_value_set_object_path_from_hash() helperThomas Haller2018-03-292-1/+35
|
* libnm: don't use GTK-Doc comment in nm-autoptr.hBeniamino Galvani2018-03-281-2/+2
| | | | | | | | | It generates the following warning: libnm/nm-autoptr.h:25: Error: NM: identifier not found on the first line: * Note that you might use this header with older versions of libnm Fixes: ff8e56336574a168d427a993d666d9e038aacbaf
* contrib/nm-live-vm: remove nm-live-vm scriptsThomas Haller2018-03-276-317/+0
| | | | | | | | | | | | | | They were not (notably) touched in more than 3 years. I doubt anybody is using them. Also, nowadays we have contrib/rpm to build NetworkManager packages for Fedora/RPM. We have copr, we have automated CI in CentOS CI and beaker. Also, nowadays it should be easy to spawn a a fedora image in a container or tools like vagrant. I think there are better alternatives. Drop the scripts.
* shared/nm-glib: add compat implementation for g_autofreeThomas Haller2018-03-271-0/+8
| | | | | | | | Eventually, we should replace our uses of libgsystem's gsystem-local-alloc.h by glib's g_auto*. As a first tiny step, add a compat implementation for g_autofree, so that we could at least go ahead and use it instead of gs_free. https://bugzilla.gnome.org/show_bug.cgi?id=794294
* libnm: add nm-autoptr.h headerThomas Haller2018-03-273-0/+88
| | | | | | | | | | | | | | | | | | | "nm-autoptr.h" is done in a way that allows you to copy the header in your source tree to support older versions of libnm, that didn't contain the header yet. For example, we might want to use it in network-manager-applet, but we don't want to bump the libnm dependency to 1.11.2+ only to get this functionality. Note that G_DEFINE_AUTOPTR_CLEANUP_FUNC() was added in glib 2.43.4, and requires compiler support for the cleanup attribute. The compiler support is taken as given, because we rely on it already. However, NetworkManager and network-manager-applet still don't depend on a glib version recent enough to provide these macros. To actually use them (*inside*) NetworkManager/network-manager-applet, we either would have to bump the glib minimal dependency, or reimplement g_autoptr in /shared/nm-utils/nm-glib.h compat header. https://bugzilla.gnome.org/show_bug.cgi?id=794294
* core: merge branch 'th/dbus-cache-properties'Thomas Haller2018-03-2732-764/+775
|\ | | | | | | https://github.com/NetworkManager/NetworkManager/pull/82
| * all: use nm_utils_hash_keys_to_array()Thomas Haller2018-03-276-58/+39
| |
| * config: cleanup fields in NMGlobalDnsConfigThomas Haller2018-03-273-84/+132
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - consistently set options, searches, domains fields to %NULL, if there are no values. - in nm_global_dns_config_update_checksum(), ensure that we uniquely hash values. E.g. a config with "searches[a], options=[b]" should hash differently from "searches=[ab], options=[]". - in nm_global_dns_config_to_dbus(), reuse the sorted domain list. We already have it, and it guarantees a consistent ordering of fields. - in global_dns_domain_from_dbus(), fix memleaks if D-Bus strdict contains duplicate entries.
| * config/trivial: rename dns_config local variableThomas Haller2018-03-272-75/+75
| | | | | | | | | | The variable serves a similar purpose, but is called "dns", "conf", and "dns_config". Choose one name: "dns_config".
| * shared: add nm_utils_hash_keys_to_array() helperThomas Haller2018-03-272-21/+36
| |
| * wifi: rework tracking of wifi-aps to use CListThomas Haller2018-03-278-289/+219
| | | | | | | | | | | | | | | | | | | | | | - no longer track APs in a hash table with their exported path as key. The exported path is already tracked by NMDBusManager's lookup index, so we can reuse that for fast lookup by path. Otherwise, track the APs in a CList per device. - as we now track APs in a CList, their order is well defined. We no longer need to sort APs and obsoletes nm_wifi_aps_get_sorted() and simplifies nm_wifi_aps_find_first_compatible().
| * core: rework lookup for exported objects by path to use indexThomas Haller2018-03-271-14/+20
| | | | | | | | | | | | We already track an index of exported objects in NMDBusManager. Actually, that index was unused previously. We either could drop it, or use it. Let's use it.
| * manager: convert hwaddr to binary once in find_device_by_permanent_hw_addr()Thomas Haller2018-03-271-2/+4
| | | | | | | | | | | | | | For comparing MAC addresses, they anyway have to be normalized to binary. Convert it once outside the loop and pass the binary form to nm_utils_hwaddr_matches(). Otherwise, we need to re-convert it every time.
| * core: track devices in manager via embedded CListThomas Haller2018-03-279-203/+205
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of using a GSList for tracking the devices, use a CList. I think a CList is in most cases the more suitable data structure then GSList: - you can find out in O(1) whether the object is linked. That is nice, for example to assert in NMDevice's destructor that the object was unlinked, and we will use that later in nm_manager_get_device_by_path(). - you can unlink the element in O(1) and you can unlink the element without having access to the link's head - Contrary to GSList, this does not require an extra slice allocation for the link node. It quite possibliy consumes slightly less memory because the CList structure is embedded in a struct that we already allocate. Even if slice allocation would be perfect to only consume 2*sizeof(gpointer) for the link note, it would at most be as-good as CList. Quite possibly, there is an overhead though. - CList possibly has better memory locality, because the link structure and the data are close to each other. Something which could be seen as disavantage, is that with CList one device can only be tracked in one NMManager instance at a time. But that is fine. There exists only one NMManager instance for now, and even if we would ever introduce multiple managers, we probably would not associate one NMDevice instance with multiple managers. The advantages are arguably not huge, but CList is IMHO clearly the more suited data structure. No need to stick to a suboptimal data structure for the job. Refactor it.
| * core/dbus: manually inline helper function to emit InterfacesAdded signalThomas Haller2018-03-261-26/+12
| |
| * core/dbus: cache variants for D-Bus exported propertiesThomas Haller2018-03-263-24/+65
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GVariant is immutable and can nicely be shared and cached. Cache the property variants. This makes getting the properties faster, at the expense of using some extra memory. Tested with https://tratt.net/laurie/src/multitime/ $ multitime -n 200 -s 0 bash -c 'echo -n .; exec busctl call org.freedesktop.NetworkManager /org/freedesktop org.freedesktop.DBus.ObjectManager GetManagedObjects &>/dev/null' # Mean Std.Dev. Min Median Max # real(before) 0.013+/-0.0000 0.001 0.012 0.013 0.019 # real(after) 0.013+/-0.0000 0.002 0.011 0.012 0.034 $ multitime -n 100 -s 0 bash -c 'for i in {1..5}; do busctl call org.freedesktop.NetworkManager /org/freedesktop org.freedesktop.DBus.ObjectManager GetManagedObjects &>/dev/null & done; wait; echo -n .' # Mean Std.Dev. Min Median Max # real(before) 0.040+/-0.0000 0.002 0.037 0.040 0.049 # real(after) 0.037+/-0.0000 0.002 0.034 0.036 0.045 $ multitime -n 30 -s 0 bash -c 'for i in {1..100}; do busctl call org.freedesktop.NetworkManager /org/freedesktop org.freedesktop.DBus.ObjectManager GetManagedObjects &>/dev/null & done; wait; echo -n .' # Mean Std.Dev. Min Median Max # real(before) 0.704+/-0.0000 0.016 0.687 0.701 0.766 # real(after) 0.639+/-0.0000 0.013 0.622 0.637 0.687 $ multitime -n 200 -s 0 bash -c 'echo -n .; exec nmcli &>/dev/null' # Mean Std.Dev. Min Median Max # real(before) 0.092+/-0.0000 0.005 0.081 0.092 0.119 # real(after) 0.092+/-0.0000 0.005 0.080 0.091 0.123 $ multitime -n 100 -s 0 bash -c 'for i in {1..5}; do nmcli &>/dev/null & done; wait; echo -n .' # Mean Std.Dev. Min Median Max # real(before) 0.436+/-0.0000 0.043 0.375 0.424 0.600 # real(after) 0.413+/-0.0000 0.022 0.380 0.410 0.558 $ multitime -n 20 -s 0 bash -c 'for i in {1..100}; do nmcli &>/dev/null & done; wait; echo -n .' # Mean Std.Dev. Min Median Max # real(before) 8.796+/-0.1070 0.291 8.073 8.818 9.247 # real(after) 8.736+/-0.0893 0.243 8.017 8.780 9.101 The time savings are small, but that is because caching mostly speeds up the GetManagedObjects calls, and that is only a small part of the entire nmcli call from client side.
* libnm-core: trivial: fix indentationFrancesco Giudici2018-03-261-7/+7
|
* platform: reorder failure checks in nm_platform_ip_route_sync()Thomas Haller2018-03-261-5/+5
| | | | | | | | | Move handling non-NM_IP_CONFIG_SOURCE_USER routes first. These are routes that were added manually by the user in the connection. Note that there is no change in behavior, because of how _err_inval_due_to_ipv6_tentative_pref_src() would only accept user routes already.
* ndisc/trivial: indentation and add "const" to auto variableThomas Haller2018-03-261-24/+24
|
* libnm: don't use deprecated tags for GOobject introspectionThomas Haller2018-03-269-31/+14
|\ | | | | | | | | https://bugzilla.gnome.org/show_bug.cgi?id=744250 https://bugzilla.gnome.org/show_bug.cgi?id=794658
| * libnm-glib: do not use deprecated Gtk-Doc Type: and Virtual: tagsJiří Klimeš2018-03-264-17/+6
| | | | | | | | | | | | Signed-off-by: Jiří Klimeš <jklimes@redhat.com> https://bugzilla.gnome.org/show_bug.cgi?id=744250
| * libnm: don't use deprecated tags for GOobject introspectionJiří Klimeš2018-03-265-24/+8
| | | | | | | | | | | | | | | | | | | | Top level tags are deprecated in favour of identifier annotations. https://mail.gnome.org/archives/commits-list/2013-October/msg03220.html https://wiki.gnome.org/action/show/Projects/GObjectIntrospection/Annotations?action=show&redirect=GObjectIntrospection%2FAnnotations#Type_signature Signed-off-by: Jiří Klimeš <jklimes@redhat.com> https://bugzilla.gnome.org/show_bug.cgi?id=744250
* | gobject-introspection: made several fixes to the annotationsCorentin Noël2018-03-2624-100/+46
|/ | | | https://bugzilla.gnome.org/show_bug.cgi?id=794658
* platform: improve logging message for failure to add routeThomas Haller2018-03-221-4/+6
| | | | | The errno for this particular failure differs between IPv4 and IPv6. Of course it does.
* platform: assert for valid argument in nmp_object_unref()Thomas Haller2018-03-221-0/+2
|
* manager: retry activating devices when the parent becomes managedBeniamino Galvani2018-03-221-0/+4
| | | | | | | | | | | | | Since commit ed640f857a1a ("manager: ignore unmanaged devices when looking for parent by UUID"), unmanaged devices are ignored when looking for potential parent connection matches. Therefore, a software device can fail autoactivation because the parent is not managed yet and NM never tries to reactivate it. Ensure that we retry other devices when a parent device becomes managed. Fixes: ed640f857a1a1eae45d92cce35ea8dcfd8aba08d https://bugzilla.redhat.com/show_bug.cgi?id=1553595
* core: merge branch 'th/ipv6-ll-reapply-rh1552069' (#75)Thomas Haller2018-03-2132-1997/+817
|\ | | | | | | | | | | | | A larger branch of refactoring and cleanups. This was a spin-off of pr#75, as the branch grew too large. https://github.com/NetworkManager/NetworkManager/pull/75