Commit ff1d9291 authored by Eugene Crosser's avatar Eugene Crosser Committed by David S. Miller

qeth: BRIDGEPORT "sanity check"

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: default avatarThomas Richter <tmricht@linux.vnet.ibm.com>
Signed-off-by: default avatarEugene Crosser <Eugene.Crosser@ru.ibm.com>
Signed-off-by: default avatarUrsula Braun <ursula.braun@de.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9c23f4da
...@@ -86,7 +86,9 @@ static ssize_t qeth_bridge_port_role_store(struct device *dev, ...@@ -86,7 +86,9 @@ static ssize_t qeth_bridge_port_role_store(struct device *dev,
mutex_lock(&card->conf_mutex); 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); rc = qeth_bridgeport_setrole(card, role);
if (!rc) if (!rc)
card->options.sbp.role = role; card->options.sbp.role = role;
...@@ -184,6 +186,7 @@ static ssize_t qeth_bridgeport_reflect_store(struct device *dev, ...@@ -184,6 +186,7 @@ static ssize_t qeth_bridgeport_reflect_store(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
int enable, primary; int enable, primary;
int rc = 0;
if (!card) if (!card)
return -EINVAL; return -EINVAL;
...@@ -202,12 +205,17 @@ static ssize_t qeth_bridgeport_reflect_store(struct device *dev, ...@@ -202,12 +205,17 @@ static ssize_t qeth_bridgeport_reflect_store(struct device *dev,
mutex_lock(&card->conf_mutex); mutex_lock(&card->conf_mutex);
card->options.sbp.reflect_promisc = enable; if (card->options.sbp.role != QETH_SBP_ROLE_NONE)
card->options.sbp.reflect_promisc_primary = primary; rc = -EPERM;
else {
card->options.sbp.reflect_promisc = enable;
card->options.sbp.reflect_promisc_primary = primary;
rc = 0;
}
mutex_unlock(&card->conf_mutex); mutex_unlock(&card->conf_mutex);
return count; return rc ? rc : count;
} }
static DEVICE_ATTR(bridge_reflect_promisc, 0644, static DEVICE_ATTR(bridge_reflect_promisc, 0644,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment