All of lore.kernel.org
 help / color / mirror / Atom feed
* Unique IDs for rules?
@ 2004-01-19 13:31 David Cannings
  2004-01-19 16:03 ` Henrik Nordstrom
  0 siblings, 1 reply; 5+ messages in thread
From: David Cannings @ 2004-01-19 13:31 UTC (permalink / raw)
  To: netfilter-devel

I've taken a look at the iptables manual page but can't seem to see 
anything that would suit what I want.  I have a number of rules that I 
grep for every five minutes, reading the packet/byte count then resetting 
their totals by using --replace and --set-counters.  At present, I know 
that these rules will always be the ones at the top of my INPUT chain, so 
I know their IDs will be 1, 2, 3 etc.

I want to do similar with other rules elsewhere in the chain but I can't 
be sure that they'll always be number 12, for example.  This makes 
grepping for them a little harder.  Would it be possible to have some 
sort of "comment" field for each rule so that some sort of token or 
unique ID for the rule could be inserted.  That way, it would simply be a 
case of "iptables -L -v | grep 'token'".  

Whether such an idea would add extra overhead to processing I don't know.  
I can also see that adding an extra column to the iptables output could 
be troublesome for those with scripts that rely on the present format but 
I'm sure it could be accomodated, somehow.

Thanks,

David

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Unique IDs for rules?
  2004-01-19 13:31 Unique IDs for rules? David Cannings
@ 2004-01-19 16:03 ` Henrik Nordstrom
  2004-01-19 17:38   ` David Cannings
  0 siblings, 1 reply; 5+ messages in thread
From: Henrik Nordstrom @ 2004-01-19 16:03 UTC (permalink / raw)
  To: david; +Cc: netfilter-devel

On Mon, 19 Jan 2004, David Cannings wrote:

> I want to do similar with other rules elsewhere in the chain but I can't 
> be sure that they'll always be number 12, for example.  This makes 
> grepping for them a little harder.  Would it be possible to have some 
> sort of "comment" field for each rule so that some sort of token or 
> unique ID for the rule could be inserted.  That way, it would simply be a 
> case of "iptables -L -v | grep 'token'".  

There was a dummy match posted some time ago intended for this purpose, or 
at least it was discussed. This adds very little extra overhead provided 
the match is the last match used in the rule.

As an alternative you can always have the target rule in a custom chain
with a jump in the main chain. This way you always know where to look. 
This adds a about marginally more overhead than the above if done 
correctly.

Regards
Henrik

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Unique IDs for rules?
  2004-01-19 16:03 ` Henrik Nordstrom
@ 2004-01-19 17:38   ` David Cannings
  2004-01-19 17:52     ` Henrik Nordstrom
  2004-01-19 18:04     ` Brad Fisher
  0 siblings, 2 replies; 5+ messages in thread
From: David Cannings @ 2004-01-19 17:38 UTC (permalink / raw)
  To: Henrik Nordstrom; +Cc: netfilter-devel

On Monday 19 January 2004 4:03 pm, Henrik Nordstrom wrote:
> On Mon, 19 Jan 2004, David Cannings wrote:
> > I want to do similar with other rules elsewhere in the chain but I
> > can't be sure that they'll always be number 12, for example.  This
> > makes grepping for them a little harder.  Would it be possible to
> > have some sort of "comment" field for each rule so that some sort of
> > token or unique ID for the rule could be inserted.  That way, it
> > would simply be a case of "iptables -L -v | grep 'token'".
>
> There was a dummy match posted some time ago intended for this purpose,
> or at least it was discussed. This adds very little extra overhead
> provided the match is the last match used in the rule.
>
> As an alternative you can always have the target rule in a custom chain
> with a jump in the main chain. This way you always know where to look.
> This adds a about marginally more overhead than the above if done
> correctly.

An excellent idea, thank you.  Doing it this way, I will also be able to 
count bytes in/out of specific ports (such as HTTP) which will let me 
graph even more useless statistics!  One last question, however.  I've 
created a new chain called COUNTER.  In this chain, I've got two rules:

iptables -A COUNTER -i eth0
iptables -A COUNTER -o eth0

To count packets in and out of eth0, respectively.  I then jump to this 
chain from the top of both INPUT and OUTPUT, using a rule:

iptables -I INPUT -j COUNTER
iptables -I OUTPUT -j COUNTER

Is it "safe" to jump like this from both input and output chains to one 
shared chain?  As I am not affecting the destiny of the packet (and seems 
iptables lets me) I feel it must be, however I thought I would check 
first.

Thanks again,

David

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Unique IDs for rules?
  2004-01-19 17:38   ` David Cannings
@ 2004-01-19 17:52     ` Henrik Nordstrom
  2004-01-19 18:04     ` Brad Fisher
  1 sibling, 0 replies; 5+ messages in thread
From: Henrik Nordstrom @ 2004-01-19 17:52 UTC (permalink / raw)
  To: david; +Cc: netfilter-devel

On Mon, 19 Jan 2004, David Cannings wrote:

> Is it "safe" to jump like this from both input and output chains to one 
> shared chain?

Yes, but this is now material for the netfilter list, not 
netfilter-devel..

Regards
Henrik

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Unique IDs for rules?
  2004-01-19 17:38   ` David Cannings
  2004-01-19 17:52     ` Henrik Nordstrom
@ 2004-01-19 18:04     ` Brad Fisher
  1 sibling, 0 replies; 5+ messages in thread
From: Brad Fisher @ 2004-01-19 18:04 UTC (permalink / raw)
  To: david; +Cc: netfilter-devel



David Cannings wrote:

> On Monday 19 January 2004 4:03 pm, Henrik Nordstrom wrote:
> > On Mon, 19 Jan 2004, David Cannings wrote:
> > > I want to do similar with other rules elsewhere in the chain but I
> > > can't be sure that they'll always be number 12, for example.  This
> > > makes grepping for them a little harder.  Would it be possible to
> > > have some sort of "comment" field for each rule so that some sort of
> > > token or unique ID for the rule could be inserted.  That way, it
> > > would simply be a case of "iptables -L -v | grep 'token'".
> >
> > There was a dummy match posted some time ago intended for this purpose,
> > or at least it was discussed. This adds very little extra overhead
> > provided the match is the last match used in the rule.
> >

FWIW: I did post a patch for a "comment" match a while back.  Splitting your
rules into separate chains is probably the way to go for your situation, but
I thought I'd mention it.  If you're still interested, I'd be glad to send
you a copy of the patch.

-Brad

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-01-19 18:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-19 13:31 Unique IDs for rules? David Cannings
2004-01-19 16:03 ` Henrik Nordstrom
2004-01-19 17:38   ` David Cannings
2004-01-19 17:52     ` Henrik Nordstrom
2004-01-19 18:04     ` Brad Fisher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.