Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3646eab6 authored by Chris Lew's avatar Chris Lew
Browse files

net: qrtr: Send BYE message for all nodes on ept



An ept can represent multiple nodes in a system. If an ept unregisters,
qrtr should send a BYE control message for all the nodes that it
represents. Iterate through the node tree to find all the nodes that
belong to the ept.

Change-Id: Ia0b1573274e07d2f94092bd464105bc6ebca5ef8
Signed-off-by: default avatarChris Lew <clew@codeaurora.org>
parent a0b74a09
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -708,22 +708,33 @@ EXPORT_SYMBOL_GPL(qrtr_endpoint_register);
 */
void qrtr_endpoint_unregister(struct qrtr_endpoint *ep)
{
	struct radix_tree_iter iter;
	struct qrtr_node *node = ep->node;
	struct sockaddr_qrtr src = {AF_QIPCRTR, node->nid, QRTR_PORT_CTRL};
	struct sockaddr_qrtr dst = {AF_QIPCRTR, qrtr_local_nid, QRTR_PORT_CTRL};
	struct qrtr_ctrl_pkt *pkt;
	struct sk_buff *skb;
	void __rcu **slot;

	mutex_lock(&node->ep_lock);
	node->ep = NULL;
	mutex_unlock(&node->ep_lock);

	/* Notify the local controller about the event */
	down_read(&qrtr_node_lock);
	radix_tree_for_each_slot(slot, &qrtr_nodes, &iter, 0) {
		if (node != *slot)
			continue;

		skb = qrtr_alloc_ctrl_packet(&pkt);
	if (skb) {
		if (!skb)
			continue;

		src.sq_node = iter.index;
		pkt->cmd = cpu_to_le32(QRTR_TYPE_BYE);
		qrtr_local_enqueue(NULL, skb, QRTR_TYPE_BYE, &src, &dst);
	}
	up_read(&qrtr_node_lock);

	/* Wake up any transmitters waiting for resume-tx from the node */
	wake_up_interruptible_all(&node->resume_tx);