Skip to content

Commit

Permalink
net: qrtr: Inform open sockets about new controller
Browse files Browse the repository at this point in the history
As the higher level communication only deals with "services" the
a service directory is required to keep track of local and remote
services. In order for qrtr clients to be informed about when the
service directory implementation is available some event needs to be
passed to them.

Rather than introducing support for broadcasting such a message in-band
to all open local sockets we flag each socket with ENETRESET, as there
are no other expected operations that would benefit from having support
from locally broadcasting messages.

Cc: Courtney Cavin <ccavin@gmail.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Bjorn Andersson authored and David S. Miller committed Jun 8, 2017
1 parent 1784473 commit b24844b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions net/qrtr/qrtr.c
Original file line number Diff line number Diff line change
@@ -530,6 +530,26 @@ static int qrtr_port_assign(struct qrtr_sock *ipc, int *port)
return 0;
}

/* Reset all non-control ports */
static void qrtr_reset_ports(void)
{
struct qrtr_sock *ipc;
int id;

mutex_lock(&qrtr_port_lock);
idr_for_each_entry(&qrtr_ports, ipc, id) {
/* Don't reset control port */
if (id == 0)
continue;

sock_hold(&ipc->sk);
ipc->sk.sk_err = ENETRESET;
wake_up_interruptible(sk_sleep(&ipc->sk));
sock_put(&ipc->sk);
}
mutex_unlock(&qrtr_port_lock);
}

/* Bind socket to address.
*
* Socket should be locked upon call.
@@ -558,6 +578,10 @@ static int __qrtr_bind(struct socket *sock,

sock_reset_flag(sk, SOCK_ZAPPED);

/* Notify all open ports about the new controller */
if (port == QRTR_PORT_CTRL)
qrtr_reset_ports();

return 0;
}

0 comments on commit b24844b

Please sign in to comment.