From owner-svn-src-all@FreeBSD.ORG Fri Mar 20 14:05:18 2015 Return-Path: Delivered-To: svn-src-all@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 C185CFE5; Fri, 20 Mar 2015 14:05:18 +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 A294C8F; Fri, 20 Mar 2015 14:05:18 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t2KE5I7D055567; Fri, 20 Mar 2015 14:05:18 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t2KE5I2w055566; Fri, 20 Mar 2015 14:05:18 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201503201405.t2KE5I2w055566@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Fri, 20 Mar 2015 14:05:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r280280 - head/sys/net X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Mar 2015 14:05:18 -0000 Author: glebius Date: Fri Mar 20 14:05:17 2015 New Revision: 280280 URL: https://svnweb.freebsd.org/changeset/base/280280 Log: Now, when r272244 introduced counter(9) based counters for all interfaces, revert the r271538, which did that for vlan(4) only. No objections: melifaro Sponsored by: Nginx, Inc. Modified: head/sys/net/if_vlan.c Modified: head/sys/net/if_vlan.c ============================================================================== --- head/sys/net/if_vlan.c Fri Mar 20 10:27:06 2015 (r280279) +++ head/sys/net/if_vlan.c Fri Mar 20 14:05:17 2015 (r280280) @@ -104,12 +104,6 @@ struct vlan_mc_entry { struct ifvlan { struct ifvlantrunk *ifv_trunk; struct ifnet *ifv_ifp; - counter_u64_t ifv_ipackets; - counter_u64_t ifv_ibytes; - counter_u64_t ifv_opackets; - counter_u64_t ifv_obytes; - counter_u64_t ifv_omcasts; - counter_u64_t ifv_oerrors; #define TRUNK(ifv) ((ifv)->ifv_trunk) #define PARENT(ifv) ((ifv)->ifv_trunk->parent) void *ifv_cookie; @@ -202,7 +196,6 @@ static void vlan_init(void *foo); static void vlan_input(struct ifnet *ifp, struct mbuf *m); static int vlan_ioctl(struct ifnet *ifp, u_long cmd, caddr_t addr); static void vlan_qflush(struct ifnet *ifp); -static uint64_t vlan_get_counter(struct ifnet *ifp, ift_counter cnt); static int vlan_setflag(struct ifnet *ifp, int flag, int status, int (*func)(struct ifnet *, int)); static int vlan_setflags(struct ifnet *ifp, int status); @@ -955,14 +948,6 @@ vlan_clone_create(struct if_clone *ifc, return (ENOSPC); } SLIST_INIT(&ifv->vlan_mc_listhead); - /* Prepare pcpu counters */ - ifv->ifv_ipackets = counter_u64_alloc(M_WAITOK); - ifv->ifv_opackets = counter_u64_alloc(M_WAITOK); - ifv->ifv_ibytes = counter_u64_alloc(M_WAITOK); - ifv->ifv_obytes = counter_u64_alloc(M_WAITOK); - ifv->ifv_omcasts = counter_u64_alloc(M_WAITOK); - ifv->ifv_oerrors = counter_u64_alloc(M_WAITOK); - ifp->if_softc = ifv; /* * Set the name manually rather than using if_initname because @@ -981,7 +966,6 @@ vlan_clone_create(struct if_clone *ifc, ifp->if_qflush = vlan_qflush; ifp->if_ioctl = vlan_ioctl; ifp->if_flags = VLAN_IFFLAGS; - ifp->if_get_counter = vlan_get_counter; ether_ifattach(ifp, eaddr); /* Now undo some of the damage... */ ifp->if_baudrate = 0; @@ -1024,12 +1008,6 @@ vlan_clone_destroy(struct if_clone *ifc, ether_ifdetach(ifp); /* first, remove it from system-wide lists */ vlan_unconfig(ifp); /* now it can be unconfigured and freed */ if_free(ifp); - counter_u64_free(ifv->ifv_ipackets); - counter_u64_free(ifv->ifv_opackets); - counter_u64_free(ifv->ifv_ibytes); - counter_u64_free(ifv->ifv_obytes); - counter_u64_free(ifv->ifv_omcasts); - counter_u64_free(ifv->ifv_oerrors); free(ifv, M_VLAN); ifc_free_unit(ifc, unit); @@ -1067,7 +1045,7 @@ vlan_transmit(struct ifnet *ifp, struct */ if (!UP_AND_RUNNING(p)) { m_freem(m); - counter_u64_add(ifv->ifv_oerrors, 1); + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return (ENETDOWN); } @@ -1094,7 +1072,7 @@ vlan_transmit(struct ifnet *ifp, struct if (n > 0) { if_printf(ifp, "cannot pad short frame\n"); - counter_u64_add(ifv->ifv_oerrors, 1); + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(m); return (0); } @@ -1114,7 +1092,7 @@ vlan_transmit(struct ifnet *ifp, struct m = ether_vlanencap(m, ifv->ifv_vid); if (m == NULL) { if_printf(ifp, "unable to prepend VLAN header\n"); - counter_u64_add(ifv->ifv_oerrors, 1); + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return (0); } } @@ -1124,40 +1102,14 @@ vlan_transmit(struct ifnet *ifp, struct */ error = (p->if_transmit)(p, m); if (error == 0) { - counter_u64_add(ifv->ifv_opackets, 1); - counter_u64_add(ifv->ifv_obytes, len); - counter_u64_add(ifv->ifv_omcasts, mcast); + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_OBYTES, len); + if_inc_counter(ifp, IFCOUNTER_OMCASTS, mcast); } else - counter_u64_add(ifv->ifv_oerrors, 1); + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return (error); } -static uint64_t -vlan_get_counter(struct ifnet *ifp, ift_counter cnt) -{ - struct ifvlan *ifv; - - ifv = ifp->if_softc; - - switch (cnt) { - case IFCOUNTER_IPACKETS: - return (counter_u64_fetch(ifv->ifv_ipackets)); - case IFCOUNTER_OPACKETS: - return (counter_u64_fetch(ifv->ifv_opackets)); - case IFCOUNTER_IBYTES: - return (counter_u64_fetch(ifv->ifv_ibytes)); - case IFCOUNTER_OBYTES: - return (counter_u64_fetch(ifv->ifv_obytes)); - case IFCOUNTER_OMCASTS: - return (counter_u64_fetch(ifv->ifv_omcasts)); - case IFCOUNTER_OERRORS: - return (counter_u64_fetch(ifv->ifv_oerrors)); - default: - return (if_get_counter_default(ifp, cnt)); - } - /* NOTREACHED */ -} - /* * The ifp->if_qflush entry point for vlan(4) is a no-op. */ @@ -1232,8 +1184,8 @@ vlan_input(struct ifnet *ifp, struct mbu TRUNK_RUNLOCK(trunk); m->m_pkthdr.rcvif = ifv->ifv_ifp; - counter_u64_add(ifv->ifv_ipackets, 1); - counter_u64_add(ifv->ifv_ibytes, m->m_pkthdr.len); + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); /* Pass it back through the parent's input routine. */ (*ifp->if_input)(ifv->ifv_ifp, m);