RDMA/cma: fix first byte overwritten for AF_IB
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
@@ -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
A message that is not in the archive (sent off-list or not yet received): 1418744596-25251-1-git-send-email-jinpu.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org
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 isAF_IB, so move the version set inside if condition.Reported-by Fabian Holler <[email protected]>Signed-off-by Jack Wang <[email protected]>--- drivers/infiniband/core/cma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/infiniband/core/cma.c +1
-1@@ -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
A message that is not in the archive (sent off-list or not yet received): 1828884A29C6694DAF28B7E6B8A8237399E2DE69-8oqHQFITsIHTXloPLtfHfbfspsVTdybXVpNB7YpNyf8@public.gmane.org
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 isAF_IB, so move the version set inside if condition.Reported-by Fabian Holler <[email protected]>Signed-off-by Jack Wang <[email protected]>--- drivers/infiniband/core/cma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/infiniband/core/cma.c +1
-1@@ -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
A message that is not in the archive (sent off-list or not yet received): CAMGffEn9cxNqv48Vyv_TSB5yO7CgGLDHGjVJBRTihPw0v=EJhw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
PiBJIGNoZWNrZWQgbmZpbmlCYW5kIFRNIEFyY2hpdGVjdHVyZSBSZWxlYXNlIDEuMi4xIFZPTFVN RSAxIC0gR0VORVJBTA0KPiBT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c2luZyBBRl9JTkVULiAgSW4gdGhpcyBleGFtcGxlLCB0aGUgY2xpZW50 IHNpZGUgaXMgc3RpbGwgcmVxdWlyZWQgdG8gZm9ybWF0IHRoZSBwcml2YXRlIGRhdGEgYXMgaW5k aWNhdGVkIGluIHRoZSBBbm5leC4gIEkuZS4gdGhlIG9yaWdpbmFsIElQIGFkZHJlc3NpbmcgdGhh dCB3YXMgdXNlZCBzaG91bGQgYXBwZWFyIGFzIHBhcnQgb2YgdGhlIHByaXZhdGUgZGF0YS4NCg0K VGhlIHBvcnQgc3BhY2UgKHdoaWNoIG1hcHMgdG8gdGhlIHNlcnZpY2UgSUQpIG5lZWRzIHRvIGJl 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
A message that is not in the archive (sent off-list or not yet received): 1828884A29C6694DAF28B7E6B8A8237399E30341-8oqHQFITsIHTXloPLtfHfbfspsVTdybXVpNB7YpNyf8@public.gmane.org
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 usingAF_IB. This prevents the kernel from needing to perform a duplicate address resolution. The listening side of the connection may still be usingAF_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
A message that is not in the archive (sent off-list or not yet received): CAMGffEktJGzk4FyLh85UAu2Y1998OZJ_p8=-6rzsQ28-KwEDzA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
PiBTbyBpdCdzIHBvc3NpYmxlIG9uIHNlcnZlciBzaWRlIGxpc3RlbiB1c2luZyBBRl9JTkVULCBi dXQgY2xpZW50DQo+IHJkbWFfcmVzb2x2ZV9hZGRyL3JkbWFfcmVzb2x2ZV9yb3V0ZS9yZG1hX2Nv bm5lY3Qgd2l0aCBBRl9JQj8NCg0KWWVzDQo=
--
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
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 isAF_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
A message that is not in the archive (sent off-list or not yet received): 54915D84.5000405-VPRAkNaXOzVWk0Htik3J/[email protected]
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 isAF_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