From 16174ce41b458dbc236f418497633ccb2eb1ecd7 Mon Sep 17 00:00:00 2001 From: dlg Date: Tue, 26 May 2015 11:36:26 +0000 Subject: [PATCH] move add_net_randomness from ether_input to the if_input task. change it from feeding the ethertype of the packet (which is almost certainly an ip packet or vlan packet, so not that variable) to the number of packets about to be processed. ok deraadt@ mpi@ --- sys/net/if.c | 6 +++++- sys/net/if_ethersubr.c | 9 +-------- sys/net/if_tun.c | 5 +---- sys/net/netisr.h | 3 +-- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index b740c41467a..7f6a88e0bc5 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.333 2015/05/20 08:28:54 mpi Exp $ */ +/* $OpenBSD: if.c,v 1.334 2015/05/26 11:36:26 dlg Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -81,6 +81,8 @@ #include #include +#include + #include #include #include @@ -523,6 +525,8 @@ if_input_process(void *xmq) if (ml_empty(&ml)) return; + add_net_randomness(ml_len(&ml)); + KERNEL_LOCK(); s = splnet(); while ((m = ml_dequeue(&ml)) != NULL) { diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index 1d023091a48..3fe86227a93 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ethersubr.c,v 1.199 2015/05/19 11:09:24 mpi Exp $ */ +/* $OpenBSD: if_ethersubr.c,v 1.200 2015/05/26 11:36:26 dlg Exp $ */ /* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */ /* @@ -99,8 +99,6 @@ didn't get a copy, you may request one from . #include #include -#include - #if NBPFILTER > 0 #include #endif @@ -476,11 +474,6 @@ ether_input(struct mbuf *m, void *hdr) etype = ntohs(eh->ether_type); - if (!(netisr & (1 << NETISR_RND_DONE))) { - add_net_randomness(etype); - atomic_setbits_int(&netisr, (1 << NETISR_RND_DONE)); - } - #if NBRIDGE > 0 /* * Tap the packet off here for a bridge, if configured and diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index c66c95b9c1a..c4ea429615c 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tun.c,v 1.143 2015/05/20 08:28:54 mpi Exp $ */ +/* $OpenBSD: if_tun.c,v 1.144 2015/05/26 11:36:26 dlg Exp $ */ /* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */ /* @@ -882,9 +882,6 @@ tunwrite(dev_t dev, struct uio *uio, int ioflag) #endif if (tp->tun_flags & TUN_LAYER2) { - /* quirk to not add randomness from a virtual device */ - atomic_setbits_int(&netisr, (1 << NETISR_RND_DONE)); - s = splnet(); ether_input_mbuf(ifp, top); splx(s); diff --git a/sys/net/netisr.h b/sys/net/netisr.h index 9d09d25048b..5aba72daa11 100644 --- a/sys/net/netisr.h +++ b/sys/net/netisr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: netisr.h,v 1.40 2014/08/10 07:28:32 guenther Exp $ */ +/* $OpenBSD: netisr.h,v 1.41 2015/05/26 11:36:26 dlg Exp $ */ /* $NetBSD: netisr.h,v 1.12 1995/08/12 23:59:24 mycroft Exp $ */ /* @@ -50,7 +50,6 @@ * interrupt used for scheduling the network code to calls * on the lowest level routine of each protocol. */ -#define NETISR_RND_DONE 1 #define NETISR_IP 2 /* same as AF_INET */ #define NETISR_TX 3 /* for if_snd processing */ #define NETISR_MPLS 4 /* AF_MPLS would overflow */ -- 2.20.1