Detecting LINK_UP / LINK_DOWN events

Sastry Tumuluri sas3 at tumuluri.name
Tue May 22 13:48:29 UTC 2007


> -----Original Message-----
> From: Nikos Vassiliadis [mailto:nvass at teledomenet.gr] 
> Sent: Tuesday, May 22, 2007 2:58 PM

> On Tuesday 22 May 2007 12:19, Sastry Tumuluri wrote:
> > > -----Original Message-----
> > > From: Tom Judge [mailto:tom at tomjudge.com]
> > > Sent: Tuesday, May 22, 2007 12:01 AM

> > > Sastry Tumuluri wrote:
> > > > Friends,
> > > >
> > > > I am trying to catch and do some extra processing on 
> LINK_UP and 
> > > > LINK_DOWN events for my net interfaces (e.g., notify my
> > >
> > > admin, log the event, ...).
> > >
> > > > Tried this on both FreeBSD 6.1 and on FreeBSD 6.2.
> > > >
> > > > I tried using the devd.conf file with the following code (shows 
> > > > LINK_DOWN; wrote similar stuff for LINK_UP):
> > > >
> > > > notify 10 {
> > > >    match   "type"    "LINK_DOWN";
> > > >    action   "logger -s alert: Caught LINK_DOWN on dev: 
> $device-name
> > > > subsys:  $subsystem";
> > > > };
> > > >
> > > > Didn't work. I tried the above with both strict match 
> conditions 
> > > > (using vendor, device and class matches) as well as very
> > >
> > > general (like the above).
> > >
> > > > Didn't work.
> > > > I ran killed devd and ran it in the foreground with "devd
> > >
> > > -dD". Then I
> > >
> > > > logged into a different pty and used
> > > > ifconfig lnc0 down     #(lnc0 is my ethernet device).
> > > > devd doesn't even seem to catch the event (no output at all
> > >
> > > - both on
> > >
> > > > screen and in syslog).
> > > >
> > > >
> > > > On the other hand, "nomatch" and "attach" messages do 
> seem to get 
> > > > through (I wrote similar stuff for nomatch & attach, 
> and they are 
> > > > showing up at bootup and in syslog).
> > > > What could I be doing wrong?
> > >
> > > Have you had a look at net/ifstated in ports?
> > >
> > > Tom
> >
> > Thanks, Tom! Though I had not heard of ifstated before 
> this, it looks 
> > interesting. I've managed to quickly get the latest port 
> and install 
> > it without any hassles - but am still a bit short on 
> documentation - 
> > esp., how the .conf file works, and how to make ifstated 
> work for me. 
> > I haven't used carp so far; and am not sure whether I need 
> to, if all 
> > I want is a simple "notification / logging". Any suggestions?
> >
> > On the other hand, I am still curious why devd didn't work in the 
> > first place. Is it a "futuristic" feature already 
> advertised (in the 
> > devd.conf file, there are examples of LINK_UP/LINK_DOWN 
> that make it 
> > look like it should work)? Or a case for better documentation?
> 
> Did you try pulling the plug?
> LINK events refer to the change of link status, not the "UP" 
> status. That is the "status: active" line .
> 
> nik:0:~$ ifconfig fxp0
> fxp0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
>         options=8<VLAN_MTU>
>         inet 192.168.1.71 netmask 0xffffff00 broadcast 192.168.1.255
>         ether 00:0c:f1:b9:38:50
>         media: Ethernet autoselect (100baseTX <full-duplex>)
>         status: active
> 
> HTH, Nikos
> 

That solved one mystery, Nikos! Yes, the LINK_UP/LINK_DOWN do seem to refer 
to the status of the physical media (plugged in or out). While at it, I also
found that
ifconfig em0 down     (not pulling out the media, just the command)
	does not send any status message (perhaps a driver feature? Not
sure), but
ifconfig em0 up
	does send a LINK_DOWN first and then a LINK_UP. This doesn't seem to
	have any relation to whether or not the IP address is there or
-aliased.

It still leaves me with my original problem that of "detecting changes to
the 
interfaces and logging them / sending alerts". This needs to work for me for
any
Interface: real / psuedo (is that word for ppp0/tun0/etc...?) and any type
of
change: e.g. ip-addr change thru dhcp/pppoe/static etc.. :-( So I guess I'll

keep plugging away at ifstated (carp or no-carp), then!! :-)

Regards,

==Sas3==

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.467 / Virus Database: 269.7.6/814 - Release Date: 5/21/2007
2:01 PM
 



More information about the freebsd-net mailing list