Patchwork [Open-FCoE,3/3] libfc: Do not send PRLI to nodes with incompatible roles

login
register
mail settings
Submitter Mark Rustad
Date March 19, 2013, 11:18 p.m.
Message ID <20130319231810.2080.68877.stgit@host1-mdrustad.localdomain>
Download mbox | patch
Permalink /patch/17/
State Rejected
Headers show

Comments

Mark Rustad - March 19, 2013, 11:18 p.m.
Do not send a PRLI in response to a PLOGI from a node
that has an incompatible role.

Signed-off-by: Mark Rustad <mark.d.rustad@intel.com>
Tested-by: Jack Morgan <jack.morgan@intel.com>
---

 drivers/scsi/libfc/fc_rport.c |   17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
Mark Rustad - March 22, 2013, 7:01 p.m.
On Mar 19, 2013, at 4:18 PM, Mark Rustad <mark.d.rustad@intel.com> wrote:

> Do not send a PRLI in response to a PLOGI from a node
> that has an incompatible role.

This really isn't the right way to do this. I hope to have a better patch soon that will reject incoming PLOGI's and suppress outgoing PLOGIs for nodes with incompatible roles.

> Signed-off-by: Mark Rustad <mark.d.rustad@intel.com>
> Tested-by: Jack Morgan <jack.morgan@intel.com>
> ---
> 
> drivers/scsi/libfc/fc_rport.c |   17 ++++++++++++++++-
> 1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
> index 197824a..f769ad4 100644
> --- a/drivers/scsi/libfc/fc_rport.c
> +++ b/drivers/scsi/libfc/fc_rport.c
> @@ -1557,6 +1557,20 @@ static void fc_rport_recv_req(struct fc_lport *lport, struct fc_frame *fp)
> 	}
> }
> 
> +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_recv_plogi_req() - Handler for Port Login (PLOGI) requests
>  * @lport: The local port that received the PLOGI request
> @@ -1662,7 +1676,8 @@ static void fc_rport_recv_plogi_req(struct fc_lport *lport,
> 	fc_plogi_fill(lport, fp, ELS_LS_ACC);
> 	fc_fill_reply_hdr(fp, rx_fp, FC_RCTL_ELS_REP, 0);
> 	lport->tt.frame_send(lport, fp);
> -	fc_rport_enter_prli(rdata);
> +	if (fc_rport_compatible_roles(lport, rdata))
> +		fc_rport_enter_prli(rdata);
> out:
> 	mutex_unlock(&rdata->rp_mutex);
> 	fc_frame_free(rx_fp);

Patch

diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
index 197824a..f769ad4 100644
--- a/drivers/scsi/libfc/fc_rport.c
+++ b/drivers/scsi/libfc/fc_rport.c
@@ -1557,6 +1557,20 @@  static void fc_rport_recv_req(struct fc_lport *lport, struct fc_frame *fp)
 	}
 }
 
+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_recv_plogi_req() - Handler for Port Login (PLOGI) requests
  * @lport: The local port that received the PLOGI request
@@ -1662,7 +1676,8 @@  static void fc_rport_recv_plogi_req(struct fc_lport *lport,
 	fc_plogi_fill(lport, fp, ELS_LS_ACC);
 	fc_fill_reply_hdr(fp, rx_fp, FC_RCTL_ELS_REP, 0);
 	lport->tt.frame_send(lport, fp);
-	fc_rport_enter_prli(rdata);
+	if (fc_rport_compatible_roles(lport, rdata))
+		fc_rport_enter_prli(rdata);
 out:
 	mutex_unlock(&rdata->rp_mutex);
 	fc_frame_free(rx_fp);