From: Stephen Hemminger <stephen@networkplumber.org>
To: Erik Kline <ek@loon.com>
Cc: "Cong Wang" <xiyou.wangcong@gmail.com>, 杜英杰 <leondyj@pku.edu.cn>,
"Linux Kernel Network Developers" <netdev@vger.kernel.org>
Subject: Re: some question about "/sys/class/net/<iface>/operstate"
Date: Wed, 11 Nov 2020 13:17:24 -0800 [thread overview]
Message-ID: <20201111131724.3ee61c26@hermes.local> (raw)
In-Reply-To: <CAAedzxoW76P7jk3k4auR+DY_829FKwVLBi6uDzn7C2Y6381=YQ@mail.gmail.com>
On Wed, 11 Nov 2020 12:34:51 -0800
Erik Kline <ek@loon.com> wrote:
> On Wed, Nov 11, 2020 at 11:55 AM Stephen Hemminger
> <stephen@networkplumber.org> wrote:
> >
> > On Wed, 11 Nov 2020 11:02:14 -0800
> > Cong Wang <xiyou.wangcong@gmail.com> wrote:
> >
> > > On Tue, Nov 10, 2020 at 8:32 PM 杜英杰 <leondyj@pku.edu.cn> wrote:
> > > >
> > > > I want to use inotify to monitor /sys/class/net//operstate to detect status of a iface in real time.
> > > > when I ifdown && ifup eth3, the content of operstate changed, but the file's Modify time didn't change.
> > > > I don't know the reason, is there any file which can be monitored by inotify to get iface status in real time?
> > > > Much appreciation for any advice!
> > >
> > > You need to listen to netdev netlink messages for changes like
> > > this. These messages are generated in real-time.
> >
> > The /sys and /proc are pseudo-filesystems. The file modify time and inotify do not work
> > as expected on these files. Cong is right you need to use netlink for this.
>
> 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 every counter
value. So having any kind of notification would be a major performance hit.
prev parent reply other threads:[~2020-11-11 21:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-11 4:31 some question about "/sys/class/net/<iface>/operstate" 杜英杰
2020-11-11 19:02 ` Cong Wang
2020-11-11 19:55 ` Stephen Hemminger
2020-11-11 20:34 ` Erik Kline
2020-11-11 21:17 ` Stephen Hemminger [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201111131724.3ee61c26@hermes.local \
--to=stephen@networkplumber.org \
--cc=ek@loon.com \
--cc=leondyj@pku.edu.cn \
--cc=netdev@vger.kernel.org \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).