Author: markj
Date: Sun Jan  8 18:46:00 2017
New Revision: 311695
URL: https://svnweb.freebsd.org/changeset/base/311695

Log:
  Release the ND6 list lock before making a prefix off-link in nd6_timer().
  
  Reported by:  Jim <bm-2cwfdfg5cjsquqkjyry7hzt9lypbsew...@bitmessage.ch>
  X-MFC With:   r306829

Modified:
  head/sys/netinet6/nd6.c

Modified: head/sys/netinet6/nd6.c
==============================================================================
--- head/sys/netinet6/nd6.c     Sun Jan  8 18:33:13 2017        (r311694)
+++ head/sys/netinet6/nd6.c     Sun Jan  8 18:46:00 2017        (r311695)
@@ -910,7 +910,7 @@ nd6_timer(void *arg)
        struct nd_defrouter *dr, *ndr;
        struct nd_prefix *pr, *npr;
        struct in6_ifaddr *ia6, *nia6;
-       bool onlink_locked;
+       uint64_t genid;
 
        TAILQ_INIT(&drq);
        LIST_INIT(&prl);
@@ -1022,7 +1022,6 @@ nd6_timer(void *arg)
        }
 
        ND6_WLOCK();
-       onlink_locked = false;
 restart:
        LIST_FOREACH_SAFE(pr, &V_nd_prefix, ndpr_entry, npr) {
                /*
@@ -1045,22 +1044,19 @@ restart:
                        continue;
                }
                if ((pr->ndpr_stateflags & NDPRF_ONLINK) != 0) {
-                       if (!onlink_locked) {
-                               onlink_locked = ND6_ONLINK_TRYLOCK();
-                               if (!onlink_locked) {
-                                       ND6_WUNLOCK();
-                                       ND6_ONLINK_LOCK();
-                                       onlink_locked = true;
-                                       ND6_WLOCK();
-                                       goto restart;
-                               }
-                       }
+                       genid = V_nd6_list_genid;
+                       nd6_prefix_ref(pr);
+                       ND6_WUNLOCK();
+                       ND6_ONLINK_LOCK();
                        (void)nd6_prefix_offlink(pr);
+                       ND6_ONLINK_UNLOCK();
+                       ND6_WLOCK();
+                       nd6_prefix_rele(pr);
+                       if (genid != V_nd6_list_genid)
+                               goto restart;
                }
        }
        ND6_WUNLOCK();
-       if (onlink_locked)
-               ND6_ONLINK_UNLOCK();
 
        while ((pr = LIST_FIRST(&prl)) != NULL) {
                LIST_REMOVE(pr, ndpr_entry);
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to