]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
IPoIB: Don't start send-only joins while multicast thread is stopped
authorMichael S. Tsirkin <mst@mellanox.co.il>
Wed, 8 Feb 2006 00:37:08 +0000 (16:37 -0800)
committerRoland Dreier <rolandd@cisco.com>
Wed, 8 Feb 2006 00:37:08 +0000 (16:37 -0800)
Fix the following race scenario:
  - Device is up.
  - Port event or set mcast list triggers ipoib_mcast_stop_thread,
    this cancels the query and waits on mcast "done" completion.
  - Completion is called and "done" is set.
  - Meanwhile, ipoib_mcast_send arrives and starts a new query,
    re-initializing "done".

Fix this by adding a "multicast started" bit and checking it before
starting a send-only join.

Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/ulp/ipoib/ipoib.h
drivers/infiniband/ulp/ipoib/ipoib_multicast.c

index e0a5412b7e68042f820a0c6c32261eba3f39d23c..2f85a9a831b1a6b5787b58326270cd7f45c3e570 100644 (file)
@@ -78,6 +78,7 @@ enum {
        IPOIB_FLAG_SUBINTERFACE   = 4,
        IPOIB_MCAST_RUN           = 5,
        IPOIB_STOP_REAPER         = 6,
+       IPOIB_MCAST_STARTED       = 7,
 
        IPOIB_MAX_BACKOFF_SECONDS = 16,
 
index ccaa0c387076e8b0a36dc90dbb830528b09b93da..1c7148208ce8c67c0cd58dbdb82508302fb3af79 100644 (file)
@@ -601,6 +601,10 @@ int ipoib_mcast_start_thread(struct net_device *dev)
                queue_work(ipoib_workqueue, &priv->mcast_task);
        mutex_unlock(&mcast_mutex);
 
+       spin_lock_irq(&priv->lock);
+       set_bit(IPOIB_MCAST_STARTED, &priv->flags);
+       spin_unlock_irq(&priv->lock);
+
        return 0;
 }
 
@@ -611,6 +615,10 @@ int ipoib_mcast_stop_thread(struct net_device *dev, int flush)
 
        ipoib_dbg_mcast(priv, "stopping multicast thread\n");
 
+       spin_lock_irq(&priv->lock);
+       clear_bit(IPOIB_MCAST_STARTED, &priv->flags);
+       spin_unlock_irq(&priv->lock);
+
        mutex_lock(&mcast_mutex);
        clear_bit(IPOIB_MCAST_RUN, &priv->flags);
        cancel_delayed_work(&priv->mcast_task);
@@ -693,6 +701,12 @@ void ipoib_mcast_send(struct net_device *dev, union ib_gid *mgid,
         */
        spin_lock(&priv->lock);
 
+       if (!test_bit(IPOIB_MCAST_STARTED, &priv->flags)) {
+               ++priv->stats.tx_dropped;
+               dev_kfree_skb_any(skb);
+               goto unlock;
+       }
+
        mcast = __ipoib_mcast_find(dev, mgid);
        if (!mcast) {
                /* Let's create a new send only group now */
@@ -754,6 +768,7 @@ out:
                ipoib_send(dev, skb, mcast->ah, IB_MULTICAST_QPN);
        }
 
+unlock:
        spin_unlock(&priv->lock);
 }