All of lore.kernel.org
 help / color / mirror / Atom feed
From: Krishna Kumar <krkumar2@in.ibm.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, Krishna Kumar <krkumar2@in.ibm.com>
Subject: [PATCH] net: Simplify skb_tx_hash()
Date: Wed, 18 Feb 2009 11:02:11 +0530	[thread overview]
Message-ID: <20090218053211.16619.33544.sendpatchset@localhost.localdomain> (raw)

From: Krishna Kumar <krkumar2@in.ibm.com>

The initialization of skb_tx_hashrnd is moved so that it gets called
after "random" driver is initialized. Random numbers generated at this
point are different across 3 immediate reboots:
	(reboot1) Random number: 0xd52f08b6
	(reboot2) Random number: 0x8beeef46
	(reboot3) Random number: 0x7d60a4b6

Signed-off-by: Krishna Kumar <krkumar2@in.ibm.com>
---

 net/core/dev.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff -ruNp net-next-2.6.org/net/core/dev.c net-next-2.6.new/net/core/dev.c
--- net-next-2.6.org/net/core/dev.c	2009-02-17 18:57:15.000000000 +0530
+++ net-next-2.6.new/net/core/dev.c	2009-02-17 19:00:23.000000000 +0530
@@ -1745,17 +1745,11 @@ out_kfree_skb:
 }
 
 static u32 skb_tx_hashrnd;
-static int skb_tx_hashrnd_initialized = 0;
 
 static u16 skb_tx_hash(struct net_device *dev, struct sk_buff *skb)
 {
 	u32 hash;
 
-	if (unlikely(!skb_tx_hashrnd_initialized)) {
-		get_random_bytes(&skb_tx_hashrnd, 4);
-		skb_tx_hashrnd_initialized = 1;
-	}
-
 	if (skb_rx_queue_recorded(skb)) {
 		hash = skb_get_rx_queue(skb);
 	} else if (skb->sk && skb->sk->sk_hash) {
@@ -5291,6 +5285,14 @@ out:
 
 subsys_initcall(net_dev_init);
 
+static int __init initialize_hashrnd(void)
+{
+	get_random_bytes(&skb_tx_hashrnd, sizeof(skb_tx_hashrnd));
+	return 0;
+}
+
+late_initcall_sync(initialize_hashrnd);
+
 EXPORT_SYMBOL(__dev_get_by_index);
 EXPORT_SYMBOL(__dev_get_by_name);
 EXPORT_SYMBOL(__dev_remove_pack);

             reply	other threads:[~2009-02-18  6:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-18  5:32 Krishna Kumar [this message]
2009-02-18  6:53 ` [PATCH] net: Simplify skb_tx_hash() David Miller
2009-02-18  7:27   ` Krishna Kumar2
2009-02-18  7:41     ` David Miller

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=20090218053211.16619.33544.sendpatchset@localhost.localdomain \
    --to=krkumar2@in.ibm.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.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.