linux-s390.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ursula Braun <ubraun@linux.vnet.ibm.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-s390@vger.kernel.org,
	ursula.braun@de.ibm.com, ubraun@linux.vnet.ibm.com,
	Eugene Crosser <Eugene.Crosser@ru.ibm.com>
Subject: [PATCH net-next 6/8] qeth: BRIDGEPORT "sanity check"
Date: Mon, 18 May 2015 14:27:57 +0200	[thread overview]
Message-ID: <1431952079-6847-7-git-send-email-ubraun@linux.vnet.ibm.com> (raw)
In-Reply-To: <1431952079-6847-1-git-send-email-ubraun@linux.vnet.ibm.com>

From: Eugene Crosser <Eugene.Crosser@ru.ibm.com>

Forbid enabling IFF_PROMISC reflection to BRIDGEPORT when a role
is already assigned, and forbid direct manipulation of the role
when reflection mode is engaged.

Reviewed-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Signed-off-by: Eugene Crosser <Eugene.Crosser@ru.ibm.com>
Signed-off-by: Ursula Braun <ursula.braun@de.ibm.com>
---
 drivers/s390/net/qeth_l2_sys.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/s390/net/qeth_l2_sys.c b/drivers/s390/net/qeth_l2_sys.c
index a553fba..52673cd 100644
--- a/drivers/s390/net/qeth_l2_sys.c
+++ b/drivers/s390/net/qeth_l2_sys.c
@@ -86,7 +86,9 @@ static ssize_t qeth_bridge_port_role_store(struct device *dev,
 
 	mutex_lock(&card->conf_mutex);
 
-	if (qeth_card_hw_is_reachable(card)) {
+	if (card->options.sbp.reflect_promisc) /* Forbid direct manipulation */
+		rc = -EPERM;
+	else if (qeth_card_hw_is_reachable(card)) {
 		rc = qeth_bridgeport_setrole(card, role);
 		if (!rc)
 			card->options.sbp.role = role;
@@ -184,6 +186,7 @@ static ssize_t qeth_bridgeport_reflect_store(struct device *dev,
 {
 	struct qeth_card *card = dev_get_drvdata(dev);
 	int enable, primary;
+	int rc = 0;
 
 	if (!card)
 		return -EINVAL;
@@ -202,12 +205,17 @@ static ssize_t qeth_bridgeport_reflect_store(struct device *dev,
 
 	mutex_lock(&card->conf_mutex);
 
-	card->options.sbp.reflect_promisc = enable;
-	card->options.sbp.reflect_promisc_primary = primary;
+	if (card->options.sbp.role != QETH_SBP_ROLE_NONE)
+		rc = -EPERM;
+	else {
+		card->options.sbp.reflect_promisc = enable;
+		card->options.sbp.reflect_promisc_primary = primary;
+		rc = 0;
+	}
 
 	mutex_unlock(&card->conf_mutex);
 
-	return count;
+	return rc ? rc : count;
 }
 
 static DEVICE_ATTR(bridge_reflect_promisc, 0644,
-- 
2.3.7

  parent reply	other threads:[~2015-05-18 12:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-18 12:27 [PATCH net-next 0/8] s390: network patches for net-next Ursula Braun
2015-05-18 12:27 ` [PATCH net-next 1/8] qeth: fix rx checksum offload handling Ursula Braun
2015-05-18 12:27 ` [PATCH net-next 2/8] qeth: fix handling of IPA return codes Ursula Braun
2015-05-18 12:27 ` [PATCH net-next 3/8] qeth: remove locks from sysfs _show Ursula Braun
2015-05-18 12:27 ` [PATCH net-next 4/8] qeth: IFF_PROMISC flag to BRIDGE PORT mode Ursula Braun
2015-05-18 12:27 ` [PATCH net-next 5/8] qeth: OSA version of SETBRIDGEPORT command Ursula Braun
2015-05-18 12:27 ` Ursula Braun [this message]
2015-05-18 12:27 ` [PATCH net-next 7/8] qeth: replace ENOSYS with EOPNOTSUPP Ursula Braun
2015-05-18 12:27 ` [PATCH net-next 8/8] s390/lcs: Fix null-pointer access in msg Ursula Braun
2015-05-18 16:16 ` [PATCH net-next 0/8] s390: network patches for net-next David Miller

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=1431952079-6847-7-git-send-email-ubraun@linux.vnet.ibm.com \
    --to=ubraun@linux.vnet.ibm.com \
    --cc=Eugene.Crosser@ru.ibm.com \
    --cc=davem@davemloft.net \
    --cc=linux-s390@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=ursula.braun@de.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).