From mboxrd@z Thu Jan 1 00:00:00 1970 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=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no 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 2F337C388F9 for ; Wed, 11 Nov 2020 21:17:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B155720825 for ; Wed, 11 Nov 2020 21:17:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20150623.gappssmtp.com header.i=@networkplumber-org.20150623.gappssmtp.com header.b="mEj+tQab" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725996AbgKKVRa (ORCPT ); Wed, 11 Nov 2020 16:17:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725933AbgKKVRa (ORCPT ); Wed, 11 Nov 2020 16:17:30 -0500 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86936C0613D1 for ; Wed, 11 Nov 2020 13:17:30 -0800 (PST) Received: by mail-pg1-x52a.google.com with SMTP id f38so2284660pgm.2 for ; Wed, 11 Nov 2020 13:17:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xKeSXUoPTb94VTZzArvQrdZOaZO1ARIP1gC1bThDFN0=; b=mEj+tQabiKrVPWL8ricFSm6QbRsIn9cB6UT88mz+ItP8ieG0GP7Y0/YecF1lvZvFxR SBQVSeplO78hEJR4u4dD8ABWa5NB5rPNyF8CfTSYLyhZLn24W8Xl9PJFbtUtfa1fDLEy HTAa2/fiv4LVqNF51B1sm+bNWjyCgffxJPSxddawWU4DaLfSgjU2an1VcYJ5POeBXDNZ 3L2v6cUzlb/1FGI2nyLCLasXbe2ry+K7bNyifA92BgObPWVOWvrQTew+NgMteLssDHhb 46QbYDL/yXJE0Ibu8a7DNPVRsw1IIOrweGBBBa/MdAGiHwm1nWnnQruHufyct4cwHSPD F8EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xKeSXUoPTb94VTZzArvQrdZOaZO1ARIP1gC1bThDFN0=; b=e3k09C4et62Zr+eEraf3ZiU6ktR0jss/TLEUavX7+yWCIVw97haA4qDDCCnRIHe5ac kOnuLQvKWlxv40Y2bXTF2Bfxkc4+q/dy8CEF8ZIcTtLYdG5+PFAwpAeQRJBP2Z1S0mSo fyocXUh7q49BMM5kb6S2ue/7CcPpIjyhK1yK/7zVWJnb2HH2A3MBkiLJRI3fB1yBfb/A gNghYyCk6i15C81olPH0CNYXP5ehjXGY5+X/96y4III5rnw1oN8FINL22Y6Jtd4zk0hp QpAWpPmjxQbdCppKU58OlLFI4Ip8mnSE+twW78qsPNQJNUDCQvJrQGT2hr5cEjfm53S3 Pfww== X-Gm-Message-State: AOAM533wnHU7B8QzEDG8lbAwMaaU/5Pur8tFJ1HLsfJWEziwCO/DnTze LP5hatyLTgyBEcljYkaUJnIBIw== X-Google-Smtp-Source: ABdhPJyr/nmYBCSLIlqS8cvY75Jv9KTjZ2ftDsM3qoqfe5nvQbqssqXFDwCYzdAGnxSHEySZH3uucw== X-Received: by 2002:a17:90a:1bc3:: with SMTP id r3mr5859850pjr.196.1605129449739; Wed, 11 Nov 2020 13:17:29 -0800 (PST) Received: from hermes.local (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id y201sm3462776pfb.2.2020.11.11.13.17.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Nov 2020 13:17:29 -0800 (PST) Date: Wed, 11 Nov 2020 13:17:24 -0800 From: Stephen Hemminger To: Erik Kline Cc: Cong Wang , =?UTF-8?B?5p2c6Iux5p2w?= , Linux Kernel Network Developers Subject: Re: some question about "/sys/class/net//operstate" Message-ID: <20201111131724.3ee61c26@hermes.local> In-Reply-To: References: <1a87f1b4.3d6ab.175b592a271.Coremail.leondyj@pku.edu.cn> <20201111115520.08b58818@hermes.local> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Wed, 11 Nov 2020 12:34:51 -0800 Erik Kline wrote: > On Wed, Nov 11, 2020 at 11:55 AM Stephen Hemminger > wrote: > > > > On Wed, 11 Nov 2020 11:02:14 -0800 > > Cong Wang wrote: > > =20 > > > On Tue, Nov 10, 2020 at 8:32 PM =E6=9D=9C=E8=8B=B1=E6=9D=B0 wrote: =20 > > > > > > > > I want to use inotify to monitor /sys/class/net//operstate to dete= ct status of a iface in real time. > > > > when I ifdown && ifup eth3, the content of operstate change= d, but the file's Modify time didn't change. > > > > I don't know the reason, is there any file which can be monitored b= y inotify to get iface status in real time? > > > > Much appreciation for any advice! =20 > > > > > > You need to listen to netdev netlink messages for changes like > > > this. These messages are generated in real-time. =20 > > > > The /sys and /proc are pseudo-filesystems. The file modify time and ino= tify do not work > > as expected on these files. Cong is right you need to use netlink for t= his. =20 >=20 > Related question: could/should modify time and/or inotify be made to > work? I genuinely don't know if that would even be possible (separate > from "desirable"). The problem is lots of data changes in /proc and /sys all the time, like ev= ery counter value. So having any kind of notification would be a major performance hit.