linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Robert Love <robert.w.love@intel.com>
To: linux-scsi@vger.kernel.org
Cc: Jack Morgan <jack.morgan@intel.com>,
	Mark Rustad <mark.d.rustad@intel.com>, Yi Zou <yi.zou@intel.com>
Subject: [PATCH 1/8] libfc: Reject PLOGI from nodes with incompatible role
Date: Tue, 09 Jul 2013 12:47:10 -0700	[thread overview]
Message-ID: <20130709194710.10724.48550.stgit@fritz> (raw)
In-Reply-To: <20130709194705.10724.64013.stgit@fritz>

From: Mark Rustad <mark.d.rustad@intel.com>

Reject a PLOGI from a node with an incompatible role,
that is, initiator-to-initiator or target-to-target.

Signed-off-by: Mark Rustad <mark.d.rustad@intel.com>
Reviewed-by: Yi Zou <yi.zou@intel.com>
Tested-by: Jack Morgan <jack.morgan@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
---
 drivers/scsi/libfc/fc_rport.c |   27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
index 6bbb944..c710d90 100644
--- a/drivers/scsi/libfc/fc_rport.c
+++ b/drivers/scsi/libfc/fc_rport.c
@@ -926,6 +926,20 @@ err:
 	kref_put(&rdata->kref, rdata->local_port->tt.rport_destroy);
 }
 
+static bool
+fc_rport_compatible_roles(struct fc_lport *lport, struct fc_rport_priv *rdata)
+{
+	if (rdata->ids.roles == FC_PORT_ROLE_UNKNOWN)
+		return true;
+	if ((rdata->ids.roles & FC_PORT_ROLE_FCP_TARGET) &&
+	    (lport->service_params & FCP_SPPF_INIT_FCN))
+		return true;
+	if ((rdata->ids.roles & FC_PORT_ROLE_FCP_INITIATOR) &&
+	    (lport->service_params & FCP_SPPF_TARG_FCN))
+		return true;
+	return false;
+}
+
 /**
  * fc_rport_enter_plogi() - Send Port Login (PLOGI) request
  * @rdata: The remote port to send a PLOGI to
@@ -938,6 +952,12 @@ static void fc_rport_enter_plogi(struct fc_rport_priv *rdata)
 	struct fc_lport *lport = rdata->local_port;
 	struct fc_frame *fp;
 
+	if (!fc_rport_compatible_roles(lport, rdata)) {
+		FC_RPORT_DBG(rdata, "PLOGI suppressed for incompatible role\n");
+		fc_rport_state_enter(rdata, RPORT_ST_PLOGI_WAIT);
+		return;
+	}
+
 	FC_RPORT_DBG(rdata, "Port entered PLOGI state from %s state\n",
 		     fc_rport_state(rdata));
 
@@ -1646,6 +1666,13 @@ static void fc_rport_recv_plogi_req(struct fc_lport *lport,
 		rjt_data.explan = ELS_EXPL_NONE;
 		goto reject;
 	}
+	if (!fc_rport_compatible_roles(lport, rdata)) {
+		FC_RPORT_DBG(rdata, "Received PLOGI for incompatible role\n");
+		mutex_unlock(&rdata->rp_mutex);
+		rjt_data.reason = ELS_RJT_LOGIC;
+		rjt_data.explan = ELS_EXPL_NONE;
+		goto reject;
+	}
 
 	/*
 	 * Get session payload size from incoming PLOGI.


  reply	other threads:[~2013-07-09 19:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-09 19:47 [PATCH 0/8] libfc, libfcoe, fcoe updates for 3.11(+) Robert Love
2013-07-09 19:47 ` Robert Love [this message]
2013-07-09 19:47 ` [PATCH 2/8] fcoe: Fix smatch warning in fcoe_fdmi_info function Robert Love
2013-07-09 19:47 ` [PATCH 3/8] fcoe: fix the link error status block sparse warnings Robert Love
2013-07-09 19:47 ` [PATCH 4/8] libfc: Remove extra space in fc_exch_timer_cancel definition Robert Love
2013-07-09 19:53   ` Neil Horman
2013-07-09 19:47 ` [PATCH 5/8] libfc: Differentiate echange timer cancellation debug statements Robert Love
2013-07-09 19:54   ` Neil Horman
2013-07-09 19:47 ` [PATCH 6/8] libfcoe: Fix meaningless log statement Robert Love
2013-07-09 19:54   ` Neil Horman
2013-07-09 19:47 ` [PATCH 7/8] fcoe: Stop fc_rport_priv structure leak Robert Love
2013-07-09 19:47 ` [PATCH 8/8] fcoe: Reduce number of sparse warnings Robert Love

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=20130709194710.10724.48550.stgit@fritz \
    --to=robert.w.love@intel.com \
    --cc=jack.morgan@intel.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mark.d.rustad@intel.com \
    --cc=yi.zou@intel.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).