From patchwork Thu Nov 3 09:17:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "D. Starke" X-Patchwork-Id: 14780 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp414273wru; Thu, 3 Nov 2022 02:27:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7QGMeHtO0na3AUt8eb3ri20MkVUZdm+okCWD2QR6jEOsENzqJRUwf4iZOiQqhge1+L92nW X-Received: by 2002:a05:6a00:2409:b0:54e:a3ad:d5ab with SMTP id z9-20020a056a00240900b0054ea3add5abmr29319731pfh.11.1667467639140; Thu, 03 Nov 2022 02:27:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667467639; cv=none; d=google.com; s=arc-20160816; b=EZ55Cs1lld4akr1LEzHxM/O9YH49tfuyKNJvD6teQy3B1l5B6giDpVxhbGFERxzE7P xQvVBJvMVViJzRSaO9iFj2KRmyLrBPij3E7hR/QgQcB+0fJc8CpyM8LCe+X8OKHh/eBN 8TbeE8stAZnzaLT32LwDktx/esutfaFWUiKIpBsnWhxqluh4DPKikBF3diRUyDt6lEkZ Y5t4hptGql/7NZD+5hqsdI/b8EgtiMR1ri1GNGIFXM3CvTSHsEjv9+b9UrROOfZYn7Zi ZP8WxgZGuWlB7HZCixaGsmov29FQuv9Ri9OVszvXfrLWi+7xjW35zEbS1dzAtVMyyIrz HxLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=ymHU3X/qr6+q1iY2LysQF2vzhHX/JM5cmkF/ZciRuKw=; b=RmpiquyXlhJEYtU+RYEEz5QEhvAH5B3UO1BW8aA2TFhdTCKfBzaSov25DXzN367sHF GZ/LSmw4QKHFpLJcVO2PC+i0EWoe+tL6rBNQbblN1SPDPssORl+opueipadqrQU/j2Zp Ygh3lePaUML7abmMMP1woz3MQWNWlf9PD5u+poBMpCwY6vTbBpBpP2ptUtLDhwrVN+WC Z1fMfmLfSaahmLbddRlLGDuJsz9d3hII8FLez5V++Ksgql2c0YlbGlHimhXuZdQinWoc CZbUfdiWi8CrsBRHm2W5TFkm/AwTj/2sM+lpb/lGPA64gnt7XBC4ZoLPw07uErb40kGn g3uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=m3Y1LgnT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t19-20020a1709028c9300b0017a0e7aaf6bsi153014plo.128.2022.11.03.02.27.06; Thu, 03 Nov 2022 02:27:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=m3Y1LgnT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229788AbiKCJVz (ORCPT + 99 others); Thu, 3 Nov 2022 05:21:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229688AbiKCJVS (ORCPT ); Thu, 3 Nov 2022 05:21:18 -0400 X-Greylist: delayed 63 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 03 Nov 2022 02:21:15 PDT Received: from mta-65-225.siemens.flowmailer.net (mta-65-225.siemens.flowmailer.net [185.136.65.225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30062DEAD for ; Thu, 3 Nov 2022 02:21:15 -0700 (PDT) Received: by mta-65-225.siemens.flowmailer.net with ESMTPSA id 2022110309200924e90a3c9e57b9dbd6 for ; Thu, 03 Nov 2022 10:20:10 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=daniel.starke@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc; bh=ymHU3X/qr6+q1iY2LysQF2vzhHX/JM5cmkF/ZciRuKw=; b=m3Y1LgnTK9GD/M6e5Eesa6/4c5nbgngUeunmNE09fE8Jngw2IcNfHQOIwiOQjzdM+DF0Q/ oWKAxlzd5ix83MOzbIGM18o4xWGek2qQp6GXbS5y5DBPuXB1mP5T/Pey+OH7RCxWCy2aVoUj +GACObHy4uk5QZ0zWvqC8kmm+Hwjc=; From: "D. Starke" To: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: linux-kernel@vger.kernel.org, Daniel Starke Subject: [PATCH v3 1/3] tty: n_gsm: introduce macro for minimal unit size Date: Thu, 3 Nov 2022 10:17:41 +0100 Message-Id: <20221103091743.2119-1-daniel.starke@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-314044:519-21489:flowmailer X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748466547174832226?= X-GMAIL-MSGID: =?utf-8?q?1748466547174832226?= From: Daniel Starke n_gsm has a minimal protocol overhead of 7 bytes. The current code already checks whether the configured MRU/MTU size is at least one byte more than this. Introduce the macro MIN_MTU to make this value more obvious. Signed-off-by: Daniel Starke --- drivers/tty/n_gsm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) v2 -> v3: No changes. Link: https://lore.kernel.org/all/20221024130114.2070-1-daniel.starke@siemens.com/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 5e516f5cac5a..570c40a3d78f 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -89,6 +89,7 @@ module_param(debug, int, 0600); */ #define MAX_MRU 1500 #define MAX_MTU 1500 +#define MIN_MTU (PROT_OVERHEAD + 1) /* SOF, ADDR, CTRL, LEN1, LEN2, ..., FCS, EOF */ #define PROT_OVERHEAD 7 #define GSM_NET_TX_TIMEOUT (HZ*10) @@ -2712,7 +2713,9 @@ static int gsm_config(struct gsm_mux *gsm, struct gsm_config *c) if ((c->adaption != 1 && c->adaption != 2) || c->k) return -EOPNOTSUPP; /* Check the MRU/MTU range looks sane */ - if (c->mru > MAX_MRU || c->mtu > MAX_MTU || c->mru < 8 || c->mtu < 8) + if (c->mru < MIN_MTU || c->mtu < MIN_MTU) + return -EINVAL; + if (c->mru > MAX_MRU || c->mtu > MAX_MTU) return -EINVAL; if (c->n2 > 255) return -EINVAL; @@ -3296,7 +3299,7 @@ static int gsm_create_network(struct gsm_dlci *dlci, struct gsm_netconfig *nc) return -ENOMEM; } net->mtu = dlci->gsm->mtu; - net->min_mtu = 8; + net->min_mtu = MIN_MTU; net->max_mtu = dlci->gsm->mtu; mux_net = netdev_priv(net); mux_net->dlci = dlci;