From owner-svn-src-stable@FreeBSD.ORG Sun Jul 8 12:30:25 2012 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BE75E106566C; Sun, 8 Jul 2012 12:30:25 +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 A92ED8FC20; Sun, 8 Jul 2012 12:30:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68CUPAj051449; Sun, 8 Jul 2012 12:30:25 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68CUP0v051447; Sun, 8 Jul 2012 12:30:25 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201207081230.q68CUP0v051447@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 8 Jul 2012 12:30:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238241 - stable/9/sys/netinet6 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 12:30:26 -0000 Author: bz Date: Sun Jul 8 12:30:25 2012 New Revision: 238241 URL: http://svn.freebsd.org/changeset/base/238241 Log: MFC r235986: Use M_ZERO with malloc rather than calling bzero() ourselves. Change if () panic() checks to KASSERT()s as they are only catching invariants in code flow but not dependent on network input/output. Move initial assigments indirecting pointers after the lock has been aquired. Passing layer boundries, reset M_PROTOFLAGS. Remove a NULL assignment before free. Approved by: re Modified: stable/9/sys/netinet6/nd6.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet6/nd6.c ============================================================================== --- stable/9/sys/netinet6/nd6.c Sun Jul 8 12:26:32 2012 (r238240) +++ stable/9/sys/netinet6/nd6.c Sun Jul 8 12:30:25 2012 (r238241) @@ -174,9 +174,7 @@ nd6_ifattach(struct ifnet *ifp) { struct nd_ifinfo *nd; - nd = (struct nd_ifinfo *)malloc(sizeof(*nd), M_IP6NDP, M_WAITOK); - bzero(nd, sizeof(*nd)); - + nd = (struct nd_ifinfo *)malloc(sizeof(*nd), M_IP6NDP, M_WAITOK|M_ZERO); nd->initialized = 1; nd->chlim = IPV6_DEFHLIM; @@ -284,10 +282,9 @@ nd6_option(union nd_opts *ndopts) struct nd_opt_hdr *nd_opt; int olen; - if (ndopts == NULL) - panic("ndopts == NULL in nd6_option"); - if (ndopts->nd_opts_last == NULL) - panic("uninitialized ndopts in nd6_option"); + KASSERT(ndopts != NULL, ("%s: ndopts == NULL", __func__)); + KASSERT(ndopts->nd_opts_last != NULL, ("%s: uninitialized ndopts", + __func__)); if (ndopts->nd_opts_search == NULL) return NULL; if (ndopts->nd_opts_done) @@ -335,10 +332,9 @@ nd6_options(union nd_opts *ndopts) struct nd_opt_hdr *nd_opt; int i = 0; - if (ndopts == NULL) - panic("ndopts == NULL in nd6_options"); - if (ndopts->nd_opts_last == NULL) - panic("uninitialized ndopts in nd6_options"); + KASSERT(ndopts != NULL, ("%s: ndopts == NULL", __func__)); + KASSERT(ndopts->nd_opts_last != NULL, ("%s: uninitialized ndopts", + __func__)); if (ndopts->nd_opts_search == NULL) return 0; @@ -1174,11 +1170,13 @@ done: void nd6_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info) { - struct sockaddr_in6 *gateway = (struct sockaddr_in6 *)rt->rt_gateway; + struct sockaddr_in6 *gateway; struct nd_defrouter *dr; - struct ifnet *ifp = rt->rt_ifp; + struct ifnet *ifp; RT_LOCK_ASSERT(rt); + gateway = (struct sockaddr_in6 *)rt->rt_gateway; + ifp = rt->rt_ifp; switch (req) { case RTM_ADD: @@ -1557,10 +1555,8 @@ nd6_cache_lladdr(struct ifnet *ifp, stru IF_AFDATA_UNLOCK_ASSERT(ifp); - if (ifp == NULL) - panic("ifp == NULL in nd6_cache_lladdr"); - if (from == NULL) - panic("from == NULL in nd6_cache_lladdr"); + KASSERT(ifp != NULL, ("%s: ifp == NULL", __func__)); + KASSERT(from != NULL, ("%s: from == NULL", __func__)); /* nothing must be updated for unspecified address */ if (IN6_IS_ADDR_UNSPECIFIED(from)) @@ -2084,6 +2080,8 @@ nd6_output_lle(struct ifnet *ifp, struct } return (error); } + /* Reset layer specific mbuf flags to avoid confusing lower layers. */ + m->m_flags &= ~(M_PROTOFLAGS); if ((ifp->if_flags & IFF_LOOPBACK) != 0) { return ((*ifp->if_output)(origifp, m, (struct sockaddr *)dst, NULL)); @@ -2252,7 +2250,6 @@ clear_llinfo_pqueue(struct llentry *ln) for (m_hold = ln->la_hold; m_hold; m_hold = m_hold_next) { m_hold_next = m_hold->m_nextpkt; - m_hold->m_nextpkt = NULL; m_freem(m_hold); }