Skip to contentSkip to conversation

srp_daemon fixes

PATCH Superseded Nicolas Morey-Chaisemartin 4 participants 12 messages Dec 13, 2017 – Dec 15, 2017 7 messages not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

v2 cover srp_daemon fixes

This patch series fixes two issues of srp_daemon which occur when the master SM switches. Both causes a failure to register to SM traps.

Changes since v1:
Patch#1
- Add Fixes tag to commit log
Patch#2
- Add comment on return codes of poll_cq_once
- Fix poll_cq behaviour when poll_cq_once returns an error

Nicolas Morey-Chaisemartin (2):
srp_daemon: handle SM lid change
srp_daemon: fix CQ handling

 srp_daemon/srp_daemon.c       | 10 ++++---
 srp_daemon/srp_daemon.h       |  2 +-
 srp_daemon/srp_handle_traps.c | 65 +++++++++++++++++++++++++++++++++----------
 3 files changed, 58 insertions(+), 19 deletions(-)
Signature · 6 lines
2.15.1.272.g8e603414b

--
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): 001cdcfd-8ace-261f-ab86-a09ae3582dd8-IBi9RG/[email protected]

#2 lore raw

PATCH v2 1/2 srp_daemon: handle SM lid change

When srp_daemon was running and the master SM host changes,
srp_daemon output these errors at every scan:
srp_daemon[25394]: No response to inform info registration srp_daemon[25394]: Fail to register to traps, maybe there is no opensm
running on fabric or IB port is down

This was introduced by commit 4952e5f Fix a memory leak.
A side effect of this patch was that create_ah was only called when the
port lid changes. Which meant register_to_traps used an older, obsolete, version of sm_lid and failed to connect to it.

This patch fixes this behaviour by checking for both local lid changes and
SM lid changes, and calling create_ah on any of these events.

Fixes 4952e5f7 (Fix a memory leak)
Cc [email protected] # v14, v15, v16
---
 srp_daemon/srp_daemon.c       | 10 ++++++----
 srp_daemon/srp_daemon.h       |  2 +-
 srp_daemon/srp_handle_traps.c | 14 +++++++++++---
 3 files changed, 18 insertions(+), 8 deletions(-)
srp_daemon/srp_daemon.c +6 -4
index 2465ccd9..36df5c3b 100644
@@ -1103,7 +1103,7 @@ static int get_shared_pkeys(struct resources *res,
 	int i, num_pkeys = 0;
 	uint16_t pkey;
 	uint16_t local_port_lid = get_port_lid(res->ud_res->ib_ctx,
-					       config->port_num);
+					       config->port_num, NULL);
 
 	in_mad_buf = malloc(sizeof(struct ib_user_mad) +
 			    node_table_response_size);
@@ -2092,7 +2092,7 @@ int main(int argc, char *argv[])
 {
 	int			ret;
 	struct resources       *res;
-	uint16_t 		lid;
+	uint16_t 		lid, sm_lid;
 	uint16_t 		pkey;
 	union umad_gid 		gid;
 	struct target_details  *target;
@@ -2196,8 +2196,10 @@ catas_start:
 
 			pr_debug("Starting a recalculation\n");
 			port_lid = get_port_lid(res->ud_res->ib_ctx,
-					   config->port_num);
-			if (port_lid != res->ud_res->port_attr.lid) {
+						config->port_num, &sm_lid);
+			if (port_lid != res->ud_res->port_attr.lid ||
+				sm_lid != res->ud_res->port_attr.sm_lid) {
+
 				if (res->ud_res->ah) {
 					ibv_destroy_ah(res->ud_res->ah);
 					res->ud_res->ah = NULL;
srp_daemon/srp_daemon.h +1 -1
index 5d268ed3..864b3d42 100644
@@ -299,7 +299,7 @@ void *run_thread_listen_to_events(void *res_in);
 int get_node(struct umad_resources *umad_res, uint16_t dlid, uint64_t *guid);
 int create_trap_resources(struct ud_resources *ud_res);
 int register_to_traps(struct resources *res, int subscribe);
-uint16_t get_port_lid(struct ibv_context *ib_ctx, int port_num);
+uint16_t get_port_lid(struct ibv_context *ib_ctx, int port_num, uint16_t *sm_lid);
 int create_ah(struct ud_resources *ud_res);
 void push_gid_to_list(struct sync_resources *res, union umad_gid *gid,
 		      uint16_t pkey);
srp_daemon/srp_handle_traps.c +11 -3
index 6d94634e..25f2b9ab 100644
@@ -340,12 +340,20 @@ int ud_resources_create(struct ud_resources *res)
 	return 0;
 }
 
-uint16_t get_port_lid(struct ibv_context *ib_ctx, int port_num)
+uint16_t get_port_lid(struct ibv_context *ib_ctx, int port_num, uint16_t *sm_lid)
 {
 	struct ibv_port_attr port_attr;
+	int ret;
+
+	ret = ibv_query_port(ib_ctx, port_num, &port_attr);
 
-	return ibv_query_port(ib_ctx, port_num, &port_attr) == 0 ?
-		port_attr.lid : 0;
+	if (!ret) {
+		if (sm_lid)
+			*sm_lid = port_attr.sm_lid;
+		return port_attr.lid;
+	}
+
+	return 0;
 }
 
 int create_ah(struct ud_resources *ud_res)
Signature · 7 lines
2.15.1.272.g8e603414b


--
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): be797b2f-0317-f9ac-d0ec-5284632790b9-IBi9RG/[email protected]

#4 lore raw

Re: [PATCHv2 rdma-core 1/2] srp_daemon: handle SM lid change

T24gV2VkLCAyMDE3LTEyLTEzIGF0IDEzOjMxICswMTAwLCBOaWNvbGFzIE1vcmV5LUNoYWlzZW1h cnRpbiB3cm90ZToNCj4gV2hlbiBzcnBfZGFlbW9uIHdhcyBydW5uaW5nIGFuZCB0aGUgbWFzdGVy IFNNIGhvc3QgY2hhbmdlcywNCj4gIHNycF9kYWVtb24gb3V0cHV0IHRoZXNlIGVycm9ycyBhdCBl dmVyeSBzY2FuOg0KPiBzcnBfZGFlbW9uWzI1Mzk0XTogTm8gcmVzcG9uc2UgdG8gaW5mb3JtIGlu Zm8gcmVnaXN0cmF0aW9uDQo+IHNycF9kYWVtb25bMjUzOTRdOiBGYWlsIHRvIHJlZ2lzdGVyIHRv IHRyYXBzLCBtYXliZSB0aGVyZSBpcyBubyBvcGVuc20NCj4gIHJ1bm5pbmcgb24gZmFicmljIG9y IElCIHBvcnQgaXMgZG93bg0KPiANCj4gVGhpcyB3YXMgaW50cm9kdWNlZCBieSBjb21taXQgNDk1 MmU1ZiBGaXggYSBtZW1vcnkgbGVhay4NCj4gQSBzaWRlIGVmZmVjdCBvZiB0aGlzIHBhdGNoIHdh cyB0aGF0IGNyZWF0ZV9haCB3YXMgb25seSBjYWxsZWQgd2hlbiB0aGUNCj4gIHBvcnQgbGlkIGNo YW5nZXMuIFdoaWNoIG1lYW50IHJlZ2lzdGVyX3RvX3RyYXBzIHVzZWQgYW4gb2xkZXIsIG9ic29s ZXRlLA0KPiAgdmVyc2lvbiBvZiBzbV9saWQgYW5kIGZhaWxlZCB0byBjb25uZWN0IHRvIGl0Lg0K PiANCj4gVGhpcyBwYXRjaCBmaXhlcyB0aGlzIGJlaGF2aW91ciBieSBjaGVja2luZyBmb3IgYm90 aCBsb2NhbCBsaWQgY2hhbmdlcyBhbmQNCj4gIFNNIGxpZCBjaGFuZ2VzLCBhbmQgY2FsbGluZyBj cmVhdGVfYWggb24gYW55IG9mIHRoZXNlIGV2ZW50cy4NCg0KUmVwb3J0ZWQtYnk6IEJhcnQgVmFu IEFzc2NoZSA8YmFydC52YW5hc3NjaGVAd2RjLmNvbT4NCg0KDQo=
--
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): [email protected]

#6 lore raw

Re: [PATCHv2 rdma-core 1/2] srp_daemon: handle SM lid change

T24gVGh1LCAyMDE3LTEyLTE0IGF0IDE5OjEzICswMDAwLCBCYXJ0IFZhbiBBc3NjaGUgd3JvdGU6 DQo+IE9uIFdlZCwgMjAxNy0xMi0xMyBhdCAxMzozMSArMDEwMCwgTmljb2xhcyBNb3JleS1DaGFp c2VtYXJ0aW4gd3JvdGU6DQo+ID4gVGhpcyBwYXRjaCBmaXhlcyB0aGlzIGJlaGF2aW91ciBieSBj aGVja2luZyBmb3IgYm90aCBsb2NhbCBsaWQgY2hhbmdlcyBhbmQNCj4gPiBTTSBsaWQgY2hhbmdl cywgYW5kIGNhbGxpbmcgY3JlYXRlX2FoIG9uIGFueSBvZiB0aGVzZSBldmVudHMuDQo+IA0KPiBS ZXBvcnRlZC1ieTogQmFydCBWYW4gQXNzY2hlIDxiYXJ0LnZhbmFzc2NoZUB3ZGMuY29tPg0KICBe Xl5eXl5eXl5eXg0KDQpUaGlzIHNob3VsZCBoYXZlIGJlZW46IFJldmlld2VkLWJ5Lg0KDQpCYXJ0 Lg==
--
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

#7 lore raw

Re: [PATCHv2 rdma-core 1/2] srp_daemon: handle SM lid change

In reply to a message not in the archive
Quoted 11 lines · Nicolas Morey-Chaisemartin

When srp_daemon was running and the master SM host changes,
srp_daemon output these errors at every scan:
srp_daemon[25394]: No response to inform info registration srp_daemon[25394]: Fail to register to traps, maybe there is no opensm
running on fabric or IB port is down

This was introduced by commit 4952e5f Fix a memory leak.
A side effect of this patch was that create_ah was only called when the
port lid changes. Which meant register_to_traps used an older, obsolete, version of sm_lid and failed to connect to it.

Quoted 4 lines

This patch fixes this behaviour by checking for both local lid changes and
SM lid changes, and calling create_ah on any of these events.

Fixes 4952e5f7 (Fix a memory leak)

Close. You are going to want 12 digits of the SHA, followed by the actual patch subject, the full thing in ("......").

I tried to look at the commit to provide you the actual example but get the following. Make sure the SHA you are using is correct.

$ git show 4952e5f7
fatal: ambiguous argument '4952e5f7': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

-Denny
--
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): a4b3d5e1-f611-9305-1ed2-d4a51ebe4611-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#9 lore raw

Re: [PATCHv2 rdma-core 1/2] srp_daemon: handle SM lid change

Le 15/12/2017 à 12:40, Dennis Dalessandro a écrit :

Quoted 17 lines · Nicolas Morey-Chaisemartin
Quoted 11 lines

When srp_daemon was running and the master SM host changes, srp_daemon output these errors at every scan:
srp_daemon[25394]: No response to inform info registration srp_daemon[25394]: Fail to register to traps, maybe there is no opensm running on fabric or IB port is down

This was introduced by commit 4952e5f Fix a memory leak.
A side effect of this patch was that create_ah was only called when the port lid changes. Which meant register_to_traps used an older, obsolete, version of sm_lid and failed to connect to it.

Quoted 4 lines

This patch fixes this behaviour by checking for both local lid changes and SM lid changes, and calling create_ah on any of these events.

Fixes 4952e5f7 (Fix a memory leak)
Quoted 8 lines

Close. You are going to want 12 digits of the SHA, followed by the actual patch subject, the full thing in ("......").

I tried to look at the commit to provide you the actual example but get the following. Make sure the SHA you are using is correct.

$ git show 4952e5f7
fatal: ambiguous argument '4952e5f7': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

Weird it works for me...

$ git show 4952e5f7
commit 4952e5f7df0c93d6f3972975106c5e06623a301d
Author: Roi Dayan <roid-VPRAkNaXOzVWk0Htik3J/[email protected]>
Date:   Thu Mar 21 17:38:11 2013 +0200

    Fix a memory leak

I used this command  to generate the line

$ git  log -n1 --pretty='%h (%s)' 4952e5f7df0c93d6f3972975106c5e06623a301d
4952e5f7 (Fix a memory leak)

Isn't the abbreviated hash supposed to be enough ?

Nicolas
--
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): 5c12ee61-22f3-239d-8fbb-59c381b8ce13-IBi9RG/[email protected]

#11 lore raw

Re: [PATCHv2 rdma-core 1/2] srp_daemon: handle SM lid change

T24gRnJpLCAyMDE3LTEyLTE1IGF0IDEzOjQxICswMTAwLCBOaWNvbGFzIE1vcmV5LUNoYWlzZW1h cnRpbiB3cm90ZToNCj4gSXNuJ3QgdGhlIGFiYnJldmlhdGVkIGhhc2ggc3VwcG9zZWQgdG8gYmUg ZW5vdWdoID8NCg0KTW9zdCBrZXJuZWwgZGV2ZWxvcGVycyB1c2UgdGhlIGZvbGxvd2luZyBpbiB0 aGVpciB+Ly5naXRjb25maWc6DQoNCltjb3JlXQ0KICAgICAgICBhYmJyZXYgPSAxMg0KDQpTZWUg YWxzbyBodHRwczovL3B1YmxpYy1pbmJveC5vcmcvZ2l0L0NBKzU1YUZ5MF9wd3RGT1lTMVRtbnhp cHc5WmtSTkNRSG1vWXllZ08wMHBqTWlaUWZiZ0BtYWlsLmdtYWlsLmNvbS8uDQoNCkJhcnQuDQoN Cg==
--
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: [PATCHv2 rdma-core 1/2] srp_daemon: handle SM lid change

In reply to a message not in the archive
Quoted 5 lines · Nicolas Morey-Chaisemartin

I used this command  to generate the line

$ git  log -n1 --pretty='%h (%s)' 4952e5f7df0c93d6f3972975106c5e06623a301d
4952e5f7 (Fix a memory leak)

Isn't the abbreviated hash supposed to be enough ?

You can put this alias in your .gitconfig to generate teh correct format:

[alias]

        fixes = log --abbrev=12 -1 --format='Fixes: %h (\"%s\")'

And your git is older so you need to add

[core]

	abbrev = 12

To your config too.

The 8 character abbrev is known to have collisions already for linux-kernel (but probably not in rdma-core)

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

PATCH v2 2/2 srp_daemon: fix CQ handling

In reply to a message not in the archive

SM traps are polled through poll_cq which waited for a CQ event before polling the CQ itself.
However it may happens that multiple completions are attached to a single event. As stated by the ibv_get_cq_event man page, it is required to poll the the CQ to get those completions after the call to ibv_req_notify_cq.

As completions need to be handled one by one in an outer function, start by polling the CQ and return the completion (if any) before waiting for the next completion event.
This will allow emptying all pending completions, through multiple calls to poll_cq, before waiting for a new event.

The buggy use case seems to appear when the master SM is switched multiple times between two nodes. As the number of ping-pong between the SMs increases, the number of traps sent to notify that the SM just became master increases too. This causes burst of completions linked to a single event. Note that the race condition is also possible in other scenario.

---
 srp_daemon/srp_handle_traps.c | 51 +++++++++++++++++++++++++++++++++----------
 1 file changed, 40 insertions(+), 11 deletions(-)
srp_daemon/srp_handle_traps.c +40 -11
index 25f2b9ab..77a47db3 100644
@@ -496,6 +496,34 @@ static int stop_threads(struct sync_resources *sync_res)
 	return result;
 }
 
+/*****************************************************************************
+* Function: poll_cq_once
+* Poll a CQ once.
+* Returns the number of completion polled (0 or 1).
+* Returns a negative value on error.
+*****************************************************************************/
+static int poll_cq_once(struct sync_resources *sync_res, struct ibv_cq *cq,
+			struct ibv_wc *wc)
+{
+	int ret;
+
+	ret = ibv_poll_cq(cq, 1, wc);
+	if (ret < 0) {
+		pr_err("poll CQ failed\n");
+		return ret;
+	}
+
+	if (ret > 0 && wc->status != IBV_WC_SUCCESS) {
+		if (!stop_threads(sync_res))
+			pr_err("got bad completion with status: 0x%x\n",
+			       wc->status);
+		return -ret;
+	}
+
+	return ret;
+}
+
+
 static int poll_cq(struct sync_resources *sync_res, struct ibv_cq *cq,
 		   struct ibv_wc *wc, struct ibv_comp_channel *channel)
 {
@@ -504,6 +532,16 @@ static int poll_cq(struct sync_resources *sync_res, struct ibv_cq *cq,
 	void          *ev_ctx;
 
 	if (channel) {
+		/* There may be extra completions that
+		 * were associated to the previous event.
+		 * Only poll for the first one. If there are more than one,
+		 * they will be handled by later call to poll_cq */
+		ret = poll_cq_once(sync_res, cq, wc);
+		/* return directly if there was an error or
+		 * 1 completion polled */
+		if (ret)
+			return ret;
+
 		if (ibv_get_cq_event(channel, &ev_cq, &ev_ctx)) {
 			pr_err("Failed to get cq_event\n");
 			return -1;
@@ -524,18 +562,9 @@ static int poll_cq(struct sync_resources *sync_res, struct ibv_cq *cq,
 	}
 
 	do {
-		ret = ibv_poll_cq(cq, 1, wc);
-		if (ret < 0) {
-			pr_err("poll CQ failed\n");
+		ret = poll_cq_once(sync_res, cq, wc);
+		if (ret < 0)
 			return ret;
-		}
-
-		if (ret > 0 && wc->status != IBV_WC_SUCCESS) {
-			if (!stop_threads(sync_res))
-				pr_err("got bad completion with status: 0x%x\n",
-				       wc->status);
-			return -ret;
-		}
 
 		if (ret == 0 && channel) {
 			pr_err("Weird poll returned no cqe after CQ event\n");
Signature · 6 lines
2.15.1.272.g8e603414b

--
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): 7ed5d5af-0f53-c15f-e7f2-516f6786113f-IBi9RG/[email protected]

#15 lore raw

Re: [PATCHv2 rdma-core 2/2] srp_daemon: fix CQ handling

T24gV2VkLCAyMDE3LTEyLTEzIGF0IDEzOjMyICswMTAwLCBOaWNvbGFzIE1vcmV5LUNoYWlzZW1h cnRpbiB3cm90ZToNCj4gU00gdHJhcHMgYXJlIHBvbGxlZCB0aHJvdWdoIHBvbGxfY3Egd2hpY2gg d2FpdGVkIGZvciBhIENRIGV2ZW50DQo+IGJlZm9yZSBwb2xsaW5nIHRoZSBDUSBpdHNlbGYuDQo+ IEhvd2V2ZXIgaXQgbWF5IGhhcHBlbnMgdGhhdCBtdWx0aXBsZSBjb21wbGV0aW9ucyBhcmUgYXR0 YWNoZWQNCj4gdG8gYSBzaW5nbGUgZXZlbnQuIEFzIHN0YXRlZCBieSB0aGUgaWJ2X2dldF9jcV9l dmVudCBtYW4gcGFnZSwNCj4gaXQgaXMgcmVxdWlyZWQgdG8gcG9sbCB0aGUgdGhlIENRIHRvIGdl dCB0aG9zZSBjb21wbGV0aW9ucw0KPiBhZnRlciB0aGUgY2FsbCB0byBpYnZfcmVxX25vdGlmeV9j cS4NCj4gDQo+IEFzIGNvbXBsZXRpb25zIG5lZWQgdG8gYmUgaGFuZGxlZCBvbmUgYnkgb25lIGlu IGFuIG91dGVyIGZ1bmN0aW9uLA0KPiBzdGFydCBieSBwb2xsaW5nIHRoZSBDUSBhbmQgcmV0dXJu IHRoZSBjb21wbGV0aW9uIChpZiBhbnkpIGJlZm9yZQ0KPiB3YWl0aW5nIGZvciB0aGUgbmV4dCBj b21wbGV0aW9uIGV2ZW50Lg0KPiBUaGlzIHdpbGwgYWxsb3cgZW1wdHlpbmcgYWxsIHBlbmRpbmcg Y29tcGxldGlvbnMsIHRocm91Z2ggbXVsdGlwbGUgY2FsbHMNCj4gdG8gcG9sbF9jcSwgIGJlZm9y ZSB3YWl0aW5nIGZvciBhIG5ldyBldmVudC4NCj4gDQo+IFRoZSBidWdneSB1c2UgY2FzZSBzZWVt cyB0byBhcHBlYXIgd2hlbiB0aGUgbWFzdGVyIFNNIGlzIHN3aXRjaGVkIG11bHRpcGxlDQo+IHRp bWVzIGJldHdlZW4gdHdvIG5vZGVzLiBBcyB0aGUgbnVtYmVyIG9mIHBpbmctcG9uZyBiZXR3ZWVu IHRoZSBTTXMgaW5jcmVhc2VzLA0KPiB0aGUgbnVtYmVyIG9mIHRyYXBzIHNlbnQgdG8gbm90aWZ5 IHRoYXQgdGhlIFNNIGp1c3QgYmVjYW1lIG1hc3RlciBpbmNyZWFzZXMNCj4gdG9vLiBUaGlzIGNh dXNlcyBidXJzdCBvZiBjb21wbGV0aW9ucyBsaW5rZWQgdG8gYSBzaW5nbGUgZXZlbnQuDQo+IE5v dGUgdGhhdCB0aGUgcmFjZSBjb25kaXRpb24gaXMgYWxzbyBwb3NzaWJsZSBpbiBvdGhlciBzY2Vu YXJpby4NCg0KUmV2aWV3ZWQtYnk6IEJhcnQgVmFuIEFzc2NoZSA8YmFydC52YW5hc3NjaGVAd2Rj LmNvbT4NCg0KDQoNCg==
--
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

#16 lore raw

PATCH v3 1/2 srp_daemon: handle SM lid change

In reply to a message not in the archive

When srp_daemon was running and the master SM host changes,
srp_daemon output these errors at every scan:
srp_daemon[25394]: No response to inform info registration srp_daemon[25394]: Fail to register to traps, maybe there is no opensm
running on fabric or IB port is down

This was introduced by commit 4952e5f Fix a memory leak.
A side effect of this patch was that create_ah was only called when the
port lid changes. Which meant register_to_traps used an older, obsolete, version of sm_lid and failed to connect to it.

This patch fixes this behaviour by checking for both local lid changes and
SM lid changes, and calling create_ah on any of these events.

Fixes 4952e5f7df0c (Fix a memory leak)
Cc [email protected] # v14, v15, v16

---

Since v2, expand abbrev sha1 of Fixes:... to 12B

 srp_daemon/srp_daemon.c       | 10 ++++++----
 srp_daemon/srp_daemon.h       |  2 +-
 srp_daemon/srp_handle_traps.c | 14 +++++++++++---
 3 files changed, 18 insertions(+), 8 deletions(-)
srp_daemon/srp_daemon.c +6 -4
index cec36db2e0f1..38501886110a 100644
@@ -1103,7 +1103,7 @@ static int get_shared_pkeys(struct resources *res,
 	int i, num_pkeys = 0;
 	uint16_t pkey;
 	uint16_t local_port_lid = get_port_lid(res->ud_res->ib_ctx,
-					       config->port_num);
+					       config->port_num, NULL);
 
 	in_mad_buf = malloc(sizeof(struct ib_user_mad) +
 			    node_table_response_size);
@@ -2092,7 +2092,7 @@ int main(int argc, char *argv[])
 {
 	int			ret;
 	struct resources       *res;
-	uint16_t 		lid;
+	uint16_t 		lid, sm_lid;
 	uint16_t 		pkey;
 	union umad_gid 		gid;
 	struct target_details  *target;
@@ -2196,8 +2196,10 @@ catas_start:
 
 			pr_debug("Starting a recalculation\n");
 			port_lid = get_port_lid(res->ud_res->ib_ctx,
-					   config->port_num);
-			if (port_lid != res->ud_res->port_attr.lid) {
+						config->port_num, &sm_lid);
+			if (port_lid != res->ud_res->port_attr.lid ||
+				sm_lid != res->ud_res->port_attr.sm_lid) {
+
 				if (res->ud_res->ah) {
 					ibv_destroy_ah(res->ud_res->ah);
 					res->ud_res->ah = NULL;
srp_daemon/srp_daemon.h +1 -1
index 5d268ed395e1..864b3d42fb46 100644
@@ -299,7 +299,7 @@ void *run_thread_listen_to_events(void *res_in);
 int get_node(struct umad_resources *umad_res, uint16_t dlid, uint64_t *guid);
 int create_trap_resources(struct ud_resources *ud_res);
 int register_to_traps(struct resources *res, int subscribe);
-uint16_t get_port_lid(struct ibv_context *ib_ctx, int port_num);
+uint16_t get_port_lid(struct ibv_context *ib_ctx, int port_num, uint16_t *sm_lid);
 int create_ah(struct ud_resources *ud_res);
 void push_gid_to_list(struct sync_resources *res, union umad_gid *gid,
 		      uint16_t pkey);
srp_daemon/srp_handle_traps.c +11 -3
index 6b36b15cc84c..8c428756a379 100644
@@ -340,12 +340,20 @@ int ud_resources_create(struct ud_resources *res)
 	return 0;
 }
 
-uint16_t get_port_lid(struct ibv_context *ib_ctx, int port_num)
+uint16_t get_port_lid(struct ibv_context *ib_ctx, int port_num, uint16_t *sm_lid)
 {
 	struct ibv_port_attr port_attr;
+	int ret;
+
+	ret = ibv_query_port(ib_ctx, port_num, &port_attr);
 
-	return ibv_query_port(ib_ctx, port_num, &port_attr) == 0 ?
-		port_attr.lid : 0;
+	if (!ret) {
+		if (sm_lid)
+			*sm_lid = port_attr.sm_lid;
+		return port_attr.lid;
+	}
+
+	return 0;
 }
 
 int create_ah(struct ud_resources *ud_res)
Signature · 7 lines
2.15.1.272.g8e603414b


--
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): 6ea765f9-e770-74a3-bbe7-19b7ebc76ebe-IBi9RG/[email protected]

#18 lore raw

Re: [PATCHv3 rdma-core 1/2] srp_daemon: handle SM lid change

T24gRnJpLCAyMDE3LTEyLTE1IGF0IDE3OjM2ICswMTAwLCBOaWNvbGFzIE1vcmV5LUNoYWlzZW1h cnRpbiB3cm90ZToNCj4gU2luY2UgdjIsIGV4cGFuZCBhYmJyZXYgc2hhMSBvZiBGaXhlczouLi4g dG8gMTJCDQoNCkhlbGxvIE5pY29sYXMsDQoNClBsZWFzZSBrZWVwIFJldmlld2VkLWJ5IHRhZ3Mg d2hlbiBtYWtpbmcgc21hbGwgY2hhbmdlcyBsaWtlIHRoaXMuDQoNCkJUVywgaGF2ZSB5b3UgYWxy ZWFkeSB1cGxvYWRlZCB0aGVzZSBwYXRjaGVzIHRvIGdpdGh1YiBhbmQgaGF2ZSB5b3UgYWxyZWFk eQ0Kc2VudCBhIHB1bGwgcmVxdWVzdCB0byBodHRwczovL2dpdGh1Yi5jb20vbGludXgtcmRtYS9y ZG1hLWNvcmU/IFRoYXQgaXMgaG93DQpyZG1hLWNvcmUgcGF0Y2hlcyB1c3VhbGx5IGVuZCB1cCB1 cHN0cmVhbS4gWW91IHdpbGwgc2VlIHRoYXQgYWZ0ZXIgeW91IGhhdmUNCmNyZWF0ZWQgYSBwdWxs IHJlcXVlc3QgdGhhdCBzZXZlcmFsIHZhbGlkYXRpb24gY2hlY2tzIChUcmF2aXMgQ0kpIGFyZSBz dGFydGVkDQphdXRvbWF0aWNhbGx5Lg0KDQpCYXJ0Lg0KDQo=
--
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