[clue] [tech] How to get explicit notification from a network device driver?

Will will.sterling at gmail.com
Mon Apr 23 15:50:54 MDT 2012


If you do not want the over head of a log analyzer have Syslog send your
logs to a central log hub and then analyze them there.

On Mon, Apr 23, 2012 at 2:19 PM, Jim Ockers <ockers at ockers.net> wrote:

> **
> Hi everyone,
>
> The state of the art in determining ethernet link state, and taking any
> action based on changes, seems to be to run a daemon that repeatedly polls
> the network interface and using an ioctl (SIOCGMIIPHY, SIOCETHTOOL) finds
> out if there is an ethernet link or not.
>
> It seems like it would be more deterministic, and less resource intensive,
> to just have the network card device driver DO something (or cause
> something to be done) when the link state changes.  For an embedded device
> with limited CPU I think while(1) polling is sub-optimal.  It also seems
> like it should not be too hard to get the device driver to do something
> useful in addition to its printk() message about the changed link state.
>
> How could I do this? I think system() is a bad idea because I'm not sure a
> device driver should be starting other processes that may block or
> something.  Also system() requires unistd.h and the kernel compile/build
> system doesn't seem to give drivers access to that sort of normal libc
> functions.  Anyway I welcome any ideas.
>
> For example the driver doesn't compile with the 2 lines I added (marked
> with +), and also unistd.h is not found even though I #included it:
>
>      if (!port->link) {
>          netif_carrier_off(dev);
>          printk(KERN_INFO "%s: link down\n", dev->name);
> +        printk(KERN_INFO "%s: link down, running /usr/bin/wanlinkdown\n",
> dev->name);
> +        system("/usr/bin/wanlinkdown");
>          return;
>      }
>
> I'm not heart-broken that this doesn't work because I didn't like this
> approach to begin with, but I'm still not sure exactly what would be the
> best way to get a notification without polling.  So far the only
> "notification" is the KERN_INFO message that gets printed to the dmesg log
> and also whatever is specified in syslog.conf (kern.info goes to *, which
> includes the console). In addition to the notification I want it to run a
> program or something so I get explicit real-time notification of link state
> changes without constantly polling.
>
> Thanks,
> Jim
>
> --
> Jim Ockers, P.E., P.Eng. (ockers at ockers.net)
> Contact info: http://www.ockers.net/
>
>
> _______________________________________________
> clue mailing list: clue at cluedenver.org
> For information, account preferences, or to unsubscribe see:
> http://cluedenver.org/mailman/listinfo/clue
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cluedenver.org/pipermail/clue/attachments/20120423/c644c01a/attachment.html 


More information about the clue mailing list