Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Dec 2004 22:50:01 +0100
From:      Andre Oppermann <andre@freebsd.org>
To:        Gleb Smirnoff <glebius@freebsd.org>
Cc:        net@freebsd.org
Subject:   Re: per-interface packet filters
Message-ID:  <41BE0E89.AE21445@freebsd.org>
References:  <20041213124051.GB32719@cell.sick.ru> <41BDABFB.E64C0A31@freebsd.org> <20041213184700.GA37107@cell.sick.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
Gleb Smirnoff wrote:
> 
>   Andre, Max,
> 
> please don't take this hard. I'm not going to change pfil(4) API,
> since it has everything required.

Great.

> Max, you showed me that pf has some optimizations. ipfw has only skipto
> rule, it helps to reduce CPU consumption, but makes 'ipfw show'
> more complicated.

Yes.

> On Mon, Dec 13, 2004 at 03:49:31PM +0100, Andre Oppermann wrote:
> A> > When managing a complex router with many interfaces the output
> A> > of `ipfw show` (or ipf/pf analog) is getting long and difficult to
> A> > understand. It is also important that many packets are checked
> A> > against the rules that can never be applied to them, wasting CPU
> A> > cycles.
> A> >
> A> > A simple example can be local network router with many inner interfaces
> A> > and with one interface to internet. Actually filtering is desired
> A> > only in external interface, and there is no need for local traffic
> A> > to enter packet fitlering routines, e.g. ipfw_chk().
> A>
> A> Then you argument about long ipfw show doesn't hold... ;)
> 
> I mean that this feature can be useful on a complicated setups
> because of maintainability, and even on simple ones, because
> of speed.

I don't believe the speed one.  See Luigi's reply as well.

> A> > I'd like to implement per-interface pfil hooks, like in Cisco
> A> > world. Each interface may have 'in' list of rules, 'out' list
> A> > of rules. Current global ip_{input,output}, filters may coexist
> A> > with per-interface ones, but can be turned off.
> A>
> A> Different worlds.  I wonder why everything has to "like Cisco".  It's
> A> not always the most clever way they solve a given problem.
> 
> Andre, I know your dislikes about Cisco, and I share it too. Idea
> of maintaining separate filter lists for each interface is handy, no
> matter that it is like in Cisco. Before writing this mail I have a lot
> of practice with complicated firewall setups, and I have asked several
> network administrators, who run FreeBSD routers, for their opinion.

This is ok.  It was more of an rhetorical rant by me.

> A> > Our PFIL interface is quite ready for this, and this is very nice.
> A>
> A> I don't see any changes to pfil for this.  Pfil already passes the
> A> interface in the argument call.  This is something for the packet
> A> filters (ipfw/pf/ipf) than the pfil API?
> 
> (Now I speak only about ipfw. But other filters can be used in same
> manner with a very small changes.)
> 
> We have list of rules defined in struct ip_fw_chain. At this moment
> we have only one instance of it - a global variable layer3_chain.
> What I'm going to do:
> 1) adding possibility to add new chains and editing them.
> 2) adding possibility to run ipfw_chk() against a chain other than
> layer3_chain.
> 3) Edit ip_fw_check_{in,out}, so that it can call ipfw_chk()
> on different chains. Supply chain identifier in void arg. Edit
> ipfw_hook() so that it can register ipfw as a pfil, but with
> chain different to layer3_chain.

This is what I don't get.  You can register only once with pfil.

> 4) add possibility to register a pfil_head for an interface. Once the
> pfil_head is registered, administrator can call ipfw_hook() on
> it, and hook ipfw chain to this pfil_head, either in or out.
> 5) In ip_input()/ip_output() check if interface has pfil_head
> associated with it. If it does pfil_run_hooks on it.

You are going to change the pfil API.  This is not neccessary.  pfil
passes the ifp to the hook, this is sufficient.

> Important points:
> 1. No API breakage in PFIL, at least I don't see any problems now.

But Max and me see problems.  The API does not break but it is different.
We don't want it to be different in such a way.

> 2. No conflicts with current filtering. Interface filters can happily
>    coexist with global ones.

You haven't talked about the presentation interface towards the user.
This is where everything has to start.  How would the ipfw syntax look
like?  Provide some examples please.

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

-- 
Andre


> 3. Overhead of comparing one pointer.
> 
> A> > I'll start with creating/editing alternative chains in ipfw. Then
> A> > we will need to add possibility to register per-interface hooks
> A> > in pfil, and add possibility to pass one more optional argument
> A> > from pfil to the filter itself.
> A>
> A> Can you provide example how you think the syntax should be?
> A>
> A> > I'm glad to see any constructive comments on plan.
> A>
> A> You have to be careful not to collide with the "in|out|via" inside
> A> the rules.
> 
> It is not going to collide.
> 
> --
> Totus tuus, Glebius.
> GLEBIUS-RIPN GLEB-RIPE



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