From patchwork Thu Oct 5 03:50:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 114839 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp144280qgn; Wed, 4 Oct 2017 20:53:16 -0700 (PDT) X-Received: by 10.101.67.201 with SMTP id n9mr20963987pgp.453.1507175595977; Wed, 04 Oct 2017 20:53:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507175595; cv=none; d=google.com; s=arc-20160816; b=csHv1EkJmkjdn5bRwZVWaA5BLrDlXHxhuPQBwSnTtWPOM4RbCo6q3IKifGXS5ZHHR7 0Ax4B/5/RbpIlg5tcUVAq+YXVxtumPWLKTyuDwy/SyNQGQQTYIckmls4Fte+DCfiQLwV ANRWf7qF+sl9plGL6/3b4lCW3wBFa5rSVPTGW4SHl471l3Z+UFUxbt4NSuKtjRx1SWZs FxJrAWnf4W3110vFlDOEnS9asPx4B5tVnPjuisohzTVolCTPGejSIel1HdZeX2Bvvc+X ohcHtU9btQbYlZkVwfZyyVYvEkcm0qp52Y4bDglHWzCAenh69p4mjGdDDl659fZQ8xho V2Aw== 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=pe0Jh3CwiTp5SnyNs/m5/YaMLQuCFoTgalo/e1k5T/c=; b=v7LqoHPcDrW39DuTGiE6uHY4+BzmLFskpVrwZTIDohmjVsiM81TOMyvsgGMNPZcTM+ D5/FcgaP9sGTcd9hwHd2oBIQGKdMYocwxtEvantZShdqvAiBjimCjBN6AsP52ZNlJBwg vKoVlq0IEUpmGuIo9MPb+eU+TaDyuNptdtDHUuWZROFREfNaC9vb9u8BuP7caGKSoZiS bQyF0fmCQc0A7upmfwgNUwcr0cV4UYKIHgI4LOvQyQLiNDwRv03MI0QvE0MaQBNHKKsN PBypLumkQFw4/BEoxTbT5VLQT5ANA37vHaOKcn7jIoXQgI0ETP5O/BVLwbNsJG3BRGFY 5zvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WW6UcpA1; 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 e23si1710017pfd.376.2017.10.04.20.53.15; Wed, 04 Oct 2017 20:53:15 -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 header.s=google header.b=WW6UcpA1; 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 S1751852AbdJEDvP (ORCPT + 26 others); Wed, 4 Oct 2017 23:51:15 -0400 Received: from mail-pg0-f54.google.com ([74.125.83.54]:47734 "EHLO mail-pg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751731AbdJEDvL (ORCPT ); Wed, 4 Oct 2017 23:51:11 -0400 Received: by mail-pg0-f54.google.com with SMTP id r25so5230605pgn.4 for ; Wed, 04 Oct 2017 20:51:11 -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=pe0Jh3CwiTp5SnyNs/m5/YaMLQuCFoTgalo/e1k5T/c=; b=WW6UcpA1MrciJCh0jCzn8lVBPHqqsG05FKUeXnWuZkLpTzeXRMwnYjxTgpQTc+P3nl tjruC5R52LM6xYzDsVgx3NJ2JdNiOODK4dX5bSjJcFCeAdQtZP85Cc9HL6sNQ4SGZLUK p/OdU+U7pUurvSWBlxJa/GMEksuv+siT6BVrY= 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=pe0Jh3CwiTp5SnyNs/m5/YaMLQuCFoTgalo/e1k5T/c=; b=e9YP2IfSVSkuw709DdRRNZs1Vn2Fs69/PZ9oZlLnhk6LLGKL9xqWe5GX5BwKLM7xsj PzpubIHU2mVyJ29NslTojeqNKpHymzBgth8Rl/L2vwa/tGYWFqIsE7+aoI5ysvjwdkWB 4pNLnGOdKsXT6swreo9z2OkGz5XIxBIxwVSaWZ7KxXY4210e2qjHVc24cNQi/gop26Mi Rmm98suyYpmXAb9xWdHfntLJWN5YJH+79rNEkpNGK9n47ZhKwF8fdacZ+kaYZih7LOXn Sozs87DVSlU5pdrTnXpKWCDmoUh5bi8KqkwrcScs37iHk1DNQ0wiLF4abEznvUuy1MnH cZQw== X-Gm-Message-State: AMCzsaVHMsgcAueJ6SK0gBTLpwNXLSPLaLF1lJ5gP7YdRAuZdVP4Kno4 zqE9Eu8stHAuDkPytzmYBH0LGvfAGzU= X-Google-Smtp-Source: AOwi7QBTSj9xWSXfpXkH4EKYMKasxIb0iTSM4WMbDzl5+0xXxEDXQcqiEnbrAmNrgc/zn9Lrv2ugXA== X-Received: by 10.101.74.193 with SMTP id c1mr3494091pgu.260.1507175470668; Wed, 04 Oct 2017 20:51:10 -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 f131sm13067035pfc.27.2017.10.04.20.51.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Oct 2017 20:51:10 -0700 (PDT) From: Bjorn Andersson To: "David S. Miller" Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Chris Lew Subject: [RESEND PATCH 1/7] net: qrtr: Invoke sk_error_report() after setting sk_err Date: Wed, 4 Oct 2017 20:50:59 -0700 Message-Id: <20171005035105.14677-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20171005035105.14677-1-bjorn.andersson@linaro.org> References: <20171005035105.14677-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rather than manually waking up any context sleeping on the sock to signal an error we should call sk_error_report(). This has the added benefit that in-kernel consumers can override this notification with its own callback. Signed-off-by: Bjorn Andersson --- net/qrtr/qrtr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.12.0 diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index c2f5c13550c0..7e4b49a8349e 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -541,7 +541,7 @@ static void qrtr_reset_ports(void) sock_hold(&ipc->sk); ipc->sk.sk_err = ENETRESET; - wake_up_interruptible(sk_sleep(&ipc->sk)); + ipc->sk.sk_error_report(&ipc->sk); sock_put(&ipc->sk); } mutex_unlock(&qrtr_port_lock); From patchwork Thu Oct 5 03:51: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: 114833 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp143192qgn; Wed, 4 Oct 2017 20:51:21 -0700 (PDT) X-Received: by 10.98.10.133 with SMTP id 5mr2557421pfk.346.1507175481200; Wed, 04 Oct 2017 20:51:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507175481; cv=none; d=google.com; s=arc-20160816; b=OhO8ZyHBWWMBdQ6yBwHxcRhA40uHlf9dyob4+cqy6iUejROYUUPyyVY77xAqXcWSWk Bu/FppirR0fzfVpEOfeJQJOS6YqmmDFl8agIF8JPqwm8paPZaQWrN1AGzVLPDw1Bu7LC H82IC+Xr1LcMPUiHK+dfCNnJ7fFu8q5Qn3zCoppXlkdrajz1aU9uhE5mMcU75r2Dqrqe Du4ZJJh1jBjKJtJIhzsa5ocn+DfNJO6q2rmc+KOPKkXPUluFgKOW6srAO9xor/UJZe9b mvmq6J3O0R9gfWQe7pdSjnsRPqhSPKkGy9mTuLG6i/3NHyPWn/dcuNzl2ZA3fGoYbQzl qmmg== 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=I3+wLQUTTKXeXsm1RKsoIbI7bc5Ci+3c8A7LtHn1WvM=; b=hI0U/sTWhiVR1lGup3GoJUd1BsE9gt/LHOuTlZy44AqZsF0I/ttmlOJqY06CxMmzjA RjpTi7Wbd++uOgXw6jm51ttEaSZ19jdeXTyABKY8qxvVPOdXWpz//nbRDpMasFM4BzgX fYp0TDv7vNSniLwL8jYB8Tw1ey+bp0BVEg2C3Kg0Iaf8GTsvPvi3a2hmFyWIZADeJrtx OGqlAiZRdNTildXNuT60B/sL2kjaI13LNDLplXwzEqulRNaQDl0A0JQMtxuy3JGTHVAr Xjy9e7d2PhdOQg0PWxDNNzOorK20t38HoPdClFT7e5jn5LcDd6nWy7ndLCyO2u2Tpc1l qJgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iceLVqJ7; 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 y7si7273996pfy.222.2017.10.04.20.51.20; Wed, 04 Oct 2017 20:51:21 -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 header.s=google header.b=iceLVqJ7; 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 S1751942AbdJEDvS (ORCPT + 26 others); Wed, 4 Oct 2017 23:51:18 -0400 Received: from mail-pf0-f176.google.com ([209.85.192.176]:50445 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751746AbdJEDvM (ORCPT ); Wed, 4 Oct 2017 23:51:12 -0400 Received: by mail-pf0-f176.google.com with SMTP id m63so7323765pfk.7 for ; Wed, 04 Oct 2017 20:51:12 -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=I3+wLQUTTKXeXsm1RKsoIbI7bc5Ci+3c8A7LtHn1WvM=; b=iceLVqJ7QWFOvKJ2xoS0uapbT22dDZZzZX6bRD4/pr7pPWrOeA5NpPrrX5J4QCqJjz 9f1WifMY9KovsueyNVC/XB5mXUyKeO2jhUofOjx8FHCYG3RSM0VNP+WdZxxMKUF11DDD bh9IQpKTZH+8vwNLaRQKNBeDQ7C3Tp4X2RXwE= 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=I3+wLQUTTKXeXsm1RKsoIbI7bc5Ci+3c8A7LtHn1WvM=; b=d631KGvqLVY6FkAJrR6wuxcDbetCJd44oT6U2Lb0hSpbV7bmyubGLh+iLXwJMoTeem URERDyKEW3bSmRNoBOF8FgPUFBVZHI8ybfA5QKqK3w/4N8ynkdZshH+TyYfYyo3VRIp0 p83bxJtkIc6HENuovn1zkUJf8X+V1ETAhJbAsIfCwXP5zaAxlGGR64Wxq/KqjecmftX0 zt7F35ScKupyWqdxCc7PgRVsciFrUjAJGobvpDEP9/Slu1/08H08o8GuVMOZc4XPR6Xt jwfhlJJFCUxa5U/H3Y6rUKPQtBcq2yk3PVrI/u/r3pgdLjjoJUfZ+BmkFleMO8KcoNrw UfDA== X-Gm-Message-State: AHPjjUh0/rCI1IS2QdI9DGbtdzJLfoVFdvejEc8u4BUMsUgF24hbx259 AKAnMb4dD+kL37GF7WGlVYsbcg== X-Google-Smtp-Source: AOwi7QCx8Rpl8CkDwcojbjwn3iE3POorjnT9+kxyiIPKyhhCZbzk2fpgMoUmgwXC3E4ro1CIcb3miQ== X-Received: by 10.98.71.20 with SMTP id u20mr21811432pfa.23.1507175471826; Wed, 04 Oct 2017 20:51:11 -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 f131sm13067035pfc.27.2017.10.04.20.51.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Oct 2017 20:51:11 -0700 (PDT) From: Bjorn Andersson To: "David S. Miller" Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Chris Lew Subject: [RESEND PATCH 2/7] net: qrtr: Move constants to header file Date: Wed, 4 Oct 2017 20:51:00 -0700 Message-Id: <20171005035105.14677-3-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20171005035105.14677-1-bjorn.andersson@linaro.org> References: <20171005035105.14677-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The constants are used by both the name server and clients, so clarify their value and move them to the uapi header. Signed-off-by: Bjorn Andersson --- include/uapi/linux/qrtr.h | 3 +++ net/qrtr/qrtr.c | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) -- 2.12.0 diff --git a/include/uapi/linux/qrtr.h b/include/uapi/linux/qrtr.h index 9d76c566f66e..63e8803e4d90 100644 --- a/include/uapi/linux/qrtr.h +++ b/include/uapi/linux/qrtr.h @@ -4,6 +4,9 @@ #include #include +#define QRTR_NODE_BCAST 0xffffffffu +#define QRTR_PORT_CTRL 0xfffffffeu + struct sockaddr_qrtr { __kernel_sa_family_t sq_family; __u32 sq_node; diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index 7e4b49a8349e..15981abc042c 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -61,8 +61,6 @@ struct qrtr_hdr { } __packed; #define QRTR_HDR_SIZE sizeof(struct qrtr_hdr) -#define QRTR_NODE_BCAST ((unsigned int)-1) -#define QRTR_PORT_CTRL ((unsigned int)-2) struct qrtr_sock { /* WARNING: sk must be the first member */ From patchwork Thu Oct 5 03:51: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: 114840 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp144427qgn; Wed, 4 Oct 2017 20:53:32 -0700 (PDT) X-Received: by 10.98.112.68 with SMTP id l65mr22166153pfc.292.1507175612370; Wed, 04 Oct 2017 20:53:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507175612; cv=none; d=google.com; s=arc-20160816; b=kTyB+okALktySlYR+wZPKy5Lhx4TDg0PgCSM1NLJj6QH+q7LZx5XKgDDQxspUL0Pat +bspUDM18pPSfB4VfiiGZSBgRO19cuS4ZZWMXBI2O54F/TRx4Hz+CSo75Rdy4/nS7kRN +CtGSeq1pji+zQ3iPLmGZfBHaYF5CR8hwuMdVHV9kribzOVYIclZ9oA6NZGrcPLr7mpH 2/EyGe42yWuvjMfisiCiUOOYl5N7e9Uv5wBMvRhQgLwPM5OcIedZwhtL0tHXTt+CtpBM /HbngeokCZYC6NKhvU+WQisrTWv+4EpmsLHnEN6WUdVMqBy+1qZ7/pfRuHFZufC5pX9l Bq1g== 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=uLExGBSH7Dps53dK8UxEmGQp0eRFBkQVI9UT5i0dQDA=; b=ooifN+LGFRsR7CewN8uRAbfSZSrRAXWk3/SZIeACLC3omcC+jpSJu2Ya8wbfYAC0Bu 74+zxj84FiF7cwAKq/Cdbo/J82jJy/rdxZRdHi6sbUX6CiEs3ut/g9XdmvrGO8crnKXO Eg76DJq1NOTNlD9oCihzLjsqHPXbpqK+CeV2LADsBmLOW6B1+otRAcIkoaxLil191Ucj g7BOlLdqsNC+ofSK/nMQy41tuR4hGa97NIqWJhizmPvOuNQZuwHvupy27EwxQgeinT0D cgOw0Nzw5otLmfF0MEtweER9IFQpCSfoN5fAnrOy5yDl0Ty079JUDiPnF22YV/2JxA80 1RGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KR8zGaUp; 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 b8si12789519pls.479.2017.10.04.20.53.32; Wed, 04 Oct 2017 20:53:32 -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 header.s=google header.b=KR8zGaUp; 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 S1752027AbdJEDxb (ORCPT + 26 others); Wed, 4 Oct 2017 23:53:31 -0400 Received: from mail-pf0-f182.google.com ([209.85.192.182]:57026 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751785AbdJEDvN (ORCPT ); Wed, 4 Oct 2017 23:51:13 -0400 Received: by mail-pf0-f182.google.com with SMTP id g65so7312644pfe.13 for ; Wed, 04 Oct 2017 20:51:13 -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=uLExGBSH7Dps53dK8UxEmGQp0eRFBkQVI9UT5i0dQDA=; b=KR8zGaUp1tQc7r44inHRE286jwhyHjKRas1T7klnqJAmcyaUc/QO56Qxu4ZN1qW8Zc 9/SZGW9B9DCCzxWVaMABn5fyBYsJJvT//EwisDsFPKB34RqrKhGGyhap0hE119qPNeBC KjgPf1CuTW0cEuIZLsUmEJ86f1lFwUycduUWg= 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=uLExGBSH7Dps53dK8UxEmGQp0eRFBkQVI9UT5i0dQDA=; b=q6zpmwpBKuMCZm5YI+tjqEn7zl8dRXA8hh3CS89vIHXboeb0KTTLjKaeKyJIbPtXdW GxTTJ2khf1C5iDA8JChJTEzGj9v37p3PUGqS3ibpZ8zIt/fCbjemwiuLcCppS/Bul0Vl wideynTTrgVh12dm555+i7BI/qPouc1mitZlyZKEMvMC6Bm4rup0s5a5XYEsKju8wUFU W/QoyvKzm00MmNcmajnEfF2Vf/jJm1qGVEP+XAG1jCagR/v4QPohtfaNfKUw4YYs2vH/ uznrc7ShpujLt2WYfdk7/KHZEkpMhnwXa59ZGXwzRkGA3vbu2njvxJH5wiPMEaRsBrjK Ey0Q== X-Gm-Message-State: AMCzsaVt1ARU0GAJprO1z1lT1sCLEuF9TAkJSWmZ4JjdaGmHXPxi49bH 9cCSPTtBxO4bVs8vyT7eJq7xTg== X-Google-Smtp-Source: AOwi7QB7mG7pPhIuzIqcE6VB6pwRfUGwvKHrL4lJdHnnLGpsa5Ee9NLMMTp86449I8yH25j9JlgSCw== X-Received: by 10.84.218.200 with SMTP id g8mr12374070plm.23.1507175472999; Wed, 04 Oct 2017 20:51:12 -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 f131sm13067035pfc.27.2017.10.04.20.51.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Oct 2017 20:51:12 -0700 (PDT) From: Bjorn Andersson To: "David S. Miller" Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Chris Lew Subject: [RESEND PATCH 3/7] net: qrtr: Add control packet definition to uapi Date: Wed, 4 Oct 2017 20:51:01 -0700 Message-Id: <20171005035105.14677-4-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20171005035105.14677-1-bjorn.andersson@linaro.org> References: <20171005035105.14677-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The QMUX protocol specification defines structure of the special control packet messages being sent between handlers of the control port. Add these to the uapi header, as this structure and the associated types are shared between the kernel and all userspace handlers of control messages. Signed-off-by: Bjorn Andersson --- include/uapi/linux/qrtr.h | 32 ++++++++++++++++++++++++++++++++ net/qrtr/qrtr.c | 12 ------------ 2 files changed, 32 insertions(+), 12 deletions(-) -- 2.12.0 diff --git a/include/uapi/linux/qrtr.h b/include/uapi/linux/qrtr.h index 63e8803e4d90..179af64846e0 100644 --- a/include/uapi/linux/qrtr.h +++ b/include/uapi/linux/qrtr.h @@ -13,4 +13,36 @@ struct sockaddr_qrtr { __u32 sq_port; }; +enum qrtr_pkt_type { + QRTR_TYPE_DATA = 1, + QRTR_TYPE_HELLO = 2, + QRTR_TYPE_BYE = 3, + QRTR_TYPE_NEW_SERVER = 4, + QRTR_TYPE_DEL_SERVER = 5, + QRTR_TYPE_DEL_CLIENT = 6, + QRTR_TYPE_RESUME_TX = 7, + QRTR_TYPE_EXIT = 8, + QRTR_TYPE_PING = 9, + QRTR_TYPE_NEW_LOOKUP = 10, + QRTR_TYPE_DEL_LOOKUP = 11, +}; + +struct qrtr_ctrl_pkt { + __le32 cmd; + + union { + struct { + __le32 service; + __le32 instance; + __le32 node; + __le32 port; + } server; + + struct { + __le32 node; + __le32 port; + } client; + }; +} __packed; + #endif /* _LINUX_QRTR_H */ diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index 15981abc042c..d85ca7170b8f 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -26,18 +26,6 @@ #define QRTR_MIN_EPH_SOCKET 0x4000 #define QRTR_MAX_EPH_SOCKET 0x7fff -enum qrtr_pkt_type { - QRTR_TYPE_DATA = 1, - QRTR_TYPE_HELLO = 2, - QRTR_TYPE_BYE = 3, - QRTR_TYPE_NEW_SERVER = 4, - QRTR_TYPE_DEL_SERVER = 5, - QRTR_TYPE_DEL_CLIENT = 6, - QRTR_TYPE_RESUME_TX = 7, - QRTR_TYPE_EXIT = 8, - QRTR_TYPE_PING = 9, -}; - /** * struct qrtr_hdr - (I|R)PCrouter packet header * @version: protocol version From patchwork Thu Oct 5 03:51:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 114838 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp143801qgn; Wed, 4 Oct 2017 20:52:27 -0700 (PDT) X-Received: by 10.84.235.7 with SMTP id o7mr21254795plk.163.1507175547720; Wed, 04 Oct 2017 20:52:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507175547; cv=none; d=google.com; s=arc-20160816; b=DSYbeQIbSzZp4lWGc4mMHsujJTk22CGWWpcJgJTzwP+luTGQ6xb52XbZTS/roYrca0 vq+QFMFMhZK1XwAAHk8qtmaG+sxybgYn6PC9H0GRv2FJy9zpVIP74CSX9E7isGk9a10T wm6c72whbHcCd0NL2uEkJXDUFcqjtsfW7z5Aanwrbmz1rmipOwLy+5pXMtGmvy2uAAZr Y6OUUr9UAS/VE/XFym4aroFeW9g1GpY1NdAJ1UIgZ+/s2HT2mi2JXJ0etQ//6fscsGGZ 2fqMgpBuAFYIxSMbe770E4lmasEwjZ03HxH09fUxD+XxyNyrXPNX7ch45Cr6IrQxMkXU YdYA== 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=TP1EfqGEfPlEmtf5mJKJ8gtuotFSZnDfkpZqjCnAcug=; b=eCDtgH0tforh6uciszQzy6zhR/3TQzOLO++F2m6IlKRzm37XRylUCaHCkkZ8q6v/f0 oh2odpNkPPX2kxlKQOu2QyYSCX8ZcVCP09Q+mwcqk6Hky7raninpfxnW8hhECVONredO AUKKH2aQOuPWBKQ+HtmA7ITzoOTgjxu7FUMsnxxj+WK7NdsGwWDwUwoLGPicomKjWSRI TQbJEexHOv++ALfkOl2fpj7hfxFYHu4K7la/GVb9WvtahzI1ar3sbR5gTPPAzz+X5PFw VPuc4X9c/16zEVpfoG5DcsmOGy8ADvHsiPE4wWZGuU+spi3ORftIj7a8GWnakQR2wKds BLCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B3hHBJMt; 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 r12si1891704pgp.20.2017.10.04.20.52.27; Wed, 04 Oct 2017 20:52:27 -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 header.s=google header.b=B3hHBJMt; 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 S1752014AbdJEDw0 (ORCPT + 26 others); Wed, 4 Oct 2017 23:52:26 -0400 Received: from mail-pg0-f53.google.com ([74.125.83.53]:56415 "EHLO mail-pg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751880AbdJEDvQ (ORCPT ); Wed, 4 Oct 2017 23:51:16 -0400 Received: by mail-pg0-f53.google.com with SMTP id m18so1519432pgd.13 for ; Wed, 04 Oct 2017 20:51:15 -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=TP1EfqGEfPlEmtf5mJKJ8gtuotFSZnDfkpZqjCnAcug=; b=B3hHBJMtmRqVJWcgS3r20JLMORJ9p6GXxSDHZW0kEg5VsyPasfPbaH2287jhuMtCcq x23NDDXx3THASOefSrU4StHnxT7jvLMayCLhBYIMwSi03cCgg/GxUsM3A3hlyv1AcXJC HhVVeNu9xpKzJW1Qi/tqm2SqN79Rvid+Qytxc= 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=TP1EfqGEfPlEmtf5mJKJ8gtuotFSZnDfkpZqjCnAcug=; b=N9ZkBKErMNf2OU57h2llZWk/ayRUN6UNGyrlErFNERLCpAmytSF078Fpg/wQNFuIP4 3dSinRmiS49WtJXx4f3AEfpqFUHPMFY7wxD8kgVylobWWY8MC5cP9n57vwhBB9wQ60UC J9HkHU9y1BEruby+PlXO9rD+IK/0A4k3iqsk3ilLvNEJm4Zb1XHy1k65vLAGL61jEGF1 PC2oChw3UbpK9E5Ppnyz5eVlkQrL1rZpQvccXMdtvKshVzF31OA1TG5MBbCYx/I1c0Cu 2KRfNiONNlbb1DG3xTNtCj+DY2TGXeVIMQQYwnpuyL2oodUFmoX1lHu7+Bc+y68iBCeC H9UA== X-Gm-Message-State: AMCzsaVnrAVPiyQNEdMY5Kpjhs22NnDnYGseUuG+YNJoMu04Zq7A0/oG Olur6FXpeJA4D+XqZWfSSf492g== X-Google-Smtp-Source: AOwi7QB704wqjFNFfsh3gl0f4k33bzVGEszUkbiol3OfOlgZ/YK7v1h52nqahNQnQUTsCQ5QYE0qBA== X-Received: by 10.84.224.131 with SMTP id s3mr12253198plj.409.1507175475349; Wed, 04 Oct 2017 20:51:15 -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 f131sm13067035pfc.27.2017.10.04.20.51.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Oct 2017 20:51:14 -0700 (PDT) From: Bjorn Andersson To: "David S. Miller" Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Chris Lew Subject: [RESEND PATCH 5/7] net: qrtr: Clean up control packet handling Date: Wed, 4 Oct 2017 20:51:03 -0700 Message-Id: <20171005035105.14677-6-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20171005035105.14677-1-bjorn.andersson@linaro.org> References: <20171005035105.14677-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 message header generation is deferred the internal functions for generating control packets can be simplified. This patch modifies qrtr_alloc_ctrl_packet() to, in addition to the sk_buff, return a reference to a struct qrtr_ctrl_pkt, which clarifies and simplifies the helpers to the point that these functions can be folded back into the callers. Signed-off-by: Bjorn Andersson --- net/qrtr/qrtr.c | 93 ++++++++++++++++++--------------------------------------- 1 file changed, 29 insertions(+), 64 deletions(-) -- 2.12.0 diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index 82dc83789310..a84edba7b1ef 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -255,9 +255,18 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len) } EXPORT_SYMBOL_GPL(qrtr_endpoint_post); -static struct sk_buff *qrtr_alloc_ctrl_packet(u32 type, size_t pkt_len, - u32 src_node, u32 dst_node) +/** + * qrtr_alloc_ctrl_packet() - allocate control packet skb + * @pkt: reference to qrtr_ctrl_pkt pointer + * + * 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) { + const int pkt_len = sizeof(struct qrtr_ctrl_pkt); struct sk_buff *skb; skb = alloc_skb(QRTR_HDR_SIZE + pkt_len, GFP_KERNEL); @@ -265,64 +274,7 @@ static struct sk_buff *qrtr_alloc_ctrl_packet(u32 type, size_t pkt_len, return NULL; skb_reserve(skb, QRTR_HDR_SIZE); - - return skb; -} - -/* Allocate and construct a resume-tx packet. */ -static struct sk_buff *qrtr_alloc_resume_tx(u32 src_node, - u32 dst_node, u32 port) -{ - const int pkt_len = 20; - struct sk_buff *skb; - __le32 *buf; - - skb = qrtr_alloc_ctrl_packet(QRTR_TYPE_RESUME_TX, pkt_len, - src_node, dst_node); - if (!skb) - return NULL; - - buf = skb_put_zero(skb, pkt_len); - buf[0] = cpu_to_le32(QRTR_TYPE_RESUME_TX); - buf[1] = cpu_to_le32(src_node); - buf[2] = cpu_to_le32(port); - - 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 = skb_put_zero(skb, pkt_len); - buf[0] = cpu_to_le32(QRTR_TYPE_BYE); - - 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 = skb_put_zero(skb, 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); + *pkt = skb_put_zero(skb, pkt_len); return skb; } @@ -337,6 +289,7 @@ static void qrtr_port_put(struct qrtr_sock *ipc); static void qrtr_node_rx_work(struct work_struct *work) { struct qrtr_node *node = container_of(work, struct qrtr_node, work); + struct qrtr_ctrl_pkt *pkt; struct sockaddr_qrtr dst; struct sockaddr_qrtr src; struct sk_buff *skb; @@ -372,10 +325,14 @@ static void qrtr_node_rx_work(struct work_struct *work) } if (confirm) { - skb = qrtr_alloc_resume_tx(dst_node, node->nid, dst_port); + skb = qrtr_alloc_ctrl_packet(&pkt); if (!skb) break; + pkt->cmd = cpu_to_le32(QRTR_TYPE_RESUME_TX); + pkt->client.node = cpu_to_le32(dst.sq_node); + pkt->client.port = cpu_to_le32(dst.sq_port); + if (qrtr_node_enqueue(node, skb, QRTR_TYPE_RESUME_TX, &dst, &src)) break; @@ -429,6 +386,7 @@ void qrtr_endpoint_unregister(struct qrtr_endpoint *ep) struct qrtr_node *node = ep->node; struct sockaddr_qrtr src = {AF_QIPCRTR, node->nid, QRTR_PORT_CTRL}; struct sockaddr_qrtr dst = {AF_QIPCRTR, qrtr_local_nid, QRTR_PORT_CTRL}; + struct qrtr_ctrl_pkt *pkt; struct sk_buff *skb; mutex_lock(&node->ep_lock); @@ -436,9 +394,11 @@ void qrtr_endpoint_unregister(struct qrtr_endpoint *ep) mutex_unlock(&node->ep_lock); /* Notify the local controller about the event */ - skb = qrtr_alloc_local_bye(node->nid); - if (skb) + skb = qrtr_alloc_ctrl_packet(&pkt); + if (skb) { + pkt->cmd = cpu_to_le32(QRTR_TYPE_BYE); qrtr_local_enqueue(NULL, skb, QRTR_TYPE_BYE, &src, &dst); + } qrtr_node_release(node); ep->node = NULL; @@ -474,6 +434,7 @@ static void qrtr_port_put(struct qrtr_sock *ipc) /* Remove port assignment. */ static void qrtr_port_remove(struct qrtr_sock *ipc) { + struct qrtr_ctrl_pkt *pkt; struct sk_buff *skb; int port = ipc->us.sq_port; struct sockaddr_qrtr to; @@ -482,8 +443,12 @@ static void qrtr_port_remove(struct qrtr_sock *ipc) to.sq_node = QRTR_NODE_BCAST; to.sq_port = QRTR_PORT_CTRL; - skb = qrtr_alloc_del_client(&ipc->us); + skb = qrtr_alloc_ctrl_packet(&pkt); if (skb) { + pkt->cmd = cpu_to_le32(QRTR_TYPE_DEL_CLIENT); + pkt->client.node = cpu_to_le32(ipc->us.sq_node); + pkt->client.port = cpu_to_le32(ipc->us.sq_port); + skb_set_owner_w(skb, &ipc->sk); qrtr_bcast_enqueue(NULL, skb, QRTR_TYPE_DEL_CLIENT, &ipc->us, &to); From patchwork Thu Oct 5 03:51:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 114834 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp143214qgn; Wed, 4 Oct 2017 20:51:24 -0700 (PDT) X-Received: by 10.99.191.6 with SMTP id v6mr20864518pgf.284.1507175484013; Wed, 04 Oct 2017 20:51:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507175484; cv=none; d=google.com; s=arc-20160816; b=H+Rhd1SrvOIeub1O74bcKCj55jc6pCOKwJ+a6VS7vigyOxqdvUcfP+r16VJciBp2oO 9YiNnv4OVnsqHV/oAWfOvqrTKdI5MNRnQplyWcdCaXrewaNMQosILAAFF7C9GKNZHtas VQqE4q99gyFk1nRHoVXdFQWL7t/zgjeYte4eWSGoI7kJ/evnH11KuDq6mGf7erzrujke 5+V15UP5TWnSgVMnvbIygCuXAcTz6NNqY3Bdrr0bfgxqVFyGaT8a+k0InUfx36Vyns3T 3yAH5DdPMYkZwj72yO0MdjaQTlbhls5EX7IPe2Je8Wdv8Sd0ktdYFJPsAdc2W0WAadb2 ZNlg== 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=XSXd6XSHEo4F8R7K94DBJNr95E69fSrjGOUPgJgwOP4=; b=FF+aFpZOK/Xb7wgh5BQ32E7YeAgqD2LPj6dMACaFUW4GxFMtUzHC3rSWPGmT/eq0qm nBB1SkZ7+pKrRN/S/KnKxdMkPA52javQosp9awJDB66gvpv9jXOlgeHozwfsBMVD2ckE 8dZXAeq1Yc8TeNK+UnQnPQV5mpEuGzbOXFp7u1a9ZaJACiy9ccdrgqAiGiJDIoGiSKnS Wx/G3uhqnJa2fnCdTkLSeW2tPSE7gzJ9yFMpG22KXbfYAjoT+C9dAcmsZ7UQVX2cqUVv 5C1LOT/FXndBT8AUryj+LpiNIumzBs8bj7v3ZS+d659uu5qeYYFMVNdopj9c5X2zMQHh pQWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jrdtbJmq; 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 y21si13416539pll.578.2017.10.04.20.51.23; Wed, 04 Oct 2017 20:51:23 -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 header.s=google header.b=jrdtbJmq; 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 S1751967AbdJEDvV (ORCPT + 26 others); Wed, 4 Oct 2017 23:51:21 -0400 Received: from mail-pf0-f174.google.com ([209.85.192.174]:45329 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751926AbdJEDvS (ORCPT ); Wed, 4 Oct 2017 23:51:18 -0400 Received: by mail-pf0-f174.google.com with SMTP id z84so7325226pfi.2 for ; Wed, 04 Oct 2017 20:51:18 -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=XSXd6XSHEo4F8R7K94DBJNr95E69fSrjGOUPgJgwOP4=; b=jrdtbJmqWvrlCLHfFaaFSBTIKY/5W+ZAoRtNeB3IGJ41+nTG9kSlnRIy9212cbzMgI MgBfyWzXIllFqfwnmxB0ynWt2xFzCJgrknMVX6+42p+d+sCDx6Xks9pvQ+UmjgEn4lR1 wS+oJ1kNnZIIA3An+D/pFw8zjZt/Osf/6qLUE= 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=XSXd6XSHEo4F8R7K94DBJNr95E69fSrjGOUPgJgwOP4=; b=EGDCpbh0/UT8RgLLA4krZwJGOeLsaWjoONgaJyY14ZHokKBJPaLx+FCdYjnJlsycVu 4MH7j7bi6HuDKWX3A81mIODiuTdaQW4ZwOVmGwgUnHFS57DPei7Z17oqNkFIFxonVOdp cJ4Txat8qOIoLr8vkol3rcmkdZS0kgjkyiflcCkWcmjnCsZV+xpIfDEnbSQ15PIZCqJy xEbuM8P86KBv24qWecZnuE9rlR+fxcv5GKUVT+Sep6IB0KmTZvfqvMDG0l78skdo3g4w lbtg94A3ZUG8nj0xZbjYMEX5SIf+PxUOy/Ymliavecd1Sq7WwLxTCYrB3M7nfYZVkIqX s2Ww== X-Gm-Message-State: AHPjjUhAWsJdAHNopfN94QCDnT4t3WFaCglxtGtEoVlJ5FQvQp9Wjzam yJUFLWQh+eIwv5AJrCDP61bwhQ== X-Google-Smtp-Source: AOwi7QAfwoi881q+O/rDsuI2IGC4MbM5otff/0UF9dPg4zfCkkx4h9NuAnyv57lZ/GAFiJgRVyfaaA== X-Received: by 10.98.223.88 with SMTP id u85mr22553216pfg.219.1507175477882; Wed, 04 Oct 2017 20:51:17 -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 f131sm13067035pfc.27.2017.10.04.20.51.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Oct 2017 20:51:17 -0700 (PDT) From: Bjorn Andersson To: "David S. Miller" Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Chris Lew Subject: [RESEND PATCH 7/7] net: qrtr: Support decoding incoming v2 packets Date: Wed, 4 Oct 2017 20:51:05 -0700 Message-Id: <20171005035105.14677-8-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20171005035105.14677-1-bjorn.andersson@linaro.org> References: <20171005035105.14677-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add the necessary logic for decoding incoming messages of version 2 as well. Also make sure there's room for the bigger of version 1 and 2 headers in the code allocating skbs for outgoing messages. Signed-off-by: Bjorn Andersson --- net/qrtr/qrtr.c | 132 ++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 94 insertions(+), 38 deletions(-) -- 2.12.0 diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index 7bca6ec892a5..8bb3e2bb5d0a 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -20,14 +20,15 @@ #include "qrtr.h" -#define QRTR_PROTO_VER 1 +#define QRTR_PROTO_VER_1 1 +#define QRTR_PROTO_VER_2 3 /* auto-bind range */ #define QRTR_MIN_EPH_SOCKET 0x4000 #define QRTR_MAX_EPH_SOCKET 0x7fff /** - * struct qrtr_hdr - (I|R)PCrouter packet header + * struct qrtr_hdr_v1 - (I|R)PCrouter packet header version 1 * @version: protocol version * @type: packet type; one of QRTR_TYPE_* * @src_node_id: source node @@ -37,7 +38,7 @@ * @dst_node_id: destination node * @dst_port_id: destination port */ -struct qrtr_hdr { +struct qrtr_hdr_v1 { __le32 version; __le32 type; __le32 src_node_id; @@ -48,6 +49,32 @@ struct qrtr_hdr { __le32 dst_port_id; } __packed; +/** + * struct qrtr_hdr_v2 - (I|R)PCrouter packet header later versions + * @version: protocol version + * @type: packet type; one of QRTR_TYPE_* + * @flags: bitmask of QRTR_FLAGS_* + * @optlen: length of optional header data + * @size: length of packet, excluding this header and optlen + * @src_node_id: source node + * @src_port_id: source port + * @dst_node_id: destination node + * @dst_port_id: destination port + */ +struct qrtr_hdr_v2 { + u8 version; + u8 type; + u8 flags; + u8 optlen; + __le32 size; + __le16 src_node_id; + __le16 src_port_id; + __le16 dst_node_id; + __le16 dst_port_id; +} __packed; + +#define QRTR_FLAGS_CONFIRM_RX BIT(0) + struct qrtr_cb { u32 src_node; u32 src_port; @@ -58,7 +85,8 @@ struct qrtr_cb { u8 confirm_rx; }; -#define QRTR_HDR_SIZE sizeof(struct qrtr_hdr) +#define QRTR_HDR_MAX_SIZE max_t(size_t, sizeof(struct qrtr_hdr_v1), \ + sizeof(struct qrtr_hdr_v2)) struct qrtr_sock { /* WARNING: sk must be the first member */ @@ -154,12 +182,12 @@ static int qrtr_node_enqueue(struct qrtr_node *node, struct sk_buff *skb, int type, struct sockaddr_qrtr *from, struct sockaddr_qrtr *to) { - struct qrtr_hdr *hdr; + struct qrtr_hdr_v1 *hdr; size_t len = skb->len; int rc = -ENODEV; - hdr = skb_push(skb, QRTR_HDR_SIZE); - hdr->version = cpu_to_le32(QRTR_PROTO_VER); + hdr = skb_push(skb, sizeof(*hdr)); + hdr->version = cpu_to_le32(QRTR_PROTO_VER_1); hdr->type = cpu_to_le32(type); hdr->src_node_id = cpu_to_le32(from->sq_node); hdr->src_port_id = cpu_to_le32(from->sq_port); @@ -224,52 +252,80 @@ static void qrtr_node_assign(struct qrtr_node *node, unsigned int nid) int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len) { struct qrtr_node *node = ep->node; - const struct qrtr_hdr *phdr = data; + const struct qrtr_hdr_v1 *v1; + const struct qrtr_hdr_v2 *v2; struct sk_buff *skb; struct qrtr_cb *cb; - unsigned int psize; unsigned int size; - unsigned int type; unsigned int ver; - unsigned int dst; + size_t hdrlen; - if (len < QRTR_HDR_SIZE || len & 3) + if (len & 3) return -EINVAL; - ver = le32_to_cpu(phdr->version); - size = le32_to_cpu(phdr->size); - type = le32_to_cpu(phdr->type); - dst = le32_to_cpu(phdr->dst_port_id); + skb = netdev_alloc_skb(NULL, len); + if (!skb) + return -ENOMEM; - psize = (size + 3) & ~3; + cb = (struct qrtr_cb *)skb->cb; - if (ver != QRTR_PROTO_VER) - return -EINVAL; + /* Version field in v1 is little endian, so this works for both cases */ + ver = *(u8*)data; - if (len != psize + QRTR_HDR_SIZE) - return -EINVAL; + switch (ver) { + case QRTR_PROTO_VER_1: + v1 = data; + hdrlen = sizeof(*v1); - if (dst != QRTR_PORT_CTRL && type != QRTR_TYPE_DATA) - return -EINVAL; + cb->type = le32_to_cpu(v1->type); + cb->src_node = le32_to_cpu(v1->src_node_id); + cb->src_port = le32_to_cpu(v1->src_port_id); + cb->confirm_rx = !!v1->confirm_rx; + cb->dst_node = le32_to_cpu(v1->dst_node_id); + cb->dst_port = le32_to_cpu(v1->dst_port_id); - skb = netdev_alloc_skb(NULL, len); - if (!skb) - return -ENOMEM; + size = le32_to_cpu(v1->size); + break; + case QRTR_PROTO_VER_2: + v2 = data; + hdrlen = sizeof(*v2) + v2->optlen; + + cb->type = v2->type; + cb->confirm_rx = !!(v2->flags & QRTR_FLAGS_CONFIRM_RX); + cb->src_node = le16_to_cpu(v2->src_node_id); + cb->src_port = le16_to_cpu(v2->src_port_id); + cb->dst_node = le16_to_cpu(v2->dst_node_id); + cb->dst_port = le16_to_cpu(v2->dst_port_id); + + if (cb->src_port == (u16)QRTR_PORT_CTRL) + cb->src_port = QRTR_PORT_CTRL; + if (cb->dst_port == (u16)QRTR_PORT_CTRL) + cb->dst_port = QRTR_PORT_CTRL; + + size = le32_to_cpu(v2->size); + break; + default: + pr_err("qrtr: Invalid version %d\n", ver); + goto err; + } - cb = (struct qrtr_cb *)skb->cb; - cb->src_node = le32_to_cpu(phdr->src_node_id); - cb->src_port = le32_to_cpu(phdr->src_port_id); - cb->dst_node = le32_to_cpu(phdr->dst_node_id); - cb->dst_port = le32_to_cpu(phdr->dst_port_id); - cb->type = type; - cb->confirm_rx = !!phdr->confirm_rx; + if (len != ALIGN(size, 4) + hdrlen) + goto err; - skb_put_data(skb, data + QRTR_HDR_SIZE, size); + if (cb->dst_port != QRTR_PORT_CTRL && cb->type != QRTR_TYPE_DATA) + goto err; + + skb_put_data(skb, data + hdrlen, size); skb_queue_tail(&node->rx_queue, skb); schedule_work(&node->work); return 0; + +err: + kfree_skb(skb); + return -EINVAL; + } EXPORT_SYMBOL_GPL(qrtr_endpoint_post); @@ -287,11 +343,11 @@ static struct sk_buff *qrtr_alloc_ctrl_packet(struct qrtr_ctrl_pkt **pkt) const int pkt_len = sizeof(struct qrtr_ctrl_pkt); struct sk_buff *skb; - skb = alloc_skb(QRTR_HDR_SIZE + pkt_len, GFP_KERNEL); + skb = alloc_skb(QRTR_HDR_MAX_SIZE + pkt_len, GFP_KERNEL); if (!skb) return NULL; - skb_reserve(skb, QRTR_HDR_SIZE); + skb_reserve(skb, QRTR_HDR_MAX_SIZE); *pkt = skb_put_zero(skb, pkt_len); return skb; @@ -720,12 +776,12 @@ static int qrtr_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) } plen = (len + 3) & ~3; - skb = sock_alloc_send_skb(sk, plen + QRTR_HDR_SIZE, + skb = sock_alloc_send_skb(sk, plen + QRTR_HDR_MAX_SIZE, msg->msg_flags & MSG_DONTWAIT, &rc); if (!skb) goto out_node; - skb_reserve(skb, QRTR_HDR_SIZE); + skb_reserve(skb, QRTR_HDR_MAX_SIZE); rc = memcpy_from_msg(skb_put(skb, len), msg, len); if (rc) {