From patchwork Mon Nov 16 13:55:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Schiller X-Patchwork-Id: 11908599 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 54A9CC5519F for ; Mon, 16 Nov 2020 14:01:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 16EEF223BD for ; Mon, 16 Nov 2020 14:01:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730127AbgKPOBB (ORCPT ); Mon, 16 Nov 2020 09:01:01 -0500 Received: from mxout70.expurgate.net ([194.37.255.70]:36787 "EHLO mxout70.expurgate.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727305AbgKPOBA (ORCPT ); Mon, 16 Nov 2020 09:01:00 -0500 Received: from [127.0.0.1] (helo=localhost) by relay.expurgate.net with smtp (Exim 4.90) (envelope-from ) id 1kef3w-0006Zt-Oa; Mon, 16 Nov 2020 15:00:56 +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 1kef3v-0004cZ-Ll; Mon, 16 Nov 2020 15:00:55 +0100 Received: from securemail.tdt.de (localhost [127.0.0.1]) by securemail.tdt.de (Postfix) with ESMTP id E494A240049; Mon, 16 Nov 2020 15:00:54 +0100 (CET) Received: from mail.dev.tdt.de (unknown [10.2.4.42]) by securemail.tdt.de (Postfix) with ESMTP id 65F01240047; Mon, 16 Nov 2020 15:00:54 +0100 (CET) Received: from mschiller01.dev.tdt.de (unknown [10.2.3.20]) by mail.dev.tdt.de (Postfix) with ESMTPSA id E3CCF21F0F; Mon, 16 Nov 2020 15:00:53 +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 v2 4/6] net/x25: support NETDEV_CHANGE notifier Date: Mon, 16 Nov 2020 14:55:24 +0100 Message-ID: <20201116135522.21791-5-ms@dev.tdt.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201116135522.21791-1-ms@dev.tdt.de> References: <20201116135522.21791-1-ms@dev.tdt.de> MIME-Version: 1.0 X-purgate-ID: 151534::1605535256-00000FB8-C62E8113/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 --- Change from v1: fix 'subject_prefix' and 'checkpatch' warnings --- net/x25/af_x25.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c index 25726120fcc7..6a95ca11694e 100644 --- a/net/x25/af_x25.c +++ b/net/x25/af_x25.c @@ -275,6 +275,19 @@ static int x25_device_event(struct notifier_block *this, unsigned long event, 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; } }