Source-Changes-HG archive

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

[src/trunk]: src/sys Make panic messages more informative



details:   https://anonhg.NetBSD.org/src/rev/1ea81a6921c5
branches:  trunk
changeset: 459768:1ea81a6921c5
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Wed Sep 25 09:53:37 2019 +0000

description:
Make panic messages more informative

diffstat:

 sys/net/if.c           |   6 +++---
 sys/net/if_llatbl.c    |   5 +++--
 sys/net/link_proto.c   |   7 ++++---
 sys/net/route.c        |   8 ++++----
 sys/netinet/in.c       |   6 +++---
 sys/netinet6/in6.c     |  10 ++++++----
 sys/netinet6/mld6.c    |  16 ++++++++++------
 sys/netinet6/nd6.c     |  13 ++++++++-----
 sys/netinet6/nd6_rtr.c |   9 +++++----
 sys/netipsec/key.c     |  30 +++++++++++++++++++-----------
 10 files changed, 65 insertions(+), 45 deletions(-)

diffs (truncated from 425 to 300 lines):

diff -r d87c3ec75c2c -r 1ea81a6921c5 sys/net/if.c
--- a/sys/net/if.c      Wed Sep 25 09:52:32 2019 +0000
+++ b/sys/net/if.c      Wed Sep 25 09:53:37 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.c,v 1.461 2019/09/19 06:07:24 knakahara Exp $       */
+/*     $NetBSD: if.c,v 1.462 2019/09/25 09:53:37 ozaki-r 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.461 2019/09/19 06:07:24 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.462 2019/09/25 09:53:37 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -1807,7 +1807,7 @@
 ifafree(struct ifaddr *ifa)
 {
        KASSERT(ifa != NULL);
-       KASSERT(ifa->ifa_refcnt > 0);
+       KASSERTMSG(ifa->ifa_refcnt > 0, "ifa_refcnt=%d", ifa->ifa_refcnt);
 
        if (atomic_dec_uint_nv(&ifa->ifa_refcnt) == 0) {
                free(ifa, M_IFADDR);
diff -r d87c3ec75c2c -r 1ea81a6921c5 sys/net/if_llatbl.c
--- a/sys/net/if_llatbl.c       Wed Sep 25 09:52:32 2019 +0000
+++ b/sys/net/if_llatbl.c       Wed Sep 25 09:53:37 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_llatbl.c,v 1.30 2018/07/10 19:30:37 kre Exp $       */
+/*     $NetBSD: if_llatbl.c,v 1.31 2019/09/25 09:53:37 ozaki-r Exp $   */
 /*
  * Copyright (c) 2004 Luigi Rizzo, Alessandro Cerri. All rights reserved.
  * Copyright (c) 2004-2008 Qing Li. All rights reserved.
@@ -239,7 +239,8 @@
                lle->lle_tbl = NULL;
                lle->lle_head = NULL;
 #endif
-               KASSERT(lle->lle_tbl->llt_lle_count != 0);
+               KASSERTMSG(lle->lle_tbl->llt_lle_count != 0,
+                   "llt_lle_count=%u", lle->lle_tbl->llt_lle_count);
                lle->lle_tbl->llt_lle_count--;
        }
 }
diff -r d87c3ec75c2c -r 1ea81a6921c5 sys/net/link_proto.c
--- a/sys/net/link_proto.c      Wed Sep 25 09:52:32 2019 +0000
+++ b/sys/net/link_proto.c      Wed Sep 25 09:53:37 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: link_proto.c,v 1.38 2019/04/29 11:57:22 roy Exp $      */
+/*     $NetBSD: link_proto.c,v 1.39 2019/09/25 09:53:37 ozaki-r Exp $  */
 
 /*-
  * Copyright (c) 1982, 1986, 1993
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: link_proto.c,v 1.38 2019/04/29 11:57:22 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: link_proto.c,v 1.39 2019/09/25 09:53:37 ozaki-r Exp $");
 
 #include <sys/param.h>
 #include <sys/socket.h>
@@ -220,7 +220,8 @@
                                ifaref(ifa);
                                ifa_release(ifa, &psref);
                                ifa_remove(ifp, ifa);
-                               KASSERT(ifa->ifa_refcnt == 1);
+                               KASSERTMSG(ifa->ifa_refcnt == 1, "ifa_refcnt=%d",
+                                   ifa->ifa_refcnt);
                                ifafree(ifa);
                                ifa = NULL;
                        }
diff -r d87c3ec75c2c -r 1ea81a6921c5 sys/net/route.c
--- a/sys/net/route.c   Wed Sep 25 09:52:32 2019 +0000
+++ b/sys/net/route.c   Wed Sep 25 09:53:37 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: route.c,v 1.222 2019/09/23 05:00:20 rin Exp $  */
+/*     $NetBSD: route.c,v 1.223 2019/09/25 09:53:37 ozaki-r Exp $      */
 
 /*-
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.222 2019/09/23 05:00:20 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.223 2019/09/25 09:53:37 ozaki-r Exp $");
 
 #include <sys/param.h>
 #ifdef RTFLUSH_DEBUG
@@ -621,7 +621,7 @@
 rt_ref(struct rtentry *rt)
 {
 
-       KASSERT(rt->rt_refcnt >= 0);
+       KASSERTMSG(rt->rt_refcnt >= 0, "rt_refcnt=%d", rt->rt_refcnt);
        atomic_inc_uint(&rt->rt_refcnt);
 }
 
@@ -725,7 +725,7 @@
 rt_free(struct rtentry *rt)
 {
 
-       KASSERT(rt->rt_refcnt > 0);
+       KASSERTMSG(rt->rt_refcnt > 0, "rt_refcnt=%d", rt->rt_refcnt);
        if (rt_wait_ok()) {
                atomic_dec_uint(&rt->rt_refcnt);
                _rt_free(rt);
diff -r d87c3ec75c2c -r 1ea81a6921c5 sys/netinet/in.c
--- a/sys/netinet/in.c  Wed Sep 25 09:52:32 2019 +0000
+++ b/sys/netinet/in.c  Wed Sep 25 09:53:37 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in.c,v 1.234 2019/04/29 11:57:22 roy Exp $     */
+/*     $NetBSD: in.c,v 1.235 2019/09/25 09:53:38 ozaki-r Exp $ */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.234 2019/04/29 11:57:22 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.235 2019/09/25 09:53:38 ozaki-r Exp $");
 
 #include "arp.h"
 
@@ -1937,7 +1937,7 @@
 in_lltable_destroy_lle(struct llentry *lle)
 {
 
-       KASSERT(lle->la_numheld == 0);
+       KASSERTMSG(lle->la_numheld == 0, "la_numheld=%d", lle->la_numheld);
 
        LLE_WUNLOCK(lle);
        LLE_LOCK_DESTROY(lle);
diff -r d87c3ec75c2c -r 1ea81a6921c5 sys/netinet6/in6.c
--- a/sys/netinet6/in6.c        Wed Sep 25 09:52:32 2019 +0000
+++ b/sys/netinet6/in6.c        Wed Sep 25 09:53:37 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in6.c,v 1.275 2019/04/29 11:57:22 roy Exp $    */
+/*     $NetBSD: in6.c,v 1.276 2019/09/25 09:53:38 ozaki-r Exp $        */
 /*     $KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $   */
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.275 2019/04/29 11:57:22 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.276 2019/09/25 09:53:38 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1437,7 +1437,9 @@
        mutex_enter(&in6_ifaddr_lock);
        while ((imm = LIST_FIRST(&ia->ia6_memberships)) != NULL) {
                struct in6_multi *in6m __diagused = imm->i6mm_maddr;
-               KASSERT(in6m == NULL || in6m->in6m_ifp == ifp);
+               KASSERTMSG(in6m == NULL || in6m->in6m_ifp == ifp,
+                   "in6m_ifp=%s ifp=%s", in6m ? in6m->in6m_ifp->if_xname : NULL,
+                   ifp->if_xname);
                LIST_REMOVE(imm, i6mm_chain);
                mutex_exit(&in6_ifaddr_lock);
 
@@ -2432,7 +2434,7 @@
 in6_lltable_destroy_lle(struct llentry *lle)
 {
 
-       KASSERT(lle->la_numheld == 0);
+       KASSERTMSG(lle->la_numheld == 0, "la_numheld=%d", lle->la_numheld);
 
        LLE_WUNLOCK(lle);
        LLE_LOCK_DESTROY(lle);
diff -r d87c3ec75c2c -r 1ea81a6921c5 sys/netinet6/mld6.c
--- a/sys/netinet6/mld6.c       Wed Sep 25 09:52:32 2019 +0000
+++ b/sys/netinet6/mld6.c       Wed Sep 25 09:53:37 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mld6.c,v 1.100 2018/12/22 14:28:57 maxv Exp $  */
+/*     $NetBSD: mld6.c,v 1.101 2019/09/25 09:53:38 ozaki-r Exp $       */
 /*     $KAME: mld6.c,v 1.25 2001/01/16 14:14:18 itojun Exp $   */
 
 /*
@@ -102,7 +102,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mld6.c,v 1.100 2018/12/22 14:28:57 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mld6.c,v 1.101 2019/09/25 09:53:38 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -191,7 +191,8 @@
        struct timeval now;
 
        KASSERT(rw_write_held(&in6_multilock));
-       KASSERT(in6m->in6m_timer != IN6M_TIMER_UNDEF);
+       KASSERTMSG(in6m->in6m_timer != IN6M_TIMER_UNDEF,
+           "in6m_timer=%d", in6m->in6m_timer);
 
        microtime(&now);
        in6m->in6m_timer_expire.tv_sec = now.tv_sec + in6m->in6m_timer / hz;
@@ -233,7 +234,8 @@
 {
        struct in6_multi *in6m = arg;
 
-       KASSERT(in6m->in6m_refcount > 0);
+       KASSERTMSG(in6m->in6m_refcount > 0, "in6m_refcount=%d",
+           in6m->in6m_refcount);
 
        KERNEL_LOCK_UNLESS_NET_MPSAFE();
        rw_enter(&in6_multilock, RW_WRITER);
@@ -774,7 +776,8 @@
        struct sockaddr_in6 sin6;
 
        KASSERT(rw_write_held(&in6_multilock));
-       KASSERT(in6m->in6m_refcount == 0);
+       KASSERTMSG(in6m->in6m_refcount == 0, "in6m_refcount=%d",
+           in6m->in6m_refcount);
 
        /*
         * Unlink from list if it's listed.  This must be done before
@@ -823,7 +826,8 @@
 {
 
        KASSERT(rw_write_held(&in6_multilock));
-       KASSERT(in6m->in6m_refcount > 0);
+       KASSERTMSG(in6m->in6m_refcount > 0, "in6m_refcount=%d",
+           in6m->in6m_refcount);
 
        /*
         * The caller should have a reference to in6m. So we don't need to care
diff -r d87c3ec75c2c -r 1ea81a6921c5 sys/netinet6/nd6.c
--- a/sys/netinet6/nd6.c        Wed Sep 25 09:52:32 2019 +0000
+++ b/sys/netinet6/nd6.c        Wed Sep 25 09:53:37 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nd6.c,v 1.264 2019/09/25 09:52:32 ozaki-r Exp $        */
+/*     $NetBSD: nd6.c,v 1.265 2019/09/25 09:53:38 ozaki-r Exp $        */
 /*     $KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $   */
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.264 2019/09/25 09:52:32 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.265 2019/09/25 09:53:38 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -737,7 +737,8 @@
                         * Just invalidate the prefix here. Removing it
                         * will be done when purging an associated address.
                         */
-                       KASSERT(pr->ndpr_refcnt > 0);
+                       KASSERTMSG(pr->ndpr_refcnt > 0, "ndpr_refcnt=%d",
+                           pr->ndpr_refcnt);
                        nd6_invalidate_prefix(pr);
                }
        }
@@ -898,7 +899,8 @@
                        /*
                         * All addresses referencing pr should be already freed.
                         */
-                       KASSERT(pr->ndpr_refcnt == 0);
+                       KASSERTMSG(pr->ndpr_refcnt == 0, "ndpr_refcnt=%d",
+                           pr->ndpr_refcnt);
                        nd6_prelist_remove(pr);
                }
        }
@@ -1966,7 +1968,8 @@
                        }
                        pserialize_read_exit(_s);
 
-                       KASSERT(pfx->ndpr_refcnt == 0);
+                       KASSERTMSG(pfx->ndpr_refcnt == 0, "ndpr_refcnt=%d",
+                           pfx->ndpr_refcnt);
                        nd6_prelist_remove(pfx);
                }
                ND6_UNLOCK();
diff -r d87c3ec75c2c -r 1ea81a6921c5 sys/netinet6/nd6_rtr.c
--- a/sys/netinet6/nd6_rtr.c    Wed Sep 25 09:52:32 2019 +0000
+++ b/sys/netinet6/nd6_rtr.c    Wed Sep 25 09:53:37 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nd6_rtr.c,v 1.145 2019/04/29 11:57:22 roy Exp $        */
+/*     $NetBSD: nd6_rtr.c,v 1.146 2019/09/25 09:53:38 ozaki-r Exp $    */
 /*     $KAME: nd6_rtr.c,v 1.95 2001/02/07 08:09:47 itojun Exp $        */
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.145 2019/04/29 11:57:22 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.146 2019/09/25 09:53:38 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -946,7 +946,8 @@



Home | Main Index | Thread Index | Old Index