iSCSI update for scsi-misc/2.6.39
Subsystems (10)
The following patches were made for scsi misc/2.6.39. The first 7 patches include the bnx2i update that was submitted here
http://marc.info/?l=linux-scsi&m=129426012515027&w=2
minus the patch that was adding a driver specific interface to set a tcp/ip setting.
The last patches enable TEXT PDU support in cxgbi, fix a endpoint leak during iscsi boot, and fix reading of the connection/ep ip address and port.
[PATCH 01/17] BNX2I: Allow ep CONNECT_FAILED condition to go through proper cleanup [PATCH 02/17] BNX2I: Fixed the 32-bit swapping of the LUN field for nopouts for 5771X [PATCH 03/17] BNX2I: Added handling for unsupported iSCSI offload hba [PATCH 04/17] BNX2I: Added support for the 57712(E) devices
[PATCH 05/17] BNX2I: Added jumbo MTU support for the no shost case [PATCH 06/17] BNX2I: Added iSCSI text pdu support for iSCSI offload [PATCH 07/17] BNX2I: Updated to version 2.6.2.3
[PATCH 08/17] cxgbi: enable TEXT PDU support
[PATCH 09/17] iscsi: fix iscsi_endpoint leak
[PATCH 10/17] iscsi class: remove unused active variable
[PATCH 11/17] libiscsi: add helper to convert addr to string
[PATCH 12/17] iscsi_tcp: use iscsi_conn_get_addr_param libiscsi function [PATCH 13/17] iscsi class: add callout to get iscsi_endpoint values [PATCH 14/17] cxgbi: convert to use iscsi_conn_get_addr_param
[PATCH 15/17] bnx2i: fix null ptr ref in conn get param
[PATCH 16/17] iser: export addr and port
[PATCH 17/17] be2iscsi: fix null ptr ref in conn get param
PATCH 1/17 BNX2I: Allow ep CONNECT_FAILED condition to go through proper cleanup
From: Eddie Wai <[email protected]>
Allow CNIC to go through the proper cleanup procedure for an endpoint which failed to connect. Proper cleanup is necessary for the chip to reset back to the initial state for the offloaded endpoint.
--- drivers/scsi/bnx2i/bnx2i_iscsi.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/bnx2i/bnx2i_iscsi.c +1 -1
@@ -1935,13 +1935,13 @@ static int bnx2i_ep_tcp_conn_active(struct bnx2i_endpoint *bnx2i_ep) cnic_dev_10g =1 ;switch (bnx2i_ep->state) { -case EP_STATE_CONNECT_FAILED :case EP_STATE_CLEANUP_FAILED :case EP_STATE_OFLD_FAILED :case EP_STATE_DISCONN_TIMEDOUT : ret =0 ;break ;case EP_STATE_CONNECT_START : +case EP_STATE_CONNECT_FAILED :case EP_STATE_CONNECT_COMPL :case EP_STATE_ULP_UPDATE_START :case EP_STATE_ULP_UPDATE_COMPL :
Signature · 1 line
1.7.2.3
PATCH 2/17 BNX2I: Fixed the 32-bit swapping of the LUN field for nopouts for 5771X
In reply to [email protected]From: Eddie Wai <[email protected]>
Fixed a bug where the 64-bit LUN field for nopouts were 32-bit swapped. This only pertains to 5771X devices.
--- drivers/scsi/bnx2i/bnx2i_hwi.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/bnx2i/bnx2i_hwi.c +3 -3
@@ -498,10 +498,10 @@ int bnx2i_send_iscsi_nopout(struct bnx2i_conn *bnx2i_conn,memcpy (nopout_wqe->lun, nopout_hdr->lun,8 );if (test_bit (BNX2I_NX2_DEV_57710 , &ep->hba->cnic_dev_type)) { -u32 tmp = nopout_hdr->lun[0 ]; +u32 tmp = nopout_wqe->lun[0 ];/* 57710 requires LUN field to be swapped */ - nopout_hdr->lun[0 ] = nopout_hdr->lun[1 ]; - nopout_hdr->lun[1 ] = tmp; + nopout_wqe->lun[0 ] = nopout_wqe->lun[1 ]; + nopout_wqe->lun[1 ] = tmp; } nopout_wqe->itt = ((u16)task->itt |
Signature · 1 line
1.7.2.3
PATCH 3/17 BNX2I: Added handling for unsupported iSCSI offload hba
In reply to [email protected]From: Eddie Wai <[email protected]>
The hba will now be unregistered and freed when iSCSI offload is not supported by the NIC.
--- drivers/scsi/bnx2i/bnx2i_init.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-)
drivers/scsi/bnx2i/bnx2i_init.c +15 -0
@@ -161,6 +161,21 @@ void bnx2i_start(void *handle)struct bnx2i_hba *hba = handle;int i =HZ ; +if (!hba->cnic->max_iscsi_conn) { +printk (KERN_ALERT "bnx2i: dev %s does not support " +"iSCSI\n" , hba->netdev->name); + +if (test_bit (BNX2I_CNIC_REGISTERED , &hba->reg_with_cnic)) { +mutex_lock (&bnx2i_dev_lock); +list_del_init (&hba->link); + adapter_count--; + hba->cnic->unregister_device (hba->cnic,CNIC_ULP_ISCSI ); +clear_bit (BNX2I_CNIC_REGISTERED , &hba->reg_with_cnic); +mutex_unlock (&bnx2i_dev_lock); +bnx2i_free_hba (hba); + } +return ; + }bnx2i_send_fw_iscsi_init_msg (hba);while (!test_bit (ADAPTER_STATE_UP , &hba->adapter_state) && i--)msleep (BNX2I_INIT_POLL_TIME );
Signature · 1 line
1.7.2.3
PATCH 4/17 BNX2I: Added support for the 57712(E) devices
In reply to [email protected]From: Eddie Wai <[email protected]>
Moved all PCI_DEVICE_ID_NX2_57712(E) definitions to pci_ids.h
--- drivers/net/bnx2x/bnx2x_main.c | 7 ------- drivers/scsi/bnx2i/bnx2i_init.c | 10 ++++++---- include/linux/pci_ids.h | 2 ++ 3 files changed, 8 insertions(+), 11 deletions(-)
drivers/net/bnx2x/bnx2x_main.c +0 -7
@@ -145,13 +145,6 @@ static struct { { "Broadcom NetXtreme II BCM57712E XGb" } }; -#ifndef PCI_DEVICE_ID_NX2_57712 -#define PCI_DEVICE_ID_NX2_57712 0x1662 -#endif -#ifndef PCI_DEVICE_ID_NX2_57712E -#define PCI_DEVICE_ID_NX2_57712E 0x1663 -#endif -static DEFINE_PCI_DEVICE_TABLE (bnx2x_pci_tbl) = { {PCI_VDEVICE (BROADCOM ,PCI_DEVICE_ID_NX2_57710 ),BCM57710 }, {PCI_VDEVICE (BROADCOM ,PCI_DEVICE_ID_NX2_57711 ),BCM57711 },
drivers/scsi/bnx2i/bnx2i_init.c +6 -4
@@ -29,7 +29,7 @@ static char version[] __devinitdata =MODULE_AUTHOR ("Anil Veerabhadrappa <[email protected]> and " "Eddie Wai <[email protected]>" ); -MODULE_DESCRIPTION ("Broadcom NetXtreme II BCM5706/5708/5709/57710/57711" +MODULE_DESCRIPTION ("Broadcom NetXtreme II BCM5706/5708/5709/57710/57711/57712" " iSCSI Driver" );MODULE_LICENSE ("GPL" );MODULE_VERSION (DRV_MODULE_VERSION );
@@ -88,9 +88,11 @@ void bnx2i_identify_device(struct bnx2i_hba *hba) (hba->pci_did == PCI_DEVICE_ID_NX2_5709S)) {set_bit (BNX2I_NX2_DEV_5709 , &hba->cnic_dev_type); hba->mail_queue_access =BNX2I_MQ_BIN_MODE ; - } else if (hba->pci_did == PCI_DEVICE_ID_NX2_57710 || - hba->pci_did == PCI_DEVICE_ID_NX2_57711 || - hba->pci_did == PCI_DEVICE_ID_NX2_57711E) + } else if (hba->pci_did == PCI_DEVICE_ID_NX2_57710 || + hba->pci_did == PCI_DEVICE_ID_NX2_57711 || + hba->pci_did == PCI_DEVICE_ID_NX2_57711E || + hba->pci_did == PCI_DEVICE_ID_NX2_57712 || + hba->pci_did == PCI_DEVICE_ID_NX2_57712E) set_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type); else printk(KERN_ALERT "bnx2i: unknown device, 0x%x\n",
include/linux/pci_ids.h +2 -0
@@ -2078,6 +2078,8 @@#define PCI_DEVICE_ID_TIGON3_5723 0x165b#define PCI_DEVICE_ID_TIGON3_5705M 0x165d#define PCI_DEVICE_ID_TIGON3_5705M_2 0x165e +#define PCI_DEVICE_ID_NX2_57712 0x1662 +#define PCI_DEVICE_ID_NX2_57712E 0x1663#define PCI_DEVICE_ID_TIGON3_5714 0x1668#define PCI_DEVICE_ID_TIGON3_5714S 0x1669#define PCI_DEVICE_ID_TIGON3_5780 0x166a
Signature · 1 line
1.7.2.3
PATCH 5/17 BNX2I: Added jumbo MTU support for the no shost case
In reply to [email protected]From: Eddie Wai <[email protected]>
For scenarios where the shost is not being passed to bnx2i for the iSCSI offload connection request, the code would consult the routing table to select the CNIC device.
This code path will erroneously error out if the corresponding L2 interface's MTU has been setup to > 1500.
--- drivers/scsi/bnx2i/bnx2i.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/bnx2i/bnx2i.h +1 -1
@@ -360,7 +360,7 @@ struct bnx2i_hba {#define ADAPTER_STATE_LINK_DOWN 2#define ADAPTER_STATE_INIT_FAILED 31unsigned int mtu_supported; -#define BNX2I_MAX_MTU_SUPPORTED 1500 +#define BNX2I_MAX_MTU_SUPPORTED 9000struct Scsi_Host *shost;
Signature · 1 line
1.7.2.3
PATCH 6/17 BNX2I: Added iSCSI text pdu support for iSCSI offload
In reply to [email protected]From: Eddie Wai <[email protected]>
This is part of an effort to support send target discovery via the iSCSI offload path.
--- drivers/scsi/bnx2i/bnx2i.h | 2 + drivers/scsi/bnx2i/bnx2i_hwi.c | 116 ++++++++++++++++++++++++++++++++++++++ drivers/scsi/bnx2i/bnx2i_iscsi.c | 6 ++- 3 files changed, 123 insertions(+), 1 deletions(-)
drivers/scsi/bnx2i/bnx2i.h +2 -0
@@ -751,6 +751,8 @@ extern int bnx2i_send_iscsi_login(struct bnx2i_conn *conn, struct iscsi_task *mtask);extern int bnx2i_send_iscsi_tmf (struct bnx2i_conn *conn,struct iscsi_task *mtask); +extern int bnx2i_send_iscsi_text (struct bnx2i_conn *conn, +struct iscsi_task *mtask);extern int bnx2i_send_iscsi_scsicmd (struct bnx2i_conn *conn,struct bnx2i_cmd *cmnd); extern int bnx2i_send_iscsi_nopout(struct bnx2i_conn *conn,
drivers/scsi/bnx2i/bnx2i_hwi.c +116 -0
134 lines not on this page · raw message
drivers/scsi/bnx2i/bnx2i_iscsi.c +5 -1
@@ -1092,6 +1092,9 @@ static int bnx2i_iscsi_send_generic_request(struct iscsi_task *task)case ISCSI_OP_SCSI_TMFUNC : rc =bnx2i_send_iscsi_tmf (bnx2i_conn, task);break ; +case ISCSI_OP_TEXT : + rc =bnx2i_send_iscsi_text (bnx2i_conn, task); +break ;default : iscsi_conn_printk(KERN_ALERT, bnx2i_conn->cls_conn->dd_data, "send_gen: unsupported op 0x%x\n",
@@ -2167,7 +2170,8 @@ struct iscsi_transport bnx2i_iscsi_transport = { .name = "bnx2i", .caps =CAP_RECOVERY_L0 |CAP_HDRDGST |CAP_MULTI_R2T |CAP_DATADGST | - CAP_DATA_PATH_OFFLOAD, +CAP_DATA_PATH_OFFLOAD | + CAP_TEXT_NEGO, .param_mask =ISCSI_MAX_RECV_DLENGTH |ISCSI_MAX_XMIT_DLENGTH | ISCSI_HDRDGST_EN |
Signature · 1 line
1.7.2.3
PATCH 7/17 BNX2I: Updated to version 2.6.2.3
In reply to [email protected]From: Eddie Wai <[email protected]>
--- drivers/scsi/bnx2i/bnx2i_init.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/bnx2i/bnx2i_init.c +2 -2
@@ -18,8 +18,8 @@ static struct list_head adapter_list = LIST_HEAD_INIT(adapter_list);static u32 adapter_count;#define DRV_MODULE_NAME "bnx2i" -#define DRV_MODULE_VERSION "2.6.2.2" -#define DRV_MODULE_RELDATE "Nov 23, 2010" +#define DRV_MODULE_VERSION "2.6.2.3" +#define DRV_MODULE_RELDATE "Dec 31, 2010"static char version[]__devinitdata ="Broadcom NetXtreme II iSCSI Driver " DRV_MODULE_NAME \
Signature · 1 line
1.7.2.3
PATCH 8/17 cxgbi: enable TEXT PDU support
In reply to [email protected]From: Mike Christie <[email protected]>
cxgb3i and cxgb4i support TEXT PDU offloading, so set the bits to enable it.
--- drivers/scsi/cxgbi/cxgb3i/cxgb3i.c | 2 +- drivers/scsi/cxgbi/cxgb4i/cxgb4i.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/cxgbi/cxgb3i/cxgb3i.c +1 -1
@@ -105,7 +105,7 @@ static struct iscsi_transport cxgb3i_iscsi_transport = {/* owner and name should be set already */ .caps = CAP_RECOVERY_L0 | CAP_MULTI_R2T | CAP_HDRDGST |CAP_DATADGST |CAP_DIGEST_OFFLOAD | - CAP_PADDING_OFFLOAD, + CAP_PADDING_OFFLOAD | CAP_TEXT_NEGO, .param_mask =ISCSI_MAX_RECV_DLENGTH |ISCSI_MAX_XMIT_DLENGTH |ISCSI_HDRDGST_EN |ISCSI_DATADGST_EN | ISCSI_INITIAL_R2T_EN | ISCSI_MAX_R2T |
drivers/scsi/cxgbi/cxgb4i/cxgb4i.c +1 -1
@@ -106,7 +106,7 @@ static struct iscsi_transport cxgb4i_iscsi_transport = { .name = DRV_MODULE_NAME, .caps =CAP_RECOVERY_L0 |CAP_MULTI_R2T |CAP_HDRDGST |CAP_DATADGST |CAP_DIGEST_OFFLOAD | - CAP_PADDING_OFFLOAD, + CAP_PADDING_OFFLOAD | CAP_TEXT_NEGO, .param_mask =ISCSI_MAX_RECV_DLENGTH |ISCSI_MAX_XMIT_DLENGTH |ISCSI_HDRDGST_EN |ISCSI_DATADGST_EN | ISCSI_INITIAL_R2T_EN | ISCSI_MAX_R2T |
Signature · 1 line
1.7.2.3
PATCH 9/17 iscsi: fix iscsi_endpoint leak
In reply to [email protected]From: Mike Christie <[email protected]>
When iscsid restarts it does not know the connection's endpoint, so it is getting leaked. This fixes the problem by having the iscsi class force a disconnect before a new connection is bound.
--- drivers/scsi/scsi_transport_iscsi.c | 63 +++++++++++++++++++++++++++------- include/scsi/scsi_transport_iscsi.h | 3 ++ 2 files changed, 53 insertions(+), 13 deletions(-)
drivers/scsi/scsi_transport_iscsi.c +50 -13
@@ -954,6 +954,7 @@ iscsi_create_conn(struct iscsi_cls_session *session, int dd_size, uint32_t cid)if (dd_size) conn->dd_data = &conn[1 ]; +mutex_init (&conn->ep_mutex);INIT_LIST_HEAD (&conn->conn_list); conn->transport = transport; conn->cid = cid;
@@ -1430,6 +1431,29 @@ release_host:return err; } +static int iscsi_if_ep_disconnect (struct iscsi_transport *transport, +u64 ep_handle) +{ +struct iscsi_cls_conn *conn; +struct iscsi_endpoint *ep; + +if (!transport->ep_disconnect) +return -EINVAL ; + + ep =iscsi_lookup_endpoint (ep_handle); +if (!ep) +return -EINVAL ; + conn = ep->conn; +if (conn) { +mutex_lock (&conn->ep_mutex); + conn->ep =NULL ; +mutex_unlock (&conn->ep_mutex); + } + + transport->ep_disconnect (ep); +return 0 ; +} +static int iscsi_if_transport_ep (struct iscsi_transport *transport,struct iscsi_uevent *ev,int msg_type)
@@ -1454,14 +1478,8 @@ iscsi_if_transport_ep(struct iscsi_transport *transport, ev->u.ep_poll.timeout_ms);break ;case ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT : -if (!transport->ep_disconnect) -return -EINVAL ; - - ep =iscsi_lookup_endpoint (ev->u.ep_disconnect.ep_handle); -if (!ep) -return -EINVAL ; - - transport->ep_disconnect (ep); + rc =iscsi_if_ep_disconnect (transport, + ev->u.ep_disconnect.ep_handle);break ; }return rc;
@@ -1609,12 +1627,31 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group) session =iscsi_session_lookup (ev->u.b_conn.sid); conn =iscsi_conn_lookup (ev->u.b_conn.sid, ev->u.b_conn.cid); -if (session && conn) - ev->r.retcode = transport->bind_conn (session, conn, - ev->u.b_conn.transport_eph, - ev->u.b_conn.is_leading); -else +if (conn && conn->ep) +iscsi_if_ep_disconnect (transport, conn->ep->id); + +if (!session || !conn) { err = -EINVAL ; +break ; + } + + ev->r.retcode = transport->bind_conn (session, conn, + ev->u.b_conn.transport_eph, + ev->u.b_conn.is_leading); +if (ev->r.retcode || !transport->ep_connect) +break ; + + ep =iscsi_lookup_endpoint (ev->u.b_conn.transport_eph); +if (ep) { + ep->conn = conn; + +mutex_lock (&conn->ep_mutex); + conn->ep = ep; +mutex_unlock (&conn->ep_mutex); + }else +iscsi_cls_conn_printk (KERN_ERR , conn, +"Could not set ep conn " +"binding\n" );break ;case ISCSI_UEVENT_SET_PARAM : err =iscsi_set_param (transport, ev);
include/scsi/scsi_transport_iscsi.h +3 -0
@@ -160,6 +160,8 @@ struct iscsi_cls_conn {void *dd_data;/* LLD private data */ struct iscsi_transport *transport;uint32_t cid;/* connection id */ +struct mutex ep_mutex; +struct iscsi_endpoint *ep;int active;/* must be accessed with the connlock */ struct device dev;/* sysfs transport/container device */
@@ -222,6 +224,7 @@ struct iscsi_endpoint {void *dd_data;/* LLD private data */ struct device dev;uint64_t id; +struct iscsi_cls_conn *conn; };/*
Signature · 1 line
1.7.2.3
PATCH 10/17 iscsi class: remove unused active variable
In reply to [email protected]From: Mike Christie <[email protected]>
The active variable on the iscsi_cls_conn is not used so this patch removes it.
--- drivers/scsi/scsi_transport_iscsi.c | 2 -- include/scsi/scsi_transport_iscsi.h | 1 - 2 files changed, 0 insertions(+), 3 deletions(-)
drivers/scsi/scsi_transport_iscsi.c +0 -2
@@ -976,7 +976,6 @@ iscsi_create_conn(struct iscsi_cls_session *session, int dd_size, uint32_t cid)spin_lock_irqsave (&connlock, flags);list_add (&conn->conn_list, &connlist); - conn->active =1 ;spin_unlock_irqrestore (&connlock, flags);ISCSI_DBG_TRANS_CONN (conn,"Completed conn creation\n" );
@@ -1002,7 +1001,6 @@ int iscsi_destroy_conn(struct iscsi_cls_conn *conn)unsigned long flags;spin_lock_irqsave (&connlock, flags); - conn->active =0 ;list_del (&conn->conn_list);spin_unlock_irqrestore (&connlock, flags);
include/scsi/scsi_transport_iscsi.h +0 -1
@@ -163,7 +163,6 @@ struct iscsi_cls_conn {struct mutex ep_mutex;struct iscsi_endpoint *ep; -int active;/* must be accessed with the connlock */ struct device dev;/* sysfs transport/container device */ };
Signature · 1 line
1.7.2.3
PATCH 11/17 libiscsi: add helper to convert addr to string
In reply to [email protected]From: Mike Christie <[email protected]>
This adds a helper to convert a addr struct to
a string. This will be used by the drivers in
the next patches.
--- drivers/scsi/libiscsi.c | 44 +++++++++++++++++++++++++++++++++++++++++--- include/scsi/libiscsi.h | 2 ++ 2 files changed, 43 insertions(+), 3 deletions(-)
drivers/scsi/libiscsi.c +41 -3
@@ -3352,6 +3352,47 @@ int iscsi_session_get_param(struct iscsi_cls_session *cls_session, }EXPORT_SYMBOL_GPL (iscsi_session_get_param); +int iscsi_conn_get_addr_param (struct sockaddr_storage *addr, +enum iscsi_param param,char *buf) +{ +struct sockaddr_in6 *sin6 =NULL ; +struct sockaddr_in *sin =NULL ; +int len; + +switch (addr->ss_family) { +case AF_INET : + sin = (struct sockaddr_in *)addr; +break ; +case AF_INET6 : + sin6 = (struct sockaddr_in6 *)addr; +break ; +default : +return -EINVAL ; + } + +switch (param) { +case ISCSI_PARAM_CONN_ADDRESS : +case ISCSI_HOST_PARAM_IPADDRESS : +if (sin) + len =sprintf (buf,"%pI4\n" , &sin->sin_addr.s_addr); +else + len =sprintf (buf,"%pI6\n" , &sin6->sin6_addr); +break ; +case ISCSI_PARAM_CONN_PORT : +if (sin) + len =sprintf (buf,"%hu\n" ,be16_to_cpu (sin->sin_port)); +else + len =sprintf (buf,"%hu\n" , +be16_to_cpu (sin6->sin6_port)); +break ; +default : +return -EINVAL ; + } + +return len; +} +EXPORT_SYMBOL_GPL (iscsi_conn_get_addr_param); +int iscsi_conn_get_param (struct iscsi_cls_conn *cls_conn,enum iscsi_param param,char *buf) {
@@ -3416,9 +3457,6 @@ int iscsi_host_get_param(struct Scsi_Host *shost, enum iscsi_host_param param,case ISCSI_HOST_PARAM_INITIATOR_NAME : len =sprintf (buf,"%s\n" , ihost->initiatorname);break ; -case ISCSI_HOST_PARAM_IPADDRESS : - len =sprintf (buf,"%s\n" , ihost->local_address); -break ;default :return -ENOSYS ; }
include/scsi/libiscsi.h +2 -0
@@ -394,6 +394,8 @@ extern void iscsi_session_failure(struct iscsi_session *session, enum iscsi_err err);extern int iscsi_conn_get_param (struct iscsi_cls_conn *cls_conn,enum iscsi_param param,char *buf); +extern int iscsi_conn_get_addr_param (struct sockaddr_storage *addr, +enum iscsi_param param,char *buf);extern void iscsi_suspend_tx (struct iscsi_conn *conn);extern void iscsi_suspend_queue (struct iscsi_conn *conn);extern void iscsi_conn_queue_work (struct iscsi_conn *conn);
Signature · 1 line
1.7.2.3
PATCH 12/17 iscsi_tcp: use iscsi_conn_get_addr_param libiscsi function
In reply to [email protected]From: Mike Christie <[email protected]>
This has iscsi_tcp use the iscsi_conn_get_addr_param libiscsi function. It also drops the use of the libiscsi session portal buffers, so they can be removed in the next patches. Instead of copying the values at bind time we get them during get() time. If we are not connected userspace will now get -ENOTCONN, so it knows that connection is disconnected instead of a possible stale value.
--- drivers/scsi/iscsi_tcp.c | 134 +++++++++++++++++++++++----------------------- drivers/scsi/iscsi_tcp.h | 4 ++ 2 files changed, 71 insertions(+), 67 deletions(-)
drivers/scsi/iscsi_tcp.c +67 -67
@@ -608,54 +608,12 @@ static void iscsi_sw_tcp_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)iscsi_sw_tcp_release_conn (conn); } -static int iscsi_sw_tcp_get_addr (struct iscsi_conn *conn,struct socket *sock, -char *buf,int *port, -int (*getname)(struct socket *, -struct sockaddr *, -int *addrlen)) -{ -struct sockaddr_storage *addr; -struct sockaddr_in6 *sin6; -struct sockaddr_in *sin; -int rc =0 , len; - - addr =kmalloc (sizeof (*addr),GFP_KERNEL ); -if (!addr) -return -ENOMEM ; - -if (getname (sock, (struct sockaddr *) addr, &len)) { - rc = -ENODEV ; - goto free_addr; - } - -switch (addr->ss_family) { -case AF_INET : - sin = (struct sockaddr_in *)addr; -spin_lock_bh (&conn->session->lock); -sprintf (buf,"%pI4" , &sin->sin_addr.s_addr); - *port =be16_to_cpu (sin->sin_port); -spin_unlock_bh (&conn->session->lock); -break ; -case AF_INET6 : - sin6 = (struct sockaddr_in6 *)addr; -spin_lock_bh (&conn->session->lock); -sprintf (buf,"%pI6" , &sin6->sin6_addr); - *port =be16_to_cpu (sin6->sin6_port); -spin_unlock_bh (&conn->session->lock); -break ; - } -free_addr: -kfree (addr); -return rc; -} -static int iscsi_sw_tcp_conn_bind (struct iscsi_cls_session *cls_session,struct iscsi_cls_conn *cls_conn,uint64_t transport_eph,int is_leading) { -struct Scsi_Host *shost =iscsi_session_to_shost (cls_session); -struct iscsi_host *ihost =shost_priv (shost); +struct iscsi_session *session = cls_session->dd_data;struct iscsi_conn *conn = cls_conn->dd_data;struct iscsi_tcp_conn *tcp_conn = conn->dd_data;struct iscsi_sw_tcp_conn *tcp_sw_conn = tcp_conn->dd_data;
@@ -670,27 +628,15 @@ iscsi_sw_tcp_conn_bind(struct iscsi_cls_session *cls_session, "sockfd_lookup failed %d\n", err);return -EEXIST ; } -/* -* copy these values now because if we drop the session -* userspace may still want to query the values since we will -* be using them for the reconnect -*/ - err =iscsi_sw_tcp_get_addr (conn, sock, conn->portal_address, - &conn->portal_port, kernel_getpeername); -if (err) - goto free_socket; - - err =iscsi_sw_tcp_get_addr (conn, sock, ihost->local_address, - &ihost->local_port, kernel_getsockname); -if (err) - goto free_socket; err =iscsi_conn_bind (cls_session, cls_conn, is_leading);if (err) goto free_socket; +spin_lock_bh (&session->lock);/* bind iSCSI connection and socket */ tcp_sw_conn->sock = sock; +spin_unlock_bh (&session->lock);/* setup Socket parameters */ sk = sock->sk;
@@ -752,24 +698,74 @@ static int iscsi_sw_tcp_conn_get_param(struct iscsi_cls_conn *cls_conn, enum iscsi_param param, char *buf) { struct iscsi_conn *conn = cls_conn->dd_data; -int len; +struct iscsi_tcp_conn *tcp_conn = conn->dd_data; +struct iscsi_sw_tcp_conn *tcp_sw_conn = tcp_conn->dd_data; +struct sockaddr_in6 addr; +int rc, len;switch (param) {case ISCSI_PARAM_CONN_PORT : -spin_lock_bh (&conn->session->lock); - len =sprintf (buf,"%hu\n" , conn->portal_port); -spin_unlock_bh (&conn->session->lock); -break ;case ISCSI_PARAM_CONN_ADDRESS :spin_lock_bh (&conn->session->lock); - len =sprintf (buf,"%s\n" , conn->portal_address); +if (!tcp_sw_conn || !tcp_sw_conn->sock) { +spin_unlock_bh (&conn->session->lock); +return -ENOTCONN ; + } + rc =kernel_getpeername (tcp_sw_conn->sock, + (struct sockaddr *)&addr, &len);spin_unlock_bh (&conn->session->lock); -break ; +if (rc) +return rc; + +return iscsi_conn_get_addr_param ((struct sockaddr_storage *) + &addr, param, buf);default :return iscsi_conn_get_param (cls_conn, param, buf); } -return len; +return 0 ; +} + +static int iscsi_sw_tcp_host_get_param (struct Scsi_Host *shost, +enum iscsi_host_param param,char *buf) +{ +struct iscsi_sw_tcp_host *tcp_sw_host =iscsi_host_priv (shost); +struct iscsi_session *session = tcp_sw_host->session; +struct iscsi_conn *conn; +struct iscsi_tcp_conn *tcp_conn; +struct iscsi_sw_tcp_conn *tcp_sw_conn; +struct sockaddr_in6 addr; +int rc, len; + +switch (param) { +case ISCSI_HOST_PARAM_IPADDRESS : +spin_lock_bh (&session->lock); + conn = session->leadconn; +if (!conn) { +spin_unlock_bh (&session->lock); +return -ENOTCONN ; + } + tcp_conn = conn->dd_data; + + tcp_sw_conn = tcp_conn->dd_data; +if (!tcp_sw_conn->sock) { +spin_unlock_bh (&session->lock); +return -ENOTCONN ; + } + + rc =kernel_getsockname (tcp_sw_conn->sock, + (struct sockaddr *)&addr, &len); +spin_unlock_bh (&session->lock); +if (rc) +return rc; + +return iscsi_conn_get_addr_param ((struct sockaddr_storage *) + &addr, param, buf); +default : +return iscsi_host_get_param (shost, param, buf); + } + +return 0 ; } static void
@@ -797,6 +793,7 @@ iscsi_sw_tcp_session_create(struct iscsi_endpoint *ep, uint16_t cmds_max, {struct iscsi_cls_session *cls_session;struct iscsi_session *session; +struct iscsi_sw_tcp_host *tcp_sw_host;struct Scsi_Host *shost;if (ep) {
@@ -804,7 +801,8 @@ iscsi_sw_tcp_session_create(struct iscsi_endpoint *ep, uint16_t cmds_max,return NULL ; } - shost =iscsi_host_alloc (&iscsi_sw_tcp_sht,0 ,1 ); + shost =iscsi_host_alloc (&iscsi_sw_tcp_sht, +sizeof (struct iscsi_sw_tcp_host ),1 );if (!shost)return NULL ; shost->transportt = iscsi_sw_tcp_scsi_transport;
@@ -825,6 +823,8 @@ iscsi_sw_tcp_session_create(struct iscsi_endpoint *ep, uint16_t cmds_max,if (!cls_session) goto remove_host; session = cls_session->dd_data; + tcp_sw_host =iscsi_host_priv (shost); + tcp_sw_host->session = session; shost->can_queue = session->scsi_cmds_max;if (iscsi_tcp_r2tpool_alloc (session))
@@ -929,7 +929,7 @@ static struct iscsi_transport iscsi_sw_tcp_transport = { .start_conn = iscsi_conn_start, .stop_conn = iscsi_sw_tcp_conn_stop,/* iscsi host params */ - .get_host_param = iscsi_host_get_param, + .get_host_param = iscsi_sw_tcp_host_get_param, .set_host_param = iscsi_host_set_param,/* IO */ .send_pdu = iscsi_conn_send_pdu,
drivers/scsi/iscsi_tcp.h +4 -0
@@ -55,6 +55,10 @@ struct iscsi_sw_tcp_conn {ssize_t (*sendpage)(struct socket *,struct page *,int ,size_t ,int ); }; +struct iscsi_sw_tcp_host { +struct iscsi_session *session; +}; +struct iscsi_sw_tcp_hdrbuf {struct iscsi_hdr hdrbuf; char hdrextbuf[ISCSI_MAX_AHS_SIZE +
Signature · 1 line
1.7.2.3
PATCH 13/17 iscsi class: add callout to get iscsi_endpoint values
In reply to [email protected]From: Mike Christie <[email protected]>
For drivers using the ep callbacks the addr and port are attached to the endpoint instead of the conn. This adds a callout to the iscsi_transport to get ep values. It also adds locking around the get param call to make sure that ep_disconnect does not free the LLD's ep interconnect structs from under us (the ep has a refcount so it will not go away but the LLD may have structs from other subsystems that are not allocated in the ep so we need to protect them from getting freed).
--- drivers/scsi/scsi_transport_iscsi.c | 39 +++++++++++++++++++++++++++++++++- include/scsi/scsi_transport_iscsi.h | 2 + 2 files changed, 39 insertions(+), 2 deletions(-)
drivers/scsi/scsi_transport_iscsi.c +37 -2
@@ -1782,13 +1782,48 @@ iscsi_conn_attr(data_digest, ISCSI_PARAM_DATADGST_EN);iscsi_conn_attr (ifmarker,ISCSI_PARAM_IFMARKER_EN );iscsi_conn_attr (ofmarker,ISCSI_PARAM_OFMARKER_EN );iscsi_conn_attr (persistent_port,ISCSI_PARAM_PERSISTENT_PORT ); -iscsi_conn_attr (port,ISCSI_PARAM_CONN_PORT );iscsi_conn_attr (exp_statsn,ISCSI_PARAM_EXP_STATSN );iscsi_conn_attr (persistent_address,ISCSI_PARAM_PERSISTENT_ADDRESS ); -iscsi_conn_attr (address,ISCSI_PARAM_CONN_ADDRESS );iscsi_conn_attr (ping_tmo,ISCSI_PARAM_PING_TMO );iscsi_conn_attr (recv_tmo,ISCSI_PARAM_RECV_TMO ); +#define iscsi_conn_ep_attr_show (param) \ +static ssize_t show_conn_ep_param_##param(struct device *dev, \ + struct device_attribute *attr,\ + char *buf) \ +{ \ + struct iscsi_cls_conn *conn = iscsi_dev_to_conn(dev->parent); \ + struct iscsi_transport *t = conn->transport; \ + struct iscsi_endpoint *ep; \ + ssize_t rc; \ + \ +/* \ +* Need to make sure ep_disconnect does not free the LLD's \ +* interconnect resources while we are trying to read them. \ +*/ \ +mutex_lock (&conn->ep_mutex); \ + ep = conn->ep; \ +if (!ep && t->ep_connect) { \ +mutex_unlock (&conn->ep_mutex); \ +return -ENOTCONN ; \ + } \ + \ +if (ep) \ + rc = t->get_ep_param (ep, param, buf); \ +else \ + rc = t->get_conn_param (conn, param, buf); \ +mutex_unlock (&conn->ep_mutex); \ +return rc; \ +} + +#define iscsi_conn_ep_attr (field, param) \ + iscsi_conn_ep_attr_show(param) \ +static ISCSI_CLASS_ATTR(conn, field, S_IRUGO, \ + show_conn_ep_param_##param, NULL); + +iscsi_conn_ep_attr (address,ISCSI_PARAM_CONN_ADDRESS ); +iscsi_conn_ep_attr (port,ISCSI_PARAM_CONN_PORT ); +/* * iSCSI session attrs */
include/scsi/scsi_transport_iscsi.h +2 -0
@@ -101,6 +101,8 @@ struct iscsi_transport {void (*destroy_conn) (struct iscsi_cls_conn *conn);int (*set_param) (struct iscsi_cls_conn *conn,enum iscsi_param param,char *buf,int buflen); +int (*get_ep_param) (struct iscsi_endpoint *ep,enum iscsi_param param, +char *buf);int (*get_conn_param) (struct iscsi_cls_conn *conn,enum iscsi_param param,char *buf); int (*get_session_param) (struct iscsi_cls_session *session,
Signature · 1 line
1.7.2.3
PATCH 14/17 cxgbi: convert to use iscsi_conn_get_addr_param
In reply to [email protected]From: Mike Christie <[email protected]>
This has cxgbi use the iscsi_conn_get_addr_param helper and the get ep callback.
--- drivers/scsi/cxgbi/cxgb3i/cxgb3i.c | 3 ++- drivers/scsi/cxgbi/cxgb4i/cxgb4i.c | 3 ++- drivers/scsi/cxgbi/libcxgbi.c | 36 +++++++++++++++++------------------- drivers/scsi/cxgbi/libcxgbi.h | 2 +- include/scsi/libiscsi.h | 6 ------ 5 files changed, 22 insertions(+), 28 deletions(-)
drivers/scsi/cxgbi/cxgb3i/cxgb3i.c +2 -1
@@ -137,7 +137,7 @@ static struct iscsi_transport cxgb3i_iscsi_transport = { .destroy_conn = iscsi_tcp_conn_teardown, .start_conn = iscsi_conn_start, .stop_conn = iscsi_conn_stop, - .get_conn_param = cxgbi_get_conn_param, + .get_conn_param = iscsi_conn_get_param, .set_param = cxgbi_set_conn_param, .get_stats = cxgbi_get_conn_stats,/* pdu xmit req from user space */
@@ -152,6 +152,7 @@ static struct iscsi_transport cxgb3i_iscsi_transport = { .xmit_pdu = cxgbi_conn_xmit_pdu, .parse_pdu_itt = cxgbi_parse_pdu_itt,/* TCP connect/disconnect */ + .get_ep_param = cxgbi_get_ep_param, .ep_connect = cxgbi_ep_connect, .ep_poll = cxgbi_ep_poll, .ep_disconnect = cxgbi_ep_disconnect,
drivers/scsi/cxgbi/cxgb4i/cxgb4i.c +2 -1
@@ -138,7 +138,7 @@ static struct iscsi_transport cxgb4i_iscsi_transport = { .destroy_conn = iscsi_tcp_conn_teardown, .start_conn = iscsi_conn_start, .stop_conn = iscsi_conn_stop, - .get_conn_param = cxgbi_get_conn_param, + .get_conn_param = iscsi_conn_get_param, .set_param = cxgbi_set_conn_param, .get_stats = cxgbi_get_conn_stats,/* pdu xmit req from user space */
@@ -153,6 +153,7 @@ static struct iscsi_transport cxgb4i_iscsi_transport = { .xmit_pdu = cxgbi_conn_xmit_pdu, .parse_pdu_itt = cxgbi_parse_pdu_itt,/* TCP connect/disconnect */ + .get_ep_param = cxgbi_get_ep_param, .ep_connect = cxgbi_ep_connect, .ep_poll = cxgbi_ep_poll, .ep_disconnect = cxgbi_ep_disconnect,
drivers/scsi/cxgbi/libcxgbi.c +17 -19
@@ -543,6 +543,7 @@ static struct cxgbi_sock *cxgbi_check_route(struct sockaddr *dst_addr) csk->dst = dst; csk->daddr.sin_addr.s_addr = daddr->sin_addr.s_addr; csk->daddr.sin_port = daddr->sin_port; + csk->daddr.sin_family = daddr->sin_family; csk->saddr.sin_addr.s_addr = rt->rt_src;return csk;
@@ -2200,32 +2201,34 @@ int cxgbi_set_conn_param(struct iscsi_cls_conn *cls_conn, }EXPORT_SYMBOL_GPL (cxgbi_set_conn_param); -int cxgbi_get_conn_param (struct iscsi_cls_conn *cls_conn, -enum iscsi_param param,char *buf) +int cxgbi_get_ep_param (struct iscsi_endpoint *ep,enum iscsi_param param, +char *buf) { -struct iscsi_conn *iconn = cls_conn->dd_data; +struct cxgbi_endpoint *cep = ep->dd_data; +struct cxgbi_sock *csk;int len;log_debug (1 <<CXGBI_DBG_ISCSI , -"cls_conn 0x%p, param %d.\n" , cls_conn, param); +"cls_conn 0x%p, param %d.\n" , ep, param);switch (param) {case ISCSI_PARAM_CONN_PORT : -spin_lock_bh (&iconn->session->lock); - len =sprintf (buf,"%hu\n" , iconn->portal_port); -spin_unlock_bh (&iconn->session->lock); -break ;case ISCSI_PARAM_CONN_ADDRESS : -spin_lock_bh (&iconn->session->lock); - len =sprintf (buf,"%s\n" , iconn->portal_address); -spin_unlock_bh (&iconn->session->lock); -break ; +if (!cep) +return -ENOTCONN ; + + csk = cep->csk; +if (!csk) +return -ENOTCONN ; + +return iscsi_conn_get_addr_param ((struct sockaddr_storage *) + &csk->daddr, param, buf);default : -return iscsi_conn_get_param (cls_conn, param, buf); +return -ENOSYS ; }return len; } -EXPORT_SYMBOL_GPL (cxgbi_get_conn_param); +EXPORT_SYMBOL_GPL (cxgbi_get_ep_param);struct iscsi_cls_conn *cxgbi_create_conn (struct iscsi_cls_session *cls_session,u32 cid)
@@ -2292,11 +2295,6 @@ int cxgbi_bind_conn(struct iscsi_cls_session *cls_session,cxgbi_conn_max_xmit_dlength (conn);cxgbi_conn_max_recv_dlength (conn); -spin_lock_bh (&conn->session->lock); -sprintf (conn->portal_address,"%pI4" , &csk->daddr.sin_addr.s_addr); - conn->portal_port =ntohs (csk->daddr.sin_port); -spin_unlock_bh (&conn->session->lock); -log_debug (1 <<CXGBI_DBG_ISCSI ,"cls 0x%p,0x%p, ep 0x%p, cconn 0x%p, csk 0x%p.\n" , cls_session, cls_conn, ep, cconn, csk);
drivers/scsi/cxgbi/libcxgbi.h +1 -1
@@ -712,7 +712,7 @@ void cxgbi_cleanup_task(struct iscsi_task *task);void cxgbi_get_conn_stats (struct iscsi_cls_conn *,struct iscsi_stats *);int cxgbi_set_conn_param (struct iscsi_cls_conn *,enum iscsi_param ,char *,int ); -int cxgbi_get_conn_param (struct iscsi_cls_conn *,enum iscsi_param ,char *); +int cxgbi_get_ep_param (struct iscsi_endpoint *ep,enum iscsi_param ,char *);struct iscsi_cls_conn *cxgbi_create_conn (struct iscsi_cls_session *,u32 );int cxgbi_bind_conn (struct iscsi_cls_session *,struct iscsi_cls_conn *,u64 ,int );
include/scsi/libiscsi.h +0 -6
@@ -212,9 +212,6 @@ struct iscsi_conn {/* values userspace uses to id a conn */ int persistent_port;char *persistent_address; -/* remote portal currently connected to */ -int portal_port; -char portal_address[ISCSI_ADDRESS_BUF_LEN ];/* MIB-statistics */ uint64_t txdata_octets;
@@ -319,9 +316,6 @@ struct iscsi_host {/* hw address or netdev iscsi connection is bound to */ char *hwaddress;char *netdev; -/* local address */ -int local_port; -char local_address[ISCSI_ADDRESS_BUF_LEN ];wait_queue_head_t session_removal_wq;/* protects sessions and state */
Signature · 1 line
1.7.2.3
PATCH 15/17 bnx2i: fix null ptr ref in conn get param
In reply to [email protected]From: Mike Christie <[email protected]>
bnx2i has some checks to try and make sure the ep
is not destroyed while the addr/port is getting
read. However, if after this check:
if (!(bnx2i_conn && bnx2i_conn->ep && bnx2i_conn->ep->hba))
goto out;
bnx2i_conn->ep is cleared by ep_disconnect then we will oops.
This patches fixes the problem by having the driver use the get_ep_param callback instead of get_conn_param.
--- drivers/scsi/bnx2i/bnx2i_iscsi.c | 45 ++++++++++++++++++------------------- 1 files changed, 22 insertions(+), 23 deletions(-)
drivers/scsi/bnx2i/bnx2i_iscsi.c +22 -23
@@ -1458,42 +1458,40 @@ static void bnx2i_conn_destroy(struct iscsi_cls_conn *cls_conn)/** -* bnx2i_conn_get_param - return iscsi connection parameter to caller -* @cls_conn: pointer to iscsi cls conn +* bnx2i_ep_get_param - return iscsi ep parameter to caller +* @ep: pointer to iscsi endpoint * @param: parameter type identifier * @buf: buffer pointer * -* returns iSCSI connection parameters +* returns iSCSI ep parameters */ -static int bnx2i_conn_get_param (struct iscsi_cls_conn *cls_conn, -enum iscsi_param param,char *buf) +static int bnx2i_ep_get_param (struct iscsi_endpoint *ep, +enum iscsi_param param,char *buf) { -struct iscsi_conn *conn = cls_conn->dd_data; -struct bnx2i_conn *bnx2i_conn = conn->dd_data; -int len =0 ; +struct bnx2i_endpoint *bnx2i_ep = ep->dd_data; +struct bnx2i_hba *hba = bnx2i_ep->hba; +int len = -ENOTCONN ; -if (!(bnx2i_conn && bnx2i_conn->ep && bnx2i_conn->ep->hba)) - goto out; +if (!hba) +return -ENOTCONN ;switch (param) {case ISCSI_PARAM_CONN_PORT : -mutex_lock (&bnx2i_conn->ep->hba->net_dev_lock); -if (bnx2i_conn->ep->cm_sk) - len =sprintf (buf,"%hu\n" , - bnx2i_conn->ep->cm_sk->dst_port); -mutex_unlock (&bnx2i_conn->ep->hba->net_dev_lock); +mutex_lock (&hba->net_dev_lock); +if (bnx2i_ep->cm_sk) + len =sprintf (buf,"%hu\n" , bnx2i_ep->cm_sk->dst_port); +mutex_unlock (&hba->net_dev_lock);break ;case ISCSI_PARAM_CONN_ADDRESS : -mutex_lock (&bnx2i_conn->ep->hba->net_dev_lock); -if (bnx2i_conn->ep->cm_sk) - len =sprintf (buf,"%pI4\n" , - &bnx2i_conn->ep->cm_sk->dst_ip); -mutex_unlock (&bnx2i_conn->ep->hba->net_dev_lock); +mutex_lock (&hba->net_dev_lock); +if (bnx2i_ep->cm_sk) + len =sprintf (buf,"%pI4\n" , &bnx2i_ep->cm_sk->dst_ip); +mutex_unlock (&hba->net_dev_lock);break ;default : -return iscsi_conn_get_param (cls_conn, param, buf); +return -ENOSYS ; } -out: +return len; }
@@ -2204,7 +2202,7 @@ struct iscsi_transport bnx2i_iscsi_transport = { .bind_conn = bnx2i_conn_bind, .destroy_conn = bnx2i_conn_destroy, .set_param = iscsi_set_param, - .get_conn_param = bnx2i_conn_get_param, + .get_conn_param = iscsi_conn_get_param, .get_session_param = iscsi_session_get_param, .get_host_param = bnx2i_host_get_param, .start_conn = bnx2i_conn_start,
@@ -2213,6 +2211,7 @@ struct iscsi_transport bnx2i_iscsi_transport = { .xmit_task = bnx2i_task_xmit, .get_stats = bnx2i_conn_get_stats,/* TCP connect - disconnect - option-2 interface calls */ + .get_ep_param = bnx2i_ep_get_param, .ep_connect = bnx2i_ep_connect, .ep_poll = bnx2i_ep_poll, .ep_disconnect = bnx2i_ep_disconnect,
Signature · 1 line
1.7.2.3
PATCH 16/17 iser: export addr and port
In reply to [email protected]From: Mike Christie <[email protected]>
This pactch has iser export the address and port
of the endpoint.
--- drivers/infiniband/ulp/iser/iscsi_iser.c | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-)
drivers/infiniband/ulp/iser/iscsi_iser.c +26 -0
@@ -532,6 +532,29 @@ iscsi_iser_conn_get_stats(struct iscsi_cls_conn *cls_conn, struct iscsi_stats *s stats->custom[3 ].value = conn->fmr_unalign_cnt; } +static int iscsi_iser_get_ep_param (struct iscsi_endpoint *ep, +enum iscsi_param param,char *buf) +{ +struct iser_conn *ib_conn = ep->dd_data; +int len; + +switch (param) { +case ISCSI_PARAM_CONN_PORT : +case ISCSI_PARAM_CONN_ADDRESS : +if (!ib_conn || !ib_conn->cma_id) +return -ENOTCONN ; + +return iscsi_conn_get_addr_param ((struct sockaddr_storage *) + &ib_conn->cma_id->route.addr.dst_addr, + param, buf); +break ; +default : +return -ENOSYS ; + } + +return len; +} +static struct iscsi_endpoint *iscsi_iser_ep_connect (struct Scsi_Host *shost,struct sockaddr *dst_addr,int non_blocking)
@@ -637,6 +660,8 @@ static struct iscsi_transport iscsi_iser_transport = {ISCSI_MAX_BURST |ISCSI_PDU_INORDER_EN |ISCSI_DATASEQ_INORDER_EN | +ISCSI_CONN_PORT | +ISCSI_CONN_ADDRESS |ISCSI_EXP_STATSN |ISCSI_PERSISTENT_PORT | ISCSI_PERSISTENT_ADDRESS |
@@ -659,6 +684,7 @@ static struct iscsi_transport iscsi_iser_transport = { .destroy_conn = iscsi_iser_conn_destroy, .set_param = iscsi_iser_set_param, .get_conn_param = iscsi_conn_get_param, + .get_ep_param = iscsi_iser_get_ep_param, .get_session_param = iscsi_session_get_param, .start_conn = iscsi_iser_conn_start, .stop_conn = iscsi_iser_conn_stop,
Signature · 1 line
1.7.2.3
PATCH 17/17 be2iscsi: fix null ptr ref in conn get param
In reply to [email protected]From: Mike Christie <[email protected]>
The ep_disconnect function could be freeing the ep while beiscsi_conn_get_param is running. This has the driver use the get ep param callback instead of the get conn param to fix this.
--- drivers/scsi/be2iscsi/be_iscsi.c | 18 +++++------------- drivers/scsi/be2iscsi/be_iscsi.h | 4 ++-- drivers/scsi/be2iscsi/be_main.c | 3 ++- 3 files changed, 9 insertions(+), 16 deletions(-)
drivers/scsi/be2iscsi/be_iscsi.c +5 -13
@@ -210,28 +210,20 @@ int beiscsi_conn_bind(struct iscsi_cls_session *cls_session, }/** -* beiscsi_conn_get_param - get the iscsi parameter -* @cls_conn: pointer to iscsi cls conn +* beiscsi_ep_get_param - get the iscsi parameter +* @ep: pointer to iscsi ep * @param: parameter type identifier * @buf: buffer pointer * * returns iscsi parameter */ -int beiscsi_conn_get_param (struct iscsi_cls_conn *cls_conn, +int beiscsi_ep_get_param (struct iscsi_endpoint *ep,enum iscsi_param param,char *buf) { -struct beiscsi_endpoint *beiscsi_ep; -struct iscsi_conn *conn = cls_conn->dd_data; -struct beiscsi_conn *beiscsi_conn = conn->dd_data; +struct beiscsi_endpoint *beiscsi_ep = ep->dd_data;int len =0 ;SE_DEBUG (DBG_LVL_8 ,"In beiscsi_conn_get_param, param= %d\n" , param); - beiscsi_ep = beiscsi_conn->ep; -if (!beiscsi_ep) { -SE_DEBUG (DBG_LVL_1 , -"In beiscsi_conn_get_param , no beiscsi_ep\n" ); -return -ENODEV ; - }switch (param) {case ISCSI_PARAM_CONN_PORT :
@@ -244,7 +236,7 @@ int beiscsi_conn_get_param(struct iscsi_cls_conn *cls_conn, len =sprintf (buf,"%pI6\n" , &beiscsi_ep->dst6_addr);break ;default : -return iscsi_conn_get_param (cls_conn, param, buf); +return -ENOSYS ; }return len; }
drivers/scsi/be2iscsi/be_iscsi.h +2 -2
@@ -48,8 +48,8 @@ int beiscsi_conn_bind(struct iscsi_cls_session *cls_session,struct iscsi_cls_conn *cls_conn, uint64_t transport_fd, int is_leading); -int beiscsi_conn_get_param (struct iscsi_cls_conn *cls_conn, -enum iscsi_param param,char *buf); +int beiscsi_ep_get_param (struct iscsi_endpoint *ep,enum iscsi_param param, +char *buf);int beiscsi_get_host_param (struct Scsi_Host *shost,enum iscsi_host_param param,char *buf);
drivers/scsi/be2iscsi/be_main.c +2 -1
@@ -4384,7 +4384,7 @@ struct iscsi_transport beiscsi_iscsi_transport = { .bind_conn = beiscsi_conn_bind, .destroy_conn = iscsi_conn_teardown, .set_param = beiscsi_set_param, - .get_conn_param = beiscsi_conn_get_param, + .get_conn_param = iscsi_conn_get_param, .get_session_param = iscsi_session_get_param, .get_host_param = beiscsi_get_host_param, .start_conn = beiscsi_conn_start,
@@ -4395,6 +4395,7 @@ struct iscsi_transport beiscsi_iscsi_transport = { .alloc_pdu = beiscsi_alloc_pdu, .parse_pdu_itt = beiscsi_parse_pdu, .get_stats = beiscsi_conn_get_stats, + .get_ep_param = beiscsi_ep_get_param, .ep_connect = beiscsi_ep_connect, .ep_poll = beiscsi_ep_poll, .ep_disconnect = beiscsi_ep_disconnect,
Signature · 1 line
1.7.2.3