Source-Changes-HG archive

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

[src/trunk]: src/sys/net In _if_down(), release the link state change lock be...



details:   https://anonhg.NetBSD.org/src/rev/ebffaeb45eda
branches:  trunk
changeset: 930951:ebffaeb45eda
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sat Apr 18 15:56:26 2020 +0000

description:
In _if_down(), release the link state change lock before calling
workqueue_wait().  Add a comment explaining how the locking here
works.

PR kern/55018.

diffstat:

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

diffs (41 lines):

diff -r aa2afa5a847d -r ebffaeb45eda sys/net/if.c
--- a/sys/net/if.c      Sat Apr 18 12:56:38 2020 +0000
+++ b/sys/net/if.c      Sat Apr 18 15:56:26 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.c,v 1.473 2020/02/21 00:26:23 joerg Exp $   */
+/*     $NetBSD: if.c,v 1.474 2020/04/18 15:56:26 thorpej 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.473 2020/02/21 00:26:23 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.474 2020/04/18 15:56:26 thorpej Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -2519,10 +2519,21 @@
        pserialize_read_exit(s);
        curlwp_bindx(bound);
 
+       /*
+        * Modification of if_link_cansched is serialized with the
+        * ifnet ioctl lock.
+        *
+        * The link state change lock is taken to synchronize with the
+        * read in if_link_state_change_work_schedule().  Once we set
+        * this to false, our if_link_work won't be scheduled.  But
+        * we need to wait for our if_link_work to drain in case we
+        * lost that race.
+        */
        IF_LINK_STATE_CHANGE_LOCK(ifp);
        ifp->if_link_cansched = false;
+       IF_LINK_STATE_CHANGE_UNLOCK(ifp);
+
        workqueue_wait(ifnet_link_state_wq, &ifp->if_link_work);
-       IF_LINK_STATE_CHANGE_UNLOCK(ifp);
 
        IFQ_PURGE(&ifp->if_snd);
 #if NCARP > 0



Home | Main Index | Thread Index | Old Index