All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira <pablo@eurodev.net>
To: netfilter@radom.org, Henrik Nordstrom <hno@marasystems.com>,
	KOVACS Krisztian <hidden@balabit.hu>,
	Netfilter Development Mailinglist
	<netfilter-devel@lists.netfilter.org>
Subject: Re: sparc64 match module - bug id 94
Date: Thu, 06 May 2004 16:29:15 +0200	[thread overview]
Message-ID: <409A4BBB.9080401@eurodev.net> (raw)
In-Reply-To: <20040505065402.GA18440@hamachi.radom.org>

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

Hi everyone,

dan radom wrote:

>Hi,
>
>This bug has been open for quite some time, and bugzilla doesn't really
>shows much beyond the initial bug report.  Is this something that will
>ever work?  I would love to use this feature on sparc64.
>  
>

Please, if I'm missing something, kill me softly. Is there anything 
wrong in fixing up the problem with the following patch?

regards,
Pablo

[-- Attachment #2: ipt_limit-fixup.patch --]
[-- Type: text/plain, Size: 1821 bytes --]

diff -u -r1.1.1.1 ipt_limit.c
--- a/net/ipv4/netfilter/ipt_limit.c	5 May 2004 01:30:27 -0000	1.1.1.1
+++ b/net/ipv4/netfilter/ipt_limit.c	6 May 2004 14:16:57 -0000
@@ -31,6 +31,10 @@
 
 static spinlock_t limit_lock = SPIN_LOCK_UNLOCKED;
 
+/* For SMP machines: Since every processor has a copy of the structure
+ * ipt_rateinfo, we must only work with one of them. */
+static struct ipt_rateinfo *master;
+
 /* Rusty: This is my (non-mathematically-inclined) understanding of
    this algorithm.  The `average rate' in jiffies becomes your initial
    amount of credit `credit' and the most credit you can ever have
@@ -70,17 +74,16 @@
 		int offset,
 		int *hotdrop)
 {
-	struct ipt_rateinfo *r = ((struct ipt_rateinfo *)matchinfo)->master;
 	unsigned long now = jiffies;
 
 	spin_lock_bh(&limit_lock);
-	r->credit += (now - xchg(&r->prev, now)) * CREDITS_PER_JIFFY;
-	if (r->credit > r->credit_cap)
-		r->credit = r->credit_cap;
+	master->credit += (now - xchg(&master->prev, now)) * CREDITS_PER_JIFFY;
+	if (master->credit > master->credit_cap)
+		master->credit = master->credit_cap;
 
-	if (r->credit >= r->cost) {
+	if (master->credit >= master->cost) {
 		/* We're not limited. */
-		r->credit -= r->cost;
+		master->credit -= master->cost;
 		spin_unlock_bh(&limit_lock);
 		return 1;
 	}
@@ -129,7 +132,7 @@
 	r->cost = user2credits(r->avg);
 
 	/* For SMP, we only want to use one set of counters. */
-	r->master = r;
+	master = r;
 
 	return 1;
 }
diff -u -r1.1.1.1 ipt_limit.h
--- a/include/linux/netfilter_ipv4/ipt_limit.h	5 May 2004 01:33:05 -0000	1.1.1.1
+++ b/include/linux/netfilter_ipv4/ipt_limit.h	6 May 2004 14:17:22 -0000
@@ -14,8 +14,5 @@
 	unsigned long prev;
 	u_int32_t credit;
 	u_int32_t credit_cap, cost;
-
-	/* Ugly, ugly fucker. */
-	struct ipt_rateinfo *master;
 };
 #endif /*_IPT_RATE_H*/

  parent reply	other threads:[~2004-05-06 14:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-05  6:54 sparc64 match module - bug id 94 dan radom
2004-05-06 10:12 ` Henrik Nordstrom
2004-05-06 14:09   ` KOVACS Krisztian
2004-05-06 14:56     ` Pablo Neira
2004-05-07  6:30       ` Henrik Nordstrom
2004-05-06 15:33     ` Jozsef Kadlecsik
2004-05-07  6:20       ` Henrik Nordstrom
2004-05-06 14:29 ` Pablo Neira [this message]
2004-05-06 14:47   ` Chris Wilson
2004-05-06 14:39     ` Pablo Neira
2004-05-09 14:30 ` Pablo Neira
  -- strict thread matches above, loose matches on Subject: below --
2004-05-04 12:14 dan radom
2004-05-04 14:32 ` Antony Stone

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=409A4BBB.9080401@eurodev.net \
    --to=pablo@eurodev.net \
    --cc=hidden@balabit.hu \
    --cc=hno@marasystems.com \
    --cc=netfilter-devel@lists.netfilter.org \
    --cc=netfilter@radom.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.