Announcing ethernet link state changes via route socket

Hasso Tepper hasso at estpak.ee
Fri Mar 16 03:28:46 PDT 2007


Vlad GALU wrote:
>> There is one fundamental problem I'd like to get feedback about from
>> developers - how to make various kernel stuff react on link state
>> changes?
> 
>    There's been an IRC conversation recently regarding that. FreeBSD
> defines a EVFILT_NETDEV filter, which can have one of the following
> event bits set: NOTE_LINKUP, NOTE_LINKDOWN, NOTE_LINKINV. It's a quite
> clean interface. I don't know why OpenBSD chose to do it diferently.

After reading some code and discussion in IRC ...

These are different things. AFAICS EVFILT_NETDEV is just another event
notifying mechanism. Does anybody uses these link events in FreeBSD at all?
All BSD's do related work in if_link_state_change(), only FreeBSD schedules
it for later processing to avoid various locking issues (how we should do
regarding this?) and all actual work is done in the do_link_state_change().
So, in this regard OpenBSD and FreeBSD are not different.

What OpenBSD does it that it allows various subsystems register various
callbacks to the interfaces and the code in if.c is shorter and simpler.
This is coding issue, not the behavioural one. For example instead of the
mass of ifdefs etc if_link_state_change() looks trivial:

void
if_link_state_change(struct ifnet *ifp)
{
        rt_ifmsg(ifp);
        dohooks(ifp->if_linkstatehooks, 0);
}


-- 
Hasso Tepper





More information about the Submit mailing list