From owner-svn-src-all@FreeBSD.ORG Tue Oct 29 11:21:31 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id D016EF09; Tue, 29 Oct 2013 11:21:31 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id BD2912D79; Tue, 29 Oct 2013 11:21:31 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9TBLVvh033381; Tue, 29 Oct 2013 11:21:31 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9TBLVMm033379; Tue, 29 Oct 2013 11:21:31 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201310291121.r9TBLVMm033379@svn.freebsd.org> From: Gleb Smirnoff Date: Tue, 29 Oct 2013 11:21:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r257325 - head/sys/netinet X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 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: Tue, 29 Oct 2013 11:21:32 -0000 Author: glebius Date: Tue Oct 29 11:21:31 2013 New Revision: 257325 URL: http://svnweb.freebsd.org/changeset/base/257325 Log: Uninline inm_lookup_locked(). Now in_var.h doesn't dereference fields of struct ifnet. Sponsored by: Netflix Sponsored by: Nginx, Inc. Modified: head/sys/netinet/in_mcast.c head/sys/netinet/in_var.h Modified: head/sys/netinet/in_mcast.c ============================================================================== --- head/sys/netinet/in_mcast.c Tue Oct 29 11:17:49 2013 (r257324) +++ head/sys/netinet/in_mcast.c Tue Oct 29 11:21:31 2013 (r257325) @@ -224,6 +224,49 @@ imf_init(struct in_mfilter *imf, const i } /* + * Function for looking up an in_multi record for an IPv4 multicast address + * on a given interface. ifp must be valid. If no record found, return NULL. + * The IN_MULTI_LOCK and IF_ADDR_LOCK on ifp must be held. + */ +struct in_multi * +inm_lookup_locked(struct ifnet *ifp, const struct in_addr ina) +{ + struct ifmultiaddr *ifma; + struct in_multi *inm; + + IN_MULTI_LOCK_ASSERT(); + IF_ADDR_LOCK_ASSERT(ifp); + + inm = NULL; + TAILQ_FOREACH(ifma, &((ifp)->if_multiaddrs), ifma_link) { + if (ifma->ifma_addr->sa_family == AF_INET) { + inm = (struct in_multi *)ifma->ifma_protospec; + if (inm->inm_addr.s_addr == ina.s_addr) + break; + inm = NULL; + } + } + return (inm); +} + +/* + * Wrapper for inm_lookup_locked(). + * The IF_ADDR_LOCK will be taken on ifp and released on return. + */ +struct in_multi * +inm_lookup(struct ifnet *ifp, const struct in_addr ina) +{ + struct in_multi *inm; + + IN_MULTI_LOCK_ASSERT(); + IF_ADDR_RLOCK(ifp); + inm = inm_lookup_locked(ifp, ina); + IF_ADDR_RUNLOCK(ifp); + + return (inm); +} + +/* * Resize the ip_moptions vector to the next power-of-two minus 1. * May be called with locks held; do not sleep. */ Modified: head/sys/netinet/in_var.h ============================================================================== --- head/sys/netinet/in_var.h Tue Oct 29 11:17:49 2013 (r257324) +++ head/sys/netinet/in_var.h Tue Oct 29 11:21:31 2013 (r257325) @@ -363,49 +363,6 @@ extern struct mtx in_multi_mtx; #define IN_MULTI_LOCK_ASSERT() mtx_assert(&in_multi_mtx, MA_OWNED) #define IN_MULTI_UNLOCK_ASSERT() mtx_assert(&in_multi_mtx, MA_NOTOWNED) -/* - * Function for looking up an in_multi record for an IPv4 multicast address - * on a given interface. ifp must be valid. If no record found, return NULL. - * The IN_MULTI_LOCK and IF_ADDR_LOCK on ifp must be held. - */ -static __inline struct in_multi * -inm_lookup_locked(struct ifnet *ifp, const struct in_addr ina) -{ - struct ifmultiaddr *ifma; - struct in_multi *inm; - - IN_MULTI_LOCK_ASSERT(); - IF_ADDR_LOCK_ASSERT(ifp); - - inm = NULL; - TAILQ_FOREACH(ifma, &((ifp)->if_multiaddrs), ifma_link) { - if (ifma->ifma_addr->sa_family == AF_INET) { - inm = (struct in_multi *)ifma->ifma_protospec; - if (inm->inm_addr.s_addr == ina.s_addr) - break; - inm = NULL; - } - } - return (inm); -} - -/* - * Wrapper for inm_lookup_locked(). - * The IF_ADDR_LOCK will be taken on ifp and released on return. - */ -static __inline struct in_multi * -inm_lookup(struct ifnet *ifp, const struct in_addr ina) -{ - struct in_multi *inm; - - IN_MULTI_LOCK_ASSERT(); - IF_ADDR_RLOCK(ifp); - inm = inm_lookup_locked(ifp, ina); - IF_ADDR_RUNLOCK(ifp); - - return (inm); -} - /* Acquire an in_multi record. */ static __inline void inm_acquire_locked(struct in_multi *inm) @@ -428,6 +385,8 @@ struct route; struct ip_moptions; struct radix_node_head; +struct in_multi *inm_lookup_locked(struct ifnet *, const struct in_addr); +struct in_multi *inm_lookup(struct ifnet *, const struct in_addr); int imo_multi_filter(const struct ip_moptions *, const struct ifnet *, const struct sockaddr *, const struct sockaddr *); void inm_commit(struct in_multi *);