aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/libfc/fc_rport.c71
-rw-r--r--include/scsi/fc/fc_els.h9
2 files changed, 72 insertions, 8 deletions
diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
index e33c5c7961a..df85e19079f 100644
--- a/drivers/scsi/libfc/fc_rport.c
+++ b/drivers/scsi/libfc/fc_rport.c
@@ -1573,30 +1573,85 @@ drop:
1573 * fc_rport_recv_prlo_req() - Handler for process logout (PRLO) requests 1573 * fc_rport_recv_prlo_req() - Handler for process logout (PRLO) requests
1574 * @rdata: The remote port that sent the PRLO request 1574 * @rdata: The remote port that sent the PRLO request
1575 * @sp: The sequence that the PRLO was on 1575 * @sp: The sequence that the PRLO was on
1576 * @fp: The PRLO request frame 1576 * @rx_fp: The PRLO request frame
1577 * 1577 *
1578 * Locking Note: The rport lock is exected to be held before calling 1578 * Locking Note: The rport lock is exected to be held before calling
1579 * this function. 1579 * this function.
1580 */ 1580 */
1581static void fc_rport_recv_prlo_req(struct fc_rport_priv *rdata, 1581static void fc_rport_recv_prlo_req(struct fc_rport_priv *rdata,
1582 struct fc_seq *sp, 1582 struct fc_seq *sp,
1583 struct fc_frame *fp) 1583 struct fc_frame *rx_fp)
1584{ 1584{
1585 struct fc_lport *lport = rdata->local_port; 1585 struct fc_lport *lport = rdata->local_port;
1586
1587 struct fc_frame_header *fh; 1586 struct fc_frame_header *fh;
1587 struct fc_exch *ep;
1588 struct fc_frame *fp;
1589 struct {
1590 struct fc_els_prlo prlo;
1591 struct fc_els_spp spp;
1592 } *pp;
1593 struct fc_els_spp *rspp; /* request service param page */
1594 struct fc_els_spp *spp; /* response spp */
1595 unsigned int len;
1596 unsigned int plen;
1597 u32 f_ctl;
1588 struct fc_seq_els_data rjt_data; 1598 struct fc_seq_els_data rjt_data;
1589 1599
1590 fh = fc_frame_header_get(fp); 1600 rjt_data.fp = NULL;
1601 fh = fc_frame_header_get(rx_fp);
1591 1602
1592 FC_RPORT_DBG(rdata, "Received PRLO request while in state %s\n", 1603 FC_RPORT_DBG(rdata, "Received PRLO request while in state %s\n",
1593 fc_rport_state(rdata)); 1604 fc_rport_state(rdata));
1594 1605
1595 rjt_data.fp = NULL; 1606 len = fr_len(rx_fp) - sizeof(*fh);
1596 rjt_data.reason = ELS_RJT_UNAB; 1607 pp = fc_frame_payload_get(rx_fp, sizeof(*pp));
1597 rjt_data.explan = ELS_EXPL_NONE; 1608 if (!pp)
1609 goto reject_len;
1610 plen = ntohs(pp->prlo.prlo_len);
1611 if (plen != 20)
1612 goto reject_len;
1613 if (plen < len)
1614 len = plen;
1615
1616 rspp = &pp->spp;
1617
1618 fp = fc_frame_alloc(lport, len);
1619 if (!fp) {
1620 rjt_data.reason = ELS_RJT_UNAB;
1621 rjt_data.explan = ELS_EXPL_INSUF_RES;
1622 goto reject;
1623 }
1624
1625 sp = lport->tt.seq_start_next(sp);
1626 WARN_ON(!sp);
1627 pp = fc_frame_payload_get(fp, len);
1628 WARN_ON(!pp);
1629 memset(pp, 0, len);
1630 pp->prlo.prlo_cmd = ELS_LS_ACC;
1631 pp->prlo.prlo_obs = 0x10;
1632 pp->prlo.prlo_len = htons(len);
1633 spp = &pp->spp;
1634 spp->spp_type = rspp->spp_type;
1635 spp->spp_type_ext = rspp->spp_type_ext;
1636 spp->spp_flags = FC_SPP_RESP_ACK;
1637
1638 fc_rport_enter_delete(rdata, RPORT_EV_LOGO);
1639
1640 f_ctl = FC_FC_EX_CTX | FC_FC_LAST_SEQ;
1641 f_ctl |= FC_FC_END_SEQ | FC_FC_SEQ_INIT;
1642 ep = fc_seq_exch(sp);
1643 fc_fill_fc_hdr(fp, FC_RCTL_ELS_REP, ep->did, ep->sid,
1644 FC_TYPE_ELS, f_ctl, 0);
1645 lport->tt.seq_send(lport, sp, fp);
1646 goto drop;
1647
1648reject_len:
1649 rjt_data.reason = ELS_RJT_PROT;
1650 rjt_data.explan = ELS_EXPL_INV_LEN;
1651reject:
1598 lport->tt.seq_els_rsp_send(sp, ELS_LS_RJT, &rjt_data); 1652 lport->tt.seq_els_rsp_send(sp, ELS_LS_RJT, &rjt_data);
1599 fc_frame_free(fp); 1653drop:
1654 fc_frame_free(rx_fp);
1600} 1655}
1601 1656
1602/** 1657/**
diff --git a/include/scsi/fc/fc_els.h b/include/scsi/fc/fc_els.h
index f94328132a2..70a7e92a766 100644
--- a/include/scsi/fc/fc_els.h
+++ b/include/scsi/fc/fc_els.h
@@ -405,6 +405,15 @@ struct fc_els_prli {
405}; 405};
406 406
407/* 407/*
408 * ELS_PRLO - Process logout request and response.
409 */
410struct fc_els_prlo {
411 __u8 prlo_cmd; /* command */
412 __u8 prlo_obs; /* obsolete, but shall be set to 10h */
413 __be16 prlo_len; /* payload length */
414};
415
416/*
408 * ELS_ADISC payload 417 * ELS_ADISC payload
409 */ 418 */
410struct fc_els_adisc { 419struct fc_els_adisc {