From patchwork Tue Jun 6 18:07:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert LeBlanc X-Patchwork-Id: 9769517 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D94F960393 for ; Tue, 6 Jun 2017 18:10:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D89A9284EE for ; Tue, 6 Jun 2017 18:10:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD3DE28509; Tue, 6 Jun 2017 18:10:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FD9B284EE for ; Tue, 6 Jun 2017 18:10:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751641AbdFFSHc (ORCPT ); Tue, 6 Jun 2017 14:07:32 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:35669 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751521AbdFFSHa (ORCPT ); Tue, 6 Jun 2017 14:07:30 -0400 Received: by mail-pf0-f196.google.com with SMTP id u26so25026524pfd.2 for ; Tue, 06 Jun 2017 11:07:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leblancnet-us.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ycWgr73D6rFjUvgpDpS+CVwKnH8sgNzKVW8FJ2orjRg=; b=FsgN68LZ/mzJGxG63+kz8Ewtp8P7juDHoBT40CgJdEogGYejEvW1T1fo+/zHEvFkqP g4zk0AnXxVWvkrsv6il+N6s+81G8huj8YMy6z8o805ieZbu80gFBwMTvTQUeF1Tow/VS EUkCjh/STuugx1x7I4jqwcgnc28XkxU1UIcO6vxQrEiJqJnuCG/xIHmZqyMHawxCs9et +H3RUg7B55RAXvqaQNl7OlrHwr3QL+Kp+Vt7LGpezVfIbnja9YJtKfmB0cVlVUsiyEiP zvsyIQAds7I2G0bYU5rflYCGA4gvz6sE5dv69c4wB36bSu3H8B6ulb2ePS8a+t62G+n6 u0bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ycWgr73D6rFjUvgpDpS+CVwKnH8sgNzKVW8FJ2orjRg=; b=Dca7goTt6Y1FVW4LBxOXmxyI5GFzuO/1OkgjGhSXJB455La9VgFwjcJhO8ElJ8b+JO /iVGvwE2psKYJezr/2DusfVzqE2QQp3pfT5cF2J6mkuILUlA7W364qMd0ztt2iKQvnbs oGZGXF7WDg0rfprF6TkaatrhIkRvnvgMki67bITYddmkVw6cvzBrdh9Z7rZVYk1elScg SxIdzbs4FGhqNN1mszxexklE4FA5Fu7s/5jFuuGU7FG8U0U7cLPPvDI3cqW+fHBvDu29 4TWGDpOOLXK4//1a8AD4aZBxGR0ayzNl1Fl3BRGm8cM/5hWRyD9yNL3prhQxbutZiold qEPQ== X-Gm-Message-State: AODbwcCCDJdqTBXULQ1FOl7Si9BhtCy5BgBSfqbw+Z2/NxBjx+w53d/N WFli/Vq8eDXJjrIvExzngQ== X-Received: by 10.84.224.6 with SMTP id r6mr22389261plj.132.1496772450156; Tue, 06 Jun 2017 11:07:30 -0700 (PDT) Received: from rleblanc-pc ([2604:ba00:2:1:1043:d22c:d907:91b1]) by smtp.gmail.com with ESMTPSA id c66sm32522839pfl.81.2017.06.06.11.07.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Jun 2017 11:07:29 -0700 (PDT) Received: from rleblanc by rleblanc-pc with local (Exim 4.89) (envelope-from ) id 1dIIt6-0001Jk-8R; Tue, 06 Jun 2017 12:07:28 -0600 From: Robert LeBlanc To: lduncan@suse.com Cc: cleech@redhat.com, jejb@linux.vnet.ibm.com, martin.petersen@oracle.com, open-iscsi@googlegroups.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, ogerlitz@mellanox.com, sagi@grimberg.me, roid@mellanox.com, dledford@redhat.com, sean.hefty@intel.com, hal.rosenstock@gmail.com, linux-rdma@vger.kernel.org, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, QLogic-Storage-Upstream@qlogic.com, varun@chelsio.com, Robert LeBlanc Subject: [PATCH 3/7] ib/iSER: Add binding to source IP address. Date: Tue, 6 Jun 2017 12:07:13 -0600 Message-Id: <20170606180717.5007-4-robert@leblancnet.us> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170606180717.5007-1-robert@leblancnet.us> References: <20170606180717.5007-1-robert@leblancnet.us> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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(-) diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c index 5a887efb4bdf..7ba5ed9afe05 100644 --- a/drivers/infiniband/ulp/iser/iscsi_iser.c +++ b/drivers/infiniband/ulp/iser/iscsi_iser.c @@ -59,6 +59,7 @@ #include #include #include +#include #include @@ -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; diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.h b/drivers/infiniband/ulp/iser/iscsi_iser.h index c1ae4aeae2f9..1eda6ff49bdc 100644 --- a/drivers/infiniband/ulp/iser/iscsi_iser.h +++ b/drivers/infiniband/ulp/iser/iscsi_iser.h @@ -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, diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c b/drivers/infiniband/ulp/iser/iser_initiator.c index 12ed62ce9ff7..361d5e411fe7 100644 --- a/drivers/infiniband/ulp/iser/iser_initiator.c +++ b/drivers/infiniband/ulp/iser/iser_initiator.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include diff --git a/drivers/infiniband/ulp/iser/iser_memory.c b/drivers/infiniband/ulp/iser/iser_memory.c index 9c3e9ab53a41..c9d95b997820 100644 --- a/drivers/infiniband/ulp/iser/iser_memory.c +++ b/drivers/infiniband/ulp/iser/iser_memory.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "iscsi_iser.h" static diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c index c538a38c91ce..0a43009296b6 100644 --- a/drivers/infiniband/ulp/iser/iser_verbs.c +++ b/drivers/infiniband/ulp/iser/iser_verbs.c @@ -35,6 +35,7 @@ #include #include #include +#include #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;