public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: "Sean Hefty" <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: "Hefty,
	Sean" <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	linux-rdma <linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: [RFC] [PATCH 20/22] [for 2.6.36] rdma/ucm: allow user space to bind to AF_IB
Date: Tue, 23 Mar 2010 11:27:11 -0700	[thread overview]
Message-ID: <4FCEB75A41C444DCB6FDF20C17DCEF6E@amr.corp.intel.com> (raw)
In-Reply-To: <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>

Support user space binding to addresses using AF_IB.  Since
sockaddr_ib is larger than sockaddr_in6, we need to define
a larger structure when binding using AF_IB.  This time we
use sockaddr_storage to cover future cases.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---

 drivers/infiniband/core/ucma.c |   27 ++++++++++++++++++++++++++-
 include/rdma/rdma_user_cm.h    |   10 +++++++++-
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
index 950bd35..e2d8dcf 100644
--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -514,6 +514,30 @@ static ssize_t ucma_bind_ip(struct ucma_file *file, const char __user *inbuf,
 	return ret;
 }
 
+static ssize_t ucma_bind(struct ucma_file *file, const char __user *inbuf,
+			 int in_len, int out_len)
+{
+	struct rdma_ucm_bind cmd;
+	struct sockaddr *addr;
+	struct ucma_context *ctx;
+	int ret;
+
+	if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+		return -EFAULT;
+
+	addr = (struct sockaddr *) &cmd.addr;
+	if (cmd.reserved || !cmd.addr_size || (cmd.addr_size != rdma_addr_size(addr)))
+		return -EINVAL;
+
+	ctx = ucma_get_ctx(file, cmd.id);
+	if (IS_ERR(ctx))
+		return PTR_ERR(ctx);
+
+	ret = rdma_bind_addr(ctx->cm_id, addr);
+	ucma_put_ctx(ctx);
+	return ret;
+}
+
 static ssize_t ucma_resolve_ip(struct ucma_file *file,
 			       const char __user *inbuf,
 			       int in_len, int out_len)
@@ -1308,7 +1332,8 @@ static ssize_t (*ucma_cmd_table[])(struct ucma_file *file,
 	[RDMA_USER_CM_CMD_JOIN_IP_MCAST]= ucma_join_ip_multicast,
 	[RDMA_USER_CM_CMD_LEAVE_MCAST]	= ucma_leave_multicast,
 	[RDMA_USER_CM_CMD_MIGRATE_ID]	= ucma_migrate_id,
-	[RDMA_USER_CM_CMD_QUERY]	= ucma_query
+	[RDMA_USER_CM_CMD_QUERY]	= ucma_query,
+	[RDMA_USER_CM_CMD_BIND]		= ucma_bind
 };
 
 static ssize_t ucma_write(struct file *filp, const char __user *buf,
diff --git a/include/rdma/rdma_user_cm.h b/include/rdma/rdma_user_cm.h
index bbb724b..009b8da 100644
--- a/include/rdma/rdma_user_cm.h
+++ b/include/rdma/rdma_user_cm.h
@@ -62,7 +62,8 @@ enum {
 	RDMA_USER_CM_CMD_JOIN_IP_MCAST,
 	RDMA_USER_CM_CMD_LEAVE_MCAST,
 	RDMA_USER_CM_CMD_MIGRATE_ID,
-	RDMA_USER_CM_CMD_QUERY
+	RDMA_USER_CM_CMD_QUERY,
+	RDMA_USER_CM_CMD_BIND
 };
 
 /*
@@ -101,6 +102,13 @@ struct rdma_ucm_bind_ip {
 	__u32 id;
 };
 
+struct rdma_ucm_bind {
+	__u32 id;
+	__u16 addr_size;
+	__u16 reserved;
+	struct sockaddr_storage addr;
+};
+
 struct rdma_ucm_resolve_ip {
 	struct sockaddr_in6 src_addr;
 	struct sockaddr_in6 dst_addr;



--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2010-03-23 18:27 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-23 17:48 [RFC] [PATCH 0/22] [for 2.6.36] rdma/cm: add support for native IB addressing Sean Hefty
     [not found] ` <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2010-03-23 17:52   ` [RFC] [PATCH 1/22] [for 2.6.36] rdma/cm: define native IB address Sean Hefty
2010-03-23 17:54   ` [RFC] [PATCH 2/22] [for 2.6.36] rdma/cm: fix handling of ipv6 addressing in cma_use_port Sean Hefty
2010-03-23 17:55   ` [RFC] [PATCH 3/22] [for 2.6.36] rdma/cm: include AF_IB in loopback and any address checks Sean Hefty
2010-03-23 17:57   ` [RFC] [PATCH 4/22] [for 2.6.36] ib/addr: add AF_IB support to ip_addr_size Sean Hefty
2010-03-23 17:59   ` [RFC] [PATCH 5/22] [for 2.6.36] rdma/cm: update port reservation to support AF_IB Sean Hefty
     [not found]     ` <012F7D9E5E97445E9100EF170212AEE7-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2010-03-25 19:05       ` [RFC] [PATCH 5/22 v2] " Sean Hefty
     [not found]         ` <7451BD1514874F3E987E55040776EECC-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2010-03-25 20:29           ` Jason Gunthorpe
     [not found]             ` <20100325202924.GO29129-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-03-25 21:00               ` Sean Hefty
     [not found]                 ` <AC26D518E7AE4BE6BA3BDFC11480F8DB-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2010-03-25 22:04                   ` Jason Gunthorpe
     [not found]                     ` <20100325220435.GP29129-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-03-25 22:40                       ` Sean Hefty
     [not found]                         ` <C70579E21917462C89AAEAE3C225A58B-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2010-03-25 23:43                           ` Jason Gunthorpe
2010-03-26  3:56                           ` Sean Hefty
     [not found]                             ` <FD7DFBFAF86D4EA99F82836CBCA8AB33-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2010-03-26  4:08                               ` Jason Gunthorpe
     [not found]                                 ` <20100326040809.GD9769-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-03-26 16:06                                   ` Sean Hefty
     [not found]                                     ` <57287E48AAAD47A4BD50719B889F4596-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2010-03-26 17:17                                       ` Sean Hefty
     [not found]                                         ` <350558935FCC47B6A5ABA8402109746C-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2010-03-26 17:20                                           ` Jason Gunthorpe
     [not found]                                             ` <20100326172057.GR29129-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-03-26 17:23                                               ` Sean Hefty
2010-03-27  0:11                                           ` Sean Hefty
     [not found]                                             ` <0F1BE18DBBF74165AEA2B3283B01F338-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2010-03-27  0:44                                               ` Jason Gunthorpe
     [not found]                                                 ` <20100327004440.GE9769-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-03-27  1:01                                                   ` Sean Hefty
2010-03-23 18:01   ` [RFC] [PATCH 6/22] [for 2.6.36] rdma/cm: Allow user to specify AF_IB when binding Sean Hefty
2010-03-23 18:03   ` [RFC] [PATCH 7/22] [for 2.6.36] rdma/cm: do not modify sa_family when setting loopback address Sean Hefty
2010-03-23 18:04   ` [RFC] [PATCH 8/22] [for 2.6.36] rdma/cm: restrict AF_IB loopback to binding to IB devices only Sean Hefty
2010-03-23 18:06   ` [RFC] [PATCH 9/22] [for 2.6.36] rdma/cm: add support for AF_IB to rdma_resolve_addr Sean Hefty
2010-03-23 18:07   ` [RFC] [PATCH 10/22] [for 2.6.36] rdma/cm: add support for AF_IB to cma_get_service_id Sean Hefty
2010-03-23 18:08   ` [RFC] [PATCH 11/22] [for 2.6.36] rdma/cm: fixup white space Sean Hefty
2010-03-23 18:11   ` [RFC] [PATCH 12/22] [for 2.6.36] rdma/cm: expose private data when using AF_IB Sean Hefty
2010-03-23 18:12   ` [RFC] [PATCH 13/22] [for 2.6.36] rdma/cm: only listen on IB devices " Sean Hefty
2010-03-23 18:14   ` [RFC] [PATCH 14/22] [for 2.6.36] rdma/ucm: support querying for AF_IB addresses Sean Hefty
2010-03-23 18:16   ` [RFC] [PATCH 15/22] [for 2.6.36] ib/sa: export function to pack a path record into wire format Sean Hefty
2010-03-23 18:18   ` [RFC] [PATCH 16/22] [for 2.6.36] rdma/ucm: support querying when IB paths are not reversible Sean Hefty
2010-03-23 18:20   ` [RFC] [PATCH 17/22] [for 2.6.36] rdma/cm: export cma_get_service_id Sean Hefty
2010-03-23 18:23   ` [RFC] [PATCH 18/22] [for 2.6.36] rdma/ucm: add ability to query GID addresses Sean Hefty
2010-03-23 18:25   ` [RFC] [PATCH 19/22] [for 2.6.36] rdma/ucm: name changes to indicate only IP addresses supported Sean Hefty
2010-03-23 18:27   ` Sean Hefty [this message]
2010-03-23 18:28   ` [RFC] [PATCH 21/22] [for 2.6.36] rdma/ucm: allow user space to pass AF_IB into resolve Sean Hefty
2010-03-23 18:30   ` [RFC] [PATCH 22/22] [for 2.6.36] rdma/ucm: allow user space to specify AF_IB when joining multicast Sean Hefty
     [not found]     ` <48F1FC4C2F114E928EB38D690091185E-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2010-03-25 19:08       ` [RFC] [PATCH 22/22 v2] " Sean Hefty
2010-03-23 19:22   ` [RFC] [PATCH 0/22] [for 2.6.36] rdma/cm: add support for native IB addressing Sean Hefty
2010-03-26 17:33   ` Sean Hefty

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4FCEB75A41C444DCB6FDF20C17DCEF6E@amr.corp.intel.com \
    --to=sean.hefty-ral2jqcrhueavxtiumwx3w@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox