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

Signed-off-by: Mark Rustad <[email protected]>
Tested-by: Jack Morgan <[email protected]>
---

 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);

_______________________________________________
fcoe-devel mailing list
[email protected]
http://lists.open-fcoe.org/mailman/listinfo/fcoe-devel

Reply via email to