From patchwork Wed Nov 18 13:59:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Schiller X-Patchwork-Id: 11915175 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 08F84C6379D for ; Wed, 18 Nov 2020 14:00:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C7C032080A for ; Wed, 18 Nov 2020 14:00:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726761AbgKROAA (ORCPT ); Wed, 18 Nov 2020 09:00:00 -0500 Received: from mxout70.expurgate.net ([91.198.224.70]:38033 "EHLO mxout70.expurgate.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725790AbgKRN77 (ORCPT ); Wed, 18 Nov 2020 08:59:59 -0500 Received: from [127.0.0.1] (helo=localhost) by relay.expurgate.net with smtp (Exim 4.92) (envelope-from ) id 1kfO01-000PAO-2D; Wed, 18 Nov 2020 14:59:53 +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.92) (envelope-from ) id 1kfO00-000Jsn-6y; Wed, 18 Nov 2020 14:59:52 +0100 Received: from securemail.tdt.de (localhost [127.0.0.1]) by securemail.tdt.de (Postfix) with ESMTP id DF10E240041; Wed, 18 Nov 2020 14:59:51 +0100 (CET) Received: from mail.dev.tdt.de (unknown [10.2.4.42]) by securemail.tdt.de (Postfix) with ESMTP id 61812240040; Wed, 18 Nov 2020 14:59:51 +0100 (CET) Received: from mschiller01.dev.tdt.de (unknown [10.2.3.20]) by mail.dev.tdt.de (Postfix) with ESMTPSA id 10BB420370; Wed, 18 Nov 2020 14:59:51 +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 1/6] net/x25: handle additional netdev events Date: Wed, 18 Nov 2020 14:59:14 +0100 Message-ID: <20201118135919.1447-2-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-ID: 151534::1605707992-00008E89-0285B3DC/0/0 X-purgate: clean X-purgate-type: clean Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add / remove x25_link_device by NETDEV_REGISTER/UNREGISTER and also by NETDEV_POST_TYPE_CHANGE/NETDEV_PRE_TYPE_CHANGE. This change is needed so that the x25_neigh struct for an interface is already created when it shows up and is kept independently if the interface goes UP or DOWN. This is used in an upcomming commit, where x25 params of an neighbour will get configurable through ioctls. Additionally the NETDEV_CHANGE event makes it possible to handle carrier loss and detection. Signed-off-by: Martin Schiller --- include/net/x25.h | 2 ++ net/x25/af_x25.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ net/x25/x25_link.c | 45 +++++++++++++++++++++++++++++++++++++++------ 3 files changed, 85 insertions(+), 6 deletions(-) diff --git a/include/net/x25.h b/include/net/x25.h index d7d6c2b4ffa7..4c1502e8b2b2 100644 --- a/include/net/x25.h +++ b/include/net/x25.h @@ -231,6 +231,8 @@ int x25_backlog_rcv(struct sock *, struct sk_buff *); /* x25_link.c */ void x25_link_control(struct sk_buff *, struct x25_neigh *, unsigned short); +void x25_link_device_add(struct net_device *dev); +void x25_link_device_remove(struct net_device *dev); void x25_link_device_up(struct net_device *); void x25_link_device_down(struct net_device *); void x25_link_established(struct x25_neigh *); diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c index 046d3fee66a9..02f56386e05b 100644 --- a/net/x25/af_x25.c +++ b/net/x25/af_x25.c @@ -233,10 +233,24 @@ static int x25_device_event(struct notifier_block *this, unsigned long event, #endif ) { switch (event) { + case NETDEV_REGISTER: + pr_debug("X.25: got event NETDEV_REGISTER for device: %s\n", + dev->name); + x25_link_device_add(dev); + break; + case NETDEV_POST_TYPE_CHANGE: + pr_debug("X.25: got event NETDEV_POST_TYPE_CHANGE for device: %s\n", + dev->name); + x25_link_device_add(dev); + break; case NETDEV_UP: + pr_debug("X.25: got event NETDEV_UP for device: %s\n", + dev->name); x25_link_device_up(dev); break; case NETDEV_GOING_DOWN: + pr_debug("X.25: got event NETDEV_GOING_DOWN for device: %s\n", + dev->name); nb = x25_get_neigh(dev); if (nb) { x25_terminate_link(nb); @@ -244,10 +258,40 @@ static int x25_device_event(struct notifier_block *this, unsigned long event, } break; case NETDEV_DOWN: + pr_debug("X.25: got event NETDEV_DOWN for device: %s\n", + dev->name); x25_kill_by_device(dev); x25_route_device_down(dev); x25_link_device_down(dev); break; + case NETDEV_PRE_TYPE_CHANGE: + pr_debug("X.25: got event NETDEV_PRE_TYPE_CHANGE for device: %s\n", + dev->name); + x25_link_device_remove(dev); + break; + case NETDEV_UNREGISTER: + pr_debug("X.25: got event NETDEV_UNREGISTER for device: %s\n", + dev->name); + x25_link_device_remove(dev); + break; + case NETDEV_CHANGE: + pr_debug("X.25: got event NETDEV_CHANGE for device: %s\n", + dev->name); + nb = x25_get_neigh(dev); + if (!nb) + break; + + if (!netif_carrier_ok(dev)) { + pr_debug("X.25: Carrier lost -> set link state down: %s\n", + dev->name); + x25_terminate_link(nb); + } else { + pr_debug("X.25: Carrier detected: %s\n", + dev->name); + x25_establish_link(nb); + } + x25_neigh_put(nb); + break; } } diff --git a/net/x25/x25_link.c b/net/x25/x25_link.c index fdae054b7dc1..92828a8a4ada 100644 --- a/net/x25/x25_link.c +++ b/net/x25/x25_link.c @@ -239,9 +239,17 @@ void x25_link_terminated(struct x25_neigh *nb) /* * Add a new device. */ -void x25_link_device_up(struct net_device *dev) +void x25_link_device_add(struct net_device *dev) { - struct x25_neigh *nb = kmalloc(sizeof(*nb), GFP_ATOMIC); + struct x25_neigh *nb = x25_get_neigh(dev); + + /* Check, if we already have a neighbour for this device */ + if (nb) { + x25_neigh_put(nb); + return; + } + + nb = kmalloc(sizeof(*nb), GFP_ATOMIC); if (!nb) return; @@ -268,6 +276,20 @@ void x25_link_device_up(struct net_device *dev) write_unlock_bh(&x25_neigh_list_lock); } +/* A device is coming up */ +void x25_link_device_up(struct net_device *dev) +{ + struct x25_neigh *nb = x25_get_neigh(dev); + + if (!nb) + return; + + nb->state = X25_LINK_STATE_1; + x25_establish_link(nb); + + x25_neigh_put(nb); +} + /** * __x25_remove_neigh - remove neighbour from x25_neigh_list * @nb: - neigh to remove @@ -277,9 +299,6 @@ void x25_link_device_up(struct net_device *dev) */ static void __x25_remove_neigh(struct x25_neigh *nb) { - skb_queue_purge(&nb->queue); - x25_stop_t20timer(nb); - if (nb->node.next) { list_del(&nb->node); x25_neigh_put(nb); @@ -289,7 +308,7 @@ static void __x25_remove_neigh(struct x25_neigh *nb) /* * A device has been removed, remove its links. */ -void x25_link_device_down(struct net_device *dev) +void x25_link_device_remove(struct net_device *dev) { struct x25_neigh *nb; struct list_head *entry, *tmp; @@ -308,6 +327,20 @@ void x25_link_device_down(struct net_device *dev) write_unlock_bh(&x25_neigh_list_lock); } +/* A device is going down */ +void x25_link_device_down(struct net_device *dev) +{ + struct x25_neigh *nb = x25_get_neigh(dev); + + if (!nb) + return; + + skb_queue_purge(&nb->queue); + x25_stop_t20timer(nb); + + x25_neigh_put(nb); +} + /* * Given a device, return the neighbour address. */ From patchwork Wed Nov 18 13:59:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Schiller X-Patchwork-Id: 11915177 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=-13.9 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, 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 0E7BFC5519F 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 B523C20B80 for ; Wed, 18 Nov 2020 14:00:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726788AbgKROAE (ORCPT ); Wed, 18 Nov 2020 09:00:04 -0500 Received: from mxout70.expurgate.net ([194.37.255.70]:50425 "EHLO mxout70.expurgate.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725790AbgKROAC (ORCPT ); Wed, 18 Nov 2020 09:00:02 -0500 Received: from [127.0.0.1] (helo=localhost) by relay.expurgate.net with smtp (Exim 4.90) (envelope-from ) id 1kfO07-0007gw-1V; Wed, 18 Nov 2020 14:59:59 +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 1kfO06-0003Cs-44; Wed, 18 Nov 2020 14:59:58 +0100 Received: from securemail.tdt.de (localhost [127.0.0.1]) by securemail.tdt.de (Postfix) with ESMTP id A88C1240041; Wed, 18 Nov 2020 14:59:57 +0100 (CET) Received: from mail.dev.tdt.de (unknown [10.2.4.42]) by securemail.tdt.de (Postfix) with ESMTP id 2AD1C240040; Wed, 18 Nov 2020 14:59:57 +0100 (CET) Received: from mschiller01.dev.tdt.de (unknown [10.2.3.20]) by mail.dev.tdt.de (Postfix) with ESMTPSA id 02F3920370; Wed, 18 Nov 2020 14:59:57 +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 2/6] net/lapb: fix lapb_connect_request() for DCE Date: Wed, 18 Nov 2020 14:59:15 +0100 Message-ID: <20201118135919.1447-3-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: clean X-purgate-type: clean X-purgate-ID: 151534::1605707998-0000CF01-42F1A3D6/0/0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org For a DTE interface we should change to state LAPB_STATE_1 and start sending SABM(E). But for DCE interfaces, we simply should start the timer t1. Signed-off-by: Martin Schiller --- net/lapb/lapb_iface.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/net/lapb/lapb_iface.c b/net/lapb/lapb_iface.c index 3c03f6512c5f..8dd7c420ae93 100644 --- a/net/lapb/lapb_iface.c +++ b/net/lapb/lapb_iface.c @@ -278,10 +278,14 @@ int lapb_connect_request(struct net_device *dev) if (lapb->state == LAPB_STATE_3 || lapb->state == LAPB_STATE_4) goto out_put; - lapb_establish_data_link(lapb); + if (lapb->mode & LAPB_DCE) { + lapb_start_t1timer(lapb); + } else { + lapb_establish_data_link(lapb); - lapb_dbg(0, "(%p) S0 -> S1\n", lapb->dev); - lapb->state = LAPB_STATE_1; + lapb_dbg(0, "(%p) S0 -> S1\n", lapb->dev); + lapb->state = LAPB_STATE_1; + } rc = LAPB_OK; out_put: 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; From patchwork Wed Nov 18 13:59:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Schiller X-Patchwork-Id: 11915181 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 81877C64E69 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 4BD8B20B80 for ; Wed, 18 Nov 2020 14:00:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726849AbgKROAL (ORCPT ); Wed, 18 Nov 2020 09:00:11 -0500 Received: from mxout70.expurgate.net ([194.37.255.70]:58695 "EHLO mxout70.expurgate.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726812AbgKROAJ (ORCPT ); Wed, 18 Nov 2020 09:00:09 -0500 Received: from [127.0.0.1] (helo=localhost) by relay.expurgate.net with smtp (Exim 4.90) (envelope-from ) id 1kfO0D-0005vL-DS; Wed, 18 Nov 2020 15:00:05 +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 1kfO0C-0006vE-Mz; Wed, 18 Nov 2020 15:00:04 +0100 Received: from securemail.tdt.de (localhost [127.0.0.1]) by securemail.tdt.de (Postfix) with ESMTP id 0C5C5240041; Wed, 18 Nov 2020 15:00:04 +0100 (CET) Received: from mail.dev.tdt.de (unknown [10.2.4.42]) by securemail.tdt.de (Postfix) with ESMTP id 80AE2240040; Wed, 18 Nov 2020 15:00:03 +0100 (CET) Received: from mschiller01.dev.tdt.de (unknown [10.2.3.20]) by mail.dev.tdt.de (Postfix) with ESMTPSA id 7834720370; Wed, 18 Nov 2020 15:00:02 +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 4/6] net/lapb: fix t1 timer handling for DCE Date: Wed, 18 Nov 2020 14:59:17 +0100 Message-ID: <20201118135919.1447-5-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: clean X-purgate-ID: 151534::1605708005-000064E4-44870C75/0/0 X-purgate-type: clean Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org fix t1 timer handling for DCE in LAPB_STATE_0: o DTE interface changes immediately to LAPB_STATE_1 and start sending SABM(E). o DCE interface sends N2-times DM and changes to LAPB_STATE_1 afterwards if there is no response in the meantime. Signed-off-by: Martin Schiller --- net/lapb/lapb_timer.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/net/lapb/lapb_timer.c b/net/lapb/lapb_timer.c index 8f5b17001a07..baa247fe4ed0 100644 --- a/net/lapb/lapb_timer.c +++ b/net/lapb/lapb_timer.c @@ -85,11 +85,18 @@ static void lapb_t1timer_expiry(struct timer_list *t) switch (lapb->state) { /* - * If we are a DCE, keep going DM .. DM .. DM + * If we are a DCE, send DM up to N2 times, then switch to + * STATE_1 and send SABM(E). */ case LAPB_STATE_0: - if (lapb->mode & LAPB_DCE) + if (lapb->mode & LAPB_DCE && + lapb->n2count != lapb->n2) { + lapb->n2count++; lapb_send_control(lapb, LAPB_DM, LAPB_POLLOFF, LAPB_RESPONSE); + } else { + lapb->state = LAPB_STATE_1; + lapb_establish_data_link(lapb); + } break; /* From patchwork Wed Nov 18 13:59:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Schiller X-Patchwork-Id: 11915185 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 00B0BC64E75 for ; Wed, 18 Nov 2020 14:00:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ABD5420B80 for ; Wed, 18 Nov 2020 14:00:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726868AbgKROAR (ORCPT ); Wed, 18 Nov 2020 09:00:17 -0500 Received: from mxout70.expurgate.net ([194.37.255.70]:59597 "EHLO mxout70.expurgate.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726855AbgKROAR (ORCPT ); Wed, 18 Nov 2020 09:00:17 -0500 Received: from [127.0.0.1] (helo=localhost) by relay.expurgate.net with smtp (Exim 4.90) (envelope-from ) id 1kfO0K-0003Pj-MG; Wed, 18 Nov 2020 15:00:12 +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 1kfO0J-0007Ee-I5; Wed, 18 Nov 2020 15:00:11 +0100 Received: from securemail.tdt.de (localhost [127.0.0.1]) by securemail.tdt.de (Postfix) with ESMTP id 1BB43240041; Wed, 18 Nov 2020 15:00:11 +0100 (CET) Received: from mail.dev.tdt.de (unknown [10.2.4.42]) by securemail.tdt.de (Postfix) with ESMTP id 9293F240040; Wed, 18 Nov 2020 15:00:10 +0100 (CET) Received: from mschiller01.dev.tdt.de (unknown [10.2.3.20]) by mail.dev.tdt.de (Postfix) with ESMTPSA id 435D020370; Wed, 18 Nov 2020 15:00:09 +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 5/6] net/x25: fix restart request/confirm handling Date: Wed, 18 Nov 2020 14:59:18 +0100 Message-ID: <20201118135919.1447-6-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-ID: 151534::1605708012-000037DC-5679FC1D/0/0 X-purgate: clean Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org We have to take the actual link state into account to handle restart requests/confirms well. Also, the T20 timer needs to be stopped, if the link is terminated. Signed-off-by: Martin Schiller --- net/x25/x25_link.c | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/net/x25/x25_link.c b/net/x25/x25_link.c index 92828a8a4ada..40ffc10f7a96 100644 --- a/net/x25/x25_link.c +++ b/net/x25/x25_link.c @@ -74,16 +74,43 @@ void x25_link_control(struct sk_buff *skb, struct x25_neigh *nb, switch (frametype) { case X25_RESTART_REQUEST: - confirm = !x25_t20timer_pending(nb); - x25_stop_t20timer(nb); - nb->state = X25_LINK_STATE_3; - if (confirm) + switch (nb->state) { + case X25_LINK_STATE_2: + confirm = !x25_t20timer_pending(nb); + x25_stop_t20timer(nb); + nb->state = X25_LINK_STATE_3; + if (confirm) + x25_transmit_restart_confirmation(nb); + break; + case X25_LINK_STATE_3: + /* clear existing virtual calls */ + x25_kill_by_neigh(nb); + x25_transmit_restart_confirmation(nb); + break; + } break; case X25_RESTART_CONFIRMATION: - x25_stop_t20timer(nb); - nb->state = X25_LINK_STATE_3; + switch (nb->state) { + case X25_LINK_STATE_2: + if (x25_t20timer_pending(nb)) { + x25_stop_t20timer(nb); + nb->state = X25_LINK_STATE_3; + } else { + x25_transmit_restart_request(nb); + x25_start_t20timer(nb); + } + break; + case X25_LINK_STATE_3: + /* clear existing virtual calls */ + x25_kill_by_neigh(nb); + + x25_transmit_restart_request(nb); + nb->state = X25_LINK_STATE_2; + x25_start_t20timer(nb); + break; + } break; case X25_DIAGNOSTIC: @@ -214,8 +241,6 @@ void x25_link_established(struct x25_neigh *nb) { switch (nb->state) { case X25_LINK_STATE_0: - nb->state = X25_LINK_STATE_2; - break; case X25_LINK_STATE_1: x25_transmit_restart_request(nb); nb->state = X25_LINK_STATE_2; @@ -232,6 +257,10 @@ void x25_link_established(struct x25_neigh *nb) void x25_link_terminated(struct x25_neigh *nb) { nb->state = X25_LINK_STATE_0; + + if (x25_t20timer_pending(nb)) + x25_stop_t20timer(nb); + /* Out of order: clear existing virtual calls (X.25 03/93 4.6.3) */ x25_kill_by_neigh(nb); } From patchwork Wed Nov 18 13:59:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Schiller X-Patchwork-Id: 11915183 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=ham 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 926DEC64E7A for ; Wed, 18 Nov 2020 14:00:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3FC572080A for ; Wed, 18 Nov 2020 14:00:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726900AbgKROAY (ORCPT ); Wed, 18 Nov 2020 09:00:24 -0500 Received: from mxout70.expurgate.net ([194.37.255.70]:54423 "EHLO mxout70.expurgate.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726269AbgKROAX (ORCPT ); Wed, 18 Nov 2020 09:00:23 -0500 Received: from [127.0.0.1] (helo=localhost) by relay.expurgate.net with smtp (Exim 4.90) (envelope-from ) id 1kfO0S-0008AR-4W; Wed, 18 Nov 2020 15:00:20 +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 1kfO0R-00031n-8Y; Wed, 18 Nov 2020 15:00:19 +0100 Received: from securemail.tdt.de (localhost [127.0.0.1]) by securemail.tdt.de (Postfix) with ESMTP id 8EA02240041; Wed, 18 Nov 2020 15:00:18 +0100 (CET) Received: from mail.dev.tdt.de (unknown [10.2.4.42]) by securemail.tdt.de (Postfix) with ESMTP id 11011240040; Wed, 18 Nov 2020 15:00:18 +0100 (CET) Received: from mschiller01.dev.tdt.de (unknown [10.2.3.20]) by mail.dev.tdt.de (Postfix) with ESMTPSA id CE305200D1; Wed, 18 Nov 2020 15:00:17 +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 6/6] net/x25: remove x25_kill_by_device() Date: Wed, 18 Nov 2020 14:59:19 +0100 Message-ID: <20201118135919.1447-7-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::1605708019-0000CF01-831BCBE7/0/0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Remove unnecessary function x25_kill_by_device(). Replace the call to x25_kill_by_device() by x25_kill_by_neigh(). Therefore, also remove the call to x25_clear_forward_by_dev() in x25_route_device_down(), as this is already called by x25_kill_by_neigh(). Signed-off-by: Martin Schiller --- net/x25/af_x25.c | 22 +++++----------------- net/x25/x25_route.c | 3 --- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c index 02f56386e05b..ec90956f38d4 100644 --- a/net/x25/af_x25.c +++ b/net/x25/af_x25.c @@ -199,22 +199,6 @@ static void x25_remove_socket(struct sock *sk) write_unlock_bh(&x25_list_lock); } -/* - * Kill all bound sockets on a dropped device. - */ -static void x25_kill_by_device(struct net_device *dev) -{ - struct sock *s; - - write_lock_bh(&x25_list_lock); - - sk_for_each(s, &x25_list) - if (x25_sk(s)->neighbour && x25_sk(s)->neighbour->dev == dev) - x25_disconnect(s, ENETUNREACH, 0, 0); - - write_unlock_bh(&x25_list_lock); -} - /* * Handle device status changes. */ @@ -260,7 +244,11 @@ static int x25_device_event(struct notifier_block *this, unsigned long event, case NETDEV_DOWN: pr_debug("X.25: got event NETDEV_DOWN for device: %s\n", dev->name); - x25_kill_by_device(dev); + nb = x25_get_neigh(dev); + if (nb) { + x25_kill_by_neigh(nb); + x25_neigh_put(nb); + } x25_route_device_down(dev); x25_link_device_down(dev); break; diff --git a/net/x25/x25_route.c b/net/x25/x25_route.c index 00e46c9a5280..ec2a39e9b3e6 100644 --- a/net/x25/x25_route.c +++ b/net/x25/x25_route.c @@ -115,9 +115,6 @@ void x25_route_device_down(struct net_device *dev) __x25_remove_route(rt); } write_unlock_bh(&x25_route_list_lock); - - /* Remove any related forwarding */ - x25_clear_forward_by_dev(dev); } /*