From af51bc8eb221a56b5cf9a5dd8c776d6de9d0d903 Mon Sep 17 00:00:00 2001 From: brian Date: Thu, 27 May 1999 13:18:28 +0000 Subject: In tunclose(): Delete all routes if IFF_RUNNING is set, irrespective of IFF_UP Unset IFF_RUNNING. --- sys/net/if_tun.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'sys/net') diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index 181fa86..e553949 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -197,19 +197,23 @@ tunclose(dev, foo, bar, p) if (ifp->if_flags & IFF_UP) { s = splimp(); if_down(ifp); - if (ifp->if_flags & IFF_RUNNING) { - /* find internet addresses and delete routes */ - register struct ifaddr *ifa; - for (ifa = ifp->if_addrhead.tqh_first; ifa; - ifa = ifa->ifa_link.tqe_next) { - if (ifa->ifa_addr->sa_family == AF_INET) { - rtinit(ifa, (int)RTM_DELETE, - tp->tun_flags & TUN_DSTADDR ? RTF_HOST : 0); - } - } - } splx(s); } + + if (ifp->if_flags & IFF_RUNNING) { + register struct ifaddr *ifa; + + s = splimp(); + /* find internet addresses and delete routes */ + for (ifa = ifp->if_addrhead.tqh_first; ifa; + ifa = ifa->ifa_link.tqe_next) + if (ifa->ifa_addr->sa_family == AF_INET) + rtinit(ifa, (int)RTM_DELETE, + tp->tun_flags & TUN_DSTADDR ? RTF_HOST : 0); + ifp->if_flags &= ~IFF_RUNNING; + splx(s); + } + funsetown(tp->tun_sigio); selwakeup(&tp->tun_rsel); -- cgit v1.1