From owner-svn-src-projects@FreeBSD.ORG Thu Oct 23 23:11:06 2014 Return-Path: <owner-svn-src-projects@FreeBSD.ORG> Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 98B81FA; Thu, 23 Oct 2014 23:11:06 +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 83EC3FB1; Thu, 23 Oct 2014 23:11:06 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s9NNB5fk019275; Thu, 23 Oct 2014 23:11:05 GMT (envelope-from melifaro@FreeBSD.org) Received: (from melifaro@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s9NNB4K7019266; Thu, 23 Oct 2014 23:11:04 GMT (envelope-from melifaro@FreeBSD.org) Message-Id: <201410232311.s9NNB4K7019266@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: melifaro set sender to melifaro@FreeBSD.org using -f From: "Alexander V. Chernikov" <melifaro@FreeBSD.org> Date: Thu, 23 Oct 2014 23:11:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r273565 - in projects/routing/sys: net netinet 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" <svn-src-projects.freebsd.org> List-Unsubscribe: <http://lists.freebsd.org/mailman/options/svn-src-projects>, <mailto:svn-src-projects-request@freebsd.org?subject=unsubscribe> List-Archive: <http://lists.freebsd.org/pipermail/svn-src-projects/> List-Post: <mailto:svn-src-projects@freebsd.org> List-Help: <mailto:svn-src-projects-request@freebsd.org?subject=help> List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-projects>, <mailto:svn-src-projects-request@freebsd.org?subject=subscribe> X-List-Received-Date: Thu, 23 Oct 2014 23:11:06 -0000 Author: melifaro Date: Thu Oct 23 23:11:04 2014 New Revision: 273565 URL: https://svnweb.freebsd.org/changeset/base/273565 Log: Add new fib4_lookup_nh_extended() which fills in nhop4_extended structure without doinf L2 resolve. It also requires freeing references by calling fib4_free_nh_ext(). Convert in_pcbladdr() to use it. Convert tcp_maxmtu() to use it. Modified: projects/routing/sys/net/rt_nhops.c projects/routing/sys/net/rt_nhops.h projects/routing/sys/netinet/in_pcb.c projects/routing/sys/netinet/tcp_subr.c Modified: projects/routing/sys/net/rt_nhops.c ============================================================================== --- projects/routing/sys/net/rt_nhops.c Thu Oct 23 22:42:56 2014 (r273564) +++ projects/routing/sys/net/rt_nhops.c Thu Oct 23 23:11:04 2014 (r273565) @@ -380,7 +380,7 @@ fib4_rte_to_nh_extended(struct rtentry * struct sockaddr_in *gw; struct in_ifaddr *ia; - pnh4->nh_ifp = rte->rt_ifa->ifa_ifp; + pnh4->nh_ifp = rte->rt_ifp; pnh4->nh_mtu = min(rte->rt_mtu, rte->rt_ifp->if_mtu); if (rte->rt_flags & RTF_GATEWAY) { gw = (struct sockaddr_in *)rte->rt_gateway; @@ -435,6 +435,7 @@ fib4_lookup_nh_basic(uint32_t fibnum, st /* Prepare lookup key */ memset(&sin, 0, sizeof(sin)); + sin.sin_len = sizeof(struct sockaddr_in); sin.sin_addr = dst; RADIX_NODE_HEAD_RLOCK(rnh); @@ -453,6 +454,49 @@ fib4_lookup_nh_basic(uint32_t fibnum, st return (ENOENT); } + +int +fib4_lookup_nh_extended(uint32_t fibnum, struct in_addr dst, uint32_t flowid, + struct nhop4_extended *pnh4) +{ + struct radix_node_head *rnh; + struct radix_node *rn; + struct sockaddr_in sin; + struct rtentry *rte; + + KASSERT((fibnum < rt_numfibs), ("fib4_lookup_nh_basic: bad fibnum")); + rnh = rt_tables_get_rnh(fibnum, AF_INET); + if (rnh == NULL) + return (ENOENT); + + /* Prepare lookup key */ + memset(&sin, 0, sizeof(sin)); + sin.sin_len = sizeof(struct sockaddr_in); + sin.sin_addr = dst; + + RADIX_NODE_HEAD_RLOCK(rnh); + rn = rnh->rnh_matchaddr((void *)&sin, 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)) { + fib4_rte_to_nh_extended(rte, dst, pnh4); + RADIX_NODE_HEAD_RUNLOCK(rnh); + + return (0); + } + } + RADIX_NODE_HEAD_RUNLOCK(rnh); + + return (ENOENT); +} + +void +fib4_free_nh_ext(uint32_t fibnum, struct nhop4_extended *pnh4) +{ + +} + #endif #ifdef INET6 Modified: projects/routing/sys/net/rt_nhops.h ============================================================================== --- projects/routing/sys/net/rt_nhops.h Thu Oct 23 22:42:56 2014 (r273564) +++ projects/routing/sys/net/rt_nhops.h Thu Oct 23 23:11:04 2014 (r273565) @@ -192,6 +192,10 @@ int fib4_lookup_nh_basic(uint32_t fibnum int fib6_lookup_nh_basic(uint32_t fibnum, struct in6_addr dst, uint32_t flowid, struct nhop6_basic *pnh6); +int fib4_lookup_nh_extended(uint32_t fibnum, struct in_addr dst, + uint32_t flowid, struct nhop4_extended *pnh4); +void fib4_free_nh_ext(uint32_t fibnum, struct nhop4_extended *pnh4); + void fib4_free_nh(uint32_t fibnum, struct nhop_data *nh); void fib4_choose_prepend(uint32_t fibnum, struct nhop_data *nh_src, uint32_t flowid, struct nhop_data *nh, struct nhop4_extended *nh_ext); Modified: projects/routing/sys/netinet/in_pcb.c ============================================================================== --- projects/routing/sys/netinet/in_pcb.c Thu Oct 23 22:42:56 2014 (r273564) +++ projects/routing/sys/netinet/in_pcb.c Thu Oct 23 23:11:04 2014 (r273565) @@ -752,8 +752,7 @@ in_pcbladdr(struct inpcb *inp, struct in struct ifaddr *ifa; struct sockaddr *sa; struct sockaddr_in *sin, sin_storage; - struct nhop_data nhd, *pnhd; - struct nhop4_extended nh_ext; + struct nhop4_extended nh_ext, *pnh4; u_int fibnum; int error; @@ -780,14 +779,12 @@ in_pcbladdr(struct inpcb *inp, struct in * Find out route to destination. */ fibnum = inp->inp_inc.inc_fibnum; - pnhd = &nhd; - memset(&nhd, 0, sizeof(nhd)); + pnh4 = &nh_ext; memset(&nh_ext, 0, sizeof(nh_ext)); if ((inp->inp_socket->so_options & SO_DONTROUTE) == 0) - error = fib4_lookup_prepend(fibnum, *faddr, - NULL, &nhd, &nh_ext); + error = fib4_lookup_nh_extended(fibnum, *faddr, 0, &nh_ext); if (error != 0) { - pnhd = NULL; + pnh4 = NULL; error = 0; } @@ -799,7 +796,7 @@ in_pcbladdr(struct inpcb *inp, struct in * network and try to find a corresponding interface to take * the source address from. */ - if (pnhd == NULL) { + if (pnh4 == NULL) { struct in_ifaddr *ia; struct ifnet *ifp; @@ -973,8 +970,8 @@ in_pcbladdr(struct inpcb *inp, struct in } done: - if (pnhd != NULL) - fib4_free_nh(fibnum, pnhd); + if (pnh4 != NULL) + fib4_free_nh_ext(fibnum, pnh4); return (error); } Modified: projects/routing/sys/netinet/tcp_subr.c ============================================================================== --- projects/routing/sys/netinet/tcp_subr.c Thu Oct 23 22:42:56 2014 (r273564) +++ projects/routing/sys/netinet/tcp_subr.c Thu Oct 23 23:11:04 2014 (r273565) @@ -83,6 +83,8 @@ __FBSDID("$FreeBSD$"); #include <netinet6/nd6.h> #endif +#include <net/rt_nhops.h> + #include <netinet/tcp_fsm.h> #include <netinet/tcp_seq.h> #include <netinet/tcp_timer.h> @@ -1791,30 +1793,25 @@ tcp_mtudisc(struct inpcb *inp, int mtuof u_long tcp_maxmtu(struct in_conninfo *inc, struct tcp_ifcap *cap) { - struct route sro; - struct sockaddr_in *dst; + struct nhop4_extended nh_ext; struct ifnet *ifp; + int error; u_long maxmtu = 0; KASSERT(inc != NULL, ("tcp_maxmtu with NULL in_conninfo pointer")); - bzero(&sro, sizeof(sro)); - if (inc->inc_faddr.s_addr != INADDR_ANY) { - dst = (struct sockaddr_in *)&sro.ro_dst; - dst->sin_family = AF_INET; - dst->sin_len = sizeof(*dst); - dst->sin_addr = inc->inc_faddr; - in_rtalloc_ign(&sro, 0, inc->inc_fibnum); - } - if (sro.ro_rt != NULL) { - ifp = sro.ro_rt->rt_ifp; - if (sro.ro_rt->rt_mtu == 0) - maxmtu = ifp->if_mtu; - else - maxmtu = min(sro.ro_rt->rt_mtu, ifp->if_mtu); + if (inc->inc_faddr.s_addr == INADDR_ANY) + return (0); + + memset(&nh_ext, 0, sizeof(nh_ext)); + error = fib4_lookup_nh_extended(inc->inc_fibnum, inc->inc_faddr, 0, + &nh_ext); + if (error == 0) { + maxmtu = nh_ext.nh_mtu; /* Report additional interface capabilities. */ if (cap != NULL) { + ifp = nh_ext.nh_ifp; if (ifp->if_capenable & IFCAP_TSO4 && ifp->if_hwassist & CSUM_TSO) { cap->ifcap |= CSUM_TSO; @@ -1823,7 +1820,6 @@ tcp_maxmtu(struct in_conninfo *inc, stru cap->tsomaxsegsize = ifp->if_hw_tsomaxsegsize; } } - RTFREE(sro.ro_rt); } return (maxmtu); }