Source-Changes-HG archive

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

[src/trunk]: src/sys/net tun(4): Deliver SIGIO for hangup under tun_lock.



details:   https://anonhg.NetBSD.org/src/rev/5b3e4d2c59aa
branches:  trunk
changeset: 363500:5b3e4d2c59aa
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Mar 13 21:32:35 2022 +0000

description:
tun(4): Deliver SIGIO for hangup under tun_lock.

Otherwise, tp->tun_pgid is not stable.

diffstat:

 sys/net/if_tun.c |  10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diffs (33 lines):

diff -r f3110bc60964 -r 5b3e4d2c59aa sys/net/if_tun.c
--- a/sys/net/if_tun.c  Sun Mar 13 21:32:27 2022 +0000
+++ b/sys/net/if_tun.c  Sun Mar 13 21:32:35 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_tun.c,v 1.168 2022/03/13 21:32:27 riastradh Exp $   */
+/*     $NetBSD: if_tun.c,v 1.169 2022/03/13 21:32:35 riastradh Exp $   */
 
 /*
  * Copyright (c) 1988, Julian Onions <jpo%cs.nott.ac.uk@localhost>
@@ -19,7 +19,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.168 2022/03/13 21:32:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.169 2022/03/13 21:32:35 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -334,12 +334,10 @@
                tp->tun_flags &= ~TUN_RWAIT;
                cv_broadcast(&tp->tun_cv);
        }
-       selnotify(&tp->tun_rsel, 0, NOTE_SUBMIT);
-
-       mutex_exit(&tp->tun_lock);
-
        if (tp->tun_flags & TUN_ASYNC && tp->tun_pgid)
                fownsignal(tp->tun_pgid, SIGIO, POLL_HUP, 0, NULL);
+       selnotify(&tp->tun_rsel, 0, NOTE_SUBMIT);
+       mutex_exit(&tp->tun_lock);
 
        bpf_detach(ifp);
        if_detach(ifp);



Home | Main Index | Thread Index | Old Index