summaryrefslogtreecommitdiffstats
path: root/net/qrtr
diff options
context:
space:
mode:
authorBjorn Andersson <bjorn.andersson@linaro.org>2017-06-07 17:07:39 -0400
committerDavid S. Miller <davem@davemloft.net>2017-06-08 11:34:57 -0400
commitb24844b1b537c34e3069c4bcfb448a5a05c9e0dc (patch)
tree669f69d4c0997832483d89fb4dc344c74d12efe7 /net/qrtr
parent1784473b242585f407d3e75654d5b06f462a355b (diff)
net: qrtr: Inform open sockets about new controller
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>
Diffstat (limited to 'net/qrtr')
-rw-r--r--net/qrtr/qrtr.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c
index d7516098b5aa..c7a5d861906b 100644
--- a/net/qrtr/qrtr.c
+++ b/net/qrtr/qrtr.c
@@ -530,6 +530,26 @@ static int qrtr_port_assign(struct qrtr_sock *ipc, int *port)
530 return 0; 530 return 0;
531} 531}
532 532
533/* Reset all non-control ports */
534static void qrtr_reset_ports(void)
535{
536 struct qrtr_sock *ipc;
537 int id;
538
539 mutex_lock(&qrtr_port_lock);
540 idr_for_each_entry(&qrtr_ports, ipc, id) {
541 /* Don't reset control port */
542 if (id == 0)
543 continue;
544
545 sock_hold(&ipc->sk);
546 ipc->sk.sk_err = ENETRESET;
547 wake_up_interruptible(sk_sleep(&ipc->sk));
548 sock_put(&ipc->sk);
549 }
550 mutex_unlock(&qrtr_port_lock);
551}
552
533/* Bind socket to address. 553/* Bind socket to address.
534 * 554 *
535 * Socket should be locked upon call. 555 * Socket should be locked upon call.
@@ -558,6 +578,10 @@ static int __qrtr_bind(struct socket *sock,
558 578
559 sock_reset_flag(sk, SOCK_ZAPPED); 579 sock_reset_flag(sk, SOCK_ZAPPED);
560 580
581 /* Notify all open ports about the new controller */
582 if (port == QRTR_PORT_CTRL)
583 qrtr_reset_ports();
584
561 return 0; 585 return 0;
562} 586}
563 587