From patchwork Fri Nov 6 17:33:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 320805 Delivered-To: patch@linaro.org Received: by 2002:a17:906:d156:0:0:0:0 with SMTP id br22csp634140ejb; Fri, 6 Nov 2020 09:27:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJzqefyDeqrXwkMDXhihXhoa8EYWCpOHu7d7IRHFK9SlxBvLy2T0bOsHrdU1MMvDNyPgmqeY X-Received: by 2002:a50:cd51:: with SMTP id d17mr2992006edj.93.1604683632404; Fri, 06 Nov 2020 09:27:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604683632; cv=none; d=google.com; s=arc-20160816; b=dU9Wcloi7UUU9ctd+oCDjJmnHDSDFhCmjBmdP/qvp4EyBVf9nIlS1+DV77oz0KheeC cbkTIqgIAP7ptGChCOAfZgH2SP0zvBfsSnZAj2+zLTkIQk8wLSq2HFj/RykuGfprrTEv Y8970hzz9FgoP4WaFBUmHFve4qwiJjYTvInZZr/w9/g85iZTrFgSWbVoo0OOWJnuYZMy kftKB44m7OAJ5Mjb3SrmJCpUfBN6sE6nwiPz16Z01EL8GfO+Bkv4KybdezlFgHiSXmIE RWzkvvUwBTcEctMOihst4zv3eP/Y6dCr/T9noxb/dTeUbRJ6CzTmIIq8cRlH7IjVl5rC cPNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=qiZHU813rW8xg+F+YCWBIt/KpRIOcYYppQ2O/7ZYftw=; b=KNLCG0ppKs5eFj6+wIu5r8y+Cg6MAlOcK91VqhB4jJSgCwCQG5wl2q7CUyICZfmRbY 7R0QfkNc8Y0mVgN1oqi9PtFiMlAgr2Cv2pLXicmSxpXM0CdAklTbwx/NqdMza0aemHlt RAeRytU9B165LfJh3dKMRvHnkYEalYAnkDwxMsN8oeASkcuQK+jyYuKMXvoKUs+dw2kn LrnmIb7HpN/Ch7bSaiO9MXqSTmKkdleVwAp7QgnYoIXKCxZhNvs1Jn+WD70Y/dsWAKEH gzagmfIv/BrirQgZTPuet6gWmslWCk0S8Pg6Q3oFsOAaPsUV9eqlsYIqTyIzoDirzNvp 2cPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="LIykX/LI"; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id o17si1467882ejg.500.2020.11.06.09.27.12; Fri, 06 Nov 2020 09:27:12 -0800 (PST) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="LIykX/LI"; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 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 S1727402AbgKFR1K (ORCPT + 8 others); Fri, 6 Nov 2020 12:27:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726075AbgKFR1J (ORCPT ); Fri, 6 Nov 2020 12:27:09 -0500 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 824CCC0613CF for ; Fri, 6 Nov 2020 09:27:08 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id c9so2203594wml.5 for ; Fri, 06 Nov 2020 09:27:08 -0800 (PST) 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=qiZHU813rW8xg+F+YCWBIt/KpRIOcYYppQ2O/7ZYftw=; b=LIykX/LIcE/R0Q2p18YaAa2MWfP8VB0B7wUc7nG9ObZD+I+bnpnIKQE4r88G8WMa+A 230e5yuBbqoj+o1yabVzpqfd/2L6Rdtue1peWWXAztY5CwlESD3HczBoEzvp+3SeOk7w tHEyT6bskbOMWSWizsxS8rnaJ+R+q1RDw6/ImL+6xUQ42mNbEXHMmGMm3/CzARCssW/f UlssTIssggeU2k3sHf1j/aqMgkadPA2awkvghqa0JtaO+Wa9HRqZEvDcCHH3glkM1a5f WpZRVCCQlyhEZ8Fw6YtX4qZKuByfDCQtXn6xG7e76/bdxZnzp6qt0BbpPnV/RJMa8QqC a+kg== 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=qiZHU813rW8xg+F+YCWBIt/KpRIOcYYppQ2O/7ZYftw=; b=duaetrH1nsz+OeMw0kxQcsABixh9fV0+ubonb3w2irmV8UHedGOpi902Ngnfo2ueYC L73UX7A4+Y5/lfKTAvUTnL6S8kKJ71oZ6rlHGGs9SVUHCCJC1xIcemdJHlogN6SCEiw3 HnxT/nVP1Phi1fb7vJwYkZzhCFOgAFPhIGQO0tSJr0sdGFTDv8j3+lyw/8nOR2ctj/Ad AlkWS7cbUbaA/JTY+NT/PeNcy/DvU15ODHtS9YvgSfvpa6VHuK/0S3QYzj2TFhkXxVz3 xi3pvuowaOh9T1k21WyAozMjkWLALUQzDtZeAhj6mUB+3O6amdEsLMgcPAqLVdFjsU9M N4FA== X-Gm-Message-State: AOAM531TyXVJmlpWmX2n/x8yVKo4mVe8M9I4j6gQRXK8PSicbo2LgkD9 nlX9r6fCjmcyImLY1MFfJyxshg== X-Received: by 2002:a05:600c:22d3:: with SMTP id 19mr666424wmg.161.1604683627213; Fri, 06 Nov 2020 09:27:07 -0800 (PST) Received: from localhost.localdomain ([88.122.66.28]) by smtp.gmail.com with ESMTPSA id z191sm3183266wme.30.2020.11.06.09.27.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Nov 2020 09:27:06 -0800 (PST) From: Loic Poulain To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, manivannan.sadhasivam@linaro.org, cjhuang@codeaurora.org, netdev@vger.kernel.org, Loic Poulain Subject: [PATCH v2 1/5] net: qrtr: Fix port ID for control messages Date: Fri, 6 Nov 2020 18:33:26 +0100 Message-Id: <1604684010-24090-2-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1604684010-24090-1-git-send-email-loic.poulain@linaro.org> References: <1604684010-24090-1-git-send-email-loic.poulain@linaro.org> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The port ID for control messages was uncorrectly set with broadcast node ID value, causing message to be dropped on remote side since not passing packet filtering (cb->dst_port != QRTR_PORT_CTRL). Fixes: d27e77a3de28 ("net: qrtr: Reset the node and port ID of broadcast messages") Signed-off-by: Loic Poulain --- net/qrtr/qrtr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index b4c0db0..e09154b 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -348,7 +348,7 @@ static int qrtr_node_enqueue(struct qrtr_node *node, struct sk_buff *skb, hdr->src_port_id = cpu_to_le32(from->sq_port); if (to->sq_port == QRTR_PORT_CTRL) { hdr->dst_node_id = cpu_to_le32(node->nid); - hdr->dst_port_id = cpu_to_le32(QRTR_NODE_BCAST); + hdr->dst_port_id = cpu_to_le32(QRTR_PORT_CTRL); } else { hdr->dst_node_id = cpu_to_le32(to->sq_node); hdr->dst_port_id = cpu_to_le32(to->sq_port); From patchwork Fri Nov 6 17:33:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 320806 Delivered-To: patch@linaro.org Received: by 2002:a17:906:d156:0:0:0:0 with SMTP id br22csp634144ejb; Fri, 6 Nov 2020 09:27:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJxxiXEvYfHCIjkyx2H/Mbrus3dsF2IdlW5RihqujWMZfORfMxCq8iFJmDEzTb0p1KZLBJhj X-Received: by 2002:a17:906:4d52:: with SMTP id b18mr2995042ejv.553.1604683633195; Fri, 06 Nov 2020 09:27:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604683633; cv=none; d=google.com; s=arc-20160816; b=MxRDXzS1tmOPMXt5nq1kPHVgwKlhzKMb4G9dvJwhbcdi+RTlvHgQm+w/nFTX2LwfZR wAMLglCQfbskWGRuQXEVEVm34W5s6UrlzdTGcOzNP0t6SXeRKcdCKSNmSfIjFZv76p1Y CauBpgQQL8HPGzk+gmQt+MeMcwoDggUW9XCbiT3vCeV941slDUXqePpryzTS9cuEGkte /cgNBmT4874omLsWZDDvr4T9LhzwiIfujMhK41EVFTZ8Iz+dNQPaW26oH5J+p6htybRD pAaPZj/VIFWZPvrZbzR0PUxBeewW+YMExLxSM3wPvs5Bli59jIs+aJIDYlAPSsp3+mpX ShKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=pEBu4MEn0zrdd6kmSnIxtSlsYwCAvk6sOANEKyTQKac=; b=wZAiJG8tVMYwvWKja67bGfDsf34HTFNSdBNpSTLO09UAXwBIji7sYkfqehaFeCYQJb LuC2tMjjFSBFgzpd8gbawSlxu62crsNgFV/S8Sdv0Z0ndgHVWTJxExhCd01cJYC7i2eh P+SJNJWPBc4F0q+ZL3vBM3eFUdUeaiUyHN30o161Ga6neNshhptmOn9SXkWyDsgEFh2C TxS1xUV/cbbpQW9LZdwyknB8w+bk1/RX/fQ8pcBkiPORzfO13vZw3zq7jMDPgsd59Cu4 RVvfLGo2WUaLIdnTDW2qJc1eKKtGb9UWy+7EcfU4WEBMmhz6GZe9nkUM/rnZ4tlFIS/J YKAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Tp848QB4; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id o17si1467882ejg.500.2020.11.06.09.27.12; Fri, 06 Nov 2020 09:27:13 -0800 (PST) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Tp848QB4; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 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 S1727356AbgKFR1M (ORCPT + 8 others); Fri, 6 Nov 2020 12:27:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726999AbgKFR1K (ORCPT ); Fri, 6 Nov 2020 12:27:10 -0500 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF124C0613CF for ; Fri, 6 Nov 2020 09:27:09 -0800 (PST) Received: by mail-wr1-x441.google.com with SMTP id y12so2129845wrp.6 for ; Fri, 06 Nov 2020 09:27:09 -0800 (PST) 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=pEBu4MEn0zrdd6kmSnIxtSlsYwCAvk6sOANEKyTQKac=; b=Tp848QB4+ncG8vnPLsRqZ5TFpqijx3N7VRdr1ef8j53Zy/sRxGjPLH0VtZiTNxnzXV Kce/AvrdjaNJajerHWc4DvQN5uHLa79Y4mZzXL7Ac0PdnFSbUjTu3iOmHSam5yPrgmV7 DerZQbNGykCT3Ws3HkxqmL4PbLfFyOs5ufOR6/foBS6wIXNn+JHHHEVFb8Ovcy0MfL26 Z0h6IwTqr6eDIb1xckznkVd65oLRIOVTj0jOM0qrSeCUULw2yuE/efWFlSqiDnIXHEor j5u4sQVulB5ttoM8vLgyqO37sR1KwhBcC+QQGhpdGPVFjeXIgsrnweMtnCYp7Dh0yC0o LBjQ== 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=pEBu4MEn0zrdd6kmSnIxtSlsYwCAvk6sOANEKyTQKac=; b=TJLsPV7su92f8XWXBY46qx3zxEtfnG7lsHM8xwMqr1312P2S3lJbmaEWoSZB0vfEj6 hE8KxE4WSZhXfPJINahyYr3JqoLgNcnMSpbMudp+IEKegogXNShwWfeWr+sxcF/30teo UnKIjE5jcTs9oqoqFOGuumwDrS07tTn9c3LWSU46hNVaa4QQJbjkDOnKoot9vuMvSCoz 9/Pem12IF222k/LX0jV9yS8j1QrWGu9hWaU5L4nIzkvkkM4uEn10uH7w8eCz1Bv62Fhx q81+F2uFYQyCe/JD6zO4bXqQcGxFw0jABa2OFV1uiCNgyGR76yEO8ooKv0yfz99Z4T+m t5GQ== X-Gm-Message-State: AOAM533d03oxC/d5bj0/OFBUJNqUkDs42nr6l6IR3eqd113Btgu7AkwM Dy17KWfzd2Z9wTX7ZOycSFyXVg== X-Received: by 2002:a5d:6046:: with SMTP id j6mr3886668wrt.317.1604683628508; Fri, 06 Nov 2020 09:27:08 -0800 (PST) Received: from localhost.localdomain ([88.122.66.28]) by smtp.gmail.com with ESMTPSA id z191sm3183266wme.30.2020.11.06.09.27.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Nov 2020 09:27:08 -0800 (PST) From: Loic Poulain To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, manivannan.sadhasivam@linaro.org, cjhuang@codeaurora.org, netdev@vger.kernel.org, Loic Poulain Subject: [PATCH v2 2/5] net: qrtr: Allow forwarded services Date: Fri, 6 Nov 2020 18:33:27 +0100 Message-Id: <1604684010-24090-3-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1604684010-24090-1-git-send-email-loic.poulain@linaro.org> References: <1604684010-24090-1-git-send-email-loic.poulain@linaro.org> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org A remote endpoint (immediate neighbors node) can forward services from other nodes (non-immadiate), in that case ctrl packet node ID (offering distant service) can differ from the qrtr source node (forwarding the packet). Signed-off-by: Loic Poulain Reviewed-by: Bjorn Andersson Reviewed-by: Manivannan Sadhasivam --- net/qrtr/ns.c | 8 -------- 1 file changed, 8 deletions(-) -- 2.7.4 diff --git a/net/qrtr/ns.c b/net/qrtr/ns.c index d8252fd..d542d8f 100644 --- a/net/qrtr/ns.c +++ b/net/qrtr/ns.c @@ -469,10 +469,6 @@ static int ctrl_cmd_new_server(struct sockaddr_qrtr *from, port = from->sq_port; } - /* Don't accept spoofed messages */ - if (from->sq_node != node_id) - return -EINVAL; - srv = server_add(service, instance, node_id, port); if (!srv) return -EINVAL; @@ -511,10 +507,6 @@ static int ctrl_cmd_del_server(struct sockaddr_qrtr *from, port = from->sq_port; } - /* Don't accept spoofed messages */ - if (from->sq_node != node_id) - return -EINVAL; - /* Local servers may only unregister themselves */ if (from->sq_node == qrtr_ns.local_node && from->sq_port != port) return -EINVAL; From patchwork Fri Nov 6 17:33:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 320807 Delivered-To: patch@linaro.org Received: by 2002:a17:906:d156:0:0:0:0 with SMTP id br22csp634164ejb; Fri, 6 Nov 2020 09:27:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJzSFE1zKOb5u8+5zm+vkbjvtG6btQsS0hn4FARK0B7vuypFY/4lwjMoc+qeRlJ1D1JWvgqb X-Received: by 2002:a17:906:4e99:: with SMTP id v25mr3052248eju.242.1604683634913; Fri, 06 Nov 2020 09:27:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604683634; cv=none; d=google.com; s=arc-20160816; b=qeqxyKm17qOKz7htJ1E/lEAIwXkUnTExvdooStqQD3boDCOd9utHwl+5iWBXhHO965 a/zT9ER1bwcNS0D01gWkEa+KQD276aWwhaT++UH8K2Ec7yI+wkZzgm/hcSRHrh5a7ul0 lYjudoczRolaMroc/LZwyGI/kBKqBepAd7CUq1Pf/WNDo9wHbMqLD2PI7q1iwUwn+X8I GAWeOpd9L7K+XifFClOt75fxJgrNnoyE7sLIFG3Wabg198gaI5tt1vcjCiUa8LyuP53X d/PRuDtRUMG1r3IrSbCvXkiMw+RlYQ4pqU1FvPbT3QjFEiUF9PS2CoyBY4Q4fn5UHiHG MXwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=D/092xNhzoeqWVzgOt31RyKE4UUHqVbbhKniatrDYRo=; b=t4n+dIkkZcbRknnqemH77BcLYRHQ1RpL+TKwLUoeQ7+6q8mFQj5KViabVE2Tvj7J1C XOCMqCdEOp3sILyKUKD/wZS3zBFTI0eV5F+nrZlCcF2sQJ528XyFsAnAExsOiQglEs+K AsPs6H/Ym1T1PWw3D02FJkAWok1+NDEubT9EycHnlxF5nPVLbcLENuwQHuLRtPeWSGPg hRGM1OSo5bgDTAWQX1zKrIps/1HiOsBHOt5PaOKczEPT+rjpBiHw+oS5AO1HG98/spBL zqnkXCkNCsCy834RcC2XMdhDUpI+69xKEqXSx6PLluTXtCquY/Y/ETlgbR94UtXOQrhT 51/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zl24+w2P; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id o17si1467882ejg.500.2020.11.06.09.27.14; Fri, 06 Nov 2020 09:27:14 -0800 (PST) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zl24+w2P; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 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 S1727610AbgKFR1O (ORCPT + 8 others); Fri, 6 Nov 2020 12:27:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726075AbgKFR1L (ORCPT ); Fri, 6 Nov 2020 12:27:11 -0500 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0527C0613CF for ; Fri, 6 Nov 2020 09:27:10 -0800 (PST) Received: by mail-wr1-x444.google.com with SMTP id w1so2130467wrm.4 for ; Fri, 06 Nov 2020 09:27:10 -0800 (PST) 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=D/092xNhzoeqWVzgOt31RyKE4UUHqVbbhKniatrDYRo=; b=zl24+w2P6aoxshLsh+1QU1x0CzQVDdjoH9oEaZ/ehcxJLK3hgvzHf61Swag23oCQ4k D9zvWGX2dMvIpQk1UiK28WQth1hiCyysURF0v7ooOu5IUCy03BGPmvpDrfECte1lW0JQ iplLJzx83969nmuJjVwz9aOlAeIkDVuGGR1wNP+6sBuBRzqJTYNoSLAU/FA9VcMwY0F3 k8lfy+5g3yXe9Wm7pRl0c9nQm81u4u99pIPAlMbCGMBxpRWjqJVQ5IsK0kc3xOPU0vLY B2oxihUKnLGlKUad+E/ZiWX6BX14MDpxna7M2J0T0ayzCFPxURODf2BKMS/2vdIY6eSD Vy+g== 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=D/092xNhzoeqWVzgOt31RyKE4UUHqVbbhKniatrDYRo=; b=EHh2fyQ+KqFEHN9AsTZHS1iJR9Plf3FTWo1yq2mAq7L5qd+PpJ+gkPicpFjBDp6ndL dpKbrkA/Q4ctI+lTn2uzxqBRDqIDfhbWjdGWSYt2ZIvru6rI33fjsGcYSewEv4seHFwC UDJRPluqhiYkDU47G4AU2VvOuIWUYuO+ZXw+m/ZyYTb3QDOlIup9jqsto8313Uvl+Oh2 6I9/JE3XfbXoaIXNgUSqUO6aebnMYRsVn17cDnah54K9D5kzqqENEknLdjabMnQpwbdj nUHFY3Di96OVzrfE1M7OGGJ43PMO8e4rYB97fznp9rTcdZjcJ3ASwAOByUJvFadUr8Ld 3UYQ== X-Gm-Message-State: AOAM5305rDVwGBkupRaZClHWimEakJo4e6X2raA413bk3ZxpPFbdVi57 tkg1pIa2n8otB21O+zCF4pSDSJTSI88AjI/QcNM= X-Received: by 2002:adf:e388:: with SMTP id e8mr3829229wrm.65.1604683629693; Fri, 06 Nov 2020 09:27:09 -0800 (PST) Received: from localhost.localdomain ([88.122.66.28]) by smtp.gmail.com with ESMTPSA id z191sm3183266wme.30.2020.11.06.09.27.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Nov 2020 09:27:09 -0800 (PST) From: Loic Poulain To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, manivannan.sadhasivam@linaro.org, cjhuang@codeaurora.org, netdev@vger.kernel.org, Loic Poulain Subject: [PATCH v2 3/5] net: qrtr: Allow non-immediate node routing Date: Fri, 6 Nov 2020 18:33:28 +0100 Message-Id: <1604684010-24090-4-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1604684010-24090-1-git-send-email-loic.poulain@linaro.org> References: <1604684010-24090-1-git-send-email-loic.poulain@linaro.org> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In order to reach non-immediate remote node services that are accessed through an intermediate node, the route to the remote node needs to be saved. E.g for a [node1 <=> node2 <=> node3] network - node2 forwards node3 service to node1 - node1 must save node2 as route for reaching node3 Signed-off-by: Loic Poulain Reviewed-by: Bjorn Andersson --- net/qrtr/qrtr.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index e09154b..1d12408 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -400,12 +400,13 @@ static void qrtr_node_assign(struct qrtr_node *node, unsigned int nid) { unsigned long flags; - if (node->nid != QRTR_EP_NID_AUTO || nid == QRTR_EP_NID_AUTO) + if (nid == QRTR_EP_NID_AUTO) return; spin_lock_irqsave(&qrtr_nodes_lock, flags); radix_tree_insert(&qrtr_nodes, nid, node); - node->nid = nid; + if (node->nid == QRTR_EP_NID_AUTO) + node->nid = nid; spin_unlock_irqrestore(&qrtr_nodes_lock, flags); } @@ -493,6 +494,13 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len) qrtr_node_assign(node, cb->src_node); + if (cb->type == QRTR_TYPE_NEW_SERVER) { + /* Remote node endpoint can bridge other distant nodes */ + const struct qrtr_ctrl_pkt *pkt = data + hdrlen; + + qrtr_node_assign(node, le32_to_cpu(pkt->server.node)); + } + if (cb->type == QRTR_TYPE_RESUME_TX) { qrtr_tx_resume(node, skb); } else { From patchwork Fri Nov 6 17:33:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 320808 Delivered-To: patch@linaro.org Received: by 2002:a17:906:d156:0:0:0:0 with SMTP id br22csp634189ejb; Fri, 6 Nov 2020 09:27:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJzRCA2Dyla8FVT+UiED2dCuu285qhaGF4UUtIokbtJvGfkvOXwIxp6FQ/jQFWVq4gLqJOJT X-Received: by 2002:a17:906:cd0f:: with SMTP id oz15mr3105994ejb.200.1604683637221; Fri, 06 Nov 2020 09:27:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604683637; cv=none; d=google.com; s=arc-20160816; b=VLzJ16srryzIkEujqos1tQZc34efyr5N5raLGK80kSl+tGueFLq1OC09wMdCYJO10J XgWsmvYCHXGovDrDDCsqt6JwMao9kTNnyZN81Qgt/RH7RQk3lvk+E15MSN5SscEbFQvj zaS1MzHWiwbAD2MECYrX9MRCIj5H5JddbU3U7Ji+z0ahOYIm1N8g/x/TcFqXBbE9jxcM nL06GuCITfkjVsbIVWlKRuri3cekd2m0pdmeJsA6VwTeLqdPsu3jITtCk1/zPepB+eMi GYQjVy7nCNlNbkI9aj25SRqDhy0UowsMly39Ob4a9n4np+yP1q43D9jgSORk3ISz5txB 8fcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=BgPP+PukmIJeeeHpQyjf3pHwgKSum317O3/VfpxC1MA=; b=d1sjh0+Ao/Xg7ad0OhER+Mrn3rzPUR/3QOEU8lvOheEQP2h6ec9JFG3gRB7UXF6yo+ wQ86ZKs6sCqyPZIOhcJmSuKW/smJPlheCa6wH05bMe+0+zox+cG7ygPW4b+7P3/D1evF a1DFCyggAhR108H3HjoBZiDTclFP5GI1WFJ0/cJzp66LAb+Z9y5FiiSs68IUKnA/4vqD W8uNARYOBeOUu05SXTyhcbel4bG/R6/kW63Jtgo/L59kqBIUpaQkSvZii5K1pURHbwpc JbXbCu1NbhZDZL3slEe8RSnerQScJsS+9xCUU5JWn9NdEiF+cjGGElpOL+0CAKcMxTJb iNDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PCxq6VGt; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id o17si1467882ejg.500.2020.11.06.09.27.17; Fri, 06 Nov 2020 09:27:17 -0800 (PST) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PCxq6VGt; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 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 S1727650AbgKFR1Q (ORCPT + 8 others); Fri, 6 Nov 2020 12:27:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726075AbgKFR1O (ORCPT ); Fri, 6 Nov 2020 12:27:14 -0500 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC6C7C0613CF for ; Fri, 6 Nov 2020 09:27:11 -0800 (PST) Received: by mail-wm1-x344.google.com with SMTP id p22so2203878wmg.3 for ; Fri, 06 Nov 2020 09:27:11 -0800 (PST) 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=BgPP+PukmIJeeeHpQyjf3pHwgKSum317O3/VfpxC1MA=; b=PCxq6VGtA8PPqFwrkym2E0+cW+qNLImrumBJDfB7bkthicxGoX3WEvi238fnON0555 iiHq8KqTIZVackziDqMJwYEa/bEmKC1JvZ9Zgr7LdjRLUu48ug8D0o2ceuK8/kZExZWb Dm+viBidjQZDtGG7e/IlpXbQQ9j+Yr3mtao/gh7ufA8MCE4R8L52befy8HWayFoXkEzX 636uu0CzaneWbeMYu8T8Ljt2HuurBPRYpoW96Wac7oY8JS0yTRZJgapVHRI/X9ppq9jz dqJFyHqzHL+DpuhdVujc0Jcrp26AwfLSqxaji/qI1tRXnsRIYeMyBllH3vlvDGXolCPA k42w== 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=BgPP+PukmIJeeeHpQyjf3pHwgKSum317O3/VfpxC1MA=; b=Fo/ixeyr7yD3Lotc2is7lXNr30F9YQvUrkwBOEOPJwE0/0I9CpUNCxBi64V3UX72ji kZB0j31fxkD8jF8mWr7fZCzPclMlX1iSVH2ag4F+WPVn2aKUVNOdRtBlzA0zt0XMny+l sTK3OHNQCehmL0To2F/HGvf985N7000TJfZuuYL/Gj5JKJSLIGygZZXpNLDBa5PpgsiQ z4CZyRixy6NeRoo5XiudXMvNruUwv3A1l7VMJBEibozaBsB617sMBvQWtItB2pZ+yKUF UD0Q22d8KURCLDiVgsdwiy1d+s+Vdt0L15hMj/JI3z7bV22eIiBBd0sDiCGqmo9fAvfu 159w== X-Gm-Message-State: AOAM531Pyz5vEjY7O/1gvA+Q+7vzcjnqfisaCPGSjh3rRPuFaOn2gr6B Cob1JRSIwFwsxS2tzdnk0Li4kA== X-Received: by 2002:a1c:1c1:: with SMTP id 184mr735400wmb.16.1604683630682; Fri, 06 Nov 2020 09:27:10 -0800 (PST) Received: from localhost.localdomain ([88.122.66.28]) by smtp.gmail.com with ESMTPSA id z191sm3183266wme.30.2020.11.06.09.27.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Nov 2020 09:27:10 -0800 (PST) From: Loic Poulain To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, manivannan.sadhasivam@linaro.org, cjhuang@codeaurora.org, netdev@vger.kernel.org, Loic Poulain Subject: [PATCH v2 4/5] net: qrtr: Add GFP flags parameter to qrtr_alloc_ctrl_packet Date: Fri, 6 Nov 2020 18:33:29 +0100 Message-Id: <1604684010-24090-5-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1604684010-24090-1-git-send-email-loic.poulain@linaro.org> References: <1604684010-24090-1-git-send-email-loic.poulain@linaro.org> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This will be requested for allocating control packet in atomic context. Signed-off-by: Loic Poulain --- net/qrtr/qrtr.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index 1d12408..a05d01e 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -526,18 +526,20 @@ EXPORT_SYMBOL_GPL(qrtr_endpoint_post); /** * qrtr_alloc_ctrl_packet() - allocate control packet skb * @pkt: reference to qrtr_ctrl_pkt pointer + * @flags: the type of memory to allocate * * Returns newly allocated sk_buff, or NULL on failure * * This function allocates a sk_buff large enough to carry a qrtr_ctrl_pkt and * on success returns a reference to the control packet in @pkt. */ -static struct sk_buff *qrtr_alloc_ctrl_packet(struct qrtr_ctrl_pkt **pkt) +static struct sk_buff *qrtr_alloc_ctrl_packet(struct qrtr_ctrl_pkt **pkt, + gfp_t flags) { const int pkt_len = sizeof(struct qrtr_ctrl_pkt); struct sk_buff *skb; - skb = alloc_skb(QRTR_HDR_MAX_SIZE + pkt_len, GFP_KERNEL); + skb = alloc_skb(QRTR_HDR_MAX_SIZE + pkt_len, flags); if (!skb) return NULL; @@ -606,7 +608,7 @@ void qrtr_endpoint_unregister(struct qrtr_endpoint *ep) mutex_unlock(&node->ep_lock); /* Notify the local controller about the event */ - skb = qrtr_alloc_ctrl_packet(&pkt); + skb = qrtr_alloc_ctrl_packet(&pkt, GFP_KERNEL); if (skb) { pkt->cmd = cpu_to_le32(QRTR_TYPE_BYE); qrtr_local_enqueue(NULL, skb, QRTR_TYPE_BYE, &src, &dst); @@ -663,7 +665,7 @@ static void qrtr_port_remove(struct qrtr_sock *ipc) to.sq_node = QRTR_NODE_BCAST; to.sq_port = QRTR_PORT_CTRL; - skb = qrtr_alloc_ctrl_packet(&pkt); + skb = qrtr_alloc_ctrl_packet(&pkt, GFP_KERNEL); if (skb) { pkt->cmd = cpu_to_le32(QRTR_TYPE_DEL_CLIENT); pkt->client.node = cpu_to_le32(ipc->us.sq_node); @@ -987,7 +989,7 @@ static int qrtr_send_resume_tx(struct qrtr_cb *cb) if (!node) return -EINVAL; - skb = qrtr_alloc_ctrl_packet(&pkt); + skb = qrtr_alloc_ctrl_packet(&pkt, GFP_KERNEL); if (!skb) return -ENOMEM; From patchwork Fri Nov 6 17:33:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 320809 Delivered-To: patch@linaro.org Received: by 2002:a17:906:d156:0:0:0:0 with SMTP id br22csp634199ejb; Fri, 6 Nov 2020 09:27:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJyr4KfrdBJn/Zj+w0HFfex6LR/vOXcvjn/Sx5DZJl5dPF8uQ2maQOCZEE6PuUSnl/wibsgE X-Received: by 2002:a17:906:cd0f:: with SMTP id oz15mr3106081ejb.200.1604683638462; Fri, 06 Nov 2020 09:27:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604683638; cv=none; d=google.com; s=arc-20160816; b=I52Ln+5Yy5WDjAyRz3MU3/gr8HmRaMB7t8tuCUWlmqdq1VrwCpeFk5Yl84Dr9b6nHm H36ZO3IbW6HyYGIWrySmgx9k7skWAqWvfRCiLcEyCj+DmhZmgmEnqOBc0/guKoleke+P 77DmuUdRIBjPdZUEH+lpAEXwrY/vvVGtAdumDiViBL2jql8FRVRurz9gSP1xplJUYrnb 0KhSrE6SXOw5sV8qTBHzo/kswc2x6doJPgMO4hj4IefMDP1/G/4ji5P7Yc2ozw1KF+bk hQiPs4SY/uldsfXRkktydaY1GwGg0ZHtkSMxGZCEAMJEckzPK4bh3QHiT0MiKfVjlWON 0AqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=ROEzAe/sLPA5fA0hNij4++X8IvwRuse1DwhhV1dL1IA=; b=SwgXnnP3LFCgLzlI/FmRXPFAKHnIWyMriACKiPnuQ0+21YAbDfQuKWMc3ThOHdp1o0 Tm4nzal3JQvnHfkYq5sli/yAB/3sq9joitk/e88sTe5wscsjkLwYsAPkEjEzwhL3bKmf dycqu8wA7uyVikDtDJlA4+SZPxJdU6YEVCSU0DNusJWMxP+d3Q9Y7714CxexIn6pQ/Gv 4Kq6KPGKUokis0Eovh8QThWdAnrBVXoxOrrOZGrw8mZttwhDDsBdj4bN6h164/PbS/fP Q8uI5+7G5qCXvYIGt6R7qrOS6zhpFN7BnoT7THmPn1dUWOo3QRsNhRcBlq9buwt9t17H +2QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Aj9sCfru; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id o17si1467882ejg.500.2020.11.06.09.27.18; Fri, 06 Nov 2020 09:27:18 -0800 (PST) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Aj9sCfru; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 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 S1727661AbgKFR1R (ORCPT + 8 others); Fri, 6 Nov 2020 12:27:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727628AbgKFR1P (ORCPT ); Fri, 6 Nov 2020 12:27:15 -0500 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82F11C0613D2 for ; Fri, 6 Nov 2020 09:27:13 -0800 (PST) Received: by mail-wm1-x342.google.com with SMTP id p19so1388015wmg.0 for ; Fri, 06 Nov 2020 09:27:13 -0800 (PST) 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=ROEzAe/sLPA5fA0hNij4++X8IvwRuse1DwhhV1dL1IA=; b=Aj9sCfruDoiES8GbsFf3IAZxh1VNH05bnur/n1+XPUrNn7HQK4qP8Sq8oQq5hDua1G 9HyNdX6AuIZEZ4EzQP0uxFqiq59l3y5T/8KpPB3fZhEmXYwHfKWs7pamBs2o59tlAsHY sCApK67aOF98E7qqDgR8ucKnO1SwTR0mzDaT8KZ3L12sNYCEHItK0L1ZCi/7WN2f5Xqw BFYi/gGp+BV61KKIjwwCrMM6XS058VT3zvweyjCZbU5U+vqnBOA67OOddsNMkAykQfnj DCrMQy0hCKOTY5hh7174HdzpkjP7FWmKZMnULjtyn9XJsPbhOVG0RJ1yxanR6XmfD3uO sVwg== 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=ROEzAe/sLPA5fA0hNij4++X8IvwRuse1DwhhV1dL1IA=; b=djq1d2VCe5H4FGLW28tfLNEm7P4f1bxLH7p+0DV3gTwFPjXM2kD7k9uz1put3eddet AP1i5hCeFzAnKUJL2zVn6IlWqHYK2llEyehUVzKxoar+ONCAk8uJ162/289aDsH9/eDI OrZ1FecJr7aU6Awfk1bPABu7wiy1FeH2SxeJwaPN55W6yOhxfrAI0how21dp6Xk9fmSp BOtgFmE+feO8T2UxMK/O5mp5r1D5i/pGCTRa0c5IB0ZzyaZCRCzR50XKwA8J/LVZy8Gl iDI7/n9T8VpBGcO8tytWN+ViTsI+H3+m22ei6QIJRDUwefbCHUiiJw9bZi0XUVa9fmgb nmJQ== X-Gm-Message-State: AOAM531Foo9ys42eYGycDnIi3XfoAOrRrkTik2zoBcYCijc6LNHuWiOa wec+b5kZXOSWCTkO4PF4vN/X0w== X-Received: by 2002:a1c:ba0b:: with SMTP id k11mr642838wmf.37.1604683632161; Fri, 06 Nov 2020 09:27:12 -0800 (PST) Received: from localhost.localdomain ([88.122.66.28]) by smtp.gmail.com with ESMTPSA id z191sm3183266wme.30.2020.11.06.09.27.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Nov 2020 09:27:11 -0800 (PST) From: Loic Poulain To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, manivannan.sadhasivam@linaro.org, cjhuang@codeaurora.org, netdev@vger.kernel.org, Loic Poulain Subject: [PATCH v2 5/5] net: qrtr: Release distant nodes along the bridge node Date: Fri, 6 Nov 2020 18:33:30 +0100 Message-Id: <1604684010-24090-6-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1604684010-24090-1-git-send-email-loic.poulain@linaro.org> References: <1604684010-24090-1-git-send-email-loic.poulain@linaro.org> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Distant QRTR nodes can be accessed via an other node that acts as a bridge. When the a QRTR endpoint associated to a bridge node is released, all the linked distant nodes should also be released. This patch fixes endpoint release by: - Submitting QRTR BYE message locally on behalf of all the nodes accessible through the endpoint. - Removing all the routable node IDs from radix tree pointing to the released node endpoint. Signed-off-by: Loic Poulain --- net/qrtr/qrtr.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index a05d01e..e361de5 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -171,8 +171,13 @@ static void __qrtr_node_release(struct kref *kref) void __rcu **slot; spin_lock_irqsave(&qrtr_nodes_lock, flags); - if (node->nid != QRTR_EP_NID_AUTO) - radix_tree_delete(&qrtr_nodes, node->nid); + /* If the node is a bridge for other nodes, there are possibly + * multiple entries pointing to our released node, delete them all. + */ + radix_tree_for_each_slot(slot, &qrtr_nodes, &iter, 0) { + if (*slot == node) + radix_tree_iter_delete(&qrtr_nodes, &iter, slot); + } spin_unlock_irqrestore(&qrtr_nodes_lock, flags); list_del(&node->item); @@ -601,6 +606,7 @@ void qrtr_endpoint_unregister(struct qrtr_endpoint *ep) struct qrtr_ctrl_pkt *pkt; struct qrtr_tx_flow *flow; struct sk_buff *skb; + unsigned long flags; void __rcu **slot; mutex_lock(&node->ep_lock); @@ -608,11 +614,18 @@ void qrtr_endpoint_unregister(struct qrtr_endpoint *ep) mutex_unlock(&node->ep_lock); /* Notify the local controller about the event */ - skb = qrtr_alloc_ctrl_packet(&pkt, GFP_KERNEL); - if (skb) { - pkt->cmd = cpu_to_le32(QRTR_TYPE_BYE); - qrtr_local_enqueue(NULL, skb, QRTR_TYPE_BYE, &src, &dst); + spin_lock_irqsave(&qrtr_nodes_lock, flags); + radix_tree_for_each_slot(slot, &qrtr_nodes, &iter, 0) { + if (*slot != node) + continue; + src.sq_node = iter.index; + skb = qrtr_alloc_ctrl_packet(&pkt, GFP_ATOMIC); + if (skb) { + pkt->cmd = cpu_to_le32(QRTR_TYPE_BYE); + qrtr_local_enqueue(NULL, skb, QRTR_TYPE_BYE, &src, &dst); + } } + spin_unlock_irqrestore(&qrtr_nodes_lock, flags); /* Wake up any transmitters waiting for resume-tx from the node */ mutex_lock(&node->qrtr_tx_lock);