Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 May 2004 12:38:17 +0300
From:      Artis Caune <artis-ml@fbsd.lv>
To:        freebsd-net@freebsd.org
Subject:   Re: 'struct ifnet' question!
Message-ID:  <20040514093817.GA54302@fbsd.lv>
In-Reply-To: <200404291422.56670.max@love2party.net>
References:  <opr67qrrcccpfy5d@mail.latnet.lv> <200404291422.56670.max@love2party.net>

next in thread | previous in thread | raw e-mail | index | archive | help
Thanks,
event handlers looks very trivial to implement.

My thoughts was:
userland read rules and check if interface exist with:
   'if_nametoindex(interface)' call.

kernel stores rules without any knowledge about
interface name or direction, because I use seperate
decision tree for every interface + direction pair.

When module got departure event, all rules are flushed
from in/out decision tree:
   flush_rules(decision_tree[ifp->if_index]->out);
   flush_rules(decision_tree[ifp->if_index]->in);
because if interface is gone, rules are not valid:

# ifconfig vlan0 create
      if_findindex() returns index 6

# load rules with '... in on vlan0 ...'
      kernel store rules in 'decision_tree[6]->in'

# ifconfig vlan0 destory
      here we must flush all vlan0 rules
# ifconfig gif0 create
      gif0 got index 6

if we don't flush old rules, gif0 will use vlan0 rules
because index is reused...



And here is the problem:
If i watch departure events, interface renaming feature will
flush walid rules:
   case SIOCSIFNAME:
      ...
      EVENTHANDLER_INVOKE(ifnet_departure_event, ifp);
      ... change if_xname ...
      EVENTHANDLER_INVOKE(ifnet_arrival_event, ifp);

how about another event? ;)
      EVENTHANDLER_INVOKE(ifnet_rename_event, ifp->ifx_name, new_name);
      strlcpy(ifp->if_xname, new_name, sizeof(ifp->if_xname));




> The other (big) problem in this field is, how to handle yet unknown interfaces
> (e.g. USB/Cardbus/ppp/tun/...).
What is about usb/cardbus/... interfaces? Don't they also call
ether_ifattach()/if_attach()?





-- 
Artis

On Thu, Apr 29, 2004 at 02:22:47PM +0200, Max Laier wrote:
> Yes there is, in -current you will find some eventhandlers (in if_var.h and 
> if_clone.h) which allow you to get a notification when an interface arrives 
> or leaves. Pf (from OpenBSD 3.5) will use them to do exactly what you are 
> planning, to have O(1) interface look-ups.
> 
> Attached is my WIP version of the pf interface handling, which might be a bit 
> too complex for your purpose, but should give you the idea.
> 
> -- 
> Best regards,				| mlaier@freebsd.org
> Max Laier				| ICQ #67774661
> http://pf4freebsd.love2party.net/	| mlaier@EFnet



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040514093817.GA54302>