Skip to contentSkip to conversation

New RAW_PACKET QP type

PATCH Applied Aleksey Senin 4 participants 10 messages Jul 4, 2010 – Jan 21, 2011 6 messages not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

cover New RAW_PACKET QP type

The following patches add a new QP type named RAW_PACKET.

This type of QP is used in Ethernet environment and intended for creation of a whole packet, including L2 headers, from userspace. In order to prevent regular user from creating malicious packets, at the time of QP creation, kernel will check if the process has necessary permissions. This examination areis done in uverbs layer and is general for all low level drivers.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 4C308E07.7050903-192fA4vuk7xBDLzU/[email protected]

#2 lore raw

PATCH 1/4 Rename RAW_ETY to RAW_ETHERTYPE

Rename RAW_ETY to RAW_ETHERTYPE in order to be more precise to IBA qp types.

See discussion at
http://www.mail-archive.com/[email protected]/msg04530.html

---
 drivers/infiniband/core/verbs.c         |    4 ++--
 drivers/infiniband/hw/ehca/ehca_qp.c    |    2 +-
 drivers/infiniband/hw/mthca/mthca_cmd.c |    2 +-
 include/rdma/ib_verbs.h                 |    2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
drivers/infiniband/core/verbs.c +2 -2
index 29edeba..af7a8b0 100644
@@ -326,8 +326,8 @@ EXPORT_SYMBOL(ib_create_qp);
 
 static const struct {
 	int			valid;
-	enum ib_qp_attr_mask	req_param[IB_QPT_RAW_ETY + 1];
-	enum ib_qp_attr_mask	opt_param[IB_QPT_RAW_ETY + 1];
+	enum ib_qp_attr_mask	req_param[IB_QPT_RAW_ETHERTYPE + 1];
+	enum ib_qp_attr_mask	opt_param[IB_QPT_RAW_ETHERTYPE + 1];
 } qp_state_table[IB_QPS_ERR + 1][IB_QPS_ERR + 1] = {
 	[IB_QPS_RESET] = {
 		[IB_QPS_RESET] = { .valid = 1 },
drivers/infiniband/hw/ehca/ehca_qp.c +1 -1
index 47d388e..32fb342 100644
@@ -251,7 +251,7 @@ static inline int ibqptype2servicetype(enum ib_qp_type ibqptype)
 		return ST_UD;
 	case IB_QPT_RAW_IPV6:
 		return -EINVAL;
-	case IB_QPT_RAW_ETY:
+	case IB_QPT_RAW_ETHERTYPE:
 		return -EINVAL;
 	default:
 		ehca_gen_err("Invalid ibqptype=%x", ibqptype);
drivers/infiniband/hw/mthca/mthca_cmd.c +1 -1
index 3603ae8..f4ceecd 100644
@@ -1817,7 +1817,7 @@ int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn,
 	case IB_QPT_RAW_IPV6:
 		op_mod = 2;
 		break;
-	case IB_QPT_RAW_ETY:
+	case IB_QPT_RAW_ETHERTYPE:
 		op_mod = 3;
 		break;
 	default:
include/rdma/ib_verbs.h +1 -1
index 4f4e81b..ecf098a 100644
@@ -562,7 +562,7 @@ enum ib_qp_type {
 	IB_QPT_UC,
 	IB_QPT_UD,
 	IB_QPT_RAW_IPV6,
-	IB_QPT_RAW_ETY
+	IB_QPT_RAW_ETHERTYPE
 };
 
 enum ib_qp_create_flags {
Signature · 6 lines
1.6.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 4C3092ED.6000701-192fA4vuk7xBDLzU/[email protected]

#4 lore raw

PATCH 2/4 New RAW_PACKET QP type definition

The following patches add a new QP type named RAW_PACKET.

This type of QP is used in Ethernet environment and intended for creation of a whole packet, including L2 headers, from userspace.

Reserve a place for future XRC patch in order to be sure that OFED kernel ABI will not broken when XRC and RAW patches will be accepted to upstream kernel.

---
 drivers/infiniband/core/verbs.c |    4 ++--
 include/rdma/ib_verbs.h         |    3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/infiniband/core/verbs.c +2 -2
index af7a8b0..b04b419 100644
@@ -326,8 +326,8 @@ EXPORT_SYMBOL(ib_create_qp);
 
 static const struct {
 	int			valid;
-	enum ib_qp_attr_mask	req_param[IB_QPT_RAW_ETHERTYPE + 1];
-	enum ib_qp_attr_mask	opt_param[IB_QPT_RAW_ETHERTYPE + 1];
+	enum ib_qp_attr_mask	req_param[IB_QPT_RAW_PACKET + 1];
+	enum ib_qp_attr_mask	opt_param[IB_QPT_RAW_PACKET + 1];
 } qp_state_table[IB_QPS_ERR + 1][IB_QPS_ERR + 1] = {
 	[IB_QPS_RESET] = {
 		[IB_QPS_RESET] = { .valid = 1 },
include/rdma/ib_verbs.h +2 -1
index ecf098a..555165b 100644
@@ -562,7 +562,8 @@ enum ib_qp_type {
 	IB_QPT_UC,
 	IB_QPT_UD,
 	IB_QPT_RAW_IPV6,
-	IB_QPT_RAW_ETHERTYPE
+	IB_QPT_RAW_ETHERTYPE = 7,
+	IB_QPT_RAW_PACKET = 8
 };
 
 enum ib_qp_create_flags {
Signature · 6 lines
1.6.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 4C3095CB.2000205-192fA4vuk7xBDLzU/[email protected]

#6 lore raw

PATCH 3/4 Security check on QP type

Check if user process has permission to create RAW_PACKET QP.

In order to prevent regular user from creating malicious packets, at the time of QP creation, kernel will check if the process has necessary permissions. This examination areis done in uverbs layer and is general for all low level drivers.

---
 drivers/infiniband/core/uverbs_cmd.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/infiniband/core/uverbs_cmd.c +3 -0
index 6fcfbeb..87025fc 100644
@@ -1050,6 +1050,9 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file,
 	if (copy_from_user(&cmd, buf, sizeof cmd))
 		return -EFAULT;
 
+	if (cmd.qp_type == IB_QPT_RAW_PACKET && !capable(CAP_NET_RAW))
+		return -EPERM;
+
 	INIT_UDATA(&udata, buf + sizeof cmd,
 		   (unsigned long) cmd.response + sizeof resp,
 		   in_len - sizeof cmd, out_len - sizeof resp);
Signature · 6 lines
1.6.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 4C3096B0.5030005-192fA4vuk7xBDLzU/[email protected]

#8 lore raw

PATCH 4/4 Add RAW_PACKET to ib_attach/detach mcast calls

Added RAW_PACKET to ib_attach/detach calls

Add iWARP transport to attach/detach mcast. Differentiate between transport types when dealing with multicast.

---
 drivers/infiniband/core/verbs.c |   24 ++++++++++++++++++++----
 1 files changed, 20 insertions(+), 4 deletions(-)
drivers/infiniband/core/verbs.c +20 -4
index b04b419..a053c0e 100644
@@ -903,9 +903,17 @@ int ib_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid)
 {
 	if (!qp->device->attach_mcast)
 		return -ENOSYS;
-	if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD)
-		return -EINVAL;
 
+	switch (rdma_node_get_transport(qp->device->node_type)) {
+	case RDMA_TRANSPORT_IB:
+		if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD)
+			return -EINVAL;
+		break;
+	case RDMA_TRANSPORT_IWARP:
+		if (qp->qp_type != IB_QPT_RAW_PACKET)
+			return -EINVAL;
+		break;
+	}
 	return qp->device->attach_mcast(qp, gid, lid);
 }
 EXPORT_SYMBOL(ib_attach_mcast);
@@ -914,9 +922,17 @@ int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid)
 {
 	if (!qp->device->detach_mcast)
 		return -ENOSYS;
-	if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD)
-		return -EINVAL;
 
+	switch (rdma_node_get_transport(qp->device->node_type)) {
+	case RDMA_TRANSPORT_IB:
+		if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD)
+			return -EINVAL;
+		break;
+	case RDMA_TRANSPORT_IWARP:
+		if (qp->qp_type != IB_QPT_RAW_PACKET)
+			return -EINVAL;
+		break;
+	}
 	return qp->device->detach_mcast(qp, gid, lid);
 }
 EXPORT_SYMBOL(ib_detach_mcast);

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#9 lore raw

Re: [PATCH V1 2/4] New RAW_PACKET QP type definition

In reply to a message not in the archive
Quoted 36 lines · Aleksey Senin

The following patches add a new QP type named RAW_PACKET.

This type of QP is used in Ethernet environment and intended for creation of a whole packet, including L2 headers, from userspace.

Reserve a place for future XRC patch in order to be sure that OFED kernel ABI will not broken when XRC and RAW patches will be accepted to upstream kernel.

---
 drivers/infiniband/core/verbs.c |    4 ++--
 include/rdma/ib_verbs.h         |    3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/infiniband/core/verbs.c +2 -2
index af7a8b0..b04b419 100644
@@ -326,8 +326,8 @@ EXPORT_SYMBOL(ib_create_qp);
 
 static const struct {
 	int			valid;
-	enum ib_qp_attr_mask	req_param[IB_QPT_RAW_ETHERTYPE + 1];
-	enum ib_qp_attr_mask	opt_param[IB_QPT_RAW_ETHERTYPE + 1];
+	enum ib_qp_attr_mask	req_param[IB_QPT_RAW_PACKET + 1];
+	enum ib_qp_attr_mask	opt_param[IB_QPT_RAW_PACKET + 1];
 } qp_state_table[IB_QPS_ERR + 1][IB_QPS_ERR + 1] = {
 	[IB_QPS_RESET] = {
 		[IB_QPS_RESET] = { .valid = 1 },
include/rdma/ib_verbs.h +0 -0
index ecf098a..555165b 100644

include/rdma/ib_verbs.h enum ib_qp_type { · line 569

Quoted 9 lines
include/rdma/ib_verbs.h +2 -1
@@ -562,7 +562,8 @@ enum ib_qp_type {
 	IB_QPT_UC,
 	IB_QPT_UD,
 	IB_QPT_RAW_IPV6,
-	IB_QPT_RAW_ETHERTYPE
+	IB_QPT_RAW_ETHERTYPE = 7,
+	IB_QPT_RAW_PACKET = 8
 };
 
 enum ib_qp_create_flags {

Would it be better to just put the XRC QP type enum in with this patch?

What is the reason for XRC not being upstream?

Steve.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 4C31E3E4.8020508-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org

#11 lore raw

Re: [PATCH V1 2/4] New RAW_PACKET QP type definition

Quoted 5 lines

Would it be better to just put the XRC QP type enum in with this patch? What is the reason for XRC not being upstream?

Steve.

Definitely it would.
Roland, what is the status with XRC? If it have a chance to be accepted into the upstream, may we add it to this patch too? --
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#12 lore raw

Re: [PATCH V1 2/4] New RAW_PACKET QP type definition

In reply to a message not in the archive
Quoted 1 line · Steve Wise

Would it be better to just put the XRC QP type enum in with this patch?

You can take a look on the xrc branch @ Roland's kernel.org git tree, it has a patch with the XRC QP enum, and I believe what this patch is attempting to do, is not introducing a dependency among the xrc and "raw" qp patch sets.

Or.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#13 lore raw

Re: [PATCH V1 1/4] Rename RAW_ETY to RAW_ETHERTYPE

In reply to a message not in the archive

thanks, applied

Signature · 6 lines
Roland Dreier <[email protected]> || For corporate legal information go to:
http://www.cisco.com/web/about/doing_business/legal/cri/index.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): adaiq3q8e7h.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org

#15 lore raw

Re: [PATCH V1 1/4] Rename RAW_ETY to RAW_ETHERTYPE

Quoted 1 line · Roland Dreier

thanks, applied

Hey Roland,

Do you plan to merge the other 3 patches in this series?

https://patchwork.kernel.org/patch/110153/
https://patchwork.kernel.org/patch/110154/
https://patchwork.kernel.org/patch/110155/

Thanks,

Steve.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html