Re: per-interface packet filters

From: Gleb Smirnoff (glebius_at_freebsd.org)
Date: 12/13/04

  • Next message: Andrew White: "RE: Best layer 2 bridge over IP solution ?"
    Date: Mon, 13 Dec 2004 21:47:00 +0300
    To: Andre Oppermann <andre@freebsd.org>, mlaier@freebsd.org
    
    

      Andre, Max,

    please don't take this hard. I'm not going to change pfil(4) API,
    since it has everything required.

    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.

    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.

    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.

    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.
    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.

    Important points:
    1. No API breakage in PFIL, at least I don't see any problems now.
    2. No conflicts with current filtering. Interface filters can happily
       coexist with global ones.
    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
    _______________________________________________
    freebsd-net@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-net
    To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org"
    

  • Next message: Andrew White: "RE: Best layer 2 bridge over IP solution ?"

    Relevant Pages

    • Re: per-interface packet filters
      ... A>> (Now I speak only about ipfw. ... Supply chain identifier in void arg. ... You can register only once with pfil. ... the pfil API is designed to attach a list of generic filters to ...
      (freebsd-net)
    • Re: per-interface packet filters
      ... A>> A>> (Now I speak only about ipfw. ... Supply chain identifier in void arg. ... A>> interface and ipfw on other. ... If some developer likes idea of per-interface filters and prefers smth ...
      (freebsd-net)
    • Re: per-interface packet filters
      ... > Dear networkers, ... > and with one interface to internet. ... Current global ip_, filters may coexist ... I don't see any changes to pfil for this. ...
      (freebsd-net)
    • Re: per-interface packet filters
      ... You can register only once with pfil. ... It is possible to do this on level of ipfw. ... No. PFIL_HOOKS can hook into two directions for each protocol ... > A> You haven't talked about the presentation interface towards the user. ...
      (freebsd-net)
    • Re: multiple natd + ipfw, with 2 internal ips
      ... I have a little problem with my natd or ipfw configuration. ... Well you could if you set your internal interface to be in promiscuous mode and set proxy arp for that address ... is the next hop router, it uses ARP to find the MAC address of this router. ...
      (freebsd-net)