From owner-svn-src-projects@FreeBSD.ORG Tue Nov 4 17:05:26 2014 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8CB49A94; Tue, 4 Nov 2014 17:05:26 +0000 (UTC) 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)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6EE30ECC; Tue, 4 Nov 2014 17:05:26 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sA4H5Q6G089078; Tue, 4 Nov 2014 17:05:26 GMT (envelope-from melifaro@FreeBSD.org) Received: (from melifaro@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sA4H5PhZ089073; Tue, 4 Nov 2014 17:05:25 GMT (envelope-from melifaro@FreeBSD.org) Message-Id: <201411041705.sA4H5PhZ089073@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: melifaro set sender to melifaro@FreeBSD.org using -f From: "Alexander V. Chernikov" Date: Tue, 4 Nov 2014 17:05:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r274094 - in projects/routing/sys: net netinet6 X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Nov 2014 17:05:26 -0000 Author: melifaro Date: Tue Nov 4 17:05:24 2014 New Revision: 274094 URL: https://svnweb.freebsd.org/changeset/base/274094 Log: Convert in6p_lookup_mcast_ifp() to use new routing api. * Add special fib6_lookup_nh_ifp() to return rt_ifp instead of rt_ifa->ifa_ifp for that. Modified: projects/routing/sys/net/rt_nhops.c projects/routing/sys/net/rt_nhops.h projects/routing/sys/netinet6/in6_mcast.c projects/routing/sys/netinet6/scope6.c projects/routing/sys/netinet6/scope6_var.h Modified: projects/routing/sys/net/rt_nhops.c ============================================================================== --- projects/routing/sys/net/rt_nhops.c Tue Nov 4 17:01:40 2014 (r274093) +++ projects/routing/sys/net/rt_nhops.c Tue Nov 4 17:05:24 2014 (r274094) @@ -943,6 +943,48 @@ fib6_rte_to_nh_extended(struct rtentry * } int +fib6_lookup_nh_ifp(uint32_t fibnum, struct in6_addr *dst, uint32_t scopeid, + uint32_t flowid, struct nhop6_basic *pnh6) +{ + struct radix_node_head *rnh; + struct radix_node *rn; + struct sockaddr_in6 sin6; + struct rtentry *rte; + + if (IN6_IS_SCOPE_LINKLOCAL(dst)) { + /* Do not lookup link-local addresses in rtable */ + return (fib6_lla_to_nh_basic(dst, scopeid, pnh6)); + } + + KASSERT((fibnum < rt_numfibs), ("fib6_lookup_nh_basic: bad fibnum")); + rnh = rt_tables_get_rnh(fibnum, AF_INET6); + if (rnh == NULL) + return (ENOENT); + + /* Prepare lookup key */ + memset(&sin6, 0, sizeof(sin6)); + sin6.sin6_addr = *dst; + sin6.sin6_scope_id = scopeid; + sa6_embedscope(&sin6, 0); + + RADIX_NODE_HEAD_RLOCK(rnh); + rn = rnh->rnh_matchaddr((void *)&sin6, rnh); + if (rn != NULL && ((rn->rn_flags & RNF_ROOT) == 0)) { + rte = RNTORT(rn); + /* Ensure route & ifp is UP */ + if (RT_LINK_IS_UP(rte->rt_ifp)) { + fib6_rte_to_nh_basic(rte, dst, pnh6); + pnh6->nh_ifp = rte->rt_ifp; + RADIX_NODE_HEAD_RUNLOCK(rnh); + return (0); + } + } + RADIX_NODE_HEAD_RUNLOCK(rnh); + + return (ENOENT); +} + +int fib6_lookup_nh_basic(uint32_t fibnum, struct in6_addr *dst, uint32_t scopeid, uint32_t flowid, struct nhop6_basic *pnh6) { Modified: projects/routing/sys/net/rt_nhops.h ============================================================================== --- projects/routing/sys/net/rt_nhops.h Tue Nov 4 17:01:40 2014 (r274093) +++ projects/routing/sys/net/rt_nhops.h Tue Nov 4 17:05:24 2014 (r274094) @@ -208,6 +208,8 @@ void fib4_free_nh_ext(uint32_t fibnum, s #define NHOP_LOOKUP_REF 0x01 +int fib6_lookup_nh_ifp(uint32_t fibnum, struct in6_addr *dst, uint32_t scopeid, + uint32_t flowid, struct nhop6_basic *pnh6); int fib6_lookup_nh_basic(uint32_t fibnum, struct in6_addr *dst, uint32_t scopeid, uint32_t flowid, struct nhop6_basic *pnh6); int fib6_lookup_nh_ext(uint32_t fibnum, struct in6_addr *dst, Modified: projects/routing/sys/netinet6/in6_mcast.c ============================================================================== --- projects/routing/sys/netinet6/in6_mcast.c Tue Nov 4 17:01:40 2014 (r274093) +++ projects/routing/sys/netinet6/in6_mcast.c Tue Nov 4 17:05:24 2014 (r274094) @@ -69,6 +69,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #ifndef KTR_MLD #define KTR_MLD KTR_INET6 #endif @@ -1770,26 +1772,22 @@ static struct ifnet * in6p_lookup_mcast_ifp(const struct inpcb *in6p, const struct sockaddr_in6 *gsin6) { - struct route_in6 ro6; - struct ifnet *ifp; + struct nhop6_basic nh6; + struct in6_addr dst; + uint32_t scopeid; + uint32_t fibnum; KASSERT(in6p->inp_vflag & INP_IPV6, ("%s: not INP_IPV6 inpcb", __func__)); KASSERT(gsin6->sin6_family == AF_INET6, ("%s: not AF_INET6 group", __func__)); - ifp = NULL; - memset(&ro6, 0, sizeof(struct route_in6)); - memcpy(&ro6.ro_dst, gsin6, sizeof(struct sockaddr_in6)); - rtalloc_ign_fib((struct route *)&ro6, 0, - in6p ? in6p->inp_inc.inc_fibnum : RT_DEFAULT_FIB); - if (ro6.ro_rt != NULL) { - ifp = ro6.ro_rt->rt_ifp; - KASSERT(ifp != NULL, ("%s: null ifp", __func__)); - RTFREE(ro6.ro_rt); - } + in6_splitscope(&gsin6->sin6_addr, &dst, &scopeid); + fibnum = in6p ? in6p->inp_inc.inc_fibnum : RT_DEFAULT_FIB; + if (fib6_lookup_nh_ifp(fibnum, &dst, scopeid, 0, &nh6) != 0) + return (NULL); - return (ifp); + return (nh6.nh_ifp); } /* Modified: projects/routing/sys/netinet6/scope6.c ============================================================================== --- projects/routing/sys/netinet6/scope6.c Tue Nov 4 17:01:40 2014 (r274093) +++ projects/routing/sys/netinet6/scope6.c Tue Nov 4 17:05:24 2014 (r274094) @@ -475,7 +475,8 @@ in6_getscope(struct in6_addr *in6) } void -in6_splitscope(struct in6_addr *src, struct in6_addr *dst, uint32_t *scopeid) +in6_splitscope(const struct in6_addr *src, struct in6_addr *dst, + uint32_t *scopeid) { uint32_t zoneid; Modified: projects/routing/sys/netinet6/scope6_var.h ============================================================================== --- projects/routing/sys/netinet6/scope6_var.h Tue Nov 4 17:01:40 2014 (r274093) +++ projects/routing/sys/netinet6/scope6_var.h Tue Nov 4 17:05:24 2014 (r274094) @@ -64,7 +64,7 @@ int in6_clearscope(struct in6_addr *); uint16_t in6_getscope(struct in6_addr *); uint32_t in6_getscopezone(const struct ifnet *, int); struct ifnet* in6_getlinkifnet(uint32_t); -void in6_splitscope(struct in6_addr *src, struct in6_addr *dst, +void in6_splitscope(const struct in6_addr *src, struct in6_addr *dst, uint32_t *scopeid); #endif /* _KERNEL */