Skip to contentSkip to conversation

RDMA/cma: fix first byte overwritten for AF_IB

PATCH In review Jack Wang 3 participants 8 messages Dec 16, 2014 – Dec 18, 2014 6 messages not in the archive InfiniBand

lore
Share & tools
lore

Jack Wang

author
#0 lore raw

PATCH 1/1 RDMA/cma: fix first byte overwritten for AF_IB

If user attach private data for AF_IB, the first byte will be overwritten, because we always set the cma version no matter family is AF_IB, so move the version set inside if condition.

---
 drivers/infiniband/core/cma.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/core/cma.c +2 -1
index d570030..22a22e2 100644
@@ -2618,10 +2618,10 @@ static int cma_format_hdr(void *hdr, struct rdma_id_private *id_priv)
 	struct cma_hdr *cma_hdr;
 
 	cma_hdr = hdr;
-	cma_hdr->cma_version = CMA_VERSION;
 	if (cma_family(id_priv) == AF_INET) {
 		struct sockaddr_in *src4, *dst4;
 
+		cma_hdr->cma_version = CMA_VERSION;
 		src4 = (struct sockaddr_in *) cma_src_addr(id_priv);
 		dst4 = (struct sockaddr_in *) cma_dst_addr(id_priv);
 
@@ -2632,6 +2632,7 @@ static int cma_format_hdr(void *hdr, struct rdma_id_private *id_priv)
 	} else if (cma_family(id_priv) == AF_INET6) {
 		struct sockaddr_in6 *src6, *dst6;
 
+		cma_hdr->cma_version = CMA_VERSION;
 		src6 = (struct sockaddr_in6 *) cma_src_addr(id_priv);
 		dst6 = (struct sockaddr_in6 *) cma_dst_addr(id_priv);
 
Signature · 6 lines
1.9.1

--
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
#2 lore raw
In reply to a message not in the archive
Quoted 28 lines

If user attach private data for AF_IB, the first byte will be overwritten, because we always set the cma version no matter family is AF_IB, so move the version set inside if condition.

---
 drivers/infiniband/core/cma.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/core/cma.c +1 -1
index d570030..22a22e2 100644
@@ -2618,10 +2618,10 @@ static int cma_format_hdr(void *hdr, struct
 rdma_id_private *id_priv)
 	struct cma_hdr *cma_hdr;
 
 	cma_hdr = hdr;
-	cma_hdr->cma_version = CMA_VERSION;
 	if (cma_family(id_priv) == AF_INET) {
 		struct sockaddr_in *src4, *dst4;
 
+		cma_hdr->cma_version = CMA_VERSION;
 		src4 = (struct sockaddr_in *) cma_src_addr(id_priv);
 		dst4 = (struct sockaddr_in *) cma_dst_addr(id_priv);

drivers/infiniband/core/cma.c static int cma_format_hdr(void *hdr, struct · line 2638

Quoted 7 lines
drivers/infiniband/core/cma.c +1 -0
@@ -2632,6 +2632,7 @@ static int cma_format_hdr(void *hdr, struct
 rdma_id_private *id_priv)
 	} else if (cma_family(id_priv) == AF_INET6) {
 		struct sockaddr_in6 *src6, *dst6;
 
+		cma_hdr->cma_version = CMA_VERSION;
 		src6 = (struct sockaddr_in6 *) cma_src_addr(id_priv);
 		dst6 = (struct sockaddr_in6 *) cma_dst_addr(id_priv);

I don't think this is sufficient. The RDMA CM private data header is defined by the IB spec. If the service ID starts with the prefix 0x0000000001, it's reasonable to assume that the header is part of the private data. The receive side should probably even check the version and discard any unknown values.

- Sean
--
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

author
#4 lore raw
In reply to a message not in the archive

Hi Sean,

Thanks for looking into this.

I checked nfiniBand TM Architecture Release 1.2.1 VOLUME 1 - GENERAL SPECIFICATIONS, for RDMA IP CM service,
the private data for CM REQ is defined in:
Table 532 IP Addressing CM REQ Message Private Data Format So you mean even for RDMA IB, the private data format is also required, could you point me a little more detail?

Quoted 39 lines · Sean
Quoted 28 lines

If user attach private data for AF_IB, the first byte will be overwritten, because we always set the cma version no matter family is AF_IB, so move the version set inside if condition.

---
 drivers/infiniband/core/cma.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/core/cma.c +1 -1
index d570030..22a22e2 100644
@@ -2618,10 +2618,10 @@ static int cma_format_hdr(void *hdr, struct
 rdma_id_private *id_priv)
      struct cma_hdr *cma_hdr;
 
      cma_hdr = hdr;
-     cma_hdr->cma_version = CMA_VERSION;
      if (cma_family(id_priv) == AF_INET) {
              struct sockaddr_in *src4, *dst4;
 
+             cma_hdr->cma_version = CMA_VERSION;
              src4 = (struct sockaddr_in *) cma_src_addr(id_priv);
              dst4 = (struct sockaddr_in *) cma_dst_addr(id_priv);

drivers/infiniband/core/cma.c static int cma_format_hdr(void *hdr, struct · line 2638

Quoted 7 lines
drivers/infiniband/core/cma.c +1 -0
@@ -2632,6 +2632,7 @@ static int cma_format_hdr(void *hdr, struct
 rdma_id_private *id_priv)
      } else if (cma_family(id_priv) == AF_INET6) {
              struct sockaddr_in6 *src6, *dst6;
 
+             cma_hdr->cma_version = CMA_VERSION;
              src6 = (struct sockaddr_in6 *) cma_src_addr(id_priv);
              dst6 = (struct sockaddr_in6 *) cma_dst_addr(id_priv);

I don't think this is sufficient. The RDMA CM private data header is defined by the IB spec. If the service ID starts with the prefix 0x0000000001, it's reasonable to assume that the header is part of the private data. The receive side should probably even check the version and discard any unknown values.

- Sean

Signature · 23 lines
Mit freundlichen Grüßen,
Best Regards,

Jack Wang

Linux Kernel Developer Storage
ProfitBricks GmbH  The IaaS-Company.

ProfitBricks GmbH
Greifswalder Str. 207
D - 10405 Berlin
Tel: +49 30 5770083-42
Fax: +49 30 5770085-98
Email: [email protected]
URL: http://www.profitbricks.de

Sitz der Gesellschaft: Berlin.
Registergericht: Amtsgericht Charlottenburg, HRB 125506 B.
Geschäftsführer: Andreas Gauger, Achim Weiss.
--
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
#11 lore raw
In reply to a message not in the archive
Quoted 1 line · Jack Wang

If user attach private data for AF_IB,

Just out of curiosity, can you share what was the motivation for you to use AF_IB?

Or.

Quoted 3 lines

the first byte will
be overwritten, because we always set the cma version no matter family is AF_IB, so move the version set inside if condition.

--
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

author
#13 lore raw
In reply to a message not in the archive

Hi Or,

We have some trouble in the past about IPoIB support about neighbour discovery, AF_IB doesn't relay on IPoIB, so
we think have another option maybe give us more safe in some cases.

Quoted 17 lines · Or Gerlitz
Quoted 2 lines · Jack Wang

If user attach private data for AF_IB,

Just out of curiosity, can you share what was the motivation for you to use AF_IB?

Or.

Quoted 3 lines

the first byte will
be overwritten, because we always set the cma version no matter family is AF_IB, so move the version set inside if condition.

Signature · 23 lines
Mit freundlichen Grüßen,
Best Regards,

Jack Wang

Linux Kernel Developer Storage
ProfitBricks GmbH  The IaaS-Company.

ProfitBricks GmbH
Greifswalder Str. 207
D - 10405 Berlin
Tel: +49 30 5770083-42
Fax: +49 30 5770085-98
Email: [email protected]
URL: http://www.profitbricks.de

Sitz der Gesellschaft: Berlin.
Registergericht: Amtsgericht Charlottenburg, HRB 125506 B.
Geschäftsführer: Andreas Gauger, Achim Weiss.
--
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
#6 lore raw
In reply to a message not in the archive

PiBJIGNoZWNrZWQgbmZpbmlCYW5kIFRNIEFyY2hpdGVjdHVyZSBSZWxlYXNlIDEuMi4xIFZPTFVN RSAxIC0gR0VORVJBTA0KPiBTUEVDSUZJQ0FUSU9OUywgZm9yIFJETUEgSVAgQ00gc2VydmljZSwN Cj4gdGhlIHByaXZhdGUgZGF0YSBmb3IgQ00gUkVRIGlzIGRlZmluZWQgaW46DQo+IFRhYmxlIDUz MiBJUCBBZGRyZXNzaW5nIENNIFJFUSBNZXNzYWdlIFByaXZhdGUgRGF0YSBGb3JtYXQNCj4gU28g eW91IG1lYW4gZXZlbiBmb3IgUkRNQSBJQiwgdGhlIHByaXZhdGUgZGF0YSBmb3JtYXQgaXMgYWxz bw0KPiByZXF1aXJlZ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gc3BhY2UgKHdoaWNoIG1hcHMgdG8gdGhlIHNlcnZpY2UgSUQpIG5lZWRzIHRvIGJl IGluY2x1ZGVkIGFzIHBhcnQgb2YgdGhlIGNoZWNrIHRoYXQgZGV0ZXJtaW5lcyB0aGUgZm9ybWF0 IG9mIHRoZSBwcml2YXRlIGRhdGEsIGFuZCBub3Qgc2ltcGx5IHRoZSBhZGRyZXNzIGZhbWlseS4N Cg0KLSBTZWFuDQo=
--
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

author
#8 lore raw
In reply to a message not in the archive

Hi Sean,

Quoted 10 lines · Sean
Quoted 6 lines

I checked nfiniBand TM Architecture Release 1.2.1 VOLUME 1 - GENERAL SPECIFICATIONS, for RDMA IP CM service,
the private data for CM REQ is defined in:
Table 532 IP Addressing CM REQ Message Private Data Format So you mean even for RDMA IB, the private data format is also required, could you point me a little more detail?

The RDMA IP CM service Annex in the IB spec defines a range of service IDs that apply to the RDMA CM. If a service ID falls into this range, the private data format should also match.

For example, an app could start with AF_INET, use an alternate method to resolve the IP address to a GID (such as a user space daemon), then provide the mapped address directly to the kernel using AF_IB. This prevents the kernel from needing to perform a duplicate address resolution. The listening side of the connection may still be using AF_INET. In this example, the client side is still required to format the private data as indicated in the Annex. I.e. the original IP addressing that was used should appear as part of the private data.

So it's possible on server side listen using AF_INET, but client rdma_resolve_addr/rdma_resolve_route/rdma_connect with AF_IB?

Jack

Quoted 7 lines

The port space (which maps to the service ID) needs to be included as part of the check that determines the format of the private data, and not simply the address family.

- Sean

Signature · 23 lines
Mit freundlichen Grüßen,
Best Regards,

Jack Wang

Linux Kernel Developer Storage
ProfitBricks GmbH  The IaaS-Company.

ProfitBricks GmbH
Greifswalder Str. 207
D - 10405 Berlin
Tel: +49 30 5770083-42
Fax: +49 30 5770085-98
Email: [email protected]
URL: http://www.profitbricks.de

Sitz der Gesellschaft: Berlin.
Registergericht: Amtsgericht Charlottenburg, HRB 125506 B.
Geschäftsführer: Andreas Gauger, Achim Weiss.
--
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