Re: [PATCH v2] Re: Change the state of iface from disconnected to connected using nmcli
On Monday 21 of May 2012 16:52:33 Dan Williams wrote: On Thu, 2012-05-17 at 17:25 +0200, Jirka Klimes wrote: On Wednesday 16 of May 2012 18:02:12 Dan Williams wrote: On Mon, 2012-05-14 at 17:36 +0200, Jirka Klimes wrote: On Thursday 22 of March 2012 11:10:56 Dan Williams wrote: On Sun, 2012-03-18 at 23:43 +0530, Abhijeet Rastogi wrote: Hi, This is my first post here. I have tried googling and looking at the manpage but no help. We can use $nmcli dev disconnect iface eth0 to change the state of eth0 to disconnect. Is there a command to change it's state back to connected? I tried looking at the manpage I can't seem to find any option for that. At the moment, you need to tell NM to reconnect to something, eg 'nmcli con up uuid uuid'. Disconnect places the device into manual mode which requires user action to return to automatic mode. I suppose we can add an 'autoconnect' property to each device, which Disconnect() would set to false, but which could be changed via the D-Bus properties interface (authenticated of course) back to TRUE. This property would follow the internal 'autoconnect_inhibit' device member variable and the NMPolicy would listen for changes to this variable and retrigger an auto connection check if it changes back to TRUE. Patches accepted for that. Dan Attached are patches adding 'Autoconnect' property to NMDevice for core NM and libnm-glib as well. For the API docs, I'd say: If TRUE, indicates the device is allowed to autoconnect. If FALSE, manual intervention is required before the device will automatically connect to a known network, such as activating a connection using the device, or setting this property to TRUE. Changed the text in xml. There's a redundant NM_DEVICE_GET_PRIVATE() in nm_device_get_autoconnect(). Removed. The other thing we need to do is authenticate the property write call, which we've got some code for in nm-manager.c::prop_filter(). It's going to get a bit complicated since that function only works on the manager object, so we'll have to have something that's a bit more involved than just strcmp(propiface, NM_DBUS_IFACE). That said, it shouldn't be too bad. We basically want to enforce the same permissions as manager_device_disconnect_request() does. After some tries it seems to me that the easiest way is to tweak the prop_filter() and use it. I have added a check for .Device interface and find the right NMDevice object according to object path extracted from the D-Bus message. NM_AUTH_PERMISSION_NETWORK_CONTROL permission is used. Does it look right? I'm sending authorization changes as a separate patch, so that it is easier to see what changed. The changes were made to the previous core patch. libnm-glib didn't change. The rest of it looks good! Dan And while we're at it, to reduce confusion, we should just rename autoconnect_inhibit to autoconnect. Something like the attached patch applied on top of yours? Changed to autoconnect variable. One last thing with the permissions code; if we can't find the device when we're about to call g_object_set(), we should return NM_MANAGER_ERROR_UNKNOWN_DEVICE. Other than that they both look good. THanks! Dan Commited: e0329b4 libnm-glib: add 'autoconnect' property for devices d1cbeeb core: authenticate Set() D-Bus call for NMDevice Autoconnect property 6d9338f core: add Autoconnect property to NMDevice Jirka ___ networkmanager-list mailing list networkmanager-list@gnome.org http://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: [PATCH v2] Re: Change the state of iface from disconnected to connected using nmcli
On Thu, 2012-05-17 at 17:25 +0200, Jirka Klimes wrote: On Wednesday 16 of May 2012 18:02:12 Dan Williams wrote: On Mon, 2012-05-14 at 17:36 +0200, Jirka Klimes wrote: On Thursday 22 of March 2012 11:10:56 Dan Williams wrote: On Sun, 2012-03-18 at 23:43 +0530, Abhijeet Rastogi wrote: Hi, This is my first post here. I have tried googling and looking at the manpage but no help. We can use $nmcli dev disconnect iface eth0 to change the state of eth0 to disconnect. Is there a command to change it's state back to connected? I tried looking at the manpage I can't seem to find any option for that. At the moment, you need to tell NM to reconnect to something, eg 'nmcli con up uuid uuid'. Disconnect places the device into manual mode which requires user action to return to automatic mode. I suppose we can add an 'autoconnect' property to each device, which Disconnect() would set to false, but which could be changed via the D-Bus properties interface (authenticated of course) back to TRUE. This property would follow the internal 'autoconnect_inhibit' device member variable and the NMPolicy would listen for changes to this variable and retrigger an auto connection check if it changes back to TRUE. Patches accepted for that. Dan Attached are patches adding 'Autoconnect' property to NMDevice for core NM and libnm-glib as well. For the API docs, I'd say: If TRUE, indicates the device is allowed to autoconnect. If FALSE, manual intervention is required before the device will automatically connect to a known network, such as activating a connection using the device, or setting this property to TRUE. Changed the text in xml. There's a redundant NM_DEVICE_GET_PRIVATE() in nm_device_get_autoconnect(). Removed. The other thing we need to do is authenticate the property write call, which we've got some code for in nm-manager.c::prop_filter(). It's going to get a bit complicated since that function only works on the manager object, so we'll have to have something that's a bit more involved than just strcmp(propiface, NM_DBUS_IFACE). That said, it shouldn't be too bad. We basically want to enforce the same permissions as manager_device_disconnect_request() does. After some tries it seems to me that the easiest way is to tweak the prop_filter() and use it. I have added a check for .Device interface and find the right NMDevice object according to object path extracted from the D-Bus message. NM_AUTH_PERMISSION_NETWORK_CONTROL permission is used. Does it look right? I'm sending authorization changes as a separate patch, so that it is easier to see what changed. The changes were made to the previous core patch. libnm-glib didn't change. The rest of it looks good! Dan And while we're at it, to reduce confusion, we should just rename autoconnect_inhibit to autoconnect. Something like the attached patch applied on top of yours? Changed to autoconnect variable. One last thing with the permissions code; if we can't find the device when we're about to call g_object_set(), we should return NM_MANAGER_ERROR_UNKNOWN_DEVICE. Other than that they both look good. THanks! Dan ___ networkmanager-list mailing list networkmanager-list@gnome.org http://mail.gnome.org/mailman/listinfo/networkmanager-list
[PATCH v2] Re: Change the state of iface from disconnected to connected using nmcli
On Wednesday 16 of May 2012 18:02:12 Dan Williams wrote: On Mon, 2012-05-14 at 17:36 +0200, Jirka Klimes wrote: On Thursday 22 of March 2012 11:10:56 Dan Williams wrote: On Sun, 2012-03-18 at 23:43 +0530, Abhijeet Rastogi wrote: Hi, This is my first post here. I have tried googling and looking at the manpage but no help. We can use $nmcli dev disconnect iface eth0 to change the state of eth0 to disconnect. Is there a command to change it's state back to connected? I tried looking at the manpage I can't seem to find any option for that. At the moment, you need to tell NM to reconnect to something, eg 'nmcli con up uuid uuid'. Disconnect places the device into manual mode which requires user action to return to automatic mode. I suppose we can add an 'autoconnect' property to each device, which Disconnect() would set to false, but which could be changed via the D-Bus properties interface (authenticated of course) back to TRUE. This property would follow the internal 'autoconnect_inhibit' device member variable and the NMPolicy would listen for changes to this variable and retrigger an auto connection check if it changes back to TRUE. Patches accepted for that. Dan Attached are patches adding 'Autoconnect' property to NMDevice for core NM and libnm-glib as well. For the API docs, I'd say: If TRUE, indicates the device is allowed to autoconnect. If FALSE, manual intervention is required before the device will automatically connect to a known network, such as activating a connection using the device, or setting this property to TRUE. Changed the text in xml. There's a redundant NM_DEVICE_GET_PRIVATE() in nm_device_get_autoconnect(). Removed. The other thing we need to do is authenticate the property write call, which we've got some code for in nm-manager.c::prop_filter(). It's going to get a bit complicated since that function only works on the manager object, so we'll have to have something that's a bit more involved than just strcmp(propiface, NM_DBUS_IFACE). That said, it shouldn't be too bad. We basically want to enforce the same permissions as manager_device_disconnect_request() does. After some tries it seems to me that the easiest way is to tweak the prop_filter() and use it. I have added a check for .Device interface and find the right NMDevice object according to object path extracted from the D-Bus message. NM_AUTH_PERMISSION_NETWORK_CONTROL permission is used. Does it look right? I'm sending authorization changes as a separate patch, so that it is easier to see what changed. The changes were made to the previous core patch. libnm-glib didn't change. The rest of it looks good! Dan And while we're at it, to reduce confusion, we should just rename autoconnect_inhibit to autoconnect. Something like the attached patch applied on top of yours? Changed to autoconnect variable. Thanks for the review. JirkaFrom 2c0a08b6298e6a3057b39a20256d67c601b76e4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= jkli...@redhat.com Date: Mon, 14 May 2012 15:32:54 +0200 Subject: [PATCH 1/3] core: add Autoconnect property to NMDevice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is bound to autoconnect_inhibit private variable (has opposite meaning). While 'Autoconnect' is TRUE (default value) the device can automatically activate a connection. If it is changed to FALSE, the device will not auto-activate until 'Autoconnect' is TRUE again. Disconnect() method sets 'Autoconnect' to FALSE. NMPolicy monitors the property and schedules auto activation when FALSE-TRUE transition is made. Signed-off-by: Jiří Klimeš jkli...@redhat.com --- introspection/nm-device.xml |8 src/nm-device.c | 40 +++- src/nm-device.h |5 +++-- src/nm-manager.c|3 ++- src/nm-policy.c | 12 +++- 5 files changed, 51 insertions(+), 17 deletions(-) diff --git a/introspection/nm-device.xml b/introspection/nm-device.xml index d12d477..5e58a47 100644 --- a/introspection/nm-device.xml +++ b/introspection/nm-device.xml @@ -91,6 +91,14 @@ Whether or not this device is managed by NetworkManager. /tp:docstring /property +property name=Autoconnect type=b access=readwrite + tp:docstring +If TRUE, indicates the device is allowed to autoconnect. If FALSE, +manual intervention is required before the device will automatically +connect to a known network, such as activating a connection using the +device, or setting this property to TRUE. + /tp:docstring +/property property name=FirmwareMissing type=b access=read tp:docstring If TRUE, indicates the device is likely missing firmware necessary for diff --git a/src/nm-device.c
Re: Change the state of iface from disconnected to connected using nmcli
On Mon, 2012-05-14 at 17:36 +0200, Jirka Klimes wrote: On Thursday 22 of March 2012 11:10:56 Dan Williams wrote: On Sun, 2012-03-18 at 23:43 +0530, Abhijeet Rastogi wrote: Hi, This is my first post here. I have tried googling and looking at the manpage but no help. We can use $nmcli dev disconnect iface eth0 to change the state of eth0 to disconnect. Is there a command to change it's state back to connected? I tried looking at the manpage I can't seem to find any option for that. At the moment, you need to tell NM to reconnect to something, eg 'nmcli con up uuid uuid'. Disconnect places the device into manual mode which requires user action to return to automatic mode. I suppose we can add an 'autoconnect' property to each device, which Disconnect() would set to false, but which could be changed via the D-Bus properties interface (authenticated of course) back to TRUE. This property would follow the internal 'autoconnect_inhibit' device member variable and the NMPolicy would listen for changes to this variable and retrigger an auto connection check if it changes back to TRUE. Patches accepted for that. Dan Attached are patches adding 'Autoconnect' property to NMDevice for core NM and libnm-glib as well. For the API docs, I'd say: If TRUE, indicates the device is allowed to autoconnect. If FALSE, manual intervention is required before the device will automatically connect to a known network, such as activating a connection using the device, or setting this property to TRUE. There's a redundant NM_DEVICE_GET_PRIVATE() in nm_device_get_autoconnect(). The other thing we need to do is authenticate the property write call, which we've got some code for in nm-manager.c::prop_filter(). It's going to get a bit complicated since that function only works on the manager object, so we'll have to have something that's a bit more involved than just strcmp(propiface, NM_DBUS_IFACE). That said, it shouldn't be too bad. We basically want to enforce the same permissions as manager_device_disconnect_request() does. The rest of it looks good! Dan And while we're at it, to reduce confusion, we should just rename autoconnect_inhibit to autoconnect. Something like the attached patch applied on top of yours? diff --git a/src/nm-device.c b/src/nm-device.c index 2f69be6..1fd6de7 100644 --- a/src/nm-device.c +++ b/src/nm-device.c @@ -223,7 +223,7 @@ typedef struct { NMIP6Config * dhcp6_ip6_config; /* inhibit autoconnect feature */ - gboolean autoconnect_inhibit; + gboolean autoconnect; /* master interface for bridge, bond, vlan, etc */ NMDevice * master; @@ -743,10 +743,10 @@ nm_device_autoconnect_allowed (NMDevice *self) g_value_take_object (instance, self); g_value_init (retval, G_TYPE_BOOLEAN); - if (priv-autoconnect_inhibit) - g_value_set_boolean (retval, FALSE); - else + if (priv-autoconnect) g_value_set_boolean (retval, TRUE); + else + g_value_set_boolean (retval, FALSE); /* Use g_signal_emitv() rather than g_signal_emit() to avoid the return * value being changed if no handlers are connected */ @@ -3145,7 +3145,7 @@ nm_device_disconnect (NMDevice *device, GError **error) return FALSE; } - priv-autoconnect_inhibit = TRUE; + priv-autoconnect = FALSE; nm_device_state_changed (device, NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_USER_REQUESTED); @@ -4335,7 +4335,7 @@ nm_device_state_changed (NMDevice *device, nm_device_deactivate (device, reason); break; default: - priv-autoconnect_inhibit = FALSE; + priv-autoconnect = TRUE; break; } @@ -4655,12 +4655,3 @@ nm_device_set_dhcp_anycast_address (NMDevice *device, guint8 *addr) } } - -void -nm_device_clear_autoconnect_inhibit (NMDevice *device) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device); - g_return_if_fail (priv); - priv-autoconnect_inhibit = FALSE; -} - diff --git a/src/nm-device.h b/src/nm-device.h index f4495b9..52f5573 100644 --- a/src/nm-device.h +++ b/src/nm-device.h @@ -244,8 +244,6 @@ void nm_device_set_managed (NMDevice *device, gboolean managed, NMDeviceStateReason reason); -void nm_device_clear_autoconnect_inhibit (NMDevice *device); - void nm_device_handle_autoip4_event (NMDevice *self, const char *event, const char *address); diff --git a/src/nm-manager.c b/src/nm-manager.c index e887e57..b669bb8 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -3248,7 +3248,8 @@ do_sleep_wake (NMManager *self) nm_device_set_enabled (device, enabled); } - nm_device_clear_autoconnect_inhibit (device); + g_object_set (G_OBJECT (device), NM_DEVICE_AUTOCONNECT, TRUE, NULL); + if (nm_device_spec_match_list (device, unmanaged_specs)) nm_device_set_managed (device, FALSE,
Re: Change the state of iface from disconnected to connected using nmcli
On Thursday 22 of March 2012 11:10:56 Dan Williams wrote: On Sun, 2012-03-18 at 23:43 +0530, Abhijeet Rastogi wrote: Hi, This is my first post here. I have tried googling and looking at the manpage but no help. We can use $nmcli dev disconnect iface eth0 to change the state of eth0 to disconnect. Is there a command to change it's state back to connected? I tried looking at the manpage I can't seem to find any option for that. At the moment, you need to tell NM to reconnect to something, eg 'nmcli con up uuid uuid'. Disconnect places the device into manual mode which requires user action to return to automatic mode. I suppose we can add an 'autoconnect' property to each device, which Disconnect() would set to false, but which could be changed via the D-Bus properties interface (authenticated of course) back to TRUE. This property would follow the internal 'autoconnect_inhibit' device member variable and the NMPolicy would listen for changes to this variable and retrigger an auto connection check if it changes back to TRUE. Patches accepted for that. Dan Attached are patches adding 'Autoconnect' property to NMDevice for core NM and libnm-glib as well. Jirka From 4f1ce8b39eb8c722bc57fc853c6b381b90b2294f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= jkli...@redhat.com Date: Mon, 14 May 2012 15:32:54 +0200 Subject: [PATCH 1/2] core: add Autoconnect property to NMDevice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is bound to autoconnect_inhibit private variable (has opposite meaning). While 'Autoconnect' is TRUE (default value) the device can automatically activate a connection. If it is changed to FALSE, the device will not auto-activate until 'Autoconnect' is TRUE again. Disconnect() method sets 'Autoconnect' to FALSE. NMPolicy monitors the property and schedules auto activation when FALSE-TRUE transition is made. Signed-off-by: Jiří Klimeš jkli...@redhat.com --- introspection/nm-device.xml |6 ++ src/nm-device.c | 28 +++- src/nm-device.h |4 +++- src/nm-policy.c | 12 +++- 4 files changed, 47 insertions(+), 3 deletions(-) diff --git a/introspection/nm-device.xml b/introspection/nm-device.xml index d12d477..4b155d5 100644 --- a/introspection/nm-device.xml +++ b/introspection/nm-device.xml @@ -91,6 +91,12 @@ Whether or not this device is managed by NetworkManager. /tp:docstring /property +property name=Autoconnect type=b access=readwrite + tp:docstring +If TRUE, indicates the device can autoconnect. If FALSE, a manual intervention is required before the device +is allowed to autoconnect again, like activating a connection on the device or restarting Networkmanager. + /tp:docstring +/property property name=FirmwareMissing type=b access=read tp:docstring If TRUE, indicates the device is likely missing firmware necessary for diff --git a/src/nm-device.c b/src/nm-device.c index 2f69be6..175d044 100644 --- a/src/nm-device.c +++ b/src/nm-device.c @@ -111,6 +111,7 @@ enum { PROP_ACTIVE_CONNECTION, PROP_DEVICE_TYPE, PROP_MANAGED, + PROP_AUTOCONNECT, PROP_FIRMWARE_MISSING, PROP_TYPE_DESC, PROP_RFKILL_TYPE, @@ -3759,6 +3760,9 @@ set_property (GObject *object, guint prop_id, case PROP_MANAGED: priv-managed = g_value_get_boolean (value); break; + case PROP_AUTOCONNECT: + priv-autoconnect_inhibit = !g_value_get_boolean (value); + break; case PROP_FIRMWARE_MISSING: priv-firmware_missing = g_value_get_boolean (value); break; @@ -3867,6 +3871,9 @@ get_property (GObject *object, guint prop_id, case PROP_MANAGED: g_value_set_boolean (value, priv-managed); break; + case PROP_AUTOCONNECT: + g_value_set_boolean (value, !priv-autoconnect_inhibit); + break; case PROP_FIRMWARE_MISSING: g_value_set_boolean (value, priv-firmware_missing); break; @@ -4028,6 +4035,14 @@ nm_device_class_init (NMDeviceClass *klass) G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property + (object_class, PROP_AUTOCONNECT, + g_param_spec_boolean (NM_DEVICE_AUTOCONNECT, + Autoconnect, + Autoconnect, + TRUE, + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, PROP_FIRMWARE_MISSING, g_param_spec_boolean (NM_DEVICE_FIRMWARE_MISSING, FirmwareMissing, @@ -4655,7 +4670,6 @@ nm_device_set_dhcp_anycast_address (NMDevice *device, guint8 *addr) } } - void nm_device_clear_autoconnect_inhibit (NMDevice *device) { @@ -4664,3 +4678,15 @@ nm_device_clear_autoconnect_inhibit (NMDevice *device) priv-autoconnect_inhibit = FALSE; } +gboolean +nm_device_get_autoconnect (NMDevice *device) +{ + NMDevicePrivate *priv; +
Re: Change the state of iface from disconnected to connected using nmcli
On Sun, 2012-03-18 at 23:43 +0530, Abhijeet Rastogi wrote: Hi, This is my first post here. I have tried googling and looking at the manpage but no help. We can use $nmcli dev disconnect iface eth0 to change the state of eth0 to disconnect. Is there a command to change it's state back to connected? I tried looking at the manpage I can't seem to find any option for that. At the moment, you need to tell NM to reconnect to something, eg 'nmcli con up uuid uuid'. Disconnect places the device into manual mode which requires user action to return to automatic mode. I suppose we can add an 'autoconnect' property to each device, which Disconnect() would set to false, but which could be changed via the D-Bus properties interface (authenticated of course) back to TRUE. This property would follow the internal 'autoconnect_inhibit' device member variable and the NMPolicy would listen for changes to this variable and retrigger an auto connection check if it changes back to TRUE. Patches accepted for that. Dan I did a comprehensive as to why I want this here. https://bbs.archlinux.org/viewtopic.php?pid=1073943 Please have a look. Thanks -- Regards, Abhijeet Rastogi (shadyabhi) https://plus.google.com/107316377741966576356/ ___ networkmanager-list mailing list networkmanager-list@gnome.org http://mail.gnome.org/mailman/listinfo/networkmanager-list ___ networkmanager-list mailing list networkmanager-list@gnome.org http://mail.gnome.org/mailman/listinfo/networkmanager-list
Change the state of iface from disconnected to connected using nmcli
Hi, This is my first post here. I have tried googling and looking at the manpage but no help. We can use $nmcli dev disconnect iface eth0 to change the state of eth0 to disconnect. Is there a command to change it's state back to connected? I tried looking at the manpage I can't seem to find any option for that. I did a comprehensive as to why I want this here. https://bbs.archlinux.org/viewtopic.php?pid=1073943 Please have a look. Thanks -- Regards, Abhijeet Rastogi (shadyabhi) https://plus.google.com/107316377741966576356/ ___ networkmanager-list mailing list networkmanager-list@gnome.org http://mail.gnome.org/mailman/listinfo/networkmanager-list