From patchwork Wed Jun 7 21:07:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 103312 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp2133793qgd; Wed, 7 Jun 2017 14:08:01 -0700 (PDT) X-Received: by 10.84.212.2 with SMTP id d2mr30348653pli.26.1496869681175; Wed, 07 Jun 2017 14:08:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496869681; cv=none; d=google.com; s=arc-20160816; b=F9RUiRJJqjWxdA4U+qpyRoD87c4WL5E5J8LxzjURfFh9SmpWBSIRI/qFx3i7Hn/D31 xrwyU8cF6aNm4N3WX41nnrl/xd8wxZDEP10i89sUgCu3uG2yZWF7dXJrG7kUFK/vMSZj YoFEPlDGLcR3qqI8ZgR8ofgPKFiElyoPTja+dToLzlMum+QY/fMnHdhrM4ngNzqO21Em g3vSTn3FmCJ6VLW3th+KoaxfYtj7Nd4l9OmeH9c9T99Jp5SvvOheNY7ndOiVZ0OwM7hc ZIwszuEHiBTdnHa/1VXxHO+XIKanBBLvUeQJmgSSTEopduUouiIIe8TyysnnQcx5PwEM Bzfg== 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=trZPSTIv0LkvQ3VvBzlArdmueRgUpcWdE8yr6CsIiZA=; b=H/tri5jmWveyYjVPpQdxKMUHVOvocWZbchkcem+Ou2oBCdbYrn92eKdm5jOw7hSzjQ 7AS3FZ8EB5jxV32hA2BIwcaAoqf0215DFuNvjgez+DliA7Ovj1XXef+39EQarJnNN92N NJIELxYLEcYKsEMhSYK42gfv5DS7cFk0rPOjsWPiyjfj1j1q9i9lXipHpBe2I1wPtBFQ zOPMaj1nxuksvnObA7M84VhuYTMmZ2N/fft4ZoYvVtXbo4VgEyVXT86xar4vku+G0BpR HQJOFdZOZ2nfa5Iud8qBZSiNavxQv8jMhoJm6dOkhrcWHdQN9VKPllMERHpLVT/BqKkU mnLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-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 n5si2574136pgk.396.2017.06.07.14.08.01; Wed, 07 Jun 2017 14:08:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-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 netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-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 S1751958AbdFGVHt (ORCPT + 6 others); Wed, 7 Jun 2017 17:07:49 -0400 Received: from mail-pg0-f41.google.com ([74.125.83.41]:36585 "EHLO mail-pg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751889AbdFGVHq (ORCPT ); Wed, 7 Jun 2017 17:07:46 -0400 Received: by mail-pg0-f41.google.com with SMTP id a70so9078386pge.3 for ; Wed, 07 Jun 2017 14:07:46 -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=trZPSTIv0LkvQ3VvBzlArdmueRgUpcWdE8yr6CsIiZA=; b=RGYKLT5v1iCLeK5TqJ4HRK4CKE/NzsOpR20bxdJledk+XEyoO5CsXHFsjIiPdEB/l0 6ip6+0x6XiUYaTwB17uWTnXomwbwK3Q/8CcPVttpDxVTooobgOv+wcUYjvMYpzSvW3DA Y3ah7dtvYk+rXB3awYMPNVQDO6GGw4321ekbE= 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=trZPSTIv0LkvQ3VvBzlArdmueRgUpcWdE8yr6CsIiZA=; b=nuc+VusOTh9EfI0pYJL7EdkrrXbmu9uYsFl9RcA6u7o6dRPCchQUiKv1kU75PlbEqI eCLO4ZxXJVFAH0M+bBHL5zN3pwOQftKgURSFbTjSbY03obm8klOFjRxYna0gVT/PwccY L89Eble9+GO4xpk55WC1jQ4DWFe90tUNhYpI9ZM7VQaraPQUOvyaKc0S6HCLX6LVMQXL 3Xhl0VocbAb5Pvr0AN7bg23jYkjljYRCIuSkQabBasCt2+McTlE4OIFUq4sesglKxLbn YvQECHGpjl2doDmwViRkehxwGDbVfVtzj+qvKYPbXJaSUuD6mQzJNlGn5+1WaeRDpu9g 6NTw== X-Gm-Message-State: AODbwcBgIAppQ/+dLvBZWWJlWUbHTQFuQu/yAT3ETcDdChPs4AAp3BTh O0TY5sNsa2bQotG3 X-Received: by 10.84.213.129 with SMTP id g1mr27567122pli.202.1496869665585; Wed, 07 Jun 2017 14:07:45 -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 s131sm6564392pgs.6.2017.06.07.14.07.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Jun 2017 14:07:45 -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: [RESEND PATCH 2/4] net: qrtr: Inject BYE on remote termination Date: Wed, 7 Jun 2017 14:07:37 -0700 Message-Id: <20170607210739.27263-3-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170607210739.27263-1-bjorn.andersson@linaro.org> References: <20170607210739.27263-1-bjorn.andersson@linaro.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Per the QMUX protocol specification a terminating node can send a BYE control message to signal that the link is going down, upon receiving this all information about remote services should be discarded and local clients should be notified. In the event that the link was brought down abruptly the router is supposed to act like a BYE message has arrived. As there is no harm in receiving an extra BYE from the remote this patch implements the latter by injecting a BYE when the link to the remote is unregistered. The name service will receive the BYE and can implement the notification to the local clients. Cc: Courtney Cavin Signed-off-by: Bjorn Andersson --- net/qrtr/qrtr.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) -- 2.12.0 diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index 86d35ed50da9..e8cbab23d667 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -111,6 +111,8 @@ struct qrtr_node { struct list_head item; }; +static int qrtr_local_enqueue(struct qrtr_node *node, struct sk_buff *skb); + /* Release node resources and free the node. * * Do not call directly, use qrtr_node_release. To be used with @@ -291,6 +293,25 @@ static struct sk_buff *qrtr_alloc_resume_tx(u32 src_node, return skb; } +/* Allocate and construct a BYE message to signal remote termination */ +static struct sk_buff *qrtr_alloc_local_bye(u32 src_node) +{ + const int pkt_len = 20; + struct sk_buff *skb; + __le32 *buf; + + skb = qrtr_alloc_ctrl_packet(QRTR_TYPE_BYE, pkt_len, + src_node, qrtr_local_nid); + if (!skb) + return NULL; + + buf = (__le32 *)skb_put(skb, pkt_len); + memset(buf, 0, pkt_len); + buf[0] = cpu_to_le32(QRTR_TYPE_BYE); + + return skb; +} + static struct qrtr_sock *qrtr_port_lookup(int port); static void qrtr_port_put(struct qrtr_sock *ipc); @@ -382,11 +403,17 @@ EXPORT_SYMBOL_GPL(qrtr_endpoint_register); void qrtr_endpoint_unregister(struct qrtr_endpoint *ep) { struct qrtr_node *node = ep->node; + struct sk_buff *skb; mutex_lock(&node->ep_lock); node->ep = NULL; mutex_unlock(&node->ep_lock); + /* Notify the local controller about the event */ + skb = qrtr_alloc_local_bye(node->nid); + if (skb) + qrtr_local_enqueue(NULL, skb); + qrtr_node_release(node); ep->node = NULL; } From patchwork Wed Jun 7 21:07:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 103314 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp2133997qgd; Wed, 7 Jun 2017 14:08:31 -0700 (PDT) X-Received: by 10.99.150.2 with SMTP id c2mr34522367pge.27.1496869711131; Wed, 07 Jun 2017 14:08:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496869711; cv=none; d=google.com; s=arc-20160816; b=Nxd9gX0VCsl59w2j5cv0gx3mBey70PjvOeZst7lnMOL/oedIiMyzN8LcAk+VqBc0Xu r7s1+yAng2kaOSSLf+1x1vtQp2+HtSPSXSRIbpthQE9m2lMBPMOz5GWLN4a6wTsBCV1v hJYr7xqJ2Y+QLyvGI1akuXhJLCANMMyQFHFKmbDT1Z1ZXkRFxs9ub51ZC6rBmi/pYa+J Hk4v+HUwC08XF+X2xJNCjv24fzZKU0yw9lJp67mhbOvHHMQSPrNlXT9OM+NP7Mfc9Jrc eLxWHNxnC6JCsp11cfkkWsdWatdA+LFE3bX6AJv//7mB5mKccwAeucIFN9WXOVGPJAWK V4og== 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=FAjfYokDeQrNQJSbq279G6s7g1in1tEZ7juGFAron4oRWJDjcegeej5bu71LER++9E DdZ4iCdnYqH372J7LbdF7lGG0Z/hJGf6VqgSi1UzwihtS3cLawgnvf268Aw15s9iMyXg E1dCE6M3WmCy6iLv6FBDX7wG3dirMW982EDKFDHKZ3y9NF+8idXy7+kgJPl8N+fgQvbq 3mOQHVHTJUyPa1w9CDWBJsG/emy28ZSWLHwzX5BInU7sDJ7JnQ6ziH6tCGlzapPpBgMD IkLHwHDK++1WVvIfN7QLzHTHPBIaqs54v7e5NigGXSHCeMEa1GOuAE6Zq63hPADukhMv 7TGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-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 s82si2622156pgs.324.2017.06.07.14.08.31; Wed, 07 Jun 2017 14:08:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-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 netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-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 S1751524AbdFGVIM (ORCPT + 6 others); Wed, 7 Jun 2017 17:08:12 -0400 Received: from mail-pg0-f45.google.com ([74.125.83.45]:35370 "EHLO mail-pg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751910AbdFGVHs (ORCPT ); Wed, 7 Jun 2017 17:07:48 -0400 Received: by mail-pg0-f45.google.com with SMTP id k71so9095502pgd.2 for ; Wed, 07 Jun 2017 14:07:48 -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=eWX0zEhztOiv/6+CfRA7eR0BImRBwli50Vkjaxc1RzwTTgthKjV+3ir0ocgQtCYhdz dNpdGAyvAgkl9MabjrFNSd1WcGmG3yHKCWDs0CO9rAPB/TddpjKYvZqiFTUybwSHdv9u Np68FnDa3m/GP7dCKdAuMd3KVXmiuWyiWBw2c= 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=O9/l2at5+x3QZIdQzhzFheUK0LEbG5HQdxTUwREQb7mE7CzTK4sgmf7jTng1QSOnoF W+5yElL/XgQlo3AdIoGz2s6fDKBfWZmr2xCpT1auE/LlTkpQwQPj2oGhQ+XHjvT0o/0W uRN6TrsC9Rl09vkfYWTNrW1K3LF586gHRYbMJw7dgP4QyV7ND/PRmDzr6qTSm1Y3QKaL u1OdUtysvBcb3EOwF+9yVp8qyEMc7HI2hP7IOlwACs0VUOFAZ0nkLoKf2Ky9cXISYA7y lqVSI2PY0z1Q74J3wG+jsXqMkhsJifxH6PeEePRxjseNYmVg2nxnVibsIahlLdHry6bt Zs+A== X-Gm-Message-State: AODbwcBCT7tygz1rV8fmNdvnld3QnvOolmcDm+a5CrWkXngoLE8lMc5P 01nBmgWQJPK1jKsX X-Received: by 10.98.33.84 with SMTP id h81mr32766163pfh.81.1496869667753; Wed, 07 Jun 2017 14:07:47 -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 s131sm6564392pgs.6.2017.06.07.14.07.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Jun 2017 14:07:47 -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: [RESEND PATCH 4/4] net: qrtr: Inform open sockets about new controller Date: Wed, 7 Jun 2017 14:07:39 -0700 Message-Id: <20170607210739.27263-5-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170607210739.27263-1-bjorn.andersson@linaro.org> References: <20170607210739.27263-1-bjorn.andersson@linaro.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@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; }