All of lore.kernel.org
 help / color / mirror / Atom feed
* Limit module accept negation?
@ 2005-01-11  1:08 Jorge Agrelo
  2005-01-12 14:20 ` Samuel Jean
  0 siblings, 1 reply; 7+ messages in thread
From: Jorge Agrelo @ 2005-01-11  1:08 UTC (permalink / raw)
  To: netfilter

Can I replace this two rules

iptables -A INPUT -p tcp --syn -m limit --limit 1/s --limit-burst 4 -j ACCEPT
iptables -A INPUT -p tcp --syn -j DROP

For only this one? (Using negation)

iptables -A INPUT -p tcp --syn -m limit ! --limit 1/s --limit-burst 4 -j DROP

Thanks in advanced
**********************************
CTO: Eng. Jorge Agrelo O.
WEb: www.novadevices.com
E-Mail: jagrelo@novadevices.com
Phone: (593-2) 225-7711 ext. 105
Av. Brasil N45-08 y Condor, Quito Ecuador
**********************************

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

* Re: Limit module accept negation?
  2005-01-11  1:08 Limit module accept negation? Jorge Agrelo
@ 2005-01-12 14:20 ` Samuel Jean
  2005-01-14  0:08   ` Jorge Agrelo
  0 siblings, 1 reply; 7+ messages in thread
From: Samuel Jean @ 2005-01-12 14:20 UTC (permalink / raw)
  To: jagrelo; +Cc: netfilter

On Mon, January 10, 2005 8:08 pm, Jorge Agrelo said:
> Can I replace this two rules
>
> iptables -A INPUT -p tcp --syn -m limit --limit 1/s --limit-burst 4 -j
> ACCEPT
> iptables -A INPUT -p tcp --syn -j DROP
>
> For only this one? (Using negation)
>
> iptables -A INPUT -p tcp --syn -m limit ! --limit 1/s --limit-burst 4 -j
> DROP

Unfortunately, you can't without a bit of hacking.
If it happens you would, just grab ipt_limit.c and search for:

/* We're underlimit */

Change the return codes so it returns 0 when 'underlimit', otherwise, 1.
Am sorry if this is straigh, I am at work.
Note that this won't add '!' support but just doesn't match unless it
bursts the limit.

By the way, do you want to limit as soon as you receive more than 1/s packet
regardless of the source address?

>
> Thanks in advanced

HTH,

Samuel



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

* Re: Limit module accept negation?
  2005-01-12 14:20 ` Samuel Jean
@ 2005-01-14  0:08   ` Jorge Agrelo
  2005-01-14  1:20     ` Samuel Jean
  0 siblings, 1 reply; 7+ messages in thread
From: Jorge Agrelo @ 2005-01-14  0:08 UTC (permalink / raw)
  To: Samuel Jean; +Cc: netfilter

Hi Samuel

Yes, I want to limit (drop) as soon as we receive more than 1/s packet
regardless of the source address?, Is there any other way to do that without using
limit match with negation?

Regards
 
On 12 Jan 2005 at 9:20, Samuel Jean wrote:

> On Mon, January 10, 2005 8:08 pm, Jorge Agrelo said:
> > Can I replace this two rules
> >
> > iptables -A INPUT -p tcp --syn -m limit --limit 1/s --limit-burst 4 -j
> > ACCEPT
> > iptables -A INPUT -p tcp --syn -j DROP
> >
> > For only this one? (Using negation)
> >
> > iptables -A INPUT -p tcp --syn -m limit ! --limit 1/s --limit-burst 4 -j
> > DROP
> 
> Unfortunately, you can't without a bit of hacking.
> If it happens you would, just grab ipt_limit.c and search for:
> 
> /* We're underlimit */
> 
> Change the return codes so it returns 0 when 'underlimit', otherwise, 1.
> Am sorry if this is straigh, I am at work.
> Note that this won't add '!' support but just doesn't match unless it
> bursts the limit.
> 
> By the way, do you want to limit as soon as you receive more than 1/s packet
> regardless of the source address?
> 
> >
> > Thanks in advanced
> 
> HTH,
> 
> Samuel
> 
> 





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

* Re: Limit module accept negation?
  2005-01-14  0:08   ` Jorge Agrelo
@ 2005-01-14  1:20     ` Samuel Jean
  2005-01-14  1:24       ` Samuel Jean
  0 siblings, 1 reply; 7+ messages in thread
From: Samuel Jean @ 2005-01-14  1:20 UTC (permalink / raw)
  To: jagrelo; +Cc: netfilter

[-- Attachment #1: Type: text/plain, Size: 504 bytes --]

Jorge Agrelo wrote:

> Yes, I want to limit (drop) as soon as we receive more than 1/s packet
> regardless of the source address?, Is there any other way to do that without using
> limit match with negation?

AFAIK, there isn't.

> 
> Regards
>  

The patch below is against ipt_limit.c from 2.6.10. It's *untested* but 
reflects what I told you. It's just an exemple of how you can make
this module behaving the other way arround.

(NOTE: ipt_limit.c was written to avoid flooding -j LOG)

HTH,

Samuel

[-- Attachment #2: ipt_limit.patch --]
[-- Type: text/x-patch, Size: 337 bytes --]

--- ipt_limit.c	2005-01-13 20:14:10.000000000 -0500
+++ ipt_limit.c.orig	2005-01-13 20:13:19.000000000 -0500
@@ -82,11 +82,11 @@
 		/* We're not limited. */
 		r->credit -= r->cost;
 		spin_unlock_bh(&limit_lock);
-		return 0;
+		return 1;
 	}
 
        	spin_unlock_bh(&limit_lock);
-	return 1;
+	return 0;
 }
 
 /* Precision saver. */

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

* Re: Limit module accept negation?
  2005-01-14  1:20     ` Samuel Jean
@ 2005-01-14  1:24       ` Samuel Jean
  2005-01-14 14:36         ` Jorge Agrelo
  0 siblings, 1 reply; 7+ messages in thread
From: Samuel Jean @ 2005-01-14  1:24 UTC (permalink / raw)
  To: jagrelo; +Cc: netfilter

[-- Attachment #1: Type: text/plain, Size: 258 bytes --]

Samuel Jean wrote:
> The patch below is against ipt_limit.c from 2.6.10. It's *untested* but 
> reflects what I told you. It's just an exemple of how you can make
> this module behaving the other way arround.
> 

Doh! crapy patch. Attached good one. I hope.

[-- Attachment #2: ipt_limit.patch --]
[-- Type: text/x-patch, Size: 337 bytes --]

--- ipt_limit.c.orig	2005-01-13 20:13:19.000000000 -0500
+++ ipt_limit.c	2005-01-13 20:14:10.000000000 -0500
@@ -82,11 +82,11 @@
 		/* We're not limited. */
 		r->credit -= r->cost;
 		spin_unlock_bh(&limit_lock);
-		return 1;
+		return 0;
 	}
 
        	spin_unlock_bh(&limit_lock);
-	return 0;
+	return 1;
 }
 
 /* Precision saver. */

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

* Re: Limit module accept negation?
  2005-01-14  1:24       ` Samuel Jean
@ 2005-01-14 14:36         ` Jorge Agrelo
  2005-01-14 15:06           ` Samuel Jean
  0 siblings, 1 reply; 7+ messages in thread
From: Jorge Agrelo @ 2005-01-14 14:36 UTC (permalink / raw)
  To: Samuel Jean; +Cc: netfilter

Thanks Samuel, after I apply the patch, How look like the rule with 
limit to drop packets flowing above 1p/s

Regards

On 13 Jan 2005 at 20:24, Samuel Jean wrote:

> Samuel Jean wrote:
> > The patch below is against ipt_limit.c from 2.6.10. It's *untested* but 
> > reflects what I told you. It's just an exemple of how you can make
> > this module behaving the other way arround.
> > 
> 
> Doh! crapy patch. Attached good one. I hope.
> 





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

* Re: Limit module accept negation?
  2005-01-14 14:36         ` Jorge Agrelo
@ 2005-01-14 15:06           ` Samuel Jean
  0 siblings, 0 replies; 7+ messages in thread
From: Samuel Jean @ 2005-01-14 15:06 UTC (permalink / raw)
  To: jagrelo; +Cc: netfilter

On Fri, January 14, 2005 9:36 am, Jorge Agrelo said:
> Thanks Samuel, after I apply the patch, How look like the rule with
> limit to drop packets flowing above 1p/s

iptables -I INPUT -m limit --limit 1/s -j DROP

Let me know if that didn't work.

> Regards

Cheers,

Samuel



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

end of thread, other threads:[~2005-01-14 15:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-11  1:08 Limit module accept negation? Jorge Agrelo
2005-01-12 14:20 ` Samuel Jean
2005-01-14  0:08   ` Jorge Agrelo
2005-01-14  1:20     ` Samuel Jean
2005-01-14  1:24       ` Samuel Jean
2005-01-14 14:36         ` Jorge Agrelo
2005-01-14 15:06           ` Samuel Jean

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.