summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorRyan Thomas McBride <mcbride@cvs.openbsd.org>2007-05-28 08:48:16 +0000
committerRyan Thomas McBride <mcbride@cvs.openbsd.org>2007-05-28 08:48:16 +0000
commit74a8c6efc030ed763026122f1b3abb61ba271efa (patch)
treea08e30ddb70f428ea82a8da4b8b9184984fb551f /sys/net
parent5dca78e17380b1d00d6db7aec26ad12535851661 (diff)
Only call add_net_randomness() once per interrupt instead of once per packet. If multiple packets come in on a single interrupt the times mixed into
the randomness pool will be identical or predictably close anyways, and nanotime() is expensive. ok toby jason miod claudio
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if.c11
-rw-r--r--sys/net/netisr.h7
-rw-r--r--sys/net/netisr_dispatch.h4
3 files changed, 17 insertions, 5 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index ddef8fe82e5..bbcc27d0a57 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.157 2007/03/25 18:26:23 mpf Exp $ */
+/* $OpenBSD: if.c,v 1.158 2007/05/28 08:48:15 mcbride Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -85,6 +85,9 @@
#include <net/if_media.h>
#include <net/if_types.h>
#include <net/route.h>
+#include <net/netisr.h>
+
+#include <dev/rndvar.h>
#ifdef INET
#include <netinet/in.h>
@@ -1947,3 +1950,9 @@ sysctl_ifq(int *name, u_int namelen, void *oldp, size_t *oldlenp,
}
/* NOTREACHED */
}
+
+void
+netrndintr(void)
+{
+ add_net_randomness(0);
+}
diff --git a/sys/net/netisr.h b/sys/net/netisr.h
index d2d7ebff007..163c50db263 100644
--- a/sys/net/netisr.h
+++ b/sys/net/netisr.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: netisr.h,v 1.23 2005/06/08 07:13:24 henning Exp $ */
+/* $OpenBSD: netisr.h,v 1.24 2007/05/28 08:48:15 mcbride Exp $ */
/* $NetBSD: netisr.h,v 1.12 1995/08/12 23:59:24 mycroft Exp $ */
/*
@@ -52,6 +52,7 @@
* interrupt used for scheduling the network code to calls
* on the lowest level routine of each protocol.
*/
+#define NETISR_RND 1
#define NETISR_IP 2 /* same as AF_INET */
#define NETISR_IMP 3 /* same as AF_IMPLINK */
#define NETISR_ATALK 16 /* same as AF_APPLETALK */
@@ -69,6 +70,7 @@
#ifdef _KERNEL
extern int netisr; /* scheduling bits for network */
+void netrndintr(void);
void arpintr(void);
void ipintr(void);
void ip6intr(void);
@@ -81,9 +83,8 @@ void bridgeintr(void);
void pppoeintr(void);
void btintr(void);
-#include <dev/rndvar.h>
#define schednetisr(anisr) \
- { netisr |= 1<<(anisr); add_net_randomness(anisr); setsoftnet(); }
+ { netisr |= (1<<(anisr) | NETISR_RND); setsoftnet(); }
#endif
#endif
diff --git a/sys/net/netisr_dispatch.h b/sys/net/netisr_dispatch.h
index 2cd947f1a8c..b314a7443db 100644
--- a/sys/net/netisr_dispatch.h
+++ b/sys/net/netisr_dispatch.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: netisr_dispatch.h,v 1.10 2005/06/08 07:13:24 henning Exp $ */
+/* $OpenBSD: netisr_dispatch.h,v 1.11 2007/05/28 08:48:15 mcbride Exp $ */
/* $NetBSD: netisr_dispatch.h,v 1.2 2000/07/02 04:40:47 cgd Exp $ */
/*
@@ -34,6 +34,8 @@
* their prototypes in <net/netisr.h> (if necessary).
*/
+ DONETISR(NETISR_RND,netrndintr);
+
#ifdef INET
#if NETHER > 0
DONETISR(NETISR_ARP,arpintr);