Source-Changes-HG archive

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

[src/trunk]: src/sys/net Fix another deadlock



details:   https://anonhg.NetBSD.org/src/rev/422ffb2f6e2c
branches:  trunk
changeset: 829295:422ffb2f6e2c
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Thu Jan 25 03:09:05 2018 +0000

description:
Fix another deadlock

When waiting for a route update to finish, a waiter has to release its reference
to the route to avoid a deadlock. Because a updater tries to wait for references
to a target route (except for a reference by the updater itself) to be released.

diffstat:

 sys/net/rtsock.c |  14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diffs (40 lines):

diff -r 290d3fe7a423 -r 422ffb2f6e2c sys/net/rtsock.c
--- a/sys/net/rtsock.c  Thu Jan 25 02:45:02 2018 +0000
+++ b/sys/net/rtsock.c  Thu Jan 25 03:09:05 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtsock.c,v 1.237 2018/01/19 05:19:29 ozaki-r Exp $     */
+/*     $NetBSD: rtsock.c,v 1.238 2018/01/25 03:09:05 ozaki-r Exp $     */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.237 2018/01/19 05:19:29 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.238 2018/01/25 03:09:05 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1015,11 +1015,21 @@
                         * Release rt_so_mtx to avoid a deadlock with route_intr
                         * and also serialize updating routes to avoid another.
                         */
+                       if (rt_updating) {
+                               /* Release to allow the updater to proceed */
+                               rt_unref(rt);
+                               rt = NULL;
+                       }
                        while (rt_updating) {
                                error = cv_wait_sig(&rt_update_cv, rt_so_mtx);
                                if (error != 0)
                                        goto flush;
                        }
+                       if (rt == NULL) {
+                               error = rtrequest1(RTM_GET, &info, &rt);
+                               if (error != 0)
+                                       goto flush;
+                       }
                        rt_updating = true;
                        mutex_exit(rt_so_mtx);
 



Home | Main Index | Thread Index | Old Index