Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4206147pxu; Mon, 12 Oct 2020 12:14:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTbl7GIN4ctvyOMvIp7eerbYrMr32VA//EkBSm1Nlflp4JSd09rW1OX1sW3OepB7En6u/p X-Received: by 2002:a17:907:ab9:: with SMTP id bz25mr30582926ejc.90.1602530059265; Mon, 12 Oct 2020 12:14:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602530059; cv=none; d=google.com; s=arc-20160816; b=Qi7hDm0B2TQYqYV0yNhuupgIgrtsoJGJ1I+ucZ/OJd1caM42V2K6EbyXf/SOgDZcPu BRYpEDMgA1/G5ItAo18gFcC5+pkfHAWOFyxTWTf4i0RfmJ/tiiUHvIAxBaSI/HpJ2Lvc y9HRya0FY112F9U76Dcsa6NtadP7rz8vgfLeqU6aV95FJuOy0xHgyzmHgPrsau00+bCL 4WU6cmKYDTamAO4OOlDiiPdaWPh8RxjL/lX1nXsc1iZeARUTd7kOHgIFhGhDIgqMG46j Y/ujIC5PDBB88Ioj5tPEzhz++TD4Gv90z/fzkNvDDTIMHuJL2PkSgfBeuaVGPcfDUHlM C0bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SSCddFoVIxXjG/xr5MxjqdnO1N09StvxgKvs6YPG1i0=; b=G67Gkntpza4xf92mEP5NVcBlWqSPhe5kdmwEWmMGoTNydSKGT2BId+VMsNZUkFoWkS sCSJOPytspCzfmCE7EOGof54UjbGPw0K6jIUWXl79WFx7JsnoD8rUvTTHjtH2kaVYpES eqwfpNN/LHUhq5C0Xl8aTBkIaONkr+a+VuIC2NdjZAKz1CQvSC0owmdfKiRey2nEeNNb j1dSaCzac1hqzEQ2+IOF/3lQp9+j+4/frWhuUDAiJPIHwYFGfL1OZpsOUfPtWlo/mXbz 7yJm3AT0isCV1c1CoEeRNJNY9P/Z5WZPJDrJSHY+Z0ocV0ignDfNvse7V4oG7anjBg1r 979w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=q1bEpqas; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id yd16si2509528ejb.505.2020.10.12.12.13.55; Mon, 12 Oct 2020 12:14:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=q1bEpqas; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403780AbgJLTJg (ORCPT + 99 others); Mon, 12 Oct 2020 15:09:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:52128 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730938AbgJLTCu (ORCPT ); Mon, 12 Oct 2020 15:02:50 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D875D208FE; Mon, 12 Oct 2020 19:02:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602529369; bh=ZngKwAmXSF8Y89Coi4k6BDuZrVDvBJkayXUCDM4hY5Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q1bEpqasuBStU33qpdozsRJsKJ2SJJ2dvoc//9Fb+FXFfjT9c8uaMDl+F/wNeDeD6 92a2csNPGem/BR1Cj8rcpIjzAp2u1YYjL4VNu2pcleNJj7R8e8xup977L2paL2okcq NVCTF71JaD6w1RrFfOMpYfVx/+eZYtkYN++EVc4k= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Xie He , Martin Schiller , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.8 07/24] drivers/net/wan/x25_asy: Correct the ndo_open and ndo_stop functions Date: Mon, 12 Oct 2020 15:02:22 -0400 Message-Id: <20201012190239.3279198-7-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201012190239.3279198-1-sashal@kernel.org> References: <20201012190239.3279198-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xie He [ Upstream commit ed46cd1d4cc4b2cf05f31fe25fc68d1a9d3589ba ] 1. Move the lapb_register/lapb_unregister calls into the ndo_open/ndo_stop functions. This makes the LAPB protocol start/stop when the network interface starts/stops. When the network interface is down, the LAPB protocol shouldn't be running and the LAPB module shoudn't be generating control frames. 2. Move netif_start_queue/netif_stop_queue into the ndo_open/ndo_stop functions. This makes the TX queue start/stop when the network interface starts/stops. (netif_stop_queue was originally in the ndo_stop function. But to make the code look better, I created a new function to use as ndo_stop, and made it call the original ndo_stop function. I moved netif_stop_queue from the original ndo_stop function to the new ndo_stop function.) Cc: Martin Schiller Signed-off-by: Xie He Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/wan/x25_asy.c | 43 +++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c index 84640a0c13f35..6b427d5dec7e4 100644 --- a/drivers/net/wan/x25_asy.c +++ b/drivers/net/wan/x25_asy.c @@ -456,7 +456,6 @@ static int x25_asy_open(struct net_device *dev) { struct x25_asy *sl = netdev_priv(dev); unsigned long len; - int err; if (sl->tty == NULL) return -ENODEV; @@ -482,14 +481,7 @@ static int x25_asy_open(struct net_device *dev) sl->xleft = 0; sl->flags &= (1 << SLF_INUSE); /* Clear ESCAPE & ERROR flags */ - netif_start_queue(dev); - - /* - * Now attach LAPB - */ - err = lapb_register(dev, &x25_asy_callbacks); - if (err == LAPB_OK) - return 0; + return 0; /* Cleanup */ kfree(sl->xbuff); @@ -511,7 +503,6 @@ static int x25_asy_close(struct net_device *dev) if (sl->tty) clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags); - netif_stop_queue(dev); sl->rcount = 0; sl->xleft = 0; spin_unlock(&sl->lock); @@ -596,7 +587,6 @@ static int x25_asy_open_tty(struct tty_struct *tty) static void x25_asy_close_tty(struct tty_struct *tty) { struct x25_asy *sl = tty->disc_data; - int err; /* First make sure we're connected. */ if (!sl || sl->magic != X25_ASY_MAGIC) @@ -607,11 +597,6 @@ static void x25_asy_close_tty(struct tty_struct *tty) dev_close(sl->dev); rtnl_unlock(); - err = lapb_unregister(sl->dev); - if (err != LAPB_OK) - pr_err("%s: lapb_unregister error: %d\n", - __func__, err); - tty->disc_data = NULL; sl->tty = NULL; x25_asy_free(sl); @@ -714,15 +699,39 @@ static int x25_asy_ioctl(struct tty_struct *tty, struct file *file, static int x25_asy_open_dev(struct net_device *dev) { + int err; struct x25_asy *sl = netdev_priv(dev); if (sl->tty == NULL) return -ENODEV; + + err = lapb_register(dev, &x25_asy_callbacks); + if (err != LAPB_OK) + return -ENOMEM; + + netif_start_queue(dev); + + return 0; +} + +static int x25_asy_close_dev(struct net_device *dev) +{ + int err; + + netif_stop_queue(dev); + + err = lapb_unregister(dev); + if (err != LAPB_OK) + pr_err("%s: lapb_unregister error: %d\n", + __func__, err); + + x25_asy_close(dev); + return 0; } static const struct net_device_ops x25_asy_netdev_ops = { .ndo_open = x25_asy_open_dev, - .ndo_stop = x25_asy_close, + .ndo_stop = x25_asy_close_dev, .ndo_start_xmit = x25_asy_xmit, .ndo_tx_timeout = x25_asy_timeout, .ndo_change_mtu = x25_asy_change_mtu, -- 2.25.1