[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210129034711.518250-2-sukadev@linux.ibm.com>
Date: Thu, 28 Jan 2021 19:47:11 -0800
From: Sukadev Bhattiprolu <sukadev@...ux.ibm.com>
To: netdev@...r.kernel.org
Cc: Dany Madden <drt@...ux.ibm.com>, Lijun Pan <ljp@...ux.ibm.com>,
Rick Lindsley <ricklind@...ux.ibm.com>, abdhalee@...ibm.com,
sukadev@...ux.ibm.com
Subject: [PATCH net 2/2] ibmvnic: fix race with multiple open/close
If two or more instances of 'ip link set' commands race and first one
already brings the interface up (or down), the subsequent instances
can simply return without redoing the up/down operation.
Fixes: ed651a10875f ("ibmvnic: Updated reset handling")
Reported-by: Abdul Haleem <abdhalee@...ibm.com>
Tested-by: Abdul Haleem <abdhalee@...ibm.com>
Signed-off-by: Sukadev Bhattiprolu <sukadev@...ux.ibm.com>
---
drivers/net/ethernet/ibm/ibmvnic.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index cb7ddfefb03e..84b772921f35 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -1219,6 +1219,13 @@ static int ibmvnic_open(struct net_device *netdev)
goto out;
}
+ /* If adapter is already open, we don't have to do anything. */
+ if (adapter->state == VNIC_OPEN) {
+ netdev_dbg(netdev, "[S:%d] adapter already open\n",
+ adapter->state);
+ return 0;
+ }
+
if (adapter->state != VNIC_CLOSED) {
rc = ibmvnic_login(netdev);
if (rc)
@@ -1392,6 +1399,12 @@ static int ibmvnic_close(struct net_device *netdev)
return 0;
}
+ /* If adapter is already closed, we don't have to do anything. */
+ if (adapter->state == VNIC_CLOSED) {
+ netdev_dbg(netdev, "[S:%d] adapter already closed\n",
+ adapter->state);
+ return 0;
+ }
rc = __ibmvnic_close(netdev);
ibmvnic_cleanup(netdev);
--
2.26.2
Powered by blists - more mailing lists