[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 11 Nov 2020 11:55:20 -0800
From: Stephen Hemminger <stephen@...workplumber.org>
To: Cong Wang <xiyou.wangcong@...il.com>
Cc: 杜英杰 <leondyj@....edu.cn>,
Linux Kernel Network Developers <netdev@...r.kernel.org>
Subject: Re: some question about "/sys/class/net/<iface>/operstate"
On Wed, 11 Nov 2020 11:02:14 -0800
Cong Wang <xiyou.wangcong@...il.com> wrote:
> On Tue, Nov 10, 2020 at 8:32 PM 杜英杰 <leondyj@....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.
Powered by blists - more mailing lists