From owner-svn-src-all@FreeBSD.ORG Fri Feb 11 13:27:01 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2E15C106566C; Fri, 11 Feb 2011 13:27:01 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1D1968FC1D; Fri, 11 Feb 2011 13:27:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p1BDR0xQ061259; Fri, 11 Feb 2011 13:27:00 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p1BDR0GO061254; Fri, 11 Feb 2011 13:27:00 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201102111327.p1BDR0GO061254@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Fri, 11 Feb 2011 13:27:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r218559 - in head/sys: kern net X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Feb 2011 13:27:01 -0000 Author: bz Date: Fri Feb 11 13:27:00 2011 New Revision: 218559 URL: http://svn.freebsd.org/changeset/base/218559 Log: Mfp4 CH=177255: Make VNET_ASSERT() available with either VNET_DEBUG or INVARIANTS. Change the syntax to match KASSERT() to allow more flexible panic messages rather than having a printf with hardcoded arguments before panic. Adjust the few assertions we have to the new format (and enhance the output). Sponsored by: The FreeBSD Foundation Sponsored by: CK Software GmbH Reviewed by: jhb MFC after: 2 weeks Modified: head/sys/kern/uipc_socket.c head/sys/net/if.c head/sys/net/netisr.c head/sys/net/vnet.h Modified: head/sys/kern/uipc_socket.c ============================================================================== --- head/sys/kern/uipc_socket.c Fri Feb 11 13:18:00 2011 (r218558) +++ head/sys/kern/uipc_socket.c Fri Feb 11 13:27:00 2011 (r218559) @@ -437,7 +437,8 @@ sonewconn(struct socket *head, int conns if (over) #endif return (NULL); - VNET_ASSERT(head->so_vnet); + VNET_ASSERT(head->so_vnet != NULL, ("%s:%d so_vnet is NULL, head=%p", + __func__, __LINE__, head)); so = soalloc(head->so_vnet); if (so == NULL) return (NULL); Modified: head/sys/net/if.c ============================================================================== --- head/sys/net/if.c Fri Feb 11 13:18:00 2011 (r218558) +++ head/sys/net/if.c Fri Feb 11 13:27:00 2011 (r218559) @@ -378,8 +378,10 @@ static void vnet_if_uninit(const void *unused __unused) { - VNET_ASSERT(TAILQ_EMPTY(&V_ifnet)); - VNET_ASSERT(TAILQ_EMPTY(&V_ifg_head)); + VNET_ASSERT(TAILQ_EMPTY(&V_ifnet), ("%s:%d tailq &V_ifnet=%p " + "not empty", __func__, __LINE__, &V_ifnet)); + VNET_ASSERT(TAILQ_EMPTY(&V_ifg_head), ("%s:%d tailq &V_ifg_head=%p " + "not empty", __func__, __LINE__, &V_ifg_head)); free((caddr_t)V_ifindex_table, M_IFNET); } Modified: head/sys/net/netisr.c ============================================================================== --- head/sys/net/netisr.c Fri Feb 11 13:18:00 2011 (r218558) +++ head/sys/net/netisr.c Fri Feb 11 13:27:00 2011 (r218559) @@ -647,7 +647,8 @@ netisr_process_workstream_proto(struct n if (local_npw.nw_head == NULL) local_npw.nw_tail = NULL; local_npw.nw_len--; - VNET_ASSERT(m->m_pkthdr.rcvif != NULL); + VNET_ASSERT(m->m_pkthdr.rcvif != NULL, + ("%s:%d rcvif == NULL: m=%p", __func__, __LINE__, m)); CURVNET_SET(m->m_pkthdr.rcvif->if_vnet); netisr_proto[proto].np_handler(m); CURVNET_RESTORE(); Modified: head/sys/net/vnet.h ============================================================================== --- head/sys/net/vnet.h Fri Feb 11 13:18:00 2011 (r218558) +++ head/sys/net/vnet.h Fri Feb 11 13:27:00 2011 (r218559) @@ -118,18 +118,23 @@ void vnet_destroy(struct vnet *vnet); * Various macros -- get and set the current network stack, but also * assertions. */ +#if defined(INVARIANTS) || defined(VNET_DEBUG) +#define VNET_ASSERT(exp, msg) do { \ + if (!(exp)) \ + panic msg; \ +} while (0) +#else +#define VNET_ASSERT(exp, msg) do { \ +} while (0) +#endif + #ifdef VNET_DEBUG void vnet_log_recursion(struct vnet *, const char *, int); -#define VNET_ASSERT(condition) \ - if (!(condition)) { \ - printf("VNET_ASSERT @ %s:%d %s():\n", \ - __FILE__, __LINE__, __func__); \ - panic(#condition); \ - } - #define CURVNET_SET_QUIET(arg) \ - VNET_ASSERT((arg)->vnet_magic_n == VNET_MAGIC_N); \ + VNET_ASSERT((arg) != NULL && (arg)->vnet_magic_n == VNET_MAGIC_N, \ + ("CURVNET_SET at %s:%d %s() curvnet=%p vnet=%p", \ + __FILE__, __LINE__, __func__, curvnet, (arg))); \ struct vnet *saved_vnet = curvnet; \ const char *saved_vnet_lpush = curthread->td_vnet_lpush; \ curvnet = arg; \ @@ -143,12 +148,13 @@ void vnet_log_recursion(struct vnet *, c #define CURVNET_SET(arg) CURVNET_SET_VERBOSE(arg) #define CURVNET_RESTORE() \ - VNET_ASSERT(saved_vnet == NULL || \ - saved_vnet->vnet_magic_n == VNET_MAGIC_N); \ + VNET_ASSERT(curvnet != NULL && (saved_vnet == NULL || \ + saved_vnet->vnet_magic_n == VNET_MAGIC_N), \ + ("CURVNET_RESTORE at %s:%d %s() curvnet=%p saved_vnet=%p", \ + __FILE__, __LINE__, __func__, curvnet, saved_vnet)); \ curvnet = saved_vnet; \ curthread->td_vnet_lpush = saved_vnet_lpush; #else /* !VNET_DEBUG */ -#define VNET_ASSERT(condition) #define CURVNET_SET(arg) \ struct vnet *saved_vnet = curvnet; \ @@ -351,7 +357,7 @@ do { \ */ #define curvnet NULL -#define VNET_ASSERT(condition) +#define VNET_ASSERT(exp, msg) #define CURVNET_SET(arg) #define CURVNET_SET_QUIET(arg) #define CURVNET_RESTORE()