diff options
author | glebius <glebius@FreeBSD.org> | 2006-06-21 06:02:35 +0000 |
---|---|---|
committer | glebius <glebius@FreeBSD.org> | 2006-06-21 06:02:35 +0000 |
commit | d1e0f2db3d463b9d826c181053dde9c0a5be4c5b (patch) | |
tree | 4ffc9ef2dc4fa8e5e856e5048b07e8d6dd836f55 /sys | |
parent | 7ac9e2a5c289f30e377beda3e8f8a214c1f5e8dd (diff) | |
download | FreeBSD-src-d1e0f2db3d463b9d826c181053dde9c0a5be4c5b.zip FreeBSD-src-d1e0f2db3d463b9d826c181053dde9c0a5be4c5b.tar.gz |
- First initialize ifnet, and then insert it into global
list.
- First remove from global list, then start destroying.
PR: kern/97679
Submitted by: Alex Lyashkov <shadow itt.net.ru>
Reviewed by: rwatson, brooks
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/if.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index fc8c1cb..f92c930 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -432,9 +432,6 @@ if_attach(struct ifnet *ifp) TASK_INIT(&ifp->if_linktask, 0, do_link_state_change, ifp); IF_AFDATA_LOCK_INIT(ifp); ifp->if_afdata_initialized = 0; - IFNET_WLOCK(); - TAILQ_INSERT_TAIL(&ifnet, ifp, if_link); - IFNET_WUNLOCK(); /* * XXX - * The old code would work if the interface passed a pre-existing @@ -509,6 +506,10 @@ if_attach(struct ifnet *ifp) ifp->if_snd.altq_tbr = NULL; ifp->if_snd.altq_ifp = ifp; + IFNET_WLOCK(); + TAILQ_INSERT_TAIL(&ifnet, ifp, if_link); + IFNET_WUNLOCK(); + if (domain_init_status >= 2) if_attachdomain1(ifp); @@ -625,7 +626,18 @@ if_detach(struct ifnet *ifp) int i; struct domain *dp; struct ifnet *iter; - int found; + int found = 0; + + IFNET_WLOCK(); + TAILQ_FOREACH(iter, &ifnet, if_link) + if (iter == ifp) { + TAILQ_REMOVE(&ifnet, ifp, if_link); + found = 1; + break; + } + IFNET_WUNLOCK(); + if (!found) + return; /* * Remove/wait for pending events. @@ -707,16 +719,6 @@ if_detach(struct ifnet *ifp) KNOTE_UNLOCKED(&ifp->if_klist, NOTE_EXIT); knlist_clear(&ifp->if_klist, 0); knlist_destroy(&ifp->if_klist); - IFNET_WLOCK(); - found = 0; - TAILQ_FOREACH(iter, &ifnet, if_link) - if (iter == ifp) { - found = 1; - break; - } - if (found) - TAILQ_REMOVE(&ifnet, ifp, if_link); - IFNET_WUNLOCK(); mtx_destroy(&ifp->if_snd.ifq_mtx); IF_AFDATA_DESTROY(ifp); splx(s); |