From: Stephen Hemminger <stephen@networkplumber.org>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: 杜英杰 <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 11:55:20 -0800 [thread overview]
Message-ID: <20201111115520.08b58818@hermes.local> (raw)
In-Reply-To: <CAM_iQpVzC6PTX8b0cgXO=Pcp_jFCw-UtP__AYyoN7pZLovkqcQ@mail.gmail.com>
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.
next prev parent reply other threads:[~2020-11-11 19:55 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 [this message]
2020-11-11 20:34 ` Erik Kline
2020-11-11 21:17 ` Stephen Hemminger
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=20201111115520.08b58818@hermes.local \
--to=stephen@networkplumber.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.