[openib-general] [PATCH] IPoIB PKEY in/out event handling fix

Leonid Arsh leonida at voltaire.com
Wed Mar 22 08:14:07 PST 2006


Hello,

   the patch causes the network interface to respond to PKEY in/out
events correctly.
   As a result, you'll see a child interface in the "RUNNING" state
(netif_carrier_on()) only when the corresponding PKEY is configured by
the SM.
   When SM removes a PKEY, the "RUNNING" state will be disabled for the
corresponding network interface (netif_carrir_off().)
   (To do it,  I added IB_EVENT_PKEY_CHANGE event handling.
   To prevent flushing the device before the device is open by the
"delay open" mechanism,  I added an additional device flag called
IPOIB_FLAG_INITIALIZED.)

  The patch also prevents the child network interface from trying to
join to multicast groups until the PKEY is configured.
  We used to get error messages like:
	"ib0.f2f2: couldn't attach QP to multicast group
ff12:401b:f2f2:0:0:0:ffff:ffff"   
  in this case.
  (To do it, I just check  IPOIB_FLAG_OPER_UP flag in
ipoib_set_mcast_list() )
	
  This patch also includes the small change that I sent in my previous
patch (not applied yet) -- the IB_EVENT_PORT_ERR event handling -- see
the attached message below.
  

Signed-off-by: Leonid Arsh <leonida at voltaire.com>

Index: linux-kernel/infiniband/ulp/ipoib/ipoib_verbs.c
===================================================================
--- linux-kernel/infiniband/ulp/ipoib/ipoib_verbs.c	(revision 8499)
+++ linux-kernel/infiniband/ulp/ipoib/ipoib_verbs.c	(working copy)
@@ -251,10 +251,12 @@
 	struct ipoib_dev_priv *priv =
 		container_of(handler, struct ipoib_dev_priv,
event_handler);
 
-	if (record->event == IB_EVENT_PORT_ACTIVE ||
+        if (record->event == IB_EVENT_PORT_ERR    ||
+	    record->event == IB_EVENT_PKEY_CHANGE ||
+	    record->event == IB_EVENT_PORT_ACTIVE ||
 	    record->event == IB_EVENT_LID_CHANGE  ||
 	    record->event == IB_EVENT_SM_CHANGE) {
-		ipoib_dbg(priv, "Port active event\n");
+		ipoib_dbg(priv, "Port state change event\n");
 		schedule_work(&priv->flush_task);
 	}
 }
Index: linux-kernel/infiniband/ulp/ipoib/ipoib_main.c
===================================================================
--- linux-kernel/infiniband/ulp/ipoib/ipoib_main.c	(revision 8499)
+++ linux-kernel/infiniband/ulp/ipoib/ipoib_main.c	(working copy)
@@ -737,6 +737,11 @@
 {
 	struct ipoib_dev_priv *priv = netdev_priv(dev);
 
+	if (!test_bit(IPOIB_FLAG_OPER_UP, &priv->flags)) {
+		ipoib_dbg(priv, "IPOIB_FLAG_OPER_UP not set");
+		return;
+	}
+
 	queue_work(ipoib_workqueue, &priv->restart_task);
 }
 
Index: linux-kernel/infiniband/ulp/ipoib/ipoib.h
===================================================================
--- linux-kernel/infiniband/ulp/ipoib/ipoib.h	(revision 8499)
+++ linux-kernel/infiniband/ulp/ipoib/ipoib.h	(working copy)
@@ -79,13 +79,14 @@
 	IPOIB_MAX_MCAST_QUEUE     = 3,
 
 	IPOIB_FLAG_OPER_UP 	  = 0,
-	IPOIB_FLAG_ADMIN_UP 	  = 1,
-	IPOIB_PKEY_ASSIGNED 	  = 2,
-	IPOIB_PKEY_STOP 	  = 3,
-	IPOIB_FLAG_SUBINTERFACE   = 4,
-	IPOIB_MCAST_RUN 	  = 5,
-	IPOIB_STOP_REAPER         = 6,
-	IPOIB_MCAST_STARTED       = 7,
+	IPOIB_FLAG_INITIALIZED    = 1,
+	IPOIB_FLAG_ADMIN_UP 	  = 2,
+	IPOIB_PKEY_ASSIGNED 	  = 3,
+	IPOIB_PKEY_STOP 	  = 4,
+	IPOIB_FLAG_SUBINTERFACE   = 5,
+	IPOIB_MCAST_RUN 	  = 6,
+	IPOIB_STOP_REAPER         = 7,
+	IPOIB_MCAST_STARTED       = 8,
 
 	IPOIB_MAX_BACKOFF_SECONDS = 16,
 
Index: linux-kernel/infiniband/ulp/ipoib/ipoib_ib.c
===================================================================
--- linux-kernel/infiniband/ulp/ipoib/ipoib_ib.c	(revision 8500)
+++ linux-kernel/infiniband/ulp/ipoib/ipoib_ib.c	(working copy)
@@ -50,6 +50,8 @@
 		 "Enable data path debug tracing if > 0");
 #endif
 
+static void ipoib_pkey_dev_check_presence(struct net_device *dev);
+
 #define	IPOIB_OP_RECV	(1ul << 31)
 
 static DEFINE_MUTEX(pkey_mutex);
@@ -422,6 +424,7 @@
 	clear_bit(IPOIB_STOP_REAPER, &priv->flags);
 	queue_delayed_work(ipoib_workqueue, &priv->ah_reap_task, HZ);
 
+	set_bit(IPOIB_FLAG_INITIALIZED, &priv->flags);
 	return 0;
 }
 
@@ -429,6 +432,14 @@
 {
 	struct ipoib_dev_priv *priv = netdev_priv(dev);
 
+        ipoib_pkey_dev_check_presence(dev);
+
+	if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) {
+		ipoib_dbg(priv, "PKEY is not assigned.\n");
+		return 0;
+	}
+
+
 	set_bit(IPOIB_FLAG_OPER_UP, &priv->flags);
 
 	return ipoib_mcast_start_thread(dev);
@@ -481,6 +492,8 @@
 	struct ipoib_tx_buf *tx_req;
 	int i;
 
+
+	clear_bit(IPOIB_FLAG_INITIALIZED, &priv->flags);
 	/*
 	 * Move our QP to the error state and then reinitialize in
 	 * when all work requests have completed or have been flushed.
@@ -585,9 +598,16 @@
 	struct net_device *dev = (struct net_device *)_dev;
 	struct ipoib_dev_priv *priv = netdev_priv(dev), *cpriv;
 
-	if (!test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags))
+	if (!test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags) ) {
+		ipoib_dbg(priv, "Not flushing - IPOIB_FLAG_INITIALIZED
not set.\n");
 		return;
+	}
 
+	if (!test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags)) {
+		ipoib_dbg(priv, "Not flushing - IPOIB_FLAG_ADMIN_UP not
set.\n");
+		return;
+	}
+
 	ipoib_dbg(priv, "flushing\n");
 
 	ipoib_ib_dev_down(dev);





-----Original Message-----
From: openib-general-bounces at openib.org
[mailto:openib-general-bounces at openib.org] On Behalf Of Leonid Arsh
Sent: Sunday, March 19, 2006 4:53 PM
To: openib-general at openib.org
Subject: [openib-general] [PATCH] IPoIB network interface "RUNNING"
statuswith the cable disconnected - fix
  
Hello,

   the patch fixes a problem with the network interface "RUNNING"
status.
   The problem was  that the status stayed  "RUNNING" with the cable
disconnected,
   both for ib0 network interface and a vlan (partition) child device
(like ib0.f1f1)

   The patch causes the network interface device to be flushed when
cable is disconnected.

   This patch requires also my previous patch to be applied (ipoib_ib.c
- wrong pointer memory access bug fix), see below.


Signed-off-by: Leonid Arsh <leonida at voltaire.com>

 Index: infiniband/ulp/ipoib/ipoib_verbs.c
===================================================================
--- infiniband/ulp/ipoib/ipoib_verbs.c	(revision 8499)
+++ infiniband/ulp/ipoib/ipoib_verbs.c	(working copy)
@@ -251,10 +251,11 @@
 	struct ipoib_dev_priv *priv =
 		container_of(handler, struct ipoib_dev_priv,
event_handler);
 
-	if (record->event == IB_EVENT_PORT_ACTIVE ||
+        if (record->event == IB_EVENT_PORT_ERR    ||
+            record->event == IB_EVENT_PORT_ACTIVE ||
 	    record->event == IB_EVENT_LID_CHANGE  ||
 	    record->event == IB_EVENT_SM_CHANGE) {
-		ipoib_dbg(priv, "Port active event\n");
+		ipoib_dbg(priv, "Port state change event\n");
 		schedule_work(&priv->flush_task);
 	}
 }



-----Original Message-----
From: openib-general-bounces at openib.org
[mailto:openib-general-bounces at openib.org] On Behalf Of Leonid Arsh
Sent: Sunday, March 19, 2006 4:03 PM
To: openib-general at openib.org
Subject: [openib-general] [PATCH] ipoib_ib.c - wrong pointer memory
accessbug

Hello,
   Trying to understand the problem with "RUNNING" network interface
status when a cable is disconnected, I found an error in
ipoib_ib_dev_flush() function.
   Although this patch doesn't fix the "RUNNING" status problem yet, it
fixes a serious wrong pointer memory access bug.

 Signed-off-by: Leonid Arsh <leonida at voltaire.com>

Index: infiniband/ulp/ipoib/ipoib_ib.c
===================================================================
--- infiniband/ulp/ipoib/ipoib_ib.c	(revision 8499)
+++ infiniband/ulp/ipoib/ipoib_ib.c	(working copy)
@@ -603,7 +603,7 @@
 
 	/* Flush any child interfaces too */
 	list_for_each_entry(cpriv, &priv->child_intfs, list)
-		ipoib_ib_dev_flush(&cpriv->dev);
+		ipoib_ib_dev_flush(cpriv->dev);
 
 	mutex_unlock(&priv->vlan_mutex);
 }
_______________________________________________
openib-general mailing list
openib-general at openib.org
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit
http://openib.org/mailman/listinfo/openib-general
_______________________________________________
openib-general mailing list
openib-general at openib.org
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit
http://openib.org/mailman/listinfo/openib-general



More information about the general mailing list