From: Sukadev Bhattiprolu <sukadev@linux.ibm.com>
To: netdev@vger.kernel.org
Cc: Dany Madden <drt@linux.ibm.com>, Lijun Pan <ljp@linux.ibm.com>,
Rick Lindsley <ricklind@linux.ibm.com>,
abdhalee@in.ibm.com, sukadev@linux.ibm.com
Subject: [PATCH net 2/2] ibmvnic: fix race with multiple open/close
Date: Thu, 28 Jan 2021 19:47:11 -0800 [thread overview]
Message-ID: <20210129034711.518250-2-sukadev@linux.ibm.com> (raw)
In-Reply-To: <20210129034711.518250-1-sukadev@linux.ibm.com>
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@in.ibm.com>
Tested-by: Abdul Haleem <abdhalee@in.ibm.com>
Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.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
next prev parent reply other threads:[~2021-01-29 3:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-29 3:47 [PATCH net 1/2] ibmvnic: fix a race between open and reset Sukadev Bhattiprolu
2021-01-29 3:47 ` Sukadev Bhattiprolu [this message]
2021-01-30 15:04 ` [PATCH net 2/2] ibmvnic: fix race with multiple open/close Willem de Bruijn
2021-02-02 2:21 ` Sukadev Bhattiprolu
2021-02-01 17:39 ` [PATCH net 1/2] ibmvnic: fix a race between open and reset Dany Madden
2021-02-02 2:38 ` Jakub Kicinski
2021-02-03 5:08 ` Sukadev Bhattiprolu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210129034711.518250-2-sukadev@linux.ibm.com \
--to=sukadev@linux.ibm.com \
--cc=abdhalee@in.ibm.com \
--cc=drt@linux.ibm.com \
--cc=ljp@linux.ibm.com \
--cc=netdev@vger.kernel.org \
--cc=ricklind@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).