Date: Wed, 19 Jul 2006 16:24:53 +0530 From: "Rajkumar S" <rajkumars@gmail.com> To: freebsd-pf@freebsd.org Subject: Re: Program to add/delete a rule from pf Message-ID: <64de5c8b0607190354r6fec30afh3e1d10c5463e31eb@mail.gmail.com> In-Reply-To: <64de5c8b0607182320m6c9d0d9er5636de052e448bf3@mail.gmail.com> References: <64de5c8b0607181030h64d7d539r788ba7bbc6841e4d@mail.gmail.com> <200607181950.10304.max@love2party.net> <64de5c8b0607182320m6c9d0d9er5636de052e448bf3@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 7/19/06, Rajkumar S <rajkumars@gmail.com> wrote: > Just to clarify once more, My requirement is to add and remove rules > like the one below inside an anchor. > > block in quick on fxp0 proto tcp from 192.168.3.3 port 1025 to > 64.233.167.99 port 80 > block in quick on fxp0 proto tcp from 192.168.3.23 port 1054 to > 72.14.207.99 port 8080 Got a reply from Daniel Hartmeier in the main pf list: <quote> Why don't you create sub-anchors, one for each single rule? Then removing one rule (and the sub-anchor that contains it) can be done by simply flushing the sub-anchor. You need one call in the main ruleset or the existing anchor, using the wildcard '*', that call evaluates all sub-anchors, and the call doesn't need to be updated when you insert/remove sub-anchors. You could even use the sub-anchor names in some clever way, like put the rule's expiration time (unix epoch) in that string, so to purge expired rules, you can traverse the list of sub-anchors alphabetically and stop when a name is larger than time(NULL). Or store some ID in the name (which your plugin associates with the entry), which helps you purge the sub-anchor without traversing them all searching for some rule. Unless you expect to have several thousand rules like this concurrently, the overhead of the sub-anchor evaluation isn't that terrible. IIRC, the ioctl API once contained a call to insert/remove one particular rule in a certain place of the ruleset, but it was cumbersome, and the entire (sub-)anchor concept makes it superfluous in most cases. Daniel <quote> This basically solves my problem. Thanks every one for help and suggetions. raj
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?64de5c8b0607190354r6fec30afh3e1d10c5463e31eb>