Module Name: src
Committed By: ozaki-r
Date: Thu Dec 14 05:46:54 UTC 2017
Modified Files:
src/sys/net: if.c
Log Message:
Reorder some destruction routines in if_detach
- Destroy if_ioctl_lock at the end of the if_detach because it's used in various
destruction routines
- Move psref_target_destroy after pr_purgeif because we want to use psref in
pr_purgeif (otherwise destruction procedures can be tricky)
To generate a diff of this commit:
cvs rdiff -u -r1.413 -r1.414 src/sys/net/if.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/net/if.c
diff -u src/sys/net/if.c:1.413 src/sys/net/if.c:1.414
--- src/sys/net/if.c:1.413 Mon Dec 11 03:29:20 2017
+++ src/sys/net/if.c Thu Dec 14 05:46:54 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.413 2017/12/11 03:29:20 ozaki-r Exp $ */
+/* $NetBSD: if.c,v 1.414 2017/12/14 05:46:54 ozaki-r Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.413 2017/12/11 03:29:20 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.414 2017/12/14 05:46:54 ozaki-r Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -1317,17 +1317,6 @@ if_detach(struct ifnet *ifp)
if_deactivate(ifp);
IFNET_UNLOCK(ifp);
- IFNET_GLOBAL_LOCK();
- ifindex2ifnet[ifp->if_index] = NULL;
- TAILQ_REMOVE(&ifnet_list, ifp, if_list);
- IFNET_WRITER_REMOVE(ifp);
- pserialize_perform(ifnet_psz);
- IFNET_GLOBAL_UNLOCK();
-
- /* Wait for all readers to drain before freeing. */
- psref_target_destroy(&ifp->if_psref, ifnet_psref_class);
- PSLIST_ENTRY_DESTROY(ifp, if_pslist_entry);
-
if (ifp->if_slowtimo != NULL && ifp->if_slowtimo_ch != NULL) {
ifp->if_slowtimo = NULL;
callout_halt(ifp->if_slowtimo_ch, NULL);
@@ -1356,10 +1345,6 @@ if_detach(struct ifnet *ifp)
carp_ifdetach(ifp);
#endif
- /* carp_ifdetach still uses the lock */
- mutex_obj_free(ifp->if_ioctl_lock);
- ifp->if_ioctl_lock = NULL;
-
/*
* Rip all the addresses off the interface. This should make
* all of the routes go away.
@@ -1457,6 +1442,17 @@ again:
}
}
+ /* Wait for all readers to drain before freeing. */
+ IFNET_GLOBAL_LOCK();
+ ifindex2ifnet[ifp->if_index] = NULL;
+ TAILQ_REMOVE(&ifnet_list, ifp, if_list);
+ IFNET_WRITER_REMOVE(ifp);
+ pserialize_perform(ifnet_psz);
+ IFNET_GLOBAL_UNLOCK();
+
+ psref_target_destroy(&ifp->if_psref, ifnet_psref_class);
+ PSLIST_ENTRY_DESTROY(ifp, if_pslist_entry);
+
pfil_run_ifhooks(if_pfil, PFIL_IFNET_DETACH, ifp);
(void)pfil_head_destroy(ifp->if_pfil);
@@ -1503,6 +1499,9 @@ again:
ifp->if_percpuq = NULL;
}
+ mutex_obj_free(ifp->if_ioctl_lock);
+ ifp->if_ioctl_lock = NULL;
+
splx(s);
#ifdef IFAREF_DEBUG