Skip to contentSkip to conversation

rfc on new match type

DISCUSSION Brad Fisher 2 participants 3 messages May 7, 2003 – May 8, 2003 netfilter

lore
Share & tools
lore
#0 lore raw

I've been thinking that it may be nice to have a match which can be used to identify which application added a particular rule. For example, if there is an application (say "fwadminprogram") which adds rules it could mark those rules with an id of some sort using this match. Perhaps something like:

iptables -A <chain> -m application --application-id 2000 <other params
here>

So the application could determine which rules it added by searching for all rules with an "application" match with the id 2000. On the kernel side, the match would not actually do anything, it would just match the packet.

The main purpose of this (at least as i see it) would be to have a way to ignore rules not added by your application, so you don't have to worry (as much) about messing up what other applications may have set up. Or perhaps the application-id could be a string instead of an integer, thus allowing you to mark the rules with the application name instead.

I'll probably end up implementing this match sometime in the near future for a project i'm working on. Unless of course, someone has a better idea? Maybe it's already possible to do this with an existing match?

Anyway, just thought I'd see what others thought.

Brad Fisher
Info Link Inc.

#1 lore raw

Hello Brad & list,

Quoted 8 lines

iptables -A <chain> -m application --application-id 2000 <other params
here>

So the application could determine which rules it added by searching for all rules with an "application" match with the id 2000. On the kernel side, the match would not actually do anything, it would just match the packet.

Quoted 6 lines

The main purpose of this (at least as i see it) would be to have a way to ignore rules not added by your application, so you don't have to worry (as much) about messing up what other applications may have set up. Or perhaps the application-id could be a string instead of an integer, thus allowing you to mark the rules with the application name instead.

With a string instead of an id, this is exactly the 'comment' match that I proposed before, but with a less general application (pun intended) in mind.

You can, somewhat, emulate it today, with a pattern like this:

	iptables -A chain -s 0.0.0.0 -m string --string "start APP1"
	iptables -A chain ...
	iptables -A chain ...
	iptables -A chain -s 0.0.0.0 -m string --string "end APP1"

Note: string match with unlikely precondition, should not really compare strings most of the time; no target means no action on those lines.

Problem with this approach: you need some user space locking to make sure no two applications add such "bracketed" rules at the same time.

best regards
Patrick

#2 lore raw
Quoted 3 lines · Patrick Schaaf

With a string instead of an id, this is exactly the 'comment' match that I proposed before, but with a less general application (pun intended) in mind.

A comment match would serve my purposes just as well. I could always use a (hopefully) unique commenting style for a given app, and match on that style.

Quoted 6 lines

You can, somewhat, emulate it today, with a pattern like this:

iptables -A chain -s 0.0.0.0 -m string --string "start APP1" iptables -A chain ...
iptables -A chain ...
iptables -A chain -s 0.0.0.0 -m string --string "end APP1"

So as I understand the above example, all rules added by the application would need to be bracketed by the string match rules? How would you handle the case where your application inserts rules into a chain at arbitrary spots (say before other possibly pre-existing rules which may match the same general criteria, but in a broader sense). You could bracket each rule with the two string matches, but that seems undesirable. And that all relies on all applications respecting such bracketing.

Anyway, not complaining about the response. Your suggestion is excellent, but doesn't quite meet my needs. I do believe that if I end up implementing a match like this, I will use the above mentioned "comment" form, so it can have a more general application as suggested.

Thanks!

-Brad