From patchwork Mon Mar 2 03:25:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 11414643 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 01E0317E0 for ; Mon, 2 Mar 2020 03:27:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D5657246B7 for ; Mon, 2 Mar 2020 03:27:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="PRCfvcTK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726896AbgCBD0z (ORCPT ); Sun, 1 Mar 2020 22:26:55 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:44851 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726876AbgCBD0y (ORCPT ); Sun, 1 Mar 2020 22:26:54 -0500 Received: by mail-pl1-f195.google.com with SMTP id d9so3612506plo.11 for ; Sun, 01 Mar 2020 19:26:54 -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 :mime-version:content-transfer-encoding; bh=VeICtnOsZ2C5UP5Em+E/sXna3uaGHm7TKk8BxzBI+6c=; b=PRCfvcTKS2HCaAnNmLkIU9dpR+IRiKEYs54u4SfzV8eq05wetWOkMMYjEYBqLw/ZSI zrhpJHUnqAljml0yrq25fP+Wcqv0AZ3fQCOpIDBhS3d0S/W9KKFxU+MLyoW28s3h88Ru XdeIJs+kwZ2+eZu6KTUvJy7B+uMx6qvyeyucRiG5lvzngBFV7lcP89+iCoPxGnzzXZNx SQUqiIEUFc0YbAl0pcvv9x3FXN2r5/jXT1OvZpOnksVaPJaXSocW+VWlBvVBg3KvFBCn jFDOb6lq2jS0N91ltnoZ1w5dcSdliX6khAwlvO3XDxJYSFdBU9FaoGPYDb6DMmmf2ITS oAfA== 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:mime-version:content-transfer-encoding; bh=VeICtnOsZ2C5UP5Em+E/sXna3uaGHm7TKk8BxzBI+6c=; b=LU9ZDaD4E9WXQGCm8W+AhQfEFha7uptF2yxC6XZrM5aKMD5IiMhXhFzlRiSRcyEeOs uDlZ2hgssPseNdBkTSdSnEK9qgip7pRo0b0Ad4bnsGzmwHIxMlrm0XNW+QDnXMdl29We VFhE71bJZCGV+W1VXgL/CwmY89dv3uv2DRZJHY/+/2bCH0ljMFUBHuNTUwkl4xKm2zBW OHnBgOYX+FWMglH9VIWmVNH1IlaNW83m+SxUekrG7o2nKlV09wLvj28VuW3TCwEbEpMP p9JZtf22YnJPHqLWduyX5YSOmJhp5vS/7WZfhhuxgy7ietpUNH45S8twyE3nxUcYQ7rw wdGQ== X-Gm-Message-State: APjAAAVkBKXN/59ioatFyWDMWhG4wK4peAMwMxZOh/pQWQbqS8wnSIjB ppH+CQLbjsOiiUM+8jgi7jIKSg== X-Google-Smtp-Source: APXvYqxz7ZRhAo30RgCJ0M6uHAeTharsKZmdDEpo9bJKkn4vD/2LpuP8aWsjqSxdJvmzQEOiID2aJA== X-Received: by 2002:a17:902:a715:: with SMTP id w21mr16079228plq.244.1583119613461; Sun, 01 Mar 2020 19:26:53 -0800 (PST) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id b133sm18435739pga.43.2020.03.01.19.26.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 19:26:52 -0800 (PST) From: Bjorn Andersson To: "David S. Miller" , Jakub Kicinski , Manivannan Sadhasivam Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 1/2] net: qrtr: Respond to HELLO message Date: Sun, 1 Mar 2020 19:25:26 -0800 Message-Id: <20200302032527.552916-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200302032527.552916-1-bjorn.andersson@linaro.org> References: <20200302032527.552916-1-bjorn.andersson@linaro.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Lost in the translation from the user space implementation was the detail that HELLO mesages must be exchanged between each node pair. As such the incoming HELLO must be replied to. Similar to the previous implementation no effort is made to prevent two Linux boxes from continuously sending HELLO messages back and forth, this is left to a follow up patch. say_hello() is moved, to facilitate the new call site. Fixes: 0c2204a4ad71 ("net: qrtr: Migrate nameservice to kernel from userspace") Signed-off-by: Bjorn Andersson Reviewed-by: Manivannan Sadhasivam Tested-by: Manivannan Sadhasivam --- net/qrtr/ns.c | 54 ++++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/net/qrtr/ns.c b/net/qrtr/ns.c index 7bfde01f4e8a..e3f11052b5f6 100644 --- a/net/qrtr/ns.c +++ b/net/qrtr/ns.c @@ -286,9 +286,38 @@ static int server_del(struct qrtr_node *node, unsigned int port) return 0; } +static int say_hello(struct sockaddr_qrtr *dest) +{ + struct qrtr_ctrl_pkt pkt; + struct msghdr msg = { }; + struct kvec iv; + int ret; + + iv.iov_base = &pkt; + iv.iov_len = sizeof(pkt); + + memset(&pkt, 0, sizeof(pkt)); + pkt.cmd = cpu_to_le32(QRTR_TYPE_HELLO); + + msg.msg_name = (struct sockaddr *)dest; + msg.msg_namelen = sizeof(*dest); + + ret = kernel_sendmsg(qrtr_ns.sock, &msg, &iv, 1, sizeof(pkt)); + if (ret < 0) + pr_err("failed to send hello msg\n"); + + return ret; +} + /* Announce the list of servers registered on the local node */ static int ctrl_cmd_hello(struct sockaddr_qrtr *sq) { + int ret; + + ret = say_hello(sq); + if (ret < 0) + return ret; + return announce_servers(sq); } @@ -566,29 +595,6 @@ static void ctrl_cmd_del_lookup(struct sockaddr_qrtr *from, } } -static int say_hello(void) -{ - struct qrtr_ctrl_pkt pkt; - struct msghdr msg = { }; - struct kvec iv; - int ret; - - iv.iov_base = &pkt; - iv.iov_len = sizeof(pkt); - - memset(&pkt, 0, sizeof(pkt)); - pkt.cmd = cpu_to_le32(QRTR_TYPE_HELLO); - - msg.msg_name = (struct sockaddr *)&qrtr_ns.bcast_sq; - msg.msg_namelen = sizeof(qrtr_ns.bcast_sq); - - ret = kernel_sendmsg(qrtr_ns.sock, &msg, &iv, 1, sizeof(pkt)); - if (ret < 0) - pr_err("failed to send hello msg\n"); - - return ret; -} - static void qrtr_ns_worker(struct work_struct *work) { const struct qrtr_ctrl_pkt *pkt; @@ -725,7 +731,7 @@ void qrtr_ns_init(struct work_struct *work) if (!qrtr_ns.workqueue) goto err_sock; - ret = say_hello(); + ret = say_hello(&qrtr_ns.bcast_sq); if (ret < 0) goto err_wq; From patchwork Mon Mar 2 03:25:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 11414641 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2C10C17E0 for ; Mon, 2 Mar 2020 03:26:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0B2AC246B6 for ; Mon, 2 Mar 2020 03:26:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="RqwOLPE/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726925AbgCBD04 (ORCPT ); Sun, 1 Mar 2020 22:26:56 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:43611 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726901AbgCBD0z (ORCPT ); Sun, 1 Mar 2020 22:26:55 -0500 Received: by mail-pg1-f195.google.com with SMTP id u12so4686917pgb.10 for ; Sun, 01 Mar 2020 19:26:55 -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 :mime-version:content-transfer-encoding; bh=2IJ6v+vBNAPNbMMvS1O0Ku5Q+LCCSOnxCLcdXHEwvh4=; b=RqwOLPE/Bcg/5dpKgcIGb0cBoPI1lDtuMOdwJkQBykhfwHqDhUqvi++NUZKQQfGN2n CUOdspMkhrJYrkI4672F7G/e0wEZ40nxUi17EbG4EQur6NgQyOmPM8csIp+SSAF5yMuy rJTkL88qe+XYlD5akQ28h4/xvz45WmaU+jwnqlBnElSUp7zLNOaYAgnVefgB9goN+ima eJTY6BtxLfyI0nxO+g2OAClpjYJ9clmQSa8rRE1XgWIC4qrW7SRDdBF5zIlJq66CtkOM YuOyj1YPcT+vejzqjOyM0/c1p59hAvsoDgsf67p9ySttKgq+myv1dOUPVSYrdB4VXTgQ Wfzg== 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:mime-version:content-transfer-encoding; bh=2IJ6v+vBNAPNbMMvS1O0Ku5Q+LCCSOnxCLcdXHEwvh4=; b=BglJ9s1WkT4pJ16NCrAaSVnPuMT1SQ3gIEyERKoG0rflIAfW5SBHf13jGM0GepZ33I t6AB0wf5l+R1Hr9ItLTK9ejXQ/KCgBqHIBh2F8I5MhHKeoHc/MVPqi3IbeR4OsnTWl12 xin1ft3UpBj9SnLcukB/q0nRKdJVqezUZkZAXUj7wGll/m2Ltx3rEEZJx5EAR+DWmt4C cHYasEUoAMaJl3hVdyYML9P2z4mVoOc5PHUB50aQlQ+lO2IFc7lI6TIUcftfOm6E+poy uuu0DFDwj8SdM0TnLUrY8whH/O9Kn2oVLd/Ydcac9nMSujaWtOrYe+CCZymy4i1SKDG/ yLBg== X-Gm-Message-State: ANhLgQ2jCdBv74ForadtSuymR8cl+7eCFXARy8drvUttq9IgO6PMwfdq a0xTBXCZ8/IS88hrEW/3dGkxJQ== X-Google-Smtp-Source: ADFU+vsXk1eNu6nmXqw059tsROHTcg802qKJUw3BfLPuhaRNKqHg8tl6eNtdCUaTd4boNQ0QmypMmA== X-Received: by 2002:a63:c850:: with SMTP id l16mr4109458pgi.290.1583119614697; Sun, 01 Mar 2020 19:26:54 -0800 (PST) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id b133sm18435739pga.43.2020.03.01.19.26.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 19:26:54 -0800 (PST) From: Bjorn Andersson To: "David S. Miller" , Jakub Kicinski , Manivannan Sadhasivam Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 2/2] net: qrtr: Fix FIXME related to qrtr_ns_init() Date: Sun, 1 Mar 2020 19:25:27 -0800 Message-Id: <20200302032527.552916-3-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200302032527.552916-1-bjorn.andersson@linaro.org> References: <20200302032527.552916-1-bjorn.andersson@linaro.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The 2 second delay before calling qrtr_ns_init() meant that the remote processors would register as endpoints in qrtr and the say_hello() call would therefor broadcast the outgoing HELLO to them. With the HELLO handshake corrected this delay is no longer needed. Signed-off-by: Bjorn Andersson Reviewed-by: Manivannan Sadhasivam Tested-by: Manivannan Sadhasivam --- net/qrtr/ns.c | 2 +- net/qrtr/qrtr.c | 6 +----- net/qrtr/qrtr.h | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/net/qrtr/ns.c b/net/qrtr/ns.c index e3f11052b5f6..cfd4bd07a62b 100644 --- a/net/qrtr/ns.c +++ b/net/qrtr/ns.c @@ -693,7 +693,7 @@ static void qrtr_ns_data_ready(struct sock *sk) queue_work(qrtr_ns.workqueue, &qrtr_ns.work); } -void qrtr_ns_init(struct work_struct *work) +void qrtr_ns_init(void) { struct sockaddr_qrtr sq; int ret; diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index 423310896285..313d3194018a 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -1263,11 +1263,7 @@ static int __init qrtr_proto_init(void) return rc; } - /* FIXME: Currently, this 2s delay is required to catch the NEW_SERVER - * messages from routers. But the fix could be somewhere else. - */ - INIT_DELAYED_WORK(&qrtr_ns_work, qrtr_ns_init); - schedule_delayed_work(&qrtr_ns_work, msecs_to_jiffies(2000)); + qrtr_ns_init(); return rc; } diff --git a/net/qrtr/qrtr.h b/net/qrtr/qrtr.h index 53a237a28971..dc2b67f17927 100644 --- a/net/qrtr/qrtr.h +++ b/net/qrtr/qrtr.h @@ -29,7 +29,7 @@ void qrtr_endpoint_unregister(struct qrtr_endpoint *ep); int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len); -void qrtr_ns_init(struct work_struct *work); +void qrtr_ns_init(void); void qrtr_ns_remove(void);