diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2001-02-13 19:49:33 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2001-02-13 19:49:33 +0000 |
commit | 2211b7acb9eda9915342b5acd6419ff38a9e9d6e (patch) | |
tree | a71e1119d1c8a324c83f46a124f93cbe49e40e4f /sys/net | |
parent | c2339c9cde12add1b67ccf5ca9287e61b29a60b2 (diff) |
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?
Diffstat (limited to 'sys/net')
-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 |