From patchwork Thu Apr 20 08:50:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "D. Starke" X-Patchwork-Id: 85787 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp186879vqo; Thu, 20 Apr 2023 02:07:41 -0700 (PDT) X-Google-Smtp-Source: AKy350bFkYiDnC9ngpkst7aomt0/U5/Oe1uiaAbhuiJ4QV1NQIwyLD/jVda5uaOyZp6P64rW1IR6 X-Received: by 2002:a05:6a21:9982:b0:ec:8f81:e9f7 with SMTP id ve2-20020a056a21998200b000ec8f81e9f7mr1483963pzb.16.1681981660947; Thu, 20 Apr 2023 02:07:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681981660; cv=none; d=google.com; s=arc-20160816; b=CloXfdtKRh7nMA3JxOuOV7ahZR+baJZH4bL7qBM5M0hT6KLcGzzma3Uki1sBkIb39A 4Q26QLtsUcAj0O/jOjVwwXpaFI45ztWdnrzN1Z8rVCsfnxi/O48u93RNrN3QkU1H6TtN fNJGK3kfBY8ehb7Zn0nXgO6lm6Y9a1I2k7xFqa7ZBcLf6+al5c5/EbK6vza+0qPuwPX7 vl6P02pej6CznqPxz3iKabbY2CG2dcYArjT64ky6HqVrhyHZw/Hjsu1vEJtJHm08+cl5 2bZSSNnNo19GorsKxy3eGdLdyGNhe0DTqH8WTrqJjgLSqKjn+upnY/1vm87NXd1dL1cQ OTGA== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3x2yGjeK5u1omGmfHkW7ePEBZf1+enMbPDW41ey/pcA=; b=AEx0FjsfRR+Ylg1Bp53Zk3SxOzLbmIQS6y4zAJ/4C29D2iI4gvIGz9xcBJ5FuoVkKN 5gHdT+JcntZo5JCKEOD6X8hI9zNkGZ1791ZB3Hzh/AA964In+B049kvlDnwmUvMxcNhB KtDNprnhB+6xnGlarRIU6HE+23AZ8KcmXlwn7lqRGRPf9w9sVcEmY8sX0THSfX6D5vl1 MYIY8Qe0xiYH444CqdItln7pE19CLaf/0aULRvxTIw29OkI9MLhMk3DT/aYyYlKhZjJ7 cWZFT73KSQU6HzGERnAjy6E8VpsgjdLNdAQJfT1x3BU54RULic5Ybx7vvw1Yp/0jRmRJ Q2gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=jC6VnpGp; 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=REJECT sp=REJECT 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 pf4-20020a17090b1d8400b002449fd20726si4276529pjb.64.2023.04.20.02.07.28; Thu, 20 Apr 2023 02:07:40 -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=jC6VnpGp; 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=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234289AbjDTIzN (ORCPT + 99 others); Thu, 20 Apr 2023 04:55:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234199AbjDTIx5 (ORCPT ); Thu, 20 Apr 2023 04:53:57 -0400 Received: from mta-64-227.siemens.flowmailer.net (mta-64-227.siemens.flowmailer.net [185.136.64.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 568E846BB for ; Thu, 20 Apr 2023 01:52:06 -0700 (PDT) Received: by mta-64-227.siemens.flowmailer.net with ESMTPSA id 202304200852011396a59810ab83a424 for ; Thu, 20 Apr 2023 10:52:01 +0200 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:References:In-Reply-To; bh=3x2yGjeK5u1omGmfHkW7ePEBZf1+enMbPDW41ey/pcA=; b=jC6VnpGptfOYjt/kcGttoWZ0iYVUQEywQ1BjuMJ7ovnlexEs3HPeifOq1ZgRqGafxcj8qQ jvlLATkBil/ZBinzu123fmdn65aKhGVKJ4W9IhUFH94BNEuBOIdUGJcTrOo/7WghXGT6vWi2 IWDn2WVzvkkdHrkZZQAu4MDiJzsMY=; 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 v2 7/9] tty: n_gsm: increase gsm_mux unsupported counted where appropriate Date: Thu, 20 Apr 2023 10:50:15 +0200 Message-Id: <20230420085017.7314-7-daniel.starke@siemens.com> In-Reply-To: <20230420085017.7314-1-daniel.starke@siemens.com> References: <20230420085017.7314-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_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1763685602308271658?= X-GMAIL-MSGID: =?utf-8?q?1763685602308271658?= From: Daniel Starke The structure gsm_mux contains the 'unsupported' field. However, there is currently no place in the code which increases this counter. Increase the 'unsupported' statistics counter in the following case: - an unsupported frame type has been requested by the peer via parameter negotiation - a control frame with an unsupported but known command has been received Note that we have no means to detect an inconsistent/unsupported adaptation sufficient accuracy as this changes the structure of the UI/UIH frames. E.g. a one byte header is added in case of convergence layer type 2 instead of 1 and contains the modem signal octet with the state of the signal lines. There is no checksum or other value which indicates of this field is correct or should be present. Therefore, we can only assume protocol correctness here. See also 'gsm_dlci_data()' where this is handled. Signed-off-by: Daniel Starke --- drivers/tty/n_gsm.c | 3 +++ 1 file changed, 3 insertions(+) v1 -> v2: Added details about missing detection of inconsistent/unsupported adaption to the commit message. A question about this came up during the review. Link: https://lore.kernel.org/all/AS4PR10MB58955AB89CC251446B7509CBE0919@AS4PR10MB5895.EURPRD10.PROD.OUTLOOK.COM/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index cc7be05c37ce..ce06cbbe79af 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -1589,6 +1589,7 @@ static int gsm_process_negotiation(struct gsm_mux *gsm, unsigned int addr, if (debug & DBG_ERRORS) pr_info("%s unsupported I frame request in PN\n", __func__); + gsm->unsupported++; return -EINVAL; default: if (debug & DBG_ERRORS) @@ -1896,6 +1897,8 @@ static void gsm_control_message(struct gsm_mux *gsm, unsigned int command, /* Optional unsupported commands */ case CMD_RPN: /* Remote port negotiation */ case CMD_SNC: /* Service negotiation command */ + gsm->unsupported++; + fallthrough; default: /* Reply to bad commands with an NSC */ buf[0] = command;