From owner-svn-src-user@FreeBSD.ORG Wed Dec 31 02:23:32 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2EC9D1065672; Wed, 31 Dec 2008 02:23:32 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1ADDA8FC12; Wed, 31 Dec 2008 02:23:32 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mBV2NWax012020; Wed, 31 Dec 2008 02:23:32 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBV2NWra012019; Wed, 31 Dec 2008 02:23:32 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812310223.mBV2NWra012019@svn.freebsd.org> From: Kip Macy Date: Wed, 31 Dec 2008 02:23:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186622 - user/kmacy/HEAD_fast_net/sys/net X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Dec 2008 02:23:32 -0000 Author: kmacy Date: Wed Dec 31 02:23:31 2008 New Revision: 186622 URL: http://svn.freebsd.org/changeset/base/186622 Log: add shortcut for off-host ipv4 or ipv6 packets in ether_output Modified: user/kmacy/HEAD_fast_net/sys/net/if_ethersubr.c Modified: user/kmacy/HEAD_fast_net/sys/net/if_ethersubr.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/if_ethersubr.c Wed Dec 31 01:51:07 2008 (r186621) +++ user/kmacy/HEAD_fast_net/sys/net/if_ethersubr.c Wed Dec 31 02:23:31 2008 (r186622) @@ -163,7 +163,7 @@ static int ether_ipfw; int ether_output(struct ifnet *ifp, struct mbuf *m, struct route *ro) { - short type; + short type = 0; int error = 0, hdrcmplt = 0; u_char esrc[ETHER_ADDR_LEN], edst[ETHER_ADDR_LEN]; struct llentry *lle = ro->ro_lle; @@ -174,13 +174,11 @@ ether_output(struct ifnet *ifp, struct m struct rtentry *rt0 = ro->ro_rt; int hlen; /* link layer header length */ - #ifdef MAC error = mac_ifnet_check_transmit(ifp, m); if (error) senderr(error); #endif - M_PROFILE(m); if (ifp->if_flags & IFF_MONITOR) senderr(ENETDOWN); @@ -189,6 +187,50 @@ ether_output(struct ifnet *ifp, struct m senderr(ENETDOWN); hlen = ETHER_HDR_LEN; + + /* + * First try to see if we can shortcut most of ether_output + * 1) do we have a valid lle? + * 2) is this not a bridge? + * 3) is carp disabled? + * 4) is netgraph disabled for this device? + * 5) is this not loopback? + */ + t = pf_find_mtag(m); + if (lle != NULL && (lle->la_flags & LLE_VALID) && + ifp->if_bridge == NULL && ifp->if_carp == NULL && + IFP2AC(ifp)->ac_netgraph == NULL && + (t == NULL || t->routed)) { + + switch (dst->sa_family) { + case AF_INET: + type = htons(ETHERTYPE_IP); + break; + case AF_INET6: + type = htons(ETHERTYPE_IPV6); + break; + } + if (type != 0) { + M_PREPEND(m, ETHER_HDR_LEN, M_DONTWAIT); + if (m == NULL) + senderr(ENOBUFS); + eh = mtod(m, struct ether_header *); + (void)memcpy(&eh->ether_type, &type, + sizeof(eh->ether_type)); + (void)memcpy(eh->ether_dhost, &lle->ll_addr.mac16, + sizeof (edst)); + (void)memcpy(eh->ether_shost, IF_LLADDR(ifp), + sizeof(eh->ether_shost)); + + } + /* Continue with link-layer output */ + return ether_output_frame(ifp, m); + } + + /* + * The shortcut failed, use default path + * + */ switch (dst->sa_family) { #ifdef INET case AF_INET: @@ -340,7 +382,7 @@ ether_output(struct ifnet *ifp, struct m * reasons and compatibility with the original behavior. */ if ((ifp->if_flags & IFF_SIMPLEX) && loop_copy && - ((t = pf_find_mtag(m)) == NULL || !t->routed)) { + (t == NULL || !t->routed)) { int csum_flags = 0; if (m->m_pkthdr.csum_flags & CSUM_IP)