Source-Changes-HG archive

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

[src/trunk]: src/sys/netinet6 Fix constraint violation of pserialize in in6_i...



details:   https://anonhg.NetBSD.org/src/rev/bd6ef022445c
branches:  trunk
changeset: 358961:bd6ef022445c
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Wed Jan 24 03:44:10 2018 +0000

description:
Fix constraint violation of pserialize in in6_ifattach

in6_ifattach_loopback can sleep so we cannot use pserialize for it. Fortunately
in6_ifattach is alwasy called with IFNET_LOCK so pserialize isn't needed there
actually.

diffstat:

 sys/netinet6/in6_ifattach.c |  13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diffs (45 lines):

diff -r ac9b3c0ac256 -r bd6ef022445c sys/netinet6/in6_ifattach.c
--- a/sys/netinet6/in6_ifattach.c       Wed Jan 24 03:13:36 2018 +0000
+++ b/sys/netinet6/in6_ifattach.c       Wed Jan 24 03:44:10 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in6_ifattach.c,v 1.113 2017/11/10 07:27:57 ozaki-r Exp $       */
+/*     $NetBSD: in6_ifattach.c,v 1.114 2018/01/24 03:44:10 ozaki-r Exp $       */
 /*     $KAME: in6_ifattach.c,v 1.124 2001/07/18 08:32:51 jinmei Exp $  */
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6_ifattach.c,v 1.113 2017/11/10 07:27:57 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_ifattach.c,v 1.114 2018/01/24 03:44:10 ozaki-r Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -709,6 +709,8 @@
        struct in6_ifaddr *ia;
        struct in6_addr in6;
 
+       KASSERT(IFNET_LOCKED(ifp));
+
        /* some of the interfaces are inherently not IPv6 capable */
        switch (ifp->if_type) {
        case IFT_BRIDGE:
@@ -771,15 +773,12 @@
         * XXX multiple loopback interface case.
         */
        if ((ifp->if_flags & IFF_LOOPBACK) != 0) {
-               int s = pserialize_read_enter();
                in6 = in6addr_loopback;
+               /* These are safe and atomic thanks to IFNET_LOCK */
                if (in6ifa_ifpwithaddr(ifp, &in6) == NULL) {
-                       if (in6_ifattach_loopback(ifp) != 0) {
-                               pserialize_read_exit(s);
+                       if (in6_ifattach_loopback(ifp) != 0)
                                return;
-                       }
                }
-               pserialize_read_exit(s);
        }
 
        /*



Home | Main Index | Thread Index | Old Index