From owner-p4-projects@FreeBSD.ORG Sat Sep 15 20:04:23 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 525EE16A420; Sat, 15 Sep 2007 20:04:23 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F3EF616A419 for ; Sat, 15 Sep 2007 20:04:22 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id D557213C442 for ; Sat, 15 Sep 2007 20:04:22 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l8FK4McB000281 for ; Sat, 15 Sep 2007 20:04:22 GMT (envelope-from kmacy@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l8FK4MKI000278 for perforce@freebsd.org; Sat, 15 Sep 2007 20:04:22 GMT (envelope-from kmacy@freebsd.org) Date: Sat, 15 Sep 2007 20:04:22 GMT Message-Id: <200709152004.l8FK4MKI000278@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to kmacy@freebsd.org using -f From: Kip Macy To: Perforce Change Reviews Cc: Subject: PERFORCE change 126441 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Sep 2007 20:04:23 -0000 http://perforce.freebsd.org/chv.cgi?CH=126441 Change 126441 by kmacy@kmacy_home:ethng on 2007/09/15 20:04:04 put ether_input on a diet for the common case, move most error handling to the end of the function Affected files ... .. //depot/projects/ethng/src/sys/net/if_ethersubr.c#2 edit Differences ... ==== //depot/projects/ethng/src/sys/net/if_ethersubr.c#2 (text+ko) ==== @@ -512,58 +512,36 @@ struct ether_header *eh; u_short etype; - if ((ifp->if_flags & IFF_UP) == 0) { - m_freem(m); - return; - } + if ((ifp->if_flags & IFF_UP) == 0) + goto out; + #ifdef DIAGNOSTIC if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { if_printf(ifp, "discard frame at !IFF_DRV_RUNNING\n"); - m_freem(m); - return; + goto out; } #endif /* * Do consistency checks to verify assumptions * made by code past this point. */ - if ((m->m_flags & M_PKTHDR) == 0) { - if_printf(ifp, "discard frame w/o packet header\n"); - ifp->if_ierrors++; - m_freem(m); - return; - } - if (m->m_len < ETHER_HDR_LEN) { - /* XXX maybe should pullup? */ - if_printf(ifp, "discard frame w/o leading ethernet " - "header (len %u pkt len %u)\n", - m->m_len, m->m_pkthdr.len); - ifp->if_ierrors++; - m_freem(m); - return; - } + if ((m->m_flags & M_PKTHDR) == 0) + goto err_out_print; + if (m->m_len < ETHER_HDR_LEN) + goto err_out_print; + eh = mtod(m, struct ether_header *); etype = ntohs(eh->ether_type); #ifdef DIAGNOSTIC if (m->m_pkthdr.len > ETHER_MAX_FRAME(ifp, etype, m->m_flags & M_HASFCS) && (ifp->if_capenable & IFCAP_LRO) == 0) { - if_printf(ifp, "discard oversize frame " - "(ether type %x flags %x len %u > max %lu)\n", - etype, m->m_flags, m->m_pkthdr.len, - ETHER_MAX_FRAME(ifp, etype, - m->m_flags & M_HASFCS)); - ifp->if_ierrors++; - m_freem(m); - return; + goto err_out_print } #endif - if (m->m_pkthdr.rcvif == NULL) { - if_printf(ifp, "discard frame w/o interface pointer\n"); - ifp->if_ierrors++; - m_freem(m); - return; - } + if (m->m_pkthdr.rcvif == NULL) + goto err_out_print; + #ifdef DIAGNOSTIC if (m->m_pkthdr.rcvif != ifp) { if_printf(ifp, "Warning, frame marked as received on %s\n", @@ -605,10 +583,8 @@ ifp->if_ibytes += m->m_pkthdr.len; /* Allow monitor mode to claim this frame, after stats are updated. */ - if (ifp->if_flags & IFF_MONITOR) { - m_freem(m); - return; - } + if (ifp->if_flags & IFF_MONITOR) + goto out; /* Handle input from a lagg(4) port */ if (ifp->if_type == IFT_IEEE8023ADLAG) { @@ -635,9 +611,7 @@ #ifdef DIAGNOSTIC if_printf(ifp, "cannot pullup VLAN header\n"); #endif - ifp->if_ierrors++; - m_freem(m); - return; + goto err_out; } evl = mtod(m, struct ether_vlan_header *); @@ -704,6 +678,33 @@ random_harvest(m, 16, 3, 0, RANDOM_NET); ether_demux(ifp, m); + return; +err_out_print: + eh = mtod(m, struct ether_header *); + etype = ntohs(eh->ether_type); + + if ((m->m_flags & M_PKTHDR) == 0) + if_printf(ifp, "discard frame w/o packet header\n"); + if (m->m_len < ETHER_HDR_LEN) + if_printf(ifp, "discard frame w/o leading ethernet " + "header (len %u pkt len %u)\n", + m->m_len, m->m_pkthdr.len); +#ifdef DIAGNOSTIC + if (m->m_pkthdr.len > + ETHER_MAX_FRAME(ifp, etype, m->m_flags & M_HASFCS) && + (ifp->if_capenable & IFCAP_LRO) == 0) + if_printf(ifp, "discard oversize frame " + "(ether type %x flags %x len %u > max %lu)\n", + etype, m->m_flags, m->m_pkthdr.len, + ETHER_MAX_FRAME(ifp, etype, + m->m_flags & M_HASFCS)); +#endif + if (m->m_pkthdr.rcvif == NULL) + if_printf(ifp, "discard frame w/o interface pointer\n"); +err_out: + ifp->if_ierrors++; +out: + m_freem(m); } /*