@@ -59,6 +59,7 @@
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/module.h>
+#include <linux/inet.h>
#include <net/sock.h>
@@ -808,12 +809,16 @@ static int iscsi_iser_get_ep_param(struct iscsi_endpoint *ep,
* if fails.
*/
static struct iscsi_endpoint *
-iscsi_iser_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr,
- int non_blocking)
+iscsi_iser_ep_connect(struct Scsi_Host *shost, struct sockaddr_storage *dst_addr,
+ int non_blocking, struct iface_rec *iface)
{
int err;
struct iser_conn *iser_conn;
struct iscsi_endpoint *ep;
+ struct sockaddr_storage src_addr;
+ struct sockaddr_in *tmp_addr;
+ struct sockaddr_in6 *tmp_addr6;
+ memset(&src_addr, 0, sizeof(src_addr));
ep = iscsi_create_endpoint(0);
if (!ep)
@@ -828,8 +833,28 @@ iscsi_iser_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr,
ep->dd_data = iser_conn;
iser_conn->ep = ep;
iser_conn_init(iser_conn);
-
- err = iser_connect(iser_conn, NULL, dst_addr, non_blocking);
+ if (iface && iface->ipaddress[0]) {
+ if (strchr(iface->ipaddress, ':')) {
+ tmp_addr6 = (struct sockaddr_in6 *)&src_addr;
+ tmp_addr6->sin6_family = AF_INET6;
+ if(!in6_pton(iface->ipaddress, -1,
+ tmp_addr6->sin6_addr.s6_addr,
+ -1, NULL)) {
+ err = -EINVAL;
+ goto failure;
+ }
+ } else {
+ tmp_addr = (struct sockaddr_in *)&src_addr;
+ tmp_addr->sin_family = AF_INET;
+ if (!in4_pton(iface->ipaddress, -1,
+ (u8 *)&tmp_addr->sin_addr.s_addr,
+ -1, NULL)) {
+ err = -EINVAL;
+ goto failure;
+ }
+ }
+ }
+ err = iser_connect(iser_conn, &src_addr, dst_addr, non_blocking);
if (err)
goto failure;
@@ -628,8 +628,8 @@ void iser_unreg_rdma_mem(struct iscsi_iser_task *task,
enum iser_data_dir dir);
int iser_connect(struct iser_conn *iser_conn,
- struct sockaddr *src_addr,
- struct sockaddr *dst_addr,
+ struct sockaddr_storage *src_addr,
+ struct sockaddr_storage *dst_addr,
int non_blocking);
void iser_unreg_mem_fmr(struct iscsi_iser_task *iser_task,
@@ -35,6 +35,7 @@
#include <linux/mm.h>
#include <linux/scatterlist.h>
#include <linux/kfifo.h>
+#include <linux/if.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_host.h>
@@ -36,6 +36,7 @@
#include <linux/mm.h>
#include <linux/highmem.h>
#include <linux/scatterlist.h>
+#include <linux/if.h>
#include "iscsi_iser.h"
static
@@ -35,6 +35,7 @@
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/delay.h>
+#include <linux/if.h>
#include "iscsi_iser.h"
@@ -941,8 +942,8 @@ void iser_conn_init(struct iser_conn *iser_conn)
* sleeps until the connection is established or rejected
*/
int iser_connect(struct iser_conn *iser_conn,
- struct sockaddr *src_addr,
- struct sockaddr *dst_addr,
+ struct sockaddr_storage *src_addr,
+ struct sockaddr_storage *dst_addr,
int non_blocking)
{
struct ib_conn *ib_conn = &iser_conn->ib_conn;
@@ -968,7 +969,8 @@ int iser_connect(struct iser_conn *iser_conn,
goto id_failure;
}
- err = rdma_resolve_addr(ib_conn->cma_id, src_addr, dst_addr, 1000);
+ err = rdma_resolve_addr(ib_conn->cma_id, (struct sockaddr *)src_addr,
+ (struct sockaddr *)dst_addr, 1000);
if (err) {
iser_err("rdma_resolve_addr failed: %d\n", err);
goto addr_failure;
If the iface passed in has ip address set, then attept to create an RDMA connection using it as the source IP address. This allows iSER to use multiple ports on the same network or in more complex routing configurations. Also update to accepting sockaddr_storage. Signed-off-by: Robert LeBlanc <robert@leblancnet.us> --- drivers/infiniband/ulp/iser/iscsi_iser.c | 33 ++++++++++++++++++++++++---- drivers/infiniband/ulp/iser/iscsi_iser.h | 4 ++-- drivers/infiniband/ulp/iser/iser_initiator.c | 1 + drivers/infiniband/ulp/iser/iser_memory.c | 1 + drivers/infiniband/ulp/iser/iser_verbs.c | 8 ++++--- 5 files changed, 38 insertions(+), 9 deletions(-)