diff options
author | 2001-02-13 19:49:32 +0000 | |
---|---|---|
committer | 2001-02-13 19:49:32 +0000 | |
commit | 2e2c684035cfa92f87cf505819f06dd7a3d47f00 (patch) | |
tree | af19c7542a193fcc0eea18d6d7b42bda3240947c | |
parent | rtc stops if we miss interrupts. Inspired by code from FreeBSD. (diff) | |
download | wireguard-openbsd-2e2c684035cfa92f87cf505819f06dd7a3d47f00.tar.xz wireguard-openbsd-2e2c684035cfa92f87cf505819f06dd7a3d47f00.zip |
When detaching an interface set the if_start, if_ioctl and if_watchdog
functions to 'nops'.
Some protocols might want to output some packets while detaching and
that could be a bad idea when the interface has gone away.
Do we need to change more functions?
-rw-r--r-- | sys/net/if.c | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index c017a551ec8..d04d080a270 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.41 2001/01/30 04:22:24 kjell Exp $ */ +/* $OpenBSD: if.c,v 1.42 2001/02/13 19:49:32 art Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -124,6 +124,10 @@ int if_mark_unignore __P((struct radix_node *, void *)); int ifqmaxlen = IFQ_MAXLEN; +void if_detached_start __P((struct ifnet *)); +int if_detached_ioctl __P((struct ifnet *, u_long, caddr_t)); +void if_detached_watchdog __P((struct ifnet *)); + #ifdef INET6 /* * XXX: declare here to avoid to include many inet6 related files.. @@ -330,6 +334,11 @@ if_detach(ifp) int i, s = splimp(); struct radix_node_head *rnh; + ifp->if_flags &= ~IFF_OACTIVE; + ifp->if_start = if_detached_start; + ifp->if_ioctl = if_detached_ioctl; + ifp->if_watchdog = if_detached_watchdog; + #if NBRIDGE > 0 /* Remove the interface from any bridge it is part of. */ if (ifp->if_bridge) @@ -971,3 +980,33 @@ ifconf(cmd, data) ifc->ifc_len -= space; return (error); } + +/* + * Dummy functions replaced in ifnet during detach (if protocols decide to + * fiddle with the if during detach. + */ +void +if_detached_start(struct ifnet *ifp) +{ + struct mbuf *m; + + while (1) { + IF_DEQUEUE(&ifp->if_snd, m); + + if (m == NULL) + return; + m_freem(m); + } +} + +int +if_detached_ioctl(struct ifnet *ifp, u_long a, caddr_t b) +{ + return ENODEV; +} + +void +if_detached_watchdog(struct ifnet *ifp) +{ + /* nothing */ +}
\ No newline at end of file |