From owner-freebsd-pf@FreeBSD.ORG Mon Sep 25 17:01:03 2006 Return-Path: X-Original-To: freebsd-pf@freebsd.org Delivered-To: freebsd-pf@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7445216A403 for ; Mon, 25 Sep 2006 17:01:03 +0000 (UTC) (envelope-from max@love2party.net) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.183]) by mx1.FreeBSD.org (Postfix) with ESMTP id A363543D55 for ; Mon, 25 Sep 2006 17:00:53 +0000 (GMT) (envelope-from max@love2party.net) Received: from [88.64.186.6] (helo=amd64.laiers.local) by mrelayeu.kundenserver.de (node=mrelayeu0) with ESMTP (Nemesis), id 0MKwh2-1GRtp51qqD-00087Z; Mon, 25 Sep 2006 19:00:51 +0200 From: Max Laier Organization: FreeBSD To: freebsd-pf@freebsd.org Date: Mon, 25 Sep 2006 19:00:44 +0200 User-Agent: KMail/1.9.4 References: <9a542da30609250749i52f966a3x7a9402872d33b976@mail.gmail.com> In-Reply-To: <9a542da30609250749i52f966a3x7a9402872d33b976@mail.gmail.com> X-Face: ,,8R(x[kmU]tKN@>gtH1yQE4aslGdu+2]; R]*pL,U>^H?)gW@49@wdJ`H<=?utf-8?q?=25=7D*=5FBD=0A=09U=5For=3D=5CmOZf764=26nYj=3DJYbR1PW0ud?=>|!~,,CPC.1-D$FG@0h3#'5"k{V]a~.<=?utf-8?q?mZ=7D44=23Se=7Em=0A=09Fe=7E=5C=5DX5B=5D=5Fxj?=(ykz9QKMw_l0C2AQ]}Ym8)fU MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart1277569.CbP061ISPN"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200609251900.50657.max@love2party.net> X-Provags-ID: kundenserver.de abuse@kundenserver.de login:61c499deaeeba3ba5be80f48ecc83056 Cc: Ermal =?iso-8859-1?q?Lu=E7i?= Subject: Re: netgraph related question X-BeenThere: freebsd-pf@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Technical discussion and general questions about packet filter \(pf\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Sep 2006 17:01:03 -0000 --nextPart1277569.CbP061ISPN Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Monday 25 September 2006 16:49, Ermal Lu=E7i wrote: > I am curios how difficult would it be to write an netgraph module for > pf kinda ng_ipfw. Between 100 and 600 lines of code, depending how far you want to take it -= =20 see below. > And maybe looking for a pointer to which function this hooking needs to > be added. > After studing a little bit ng_ipfw and ipfw functions ipfw_check() is > the function which does the magic by a simple global variable, at least > as far a i can tell. > Now can it be done using the same ideas in PF too! The basic communication between netgraph and ipfw happens via mbuf tags=20 attached to the packet. Read the ng_ipfw(4) manpage for details on this. = =20 It is non-trivial to do something along those lines in pf as ruleset=20 evaluation works completely different from what ipfw does. i.e. the main=20 problem one has to solve is: How do you express the netgraph hook in=20 pf.conf? One possible sollution would be to have it as part of the scrub ruleset. =20 This is quick and easy as the scrub ruleset is always evaluated, but it=20 would be adverse to the general pf idea of stateful-filtering. The more involved sollution is to have the ng-hook as a rule option. This= =20 gives all the benefits of stateful filtering, but requires a lot more=20 changes in pf to make things work together. The basic implementation is=20 quite easy, however. All you need to do is add the option to the=20 pf_rule/pf_state structs and attach a mbuf tag accordingly. The packet=20 is then diverted to netgraph where ng_tag (or any other netgraph node)=20 can have a look at it and eventually sent back. In pf_test it will match=20 the same rule/state again (you'd have to change a couple of things to=20 avoid state irritations) and you can finally pass it, as it has a=20 netgraph tag already attached. Support of divert(4) sockets is something along the same line. It would=20 be nice to have a way to send packets from pf to a divert socket, but the=20 same problem applies: How do you express the hook-point in pf? I'd like to work on both of these problems, provided there is enough=20 interest and we can come up with a proper sollution for the hook-point=20 problem. Any ideas? > Ah, the reason i am asking this is just to integrate PF with ng_tag > which can do L7 filtering. =2D-=20 /"\ Best regards, | mlaier@freebsd.org \ / Max Laier | ICQ #67774661 X http://pf4freebsd.love2party.net/ | mlaier@EFnet / \ ASCII Ribbon Campaign | Against HTML Mail and News --nextPart1277569.CbP061ISPN Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (FreeBSD) iD8DBQBFGAtCXyyEoT62BG0RAlQnAJ9p1MRvPurDu7ebhH24oMBQWIpIJgCfakiO USQVw+0/DSPQfZTC5YwQLc0= =O4GY -----END PGP SIGNATURE----- --nextPart1277569.CbP061ISPN--