Capture the node roles from the FIP claim and claim response
frames. This makes it possible to avoid logging into nodes
that are not in a compatible role. For example, there is
no reason for an initiator to login to another initiator.

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

 drivers/scsi/fcoe/fcoe_ctlr.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
index 7583425..da03dde 100644
--- a/drivers/scsi/fcoe/fcoe_ctlr.c
+++ b/drivers/scsi/fcoe/fcoe_ctlr.c
@@ -2192,11 +2192,13 @@ static int fcoe_ctlr_vn_parse(struct fcoe_ctlr *fip,
        struct fip_wwn_desc *wwn = NULL;
        struct fip_vn_desc *vn = NULL;
        struct fip_size_desc *size = NULL;
+       struct fip_fc4_feat *ff;
        struct fcoe_rport *frport;
        size_t rlen;
        size_t dlen;
        u32 desc_mask = 0;
        u32 dtype;
+       u32 fcp_feat;
        u8 sub;
 
        memset(rdata, 0, sizeof(*rdata) + sizeof(*frport));
@@ -2277,6 +2279,15 @@ static int fcoe_ctlr_vn_parse(struct fcoe_ctlr *fip,
                case FIP_DT_FC4F:
                        if (dlen != sizeof(struct fip_fc4_feat))
                                goto len_err;
+
+                       rdata->ids.roles = 0;
+                       ff = (struct fip_fc4_feat *)desc;
+                       fcp_feat = ntohl(ff->fd_ff.fd_feat[FC_TYPE_FCP * 4 / 
32]);
+                       fcp_feat >>= (FC_TYPE_FCP * 4) % 32;
+                       if (fcp_feat & FCP_FEAT_INIT)
+                               rdata->ids.roles |= FC_RPORT_ROLE_FCP_INITIATOR;
+                       if (fcp_feat & FCP_FEAT_TARG)
+                               rdata->ids.roles |= FC_RPORT_ROLE_FCP_TARGET;
                        break;
                case FIP_DT_FCOE_SIZE:
                        if (dlen != sizeof(struct fip_size_desc))
@@ -2422,6 +2433,7 @@ static void fcoe_ctlr_vn_add(struct fcoe_ctlr *fip, 
struct fc_rport_priv *new)
                lport->tt.rport_logoff(rdata);
        ids->port_name = new->ids.port_name;
        ids->node_name = new->ids.node_name;
+       ids->roles = new->ids.roles;
        mutex_unlock(&lport->disc.disc_mutex);
 
        frport = fcoe_ctlr_rport(rdata);

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

Reply via email to