All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira <pablo@eurodev.net>
To: netfilter-devel@lists.netfilter.org,
	Harald Welte <laforge@netfilter.org>
Subject: [PATCH] cleanup for random seed initialization ip_conntrack_hash_rnd
Date: Tue, 13 Apr 2004 00:56:17 +0200	[thread overview]
Message-ID: <407B1E91.5090206@eurodev.net> (raw)

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

Hi Harald and list,

Attached a clean up for the initialization of the random seed used in 
ip_conntrack. With this patch the random seed is initialized once when 
ip_conntrack is loaded instead of checking every time a conntrack is 
created whether it was already initialized or not. If I'm missing 
something, please let me know.

regards,
Pablo

[-- Attachment #2: ip_conntrack_hash_rnd-cleanup.diff --]
[-- Type: text/plain, Size: 1157 bytes --]

diff -Nru --exclude .depend --exclude '*.o' --exclude '*.ko' --exclude '*.ver' --exclude '.*.flags' --exclude '*.orig' --exclude '*.rej' --exclude '*.cmd' --exclude '*.mod.c' --exclude '*~' linux-2.6.3-old/net/ipv4/netfilter/ip_conntrack_core.c linux-2.6.3-patched/net/ipv4/netfilter/ip_conntrack_core.c
--- linux-2.6.3-old/net/ipv4/netfilter/ip_conntrack_core.c	2004-02-18 04:57:11.000000000 +0100
+++ linux-2.6.3-patched/net/ipv4/netfilter/ip_conntrack_core.c	2004-04-13 00:46:17.000000000 +0200
@@ -109,7 +109,6 @@
 	nf_conntrack_put(&ct->infos[0]);
 }
 
-static int ip_conntrack_hash_rnd_initted;
 static unsigned int ip_conntrack_hash_rnd;
 
 static u_int32_t
@@ -628,11 +627,6 @@
 	int i;
 	static unsigned int drop_next;
 
-	if (!ip_conntrack_hash_rnd_initted) {
-		get_random_bytes(&ip_conntrack_hash_rnd, 4);
-		ip_conntrack_hash_rnd_initted = 1;
-	}
-
 	hash = hash_conntrack(tuple);
 
 	if (ip_conntrack_max &&
@@ -1369,6 +1363,8 @@
 {
 	unsigned int i;
 	int ret;
+	
+	get_random_bytes(&ip_conntrack_hash_rnd, 4);
 
 	/* Idea from tcp.c: use 1/16384 of memory.  On i386: 32MB
 	 * machine has 256 buckets.  >= 1GB machines have 8192 buckets. */

             reply	other threads:[~2004-04-12 22:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-12 22:56 Pablo Neira [this message]
2004-04-12 23:30 ` [PATCH] cleanup for random seed initialization ip_conntrack_hash_rnd Harald Welte
2004-04-13  8:19   ` Pablo Neira

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=407B1E91.5090206@eurodev.net \
    --to=pablo@eurodev.net \
    --cc=laforge@netfilter.org \
    --cc=netfilter-devel@lists.netfilter.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.