interactions between OLPC wifi and mesh interfaces



Hi,

I'm a little stuck with one issue reimplementing the OLPC mesh device
support.

1. When the user is connected to a standard network through eth0, and
then they request a connection to a mesh network on msh0, eth0 should
disconnect and go quiet before the mesh connection starts to happen.

2. When the user is on a mesh through msh0 and requests connection to a
real network through eth0, the mesh should disconnect itself.

How was this implemented in the NM-0.6 solution? It seemed to work
there.


For (1) I added code into stage1_prepare in the mesh device. It checks
to see if the companion is activated, if so it calls
nm_device_state_changed() to make it NM_DEVICE_STATE_DISCONNECTED.

This almost works. I connect to an IBSS, and then the mesh. The above
code disconnects from the IBSS and starts the mesh connection process.
However NM is still treating the devices as separate, so very quickly it
tries to look for a connection to apply to eth0 again. It finds the same
one (which Sugar's settings implementation is advertising as a network
that should be autoconnected to) and then we end up with a mess where
we're trying to connect to a mesh and an IBSS simultaneously.

Switching eth0 to NM_DEVICE_STATE_UNAVAILABLE didn't help, it just got
back on its feet in the same way.

Thoughts?


No problems (yet) with (2). I connected a signal to the companion device
state-changed within the mesh device. If the companion is moving into an
active state, and the mesh device is active, I use
nm_device_state_changed() to disconnect the mesh device. This works, at
least while sugar is not offering an autoconnect mesh network setting.

I've attached my patch which may help to explain the above situation.

Thanks,
Daniel

diff --git a/src/nm-device-olpc-mesh.c b/src/nm-device-olpc-mesh.c
index 41056d6..3c7aea8 100644
--- a/src/nm-device-olpc-mesh.c
+++ b/src/nm-device-olpc-mesh.c
@@ -694,7 +694,16 @@ real_act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
 {
 	NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (dev);
 
-	/* wait with continueing configuration untill the companion device is done
+	/* disconnect companion device, if it is connected */
+	if (nm_device_get_act_request (NM_DEVICE (priv->companion))) {
+		nm_warning("disconnecting companion device");
+		nm_device_state_changed (NM_DEVICE (priv->companion),
+		                         NM_DEVICE_STATE_UNAVAILABLE,
+		                         NM_VPN_CONNECTION_STATE_REASON_USER_DISCONNECTED);
+		nm_warning("companion disconnected");
+	}
+
+	/* wait with continuing configuration untill the companion device is done
 	 * scanning */
 	if (nm_device_wifi_is_scanning (NM_DEVICE_WIFI (priv->companion))) {
 		priv->stage1_waiting = TRUE;
@@ -888,6 +897,25 @@ companion_notify_cb (NMDeviceWifi *companion, GParamSpec *pspec, gpointer user_d
 	}
 }
 
+/* disconnect from mesh if someone starts using the companion */
+static void
+companion_state_changed_cb (NMDeviceWifi *companion, NMDeviceState state, NMDeviceState old_state, NMDeviceStateReason reason, gpointer user_data)
+{
+	NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (user_data);
+	NMDeviceState self_state = nm_device_get_state (NM_DEVICE (self));
+
+	if (self_state < NM_DEVICE_STATE_PREPARE
+			|| self_state > NM_DEVICE_STATE_ACTIVATED
+			|| state < NM_DEVICE_STATE_PREPARE
+			|| state > NM_DEVICE_STATE_ACTIVATED)
+		return;
+
+	nm_debug ("disconnecting mesh due to companion connectivity");
+	nm_device_state_changed (NM_DEVICE (self),
+	                         NM_DEVICE_STATE_DISCONNECTED,
+	                         NM_VPN_CONNECTION_STATE_REASON_USER_DISCONNECTED);
+}
+
 static gboolean
 companion_scan_allowed_cb (NMDeviceWifi *companion, gpointer user_data)
 {
@@ -930,10 +958,13 @@ is_companion (NMDeviceOlpcMesh *self, NMDevice *other)
 
 	nm_debug ("Found companion device: %s", nm_device_get_iface (other));
 
-	g_signal_connect (G_OBJECT(other), "notify::scanning",
-		G_CALLBACK(companion_notify_cb), self);
-	g_signal_connect (G_OBJECT(other), "scanning-allowed",
-		G_CALLBACK(companion_scan_allowed_cb), self);
+	/* FIXME: where to disconnect? */
+	g_signal_connect (G_OBJECT (other), "state-changed",
+		G_CALLBACK (companion_state_changed_cb), self);
+	g_signal_connect (G_OBJECT (other), "notify::scanning",
+		G_CALLBACK (companion_notify_cb), self);
+	g_signal_connect (G_OBJECT (other), "scanning-allowed",
+		G_CALLBACK (companion_scan_allowed_cb), self);
 
 	return TRUE;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]