From owner-svn-src-head@freebsd.org Tue Dec 5 20:43:25 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C9600E80CE2; Tue, 5 Dec 2017 20:43:25 +0000 (UTC) (envelope-from shurd@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 A3BE26E63F; Tue, 5 Dec 2017 20:43:25 +0000 (UTC) (envelope-from shurd@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vB5KhOsB001501; Tue, 5 Dec 2017 20:43:24 GMT (envelope-from shurd@FreeBSD.org) Received: (from shurd@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vB5KhO5U001500; Tue, 5 Dec 2017 20:43:24 GMT (envelope-from shurd@FreeBSD.org) Message-Id: <201712052043.vB5KhO5U001500@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: shurd set sender to shurd@FreeBSD.org using -f From: Stephen Hurd Date: Tue, 5 Dec 2017 20:43:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r326577 - head/sys/net X-SVN-Group: head X-SVN-Commit-Author: shurd X-SVN-Commit-Paths: head/sys/net X-SVN-Commit-Revision: 326577 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Dec 2017 20:43:25 -0000 Author: shurd Date: Tue Dec 5 20:43:24 2017 New Revision: 326577 URL: https://svnweb.freebsd.org/changeset/base/326577 Log: Avoid calling CURVNET_[SET|RESTORE] for each packet The LRO possible test was calling CURVNET_SET once for IPv4 or IPv6 for each packet in a chain. Only call it once per chain instead. Submitted by: Matthew Macy Reviewed by: cem, ae Sponsored by: Limelight Networks Differential Revision: https://reviews.freebsd.org/D13368 Modified: head/sys/net/iflib.c Modified: head/sys/net/iflib.c ============================================================================== --- head/sys/net/iflib.c Tue Dec 5 20:19:13 2017 (r326576) +++ head/sys/net/iflib.c Tue Dec 5 20:43:24 2017 (r326577) @@ -2467,13 +2467,26 @@ iflib_rxd_pkt_get(iflib_rxq_t rxq, if_rxd_info_t ri) } #if defined(INET6) || defined(INET) +static void +iflib_get_ip_forwarding(struct lro_ctrl *lc, bool *v4, bool *v6) +{ + CURVNET_SET(lc->ifp->if_vnet); +#if defined(INET6) + *v6 = VNET(ip6_forwarding); +#endif +#if defined(INET) + *v4 = VNET(ipforwarding); +#endif + CURVNET_RESTORE(); +} + /* * Returns true if it's possible this packet could be LROed. * if it returns false, it is guaranteed that tcp_lro_rx() * would not return zero. */ static bool -iflib_check_lro_possible(struct lro_ctrl *lc, struct mbuf *m) +iflib_check_lro_possible(struct mbuf *m, bool v4_forwarding, bool v6_forwarding) { struct ether_header *eh; uint16_t eh_type; @@ -2483,32 +2496,21 @@ iflib_check_lro_possible(struct lro_ctrl *lc, struct m switch (eh_type) { #if defined(INET6) case ETHERTYPE_IPV6: - { - CURVNET_SET(lc->ifp->if_vnet); - if (VNET(ip6_forwarding) == 0) { - CURVNET_RESTORE(); - return true; - } - CURVNET_RESTORE(); - break; - } + return !v6_forwarding; #endif #if defined (INET) case ETHERTYPE_IP: - { - CURVNET_SET(lc->ifp->if_vnet); - if (VNET(ipforwarding) == 0) { - CURVNET_RESTORE(); - return true; - } - CURVNET_RESTORE(); - break; - } + return !v4_forwarding; #endif } return false; } +#else +static void +iflib_get_ip_forwarding(struct lro_ctrl *lc __unused, bool *v4 __unused, bool *v6 __unused) +{ +} #endif static bool @@ -2525,6 +2527,7 @@ iflib_rxeof(iflib_rxq_t rxq, qidx_t budget) struct ifnet *ifp; int lro_enabled; bool lro_possible = false; + bool v4_forwarding, v6_forwarding; /* * XXX early demux data packets so that if_input processing only handles @@ -2601,6 +2604,8 @@ iflib_rxeof(iflib_rxq_t rxq, qidx_t budget) __iflib_fl_refill_lt(ctx, fl, budget + 8); lro_enabled = (if_getcapenable(ifp) & IFCAP_LRO); + if (lro_enabled) + iflib_get_ip_forwarding(&rxq->ifr_lc, &v4_forwarding, &v6_forwarding); mt = mf = NULL; while (mh != NULL) { m = mh; @@ -2615,7 +2620,7 @@ iflib_rxeof(iflib_rxq_t rxq, qidx_t budget) #if defined(INET6) || defined(INET) if (lro_enabled) { if (!lro_possible) { - lro_possible = iflib_check_lro_possible(&rxq->ifr_lc, m); + lro_possible = iflib_check_lro_possible(m, v4_forwarding, v6_forwarding); if (lro_possible && mf != NULL) { ifp->if_input(ifp, mf); DBG_COUNTER_INC(rx_if_input);