From patchwork Wed Jun 7 18:55:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 103310 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp2084411qgd; Wed, 7 Jun 2017 11:55:56 -0700 (PDT) X-Received: by 10.99.95.194 with SMTP id t185mr7649330pgb.19.1496861756417; Wed, 07 Jun 2017 11:55:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496861756; cv=none; d=google.com; s=arc-20160816; b=rqyESrd4FfA/yUsdK99IVHJjsweqHnUBIc5i91msPH2UJoO5MdLGHlwQPEgNVwn8Q1 cO4OrlBSInatEQTxCRDCCI/CSGJxwQvOtTB1+L1RxmJx0YslluFAWnF0sIy6ihEw0Z/s D578zXXUuWnNOODozAvm3EF/rYLzNrruV8PTqBIzx/0kzIniOa0POkT//lMK5DqOlKb5 ukPNCaf1TIOaSBcdKUhevjUgQ1+HF/xnAbiP5nFkfM1BPGsZ+5DpmnmsNs1e+l5l0Am3 EAXSO0oCd0ua02CcSbwrkKcrLkB4JZkkP7CZtYxzongzT5btaU5ZJ6KZqNI+mBdsC/hI wJdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=wsbAtJQRkV+WiCryejZUb4dPHA+7dvCq1BleeeWvY4Q=; b=VL+9cD4flwijGKVVZlg3Sx+/byDn8h4EsYzHZRrteJN5Hq81a9ePXl0ANjCY88Td6i L/7vXsBfetPFZYp9NGo8U3BFIndsXoIs1vlAS1Twtizfivrsi8Er/wNXRaPiESZdmIKc hxX5sLYNg4ZkgwnKa47n80mj0QaJ9KaSm2PFanK3rjDb5l2vaEwI/B1oJANdQNqrT/Oc S2WwzcPkeRa5NeNI0J0Z3vhk2C1g6uMI2kILpU2xgiFA6YMP575UhF3Z3/kB1KQFl9o0 BdGQPKVF3lMQidlvkZAiEkbP0utCMhJsS905g9pFarJ6djxeRN2RiviGKizO+zyOFxSI z3gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d7si2511469pln.460.2017.06.07.11.55.56; Wed, 07 Jun 2017 11:55:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752027AbdFGSzl (ORCPT + 25 others); Wed, 7 Jun 2017 14:55:41 -0400 Received: from mail-pg0-f45.google.com ([74.125.83.45]:36216 "EHLO mail-pg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751922AbdFGSzI (ORCPT ); Wed, 7 Jun 2017 14:55:08 -0400 Received: by mail-pg0-f45.google.com with SMTP id a70so8137620pge.3 for ; Wed, 07 Jun 2017 11:55:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wsbAtJQRkV+WiCryejZUb4dPHA+7dvCq1BleeeWvY4Q=; b=FLBVuQZVL7GdBcj3PX4+JP1vaYTfzGDWFmK9fcN9d4HM83zohg/1gaTC3btTNItd6Z tZBYtzPMqgx5ExEK42w2q2UucZzVHPZVpUihfN3RelgTtji4R/YTvhmzo0hTUQ5qB3+n Ms+A4DXxcjxN38a70yT/RSWy2+qBRJlFfZtp8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wsbAtJQRkV+WiCryejZUb4dPHA+7dvCq1BleeeWvY4Q=; b=SauJ5FLjrFqq2PUOfi/q+0qwekmKm/6Hztt+323VBuvFXl5U0Mabap+vyp6e0tUsRN v1xXosHhdvYapfp+smpPt1dOORnKLIikfZvVecgDC3r6isIp5gdVO6M+drib3T9it7wp j4wDuBGpbWB7qmC6XOQJ1mgtFTnRKIvk+iOuInm6vp9mGfyiyhP5u0MdlCP1M/dqQEXf PqOW/d62rp97SbhjmRkbyhej4Krtp/XhHzkklkP184AKNtuBb1qbDXGyDnpjfXjixXfj h4jxzkzvMN43MLCammNpLVypE4DO4z+JiRUgPypmvy8GVDSRXkBW8fvTRq57ltHCI66C icLg== X-Gm-Message-State: AODbwcCmi199JLfFnEd1rSDQ0WYqYqbL3CmZPl64DNP3RTqs0Qe25ZF7 +Yxuqy60CFYIrXyO X-Received: by 10.98.159.88 with SMTP id g85mr2739663pfe.21.1496861707877; Wed, 07 Jun 2017 11:55:07 -0700 (PDT) Received: from localhost.localdomain (ip68-111-217-79.sd.sd.cox.net. [68.111.217.79]) by smtp.gmail.com with ESMTPSA id u73sm5355149pfi.105.2017.06.07.11.55.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Jun 2017 11:55:07 -0700 (PDT) From: Bjorn Andersson To: "David S. Miller" Cc: Arun Kumar Neelakantam , netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Courtney Cavin Subject: [PATCH 3/4] net: qrtr: Broadcast DEL_CLIENT message when endpoint is closed Date: Wed, 7 Jun 2017 11:55:00 -0700 Message-Id: <20170607185501.6000-3-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170607185501.6000-1-bjorn.andersson@linaro.org> References: <20170607185501.6000-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Per the QMUXv2 protocol specificiation a DEL_CLIENT message should be broadcasted when an endpoint is disconnected. The protocol specification does suggest that the router can keep track of which nodes the endpoint has been communicating with to not wake up sleeping remotes unecessarily, but implementation of this suggestion is left for the future. Cc: Courtney Cavin Signed-off-by: Bjorn Andersson --- net/qrtr/qrtr.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) -- 2.12.0 diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index e8cbab23d667..d7516098b5aa 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -112,6 +112,7 @@ struct qrtr_node { }; static int qrtr_local_enqueue(struct qrtr_node *node, struct sk_buff *skb); +static int qrtr_bcast_enqueue(struct qrtr_node *node, struct sk_buff *skb); /* Release node resources and free the node. * @@ -312,6 +313,26 @@ static struct sk_buff *qrtr_alloc_local_bye(u32 src_node) return skb; } +static struct sk_buff *qrtr_alloc_del_client(struct sockaddr_qrtr *sq) +{ + const int pkt_len = 20; + struct sk_buff *skb; + __le32 *buf; + + skb = qrtr_alloc_ctrl_packet(QRTR_TYPE_DEL_CLIENT, pkt_len, + sq->sq_node, QRTR_NODE_BCAST); + if (!skb) + return NULL; + + buf = (__le32 *)skb_put(skb, pkt_len); + memset(buf, 0, pkt_len); + buf[0] = cpu_to_le32(QRTR_TYPE_DEL_CLIENT); + buf[1] = cpu_to_le32(sq->sq_node); + buf[2] = cpu_to_le32(sq->sq_port); + + return skb; +} + static struct qrtr_sock *qrtr_port_lookup(int port); static void qrtr_port_put(struct qrtr_sock *ipc); @@ -448,8 +469,15 @@ static void qrtr_port_put(struct qrtr_sock *ipc) /* Remove port assignment. */ static void qrtr_port_remove(struct qrtr_sock *ipc) { + struct sk_buff *skb; int port = ipc->us.sq_port; + skb = qrtr_alloc_del_client(&ipc->us); + if (skb) { + skb_set_owner_w(skb, &ipc->sk); + qrtr_bcast_enqueue(NULL, skb); + } + if (port == QRTR_PORT_CTRL) port = 0; From patchwork Wed Jun 7 18:55:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 103309 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp2084262qgd; Wed, 7 Jun 2017 11:55:30 -0700 (PDT) X-Received: by 10.99.178.16 with SMTP id x16mr33722641pge.220.1496861730254; Wed, 07 Jun 2017 11:55:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496861730; cv=none; d=google.com; s=arc-20160816; b=hu8UXQPEKefsMS9/P0gX6PLxFaSF0xnSnDXT2MGkS8K6VaYFWPLGmBtyvMAhUd+mP+ vDhHgechNte+JK0/aNGd2Y1kwQ9wTPfDQABT7h5WVw8mIz+qPCbWMCWBYj2rTJ15djAw AAd7Uko9Y3SAVh0Nq+hFaWUICgOarYvQdU0KOIfmS2dMcfbneYkAXgmpUMt+Qt3saf61 S3GmWAZrLCJu1AQ2wc4By9Hj5y2Fi3lO915SyEXNSsMvzc9IjrYYPGyOd9G5hk+GrNQF 0c2sMiE5Cnnwq/904c4y7R0URurnrONSPSN8+ejD2rwDOoRlMXKBjkUIsiOQxkiOlNLw I8bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=0LPKQn7O6EM8KCGgtZCIZAlN695W5rgDPvZKWmqLZEY=; b=QSrqofVg1Lugt+J3hR4eOp0lL66+/KVMD2yFswW6iu/RJ62tbiIHbBQ/xkWhmqf5/u U0Kx+aLZJ8dspLKvwrIqSR1vQaHBlGZQFHW2jYUSFvzGftSgR9qanNj4NcwbI72NfR8a a4bbEMbcuFrnJsT9jZZh3CZ5a1M4Vtug8rRvTqQlGwHIdnu3rHmNSBJ82cvAlBaPQqkH tJqafNJ4XKQs4BGS2oz80GWjeFrng2QNw3zmznbDSpDKkjh1AlL7FUACA1uB+SSJ3ugz 1sZuinokTtLL3ldp4mmRD319sIzTDJRcbx3bylgP1DtWBIiYl2AXGsLEjVP+5onPivPU vBGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p5si2453857pgn.133.2017.06.07.11.55.29; Wed, 07 Jun 2017 11:55:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752001AbdFGSzM (ORCPT + 25 others); Wed, 7 Jun 2017 14:55:12 -0400 Received: from mail-pf0-f171.google.com ([209.85.192.171]:34623 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751909AbdFGSzJ (ORCPT ); Wed, 7 Jun 2017 14:55:09 -0400 Received: by mail-pf0-f171.google.com with SMTP id 9so8670399pfj.1 for ; Wed, 07 Jun 2017 11:55:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0LPKQn7O6EM8KCGgtZCIZAlN695W5rgDPvZKWmqLZEY=; b=UB3Pke/6mhuuJacIre0AlstOEcMmbNdDChvtKB2xwtYW1xuIavjyQMIn2xhDQMsnO0 g7kclhZJtxCG5F8P7rVBPa0AxraA2h5Y6Mujsw/3bm8T5P6P0Z4cP67uhL8O1VfgpdWF 4eZsmZYBWXKm2No9TAsPdslBxIq/KnvBCuxZI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0LPKQn7O6EM8KCGgtZCIZAlN695W5rgDPvZKWmqLZEY=; b=FgsnufFiQaM720KtqwcrRPDRpJKxbuArxaZyqsCEH3pWrazG/N/kDU08njm0b7A6i9 D1QTXOzmHmSugADD6DM/0SzPzxgDsVOfVpfNS9mKnScIbcfp86fKhnv42+s6/Gvcaq/F oPx/nn9dwVgeVyW0pNsjcwxR5NF8qhzSYArXQRxD7pC7oIxAWFpaa2LpIEYoe57Xt8q0 GjH+5oNNN1MkXLbGY7mAwHrws3zQJb06D/8X2GzfNFM+hJAX1+R1Dq6UNjN+lHsWYpx6 P0ECAb0XCl56PuWoPuY3/xvYvIUcNY4gk8wyV9Bcb9101lhb0ee3x0U9YZ4giVlnomW2 sEAw== X-Gm-Message-State: AODbwcAk4C+XCkcTbHwNSYlmUHZ+gNX/cPQYFBUKXsCesWe9mWt2ShzH TRW42RHe00QwIax7 X-Received: by 10.98.142.17 with SMTP id k17mr15335845pfe.139.1496861708902; Wed, 07 Jun 2017 11:55:08 -0700 (PDT) Received: from localhost.localdomain (ip68-111-217-79.sd.sd.cox.net. [68.111.217.79]) by smtp.gmail.com with ESMTPSA id u73sm5355149pfi.105.2017.06.07.11.55.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Jun 2017 11:55:08 -0700 (PDT) From: Bjorn Andersson To: "David S. Miller" Cc: Arun Kumar Neelakantam , netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Courtney Cavin Subject: [PATCH 4/4] net: qrtr: Inform open sockets about new controller Date: Wed, 7 Jun 2017 11:55:01 -0700 Message-Id: <20170607185501.6000-4-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170607185501.6000-1-bjorn.andersson@linaro.org> References: <20170607185501.6000-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Bjorn Andersson --- net/qrtr/qrtr.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) -- 2.12.0 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) 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; }