From patchwork Wed Nov 18 13:59:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Schiller X-Patchwork-Id: 11915179 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 X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68CF8C6379F for ; Wed, 18 Nov 2020 14:00:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1F5982080A for ; Wed, 18 Nov 2020 14:00:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726826AbgKROAI (ORCPT ); Wed, 18 Nov 2020 09:00:08 -0500 Received: from mxout70.expurgate.net ([194.37.255.70]:35239 "EHLO mxout70.expurgate.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725790AbgKROAG (ORCPT ); Wed, 18 Nov 2020 09:00:06 -0500 Received: from [127.0.0.1] (helo=localhost) by relay.expurgate.net with smtp (Exim 4.90) (envelope-from ) id 1kfO0A-0001gE-KN; Wed, 18 Nov 2020 15:00:02 +0100 Received: from [195.243.126.94] (helo=securemail.tdt.de) by relay.expurgate.net with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90) (envelope-from ) id 1kfO09-0002og-Sz; Wed, 18 Nov 2020 15:00:01 +0100 Received: from securemail.tdt.de (localhost [127.0.0.1]) by securemail.tdt.de (Postfix) with ESMTP id 6E30E240041; Wed, 18 Nov 2020 15:00:01 +0100 (CET) Received: from mail.dev.tdt.de (unknown [10.2.4.42]) by securemail.tdt.de (Postfix) with ESMTP id E5735240040; Wed, 18 Nov 2020 15:00:00 +0100 (CET) Received: from mschiller01.dev.tdt.de (unknown [10.2.3.20]) by mail.dev.tdt.de (Postfix) with ESMTPSA id BE35B20370; Wed, 18 Nov 2020 15:00:00 +0100 (CET) From: Martin Schiller To: andrew.hendry@gmail.com, davem@davemloft.net, kuba@kernel.org, xie.he.0141@gmail.com Cc: linux-x25@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Schiller Subject: [PATCH net-next v3 3/6] net/lapb: handle carrier loss correctly Date: Wed, 18 Nov 2020 14:59:16 +0100 Message-ID: <20201118135919.1447-4-ms@dev.tdt.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201118135919.1447-1-ms@dev.tdt.de> References: <20201118135919.1447-1-ms@dev.tdt.de> MIME-Version: 1.0 X-purgate-type: clean X-purgate: clean X-purgate-ID: 151534::1605708002-00000FB8-B0D9A28E/0/0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org In case of carrier loss, clear all queues, enter state LABB_STATE_0 and stop all timers. By setting rc = LAPB_NOTCONNECTED, the upper layer is informed about the disconnect. Signed-off-by: Martin Schiller --- net/lapb/lapb_iface.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/net/lapb/lapb_iface.c b/net/lapb/lapb_iface.c index 8dd7c420ae93..017bc169c334 100644 --- a/net/lapb/lapb_iface.c +++ b/net/lapb/lapb_iface.c @@ -303,6 +303,18 @@ int lapb_disconnect_request(struct net_device *dev) if (!lapb) goto out; + if (!netif_carrier_ok(dev)) { + lapb_dbg(0, "(%p) Carrier lost!\n", lapb->dev); + lapb_dbg(0, "(%p) S%d -> S0\n", lapb->dev, lapb->state); + lapb_clear_queues(lapb); + lapb->state = LAPB_STATE_0; + lapb->n2count = 0; + lapb_stop_t1timer(lapb); + lapb_stop_t2timer(lapb); + rc = LAPB_NOTCONNECTED; + goto out_put; + } + switch (lapb->state) { case LAPB_STATE_0: rc = LAPB_NOTCONNECTED;