After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 770315 - [review] bg/checkpoint-improvements-bgo770315: Improve the checkpoint/rollback functionality
[review] bg/checkpoint-improvements-bgo770315: Improve the checkpoint/rollbac...
Status: RESOLVED FIXED
Product: NetworkManager
Classification: Platform
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: NetworkManager maintainer(s)
NetworkManager maintainer(s)
Depends on:
Blocks: nm-review
 
 
Reported: 2016-08-24 07:21 UTC by Beniamino Galvani
Modified: 2016-09-26 13:14 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Beniamino Galvani 2016-08-24 07:21:09 UTC
Improve the behavior of checkpoint/rollback code.

See: https://bugzilla.gnome.org/show_bug.cgi?id=757858#c8
Comment 1 Beniamino Galvani 2016-09-08 12:25:11 UTC
Pushed bg/checkpoint-improvements-bgo770315 branch for review.
Comment 2 Thomas Haller 2016-09-08 13:21:42 UTC
>> core: allow passing an applied connection to nm_act_request_new()
    

in set_property(), both setting PROP_INT_SETTINGS_CONNECTION and PROP_INT_APPLIED_CONNECTION will try to initialize priv->applied_connection.

That's IMO wrong. The setter should only remember the setting and it should be handled in the "constructed()" method.

constructed(...)
{
   ...
   if (!priv->applied_connection) {
       if (priv->settings_connection)
            priv->applied_connection = clone(priv->settings_connection);
   } else
       priv->applied_connection = clone(priv->applied_connection);




nm_settings_get_connection_by_uuid (nm_settings_get(), con_uuid);
whitespace                                 ^^^^^^^^^^^



+    gboolean realized;
+    gboolean unmanaged_explicit;

    bool realized:1;
?
Comment 3 Thomas Haller 2016-09-09 12:07:45 UTC
>> checkpoint: better handle unmanaged and unrealized devices
    

+activate:
+         if (dev_checkpoint->state == NM_DEVICE_STATE_UNMANAGED) {

in that if-block, we should always "goto next_dev" and skip the following "if(dev_checkpoint->connection)" check.



>> checkpoint: consider all devices when an empty list is passed

get_all_device_paths() seems generally useful. Could we instead add a function nm_manager_get_device_paths() which does the same?





Rest lgtm
Comment 4 Beniamino Galvani 2016-09-14 13:13:46 UTC
Fixed all the points above and repushed.
Comment 5 Thomas Haller 2016-09-14 13:31:34 UTC
+    for (iter = devices; iter; iter = g_slist_next (iter)) {
+         path = nm_exported_object_get_path (NM_EXPORTED_OBJECT (iter->data));
+         g_ptr_array_add (paths, (gpointer) path);
+    }

hm, are we sure that devices only contains exported objects? That is not immediately clear to me.

Maybe

    if (path)
       g_ptr_array_add (paths, (gpointer) path);




>> core: allow passing an applied connection to nm_act_request_new()
    

+    case PROP_INT_APPLIED_CONNECTION:
+         /* construct-only */
+         acon = g_value_get_object (value);
+         if (acon)
+              priv->applied_connection = g_object_ref (acon);


In commit 2, I was about to say, that the applied-connection does not have to be cloned in set_property() and instead just taking a reference. But eventually I didn't say that because the caller must then ensure not to modify the connection after passing it to the active connection.
That is changed now which is better performance-wise. But maybe we could add a code-comment to nm_act_request_new(), _new_active_connection(), nm_manager_activate_connection() and point out, that the caller hands over the applied-connection and must not touch it afterwards (be he still must unref when done).


+    if (!priv->applied_connection && priv->settings_connection) {
+         priv->applied_connection =
+              nm_simple_connection_new_clone ((NMConnection *) priv->settings_connection);
+         nm_connection_clear_secrets (priv->applied_connection);
+    }

could we also clear the secrets, if the applied-connection is passed-in? Probably there are none, but just to be sure.
Comment 6 Beniamino Galvani 2016-09-21 07:57:15 UTC
(In reply to Thomas Haller from comment #5)
> Maybe
> 
>     if (path)
>        g_ptr_array_add (paths, (gpointer) path);

> In commit 2, I was about to say, that the applied-connection does not have
> to be cloned in set_property() and instead just taking a reference. But
> eventually I didn't say that because the caller must then ensure not to
> modify the connection after passing it to the active connection.
> That is changed now which is better performance-wise. But maybe we could add
> a code-comment to nm_act_request_new(), _new_active_connection(),
> nm_manager_activate_connection() and point out, that the caller hands over
> the applied-connection and must not touch it afterwards (be he still must
> unref when done).

> could we also clear the secrets, if the applied-connection is passed-in?
> Probably there are none, but just to be sure.

All fixed, thanks.
Comment 7 Thomas Haller 2016-09-26 09:42:41 UTC
lgtm
Comment 8 Francesco Giudici 2016-09-26 12:48:30 UTC
LGTM, found just a typo in commit msg:
"checkpoint: use UUID instead of patch to match connections"
                                   ^^^
Comment 9 Beniamino Galvani 2016-09-26 13:14:43 UTC
(In reply to Francesco Giudici from comment #8)
> LGTM, found just a typo in commit msg:
> "checkpoint: use UUID instead of patch to match connections"
>                                    ^^^

Fixed and merged, thanks.

https://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=d27ae4a8fec0c8f21a7171e01535f8beb8e5b105