From patchwork Mon Nov 16 07:31:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Schiller X-Patchwork-Id: 11907563 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=-12.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, 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 60083C55ABD for ; Mon, 16 Nov 2020 07:37:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1EC412227F for ; Mon, 16 Nov 2020 07:37:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727779AbgKPHcd (ORCPT ); Mon, 16 Nov 2020 02:32:33 -0500 Received: from mxout70.expurgate.net ([194.37.255.70]:52677 "EHLO mxout70.expurgate.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727775AbgKPHcc (ORCPT ); Mon, 16 Nov 2020 02:32:32 -0500 Received: from [127.0.0.1] (helo=localhost) by relay.expurgate.net with smtp (Exim 4.90) (envelope-from ) id 1keYzz-0007TU-Rk; Mon, 16 Nov 2020 08:32:27 +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 1keYzy-0000GH-O6; Mon, 16 Nov 2020 08:32:26 +0100 Received: from securemail.tdt.de (localhost [127.0.0.1]) by securemail.tdt.de (Postfix) with ESMTP id 51584240049; Mon, 16 Nov 2020 08:32:26 +0100 (CET) Received: from mail.dev.tdt.de (unknown [10.2.4.42]) by securemail.tdt.de (Postfix) with ESMTP id C9173240047; Mon, 16 Nov 2020 08:32:25 +0100 (CET) Received: from mschiller01.dev.tdt.de (unknown [10.2.3.20]) by mail.dev.tdt.de (Postfix) with ESMTPSA id A0FEE20115; Mon, 16 Nov 2020 08:32:25 +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 4/6] net/x25: support NETDEV_CHANGE notifier Date: Mon, 16 Nov 2020 08:31:47 +0100 Message-ID: <20201116073149.23219-4-ms@dev.tdt.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201116073149.23219-1-ms@dev.tdt.de> References: <20201116073149.23219-1-ms@dev.tdt.de> MIME-Version: 1.0 X-purgate-ID: 151534::1605511947-00000FB8-DEB0FE5B/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 This makes it possible to handle carrier lost and detection. In case of carrier lost, we shutdown layer 3 and flush all sessions. Signed-off-by: Martin Schiller --- net/x25/af_x25.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c index d98d1145500e..d61a154b94e4 100644 --- a/net/x25/af_x25.c +++ b/net/x25/af_x25.c @@ -266,6 +266,17 @@ static int x25_device_event(struct notifier_block *this, unsigned long event, 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); + if (!netif_carrier_ok(dev)) { + pr_debug("X.25: Carrier lost -> set link state down: %s\n", dev->name); + nb = x25_get_neigh(dev); + if (nb) { + x25_link_terminated(nb); + x25_neigh_put(nb); + } + } + break; } }