diff mbox

[1/2] ibacm: Incorrect usage of BE byte order of MLID attach/detach_mcast()

Message ID 20171016141945.11276.1068.stgit@phlsvslse11.ph.intel.com (mailing list archive)
State Superseded
Headers show

Commit Message

Michael J. Ruhl Oct. 16, 2017, 2:19 p.m. UTC
From: Michael J. Ruhl <michael.j.ruhl@intel.com>

The MLID value passed to ibv_attach/detach_mcast() must be in host
byte order.

acmp.c incorrectly uses the big endian format when doing a multicast
attach/detach (join). Multicast packets are used to do name resolution
by the libibacmp library.

There are two possible results because of this issue.

If a kernel has commit 8561eae60ff9, the attach will fail with an
EINVAL.  ibacm will log this as a failure during the multicast join.

If a kernel does not have commit 8561eae60ff9, the attach will
complete successfully.  Packets sent to this address will be dropped
because the packet dlid value and the multicast address information
given by the attach will not match.

Update MLID usage to use the correct byte order.

Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
---
 ibacm/prov/acmp/src/acmp.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


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

Comments

Michael J. Ruhl Oct. 16, 2017, 2:24 p.m. UTC | #1
TWlzc2VkIHRoZSB2ZXJzaW9uaW5nIGluZm9ybWF0aW9uLCBwbGVhc2UgaWdub3JlIHRoaXMgcGF0
Y2guDQoNClJlc2VuZGluZyB3aXRoIGNvcnJlY3QgaW5mby4NCg0KTWlrZQ0KDQoNCj4gLS0tLS1P
cmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogbGludXgtcmRtYS1vd25lckB2Z2VyLmtlcm5l
bC5vcmcgW21haWx0bzpsaW51eC1yZG1hLQ0KPiBvd25lckB2Z2VyLmtlcm5lbC5vcmddIE9uIEJl
aGFsZiBPZiBNaWNoYWVsIEouIFJ1aGwNCj4gU2VudDogTW9uZGF5LCBPY3RvYmVyIDE2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GluDQo+IHRoZSBib2R5IG9mIGEg
bWVzc2FnZSB0byBtYWpvcmRvbW9Admdlci5rZXJuZWwub3JnDQo+IE1vcmUgbWFqb3Jkb21vIGlu
Zm8gYXQgIGh0dHA6Ly92Z2VyLmtlcm5lbC5vcmcvbWFqb3Jkb21vLWluZm8uaHRtbA0K
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/ibacm/prov/acmp/src/acmp.c b/ibacm/prov/acmp/src/acmp.c
index aa78416..78d9a29 100644
--- a/ibacm/prov/acmp/src/acmp.c
+++ b/ibacm/prov/acmp/src/acmp.c
@@ -732,7 +732,7 @@  static void acmp_process_join_resp(struct acm_sa_mad *sa_mad)
 			acm_log(0, "ERROR - unable to create ah\n");
 			goto out;
 		}
-		ret = ibv_attach_mcast(ep->qp, &mc_rec->mgid, mc_rec->mlid);
+		ret = ibv_attach_mcast(ep->qp, &dest->mgid, dest->av.dlid);
 		if (ret) {
 			acm_log(0, "ERROR - unable to attach QP to multicast group\n");
 			ibv_destroy_ah(dest->ah);
@@ -1429,7 +1429,7 @@  static void acmp_ep_join(struct acmp_ep *ep)
 
 	if (ep->mc_dest[0].state == ACMP_READY && ep->mc_dest[0].ah) {
 		ibv_detach_mcast(ep->qp, &ep->mc_dest[0].mgid,
-				 be16toh(ep->mc_dest[0].av.dlid));
+				 ep->mc_dest[0].av.dlid);
 		ibv_destroy_ah(ep->mc_dest[0].ah);
 		ep->mc_dest[0].ah = NULL;
 	}