per-interface packet filters

Gleb Smirnoff glebius at freebsd.org
Tue Dec 14 01:16:56 PST 2004


On Mon, Dec 13, 2004 at 10:50:01PM +0100, Andre Oppermann wrote:
A> > (Now I speak only about ipfw. But other filters can be used in same
A> > manner with a very small changes.)
A> > 
A> > We have list of rules defined in struct ip_fw_chain. At this moment
A> > we have only one instance of it - a global variable layer3_chain.
A> > What I'm going to do:
A> > 1) adding possibility to add new chains and editing them.
A> > 2) adding possibility to run ipfw_chk() against a chain other than
A> > layer3_chain.
A> > 3) Edit ip_fw_check_{in,out}, so that it can call ipfw_chk()
A> > on different chains. Supply chain identifier in void arg. Edit
A> > ipfw_hook() so that it can register ipfw as a pfil, but with
A> > chain different to layer3_chain.
A> 
A> This is what I don't get.  You can register only once with pfil.

in ipfw_hook():

    pfil_add_hook(ipfw_check_in, NULL, PFIL_IN | PFIL_WAITOK, pfh_inet);
    pfil_add_hook(ipfw_check_out, NULL, PFIL_OUT | PFIL_WAITOK, pfh_inet);

smth like: s/pfh_inet/ifp->pfil_head/

No API change.

A> > 4) add possibility to register a pfil_head for an interface. Once the
A> > pfil_head is registered, administrator can call ipfw_hook() on
A> > it, and hook ipfw chain to this pfil_head, either in or out.
A> > 5) In ip_input()/ip_output() check if interface has pfil_head
A> > associated with it. If it does pfil_run_hooks on it.
A> 
A> You are going to change the pfil API.  This is not neccessary.  pfil
A> passes the ifp to the hook, this is sufficient.

Yes. It is possible to do this on level of ipfw. But I'd prefer to do
this on level of pfil. This will give possibility to run pf on one
interface and ipfw on other. (tools, not policy).

A> > Important points:
A> > 1. No API breakage in PFIL, at least I don't see any problems now.
A> 
A> But Max and me see problems.  The API does not break but it is different.
A> We don't want it to be different in such a way.

AFAIU, the pfil API is designed to attach a list of generic filters to
a any place you want. If you say that pfil is designed to perform filtering in
ip_{in,out}put(), this sounds strange.

A> > 2. No conflicts with current filtering. Interface filters can happily
A> >    coexist with global ones.
A> 
A> You haven't talked about the presentation interface towards the user.
A> This is where everything has to start.  How would the ipfw syntax look
A> like?  Provide some examples please.

ipfw syntax will be 100% backward compatible. The following keywords would
be added:

ipfw chain list			- list configured chains
ipfw chain add | delete		- delete, remove chain
ipfw chain _number_ [common rule definition]	- add/delete rules to
						  non-default chain

It would be possible to attach chains to interfaces specifing also
direction. It will be done with ifconfig, or a specific utility (not yet
decided).

A> The problem we have is that you have a specific solution in mind without
A> adequatly stating the problem first.  Because then we would sit down and
A> work out what the best way is to implement it.  So far Max and I do not
A> agree with you on the your stated ideas to solve this.

The fact that Juniper and Cisco (and I suspect other router vendors) use this
technique, proves that it is handy for routers. I'm sure many sysadmins will
agree at this point. Users, not developers. The fact that one have written
some IP packet filter does not mean that he knows everything about its day
to day usage.

-- 
Totus tuus, Glebius.
GLEBIUS-RIPN GLEB-RIPE


More information about the freebsd-net mailing list