Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Apr 2004 13:12:17 +0300
From:      Artis Caune <artis@fbsd.lv>
To:        net@freebsd.org
Subject:   'struct ifnet' question!
Message-ID:  <opr67qmrz8k7ts4q@127.0.0.1>

next in thread | raw e-mail | index | archive | help
I'm writing kld module for traffic shaping (5.x only).
It use PFIL hooks.

There will be seperate decision trees for
every interface + IN/OUT pair.

Let's say we have rules:
   shape in  on fxp0 ...
   shape out on fxp0 ...
   shape in  on vlan0 ...
in this example we have 3 decision trees:
    - rules with 'fxp0 in'
    - rules with 'fxp0 out'
    - rules with 'vlan0 in'

When PFIL pass packet, I need find pointer
to right decision tree:
    tree = find_decision_tree(ifp->if_xname, direction);

Yeh, this works as expected, but I wonder if I can
use ifp->index instead of ifp->if_xname.
Using 'index + array pointer feature' I can find decision
tree in just one? memory access step, compared to
if_xname where I should make expensive strcmp() calls. ;)

I'm worried about 'dynamic' interfaces. e.x:
# ifconfig vlan0 create; ...
# load rules with 'shape in on vlan0'
# ifconfig vlan0 destroy
# ifconfig vlan0 create; ...

I belive at this point if_index is not the same
when rules was loaded. How safe is to use if_index
instead of if_xname? How safe is to use if_xname
with interface renaming feature (-current)?

Is there some way to track interface changes events?


thanks,

-- 
Artis



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