Source-Changes-HG archive

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

[src/trunk]: src/sys/net Do less work under the kernel lock, otherwise dhcpcd...



details:   https://anonhg.NetBSD.org/src/rev/1c05a7682b60
branches:  trunk
changeset: 813531:1c05a7682b60
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Feb 01 16:32:28 2016 +0000

description:
Do less work under the kernel lock, otherwise dhcpcd aborting causes us
to deadlock.

diffstat:

 sys/net/bpf.c |  21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

diffs (58 lines):

diff -r d46a010b061b -r 1c05a7682b60 sys/net/bpf.c
--- a/sys/net/bpf.c     Mon Feb 01 15:00:43 2016 +0000
+++ b/sys/net/bpf.c     Mon Feb 01 16:32:28 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bpf.c,v 1.193 2015/12/16 23:14:42 christos Exp $       */
+/*     $NetBSD: bpf.c,v 1.194 2016/02/01 16:32:28 christos Exp $       */
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.193 2015/12/16 23:14:42 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.194 2016/02/01 16:32:28 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_bpf.h"
@@ -475,12 +475,18 @@
 static int
 bpf_close(struct file *fp)
 {
-       struct bpf_d *d = fp->f_bpf;
+       struct bpf_d *d;
        int s;
 
        KERNEL_LOCK(1, NULL);
        mutex_enter(&bpf_mtx);
 
+       if ((d = fp->f_bpf) == NULL) {
+               mutex_exit(&bpf_mtx);
+               KERNEL_UNLOCK_ONE(NULL);
+               return 0;
+       }
+
        /*
         * Refresh the PID associated with this bpf file.
         */
@@ -495,14 +501,15 @@
        splx(s);
        bpf_freed(d);
        LIST_REMOVE(d, bd_list);
+       fp->f_bpf = NULL;
+
+       mutex_exit(&bpf_mtx);
+       KERNEL_UNLOCK_ONE(NULL);
+
        callout_destroy(&d->bd_callout);
        seldestroy(&d->bd_sel);
        softint_disestablish(d->bd_sih);
        free(d, M_DEVBUF);
-       fp->f_bpf = NULL;
-
-       mutex_exit(&bpf_mtx);
-       KERNEL_UNLOCK_ONE(NULL);
 
        return (0);
 }



Home | Main Index | Thread Index | Old Index