Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net Reorder some destruction routines in if_detach



details:   https://anonhg.NetBSD.org/src/rev/a5fcdb0a3b12
branches:  trunk
changeset: 828444:a5fcdb0a3b12
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Thu Dec 14 05:46:54 2017 +0000

description:
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)

diffstat:

 sys/net/if.c |  33 ++++++++++++++++-----------------
 1 files changed, 16 insertions(+), 17 deletions(-)

diffs (75 lines):

diff -r 2c5f5ec0c743 -r a5fcdb0a3b12 sys/net/if.c
--- a/sys/net/if.c      Thu Dec 14 05:45:55 2017 +0000
+++ b/sys/net/if.c      Thu Dec 14 05:46:54 2017 +0000
@@ -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_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 @@
                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 @@
                }
        }
 
+       /* 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 @@
                ifp->if_percpuq = NULL;
        }
 
+       mutex_obj_free(ifp->if_ioctl_lock);
+       ifp->if_ioctl_lock = NULL;
+
        splx(s);
 
 #ifdef IFAREF_DEBUG



Home | Main Index | Thread Index | Old Index