From patchwork Thu Nov 25 06:07:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Kerr X-Patchwork-Id: 12638439 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AFC11C433F5 for ; Thu, 25 Nov 2021 06:10:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346821AbhKYGOC (ORCPT ); Thu, 25 Nov 2021 01:14:02 -0500 Received: from pi.codeconstruct.com.au ([203.29.241.158]:57904 "EHLO codeconstruct.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347376AbhKYGMB (ORCPT ); Thu, 25 Nov 2021 01:12:01 -0500 Received: by codeconstruct.com.au (Postfix, from userid 10000) id 6F51C20294; Thu, 25 Nov 2021 14:08:49 +0800 (AWST) From: Jeremy Kerr To: netdev@vger.kernel.org Cc: Matt Johnston , "David S. Miller" , Jakub Kicinski , Greg Kroah-Hartman , Jiri Slaby Subject: [PATCH net-next v2 1/3] mctp: serial: cancel tx work on ldisc close Date: Thu, 25 Nov 2021 14:07:37 +0800 Message-Id: <20211125060739.3023442-2-jk@codeconstruct.com.au> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211125060739.3023442-1-jk@codeconstruct.com.au> References: <20211125060739.3023442-1-jk@codeconstruct.com.au> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org We want to ensure that the tx work has finished before returning from the ldisc close op, so do a synchronous cancel. Reported-by: Jiri Slaby Signed-off-by: Jeremy Kerr --- v2: - cancel work after netdev unregister --- drivers/net/mctp/mctp-serial.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/mctp/mctp-serial.c b/drivers/net/mctp/mctp-serial.c index 9ac0e187f36e..85b407f4df11 100644 --- a/drivers/net/mctp/mctp-serial.c +++ b/drivers/net/mctp/mctp-serial.c @@ -479,6 +479,7 @@ static void mctp_serial_close(struct tty_struct *tty) int idx = dev->idx; unregister_netdev(dev->netdev); + cancel_work_sync(&dev->tx_work); ida_free(&mctp_serial_ida, idx); } From patchwork Thu Nov 25 06:07:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Kerr X-Patchwork-Id: 12638443 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DFB72C4332F for ; Thu, 25 Nov 2021 06:10:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346862AbhKYGOD (ORCPT ); Thu, 25 Nov 2021 01:14:03 -0500 Received: from pi.codeconstruct.com.au ([203.29.241.158]:57920 "EHLO codeconstruct.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347393AbhKYGMB (ORCPT ); Thu, 25 Nov 2021 01:12:01 -0500 Received: by codeconstruct.com.au (Postfix, from userid 10000) id D9B6420297; Thu, 25 Nov 2021 14:08:49 +0800 (AWST) From: Jeremy Kerr To: netdev@vger.kernel.org Cc: Matt Johnston , "David S. Miller" , Jakub Kicinski , Greg Kroah-Hartman , Jiri Slaby Subject: [PATCH net-next v2 2/3] mctp: serial: enforce fixed MTU Date: Thu, 25 Nov 2021 14:07:38 +0800 Message-Id: <20211125060739.3023442-3-jk@codeconstruct.com.au> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211125060739.3023442-1-jk@codeconstruct.com.au> References: <20211125060739.3023442-1-jk@codeconstruct.com.au> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The current serial driver requires a maximum MTU of 68, and it doesn't make sense to set a MTU below the MCTP-required baseline (of 68) either. This change sets the min_mtu & max_mtu of the mctp netdev, essentially disallowing changes. By using these instead of a ndo_change_mtu op, we get the netlink extacks reported too. Signed-off-by: Jeremy Kerr --- drivers/net/mctp/mctp-serial.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/mctp/mctp-serial.c b/drivers/net/mctp/mctp-serial.c index 85b407f4df11..b0e14a63b10d 100644 --- a/drivers/net/mctp/mctp-serial.c +++ b/drivers/net/mctp/mctp-serial.c @@ -410,7 +410,14 @@ static const struct net_device_ops mctp_serial_netdev_ops = { static void mctp_serial_setup(struct net_device *ndev) { ndev->type = ARPHRD_MCTP; + + /* we limit at the fixed MTU, which is also the MCTP-standard + * baseline MTU, so is also our minimum + */ ndev->mtu = MCTP_SERIAL_MTU; + ndev->max_mtu = MCTP_SERIAL_MTU; + ndev->min_mtu = MCTP_SERIAL_MTU; + ndev->hard_header_len = 0; ndev->addr_len = 0; ndev->tx_queue_len = DEFAULT_TX_QUEUE_LEN; From patchwork Thu Nov 25 06:07:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Kerr X-Patchwork-Id: 12638441 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63D12C433EF for ; Thu, 25 Nov 2021 06:10:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346868AbhKYGOE (ORCPT ); Thu, 25 Nov 2021 01:14:04 -0500 Received: from pi.codeconstruct.com.au ([203.29.241.158]:57932 "EHLO codeconstruct.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347399AbhKYGMC (ORCPT ); Thu, 25 Nov 2021 01:12:02 -0500 Received: by codeconstruct.com.au (Postfix, from userid 10000) id 545B22029A; Thu, 25 Nov 2021 14:08:50 +0800 (AWST) From: Jeremy Kerr To: netdev@vger.kernel.org Cc: Matt Johnston , "David S. Miller" , Jakub Kicinski , Greg Kroah-Hartman , Jiri Slaby Subject: [PATCH net-next v2 3/3] mctp: serial: remove unnecessary ldisc data check Date: Thu, 25 Nov 2021 14:07:39 +0800 Message-Id: <20211125060739.3023442-4-jk@codeconstruct.com.au> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211125060739.3023442-1-jk@codeconstruct.com.au> References: <20211125060739.3023442-1-jk@codeconstruct.com.au> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Jiri assures me that a ldisc->open with tty->disc_data set should never happen, so this check doesn't do anything. Reported-by: Jiri Slaby Signed-off-by: Jeremy Kerr --- drivers/net/mctp/mctp-serial.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/net/mctp/mctp-serial.c b/drivers/net/mctp/mctp-serial.c index b0e14a63b10d..eaa6fb3224bc 100644 --- a/drivers/net/mctp/mctp-serial.c +++ b/drivers/net/mctp/mctp-serial.c @@ -439,9 +439,6 @@ static int mctp_serial_open(struct tty_struct *tty) if (!tty->ops->write) return -EOPNOTSUPP; - if (tty->disc_data) - return -EEXIST; - idx = ida_alloc(&mctp_serial_ida, GFP_KERNEL); if (idx < 0) return idx;