diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2009-08-10 11:22:11 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2009-08-10 11:22:11 +0000 |
commit | 7f286369dd362fcb8ab472bc3682f0de0568be3d (patch) | |
tree | 62b4d0f42028f1104aa2f549303aeea47cde8bb2 | |
parent | da4d9bdfabf577c666aee81ebc914ff35f0321e9 (diff) |
At sys_reboot time, bring all the interfaces down so that their xxstop
functions are called, which will turn off DMA. Receiving packets into
your memory after a system reboot is pretty nasty. This will also mean
that the shutdown hooks can go; this solution is smaller.
ok henning miod dlg kettenis
-rw-r--r-- | sys/kern/kern_xxx.c | 6 | ||||
-rw-r--r-- | sys/net/if.c | 28 | ||||
-rw-r--r-- | sys/net/if.h | 3 |
3 files changed, 34 insertions, 3 deletions
diff --git a/sys/kern/kern_xxx.c b/sys/kern/kern_xxx.c index 783aa5825dc..5beade18f06 100644 --- a/sys/kern/kern_xxx.c +++ b/sys/kern/kern_xxx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_xxx.c,v 1.11 2009/04/03 09:30:15 art Exp $ */ +/* $OpenBSD: kern_xxx.c,v 1.12 2009/08/10 11:22:10 deraadt Exp $ */ /* $NetBSD: kern_xxx.c,v 1.32 1996/04/22 01:38:41 christos Exp $ */ /* @@ -42,6 +42,8 @@ #include <sys/mount.h> #include <sys/syscallargs.h> +#include <net/if.h> + /* ARGSUSED */ int sys_reboot(struct proc *p, void *v, register_t *retval) @@ -66,6 +68,8 @@ sys_reboot(struct proc *p, void *v, register_t *retval) } } + if_downall(); + boot(SCARG(uap, opt)); atomic_clearbits_int(&p->p_flag, P_CPUPEG); /* XXX */ diff --git a/sys/net/if.c b/sys/net/if.c index c1baaf9f921..df140d42cb2 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.197 2009/07/09 06:40:20 blambert Exp $ */ +/* $OpenBSD: if.c,v 1.198 2009/08/10 11:22:10 deraadt Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -1058,6 +1058,32 @@ link_rtrequest(int cmd, struct rtentry *rt, struct rt_addrinfo *info) } /* + * Bring down all interfaces + */ +void +if_downall(void) +{ + struct ifreq ifrq; /* XXX only partly built */ + struct ifnet *ifp; + int s; + + s = splnet(); + for (ifp = TAILQ_FIRST(&ifnet); ifp; ifp = TAILQ_NEXT(ifp, if_list)) { + if ((ifp->if_flags & IFF_UP) == 0) + continue; + if_down(ifp); + ifp->if_flags &= ~IFF_UP; + + if (ifp->if_ioctl) { + ifrq.ifr_flags = ifp->if_flags; + (void) (*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, + (caddr_t)&ifrq); + } + } + splx(s); +} + +/* * Mark an interface down and notify protocols of * the transition. * NOTE: must be called at splsoftnet or equivalent. diff --git a/sys/net/if.h b/sys/net/if.h index ebec346c825..e4c78fa5213 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if.h,v 1.107 2009/06/06 12:31:17 rainer Exp $ */ +/* $OpenBSD: if.h,v 1.108 2009/08/10 11:22:10 deraadt Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -791,6 +791,7 @@ void if_attachtail(struct ifnet *); void if_attachhead(struct ifnet *); void if_detach(struct ifnet *); void if_down(struct ifnet *); +void if_downall(void); void if_link_state_change(struct ifnet *); void if_qflush(struct ifqueue *); void if_slowtimo(void *); |