From owner-svn-src-all@FreeBSD.ORG Mon Apr 20 22:08:13 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 E108F952; Mon, 20 Apr 2015 22:08:12 +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 CF6B2AE6; Mon, 20 Apr 2015 22:08:12 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3KM8CBu094228; Mon, 20 Apr 2015 22:08:12 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3KM8C4U094224; Mon, 20 Apr 2015 22:08:12 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201504202208.t3KM8C4U094224@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 20 Apr 2015 22:08:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r281797 - 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.20 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: Mon, 20 Apr 2015 22:08:13 -0000 Author: markj Date: Mon Apr 20 22:08:11 2015 New Revision: 281797 URL: https://svnweb.freebsd.org/changeset/base/281797 Log: Move the definition of struct bpf_if to bpf.c. A couple of fields are still exposed via struct bpf_if_ext so that bpf_peers_present() can be inlined into its callers. However, this change eliminates some type duplication in the resulting CTF container, since otherwise ctfmerge(1) propagates the duplication through all types that contain a struct bpf_if. Differential Revision: https://reviews.freebsd.org/D2319 Reviewed by: melifaro, rpaulo Modified: head/sys/net/bpf.c head/sys/net/bpf.h Modified: head/sys/net/bpf.c ============================================================================== --- head/sys/net/bpf.c Mon Apr 20 21:45:38 2015 (r281796) +++ head/sys/net/bpf.c Mon Apr 20 22:08:11 2015 (r281797) @@ -69,7 +69,6 @@ __FBSDID("$FreeBSD$"); #include #include -#define BPF_INTERNAL #include #include #ifdef BPF_JITTER @@ -90,6 +89,20 @@ __FBSDID("$FreeBSD$"); MALLOC_DEFINE(M_BPF, "BPF", "BPF data"); +struct bpf_if { +#define bif_next bif_ext.bif_next +#define bif_dlist bif_ext.bif_dlist + struct bpf_if_ext bif_ext; /* public members */ + u_int bif_dlt; /* link layer type */ + u_int bif_hdrlen; /* length of link header */ + struct ifnet *bif_ifp; /* corresponding interface */ + struct rwlock bif_lock; /* interface lock */ + LIST_HEAD(, bpf_d) bif_wlist; /* writer-only list */ + int bif_flags; /* Interface flags */ +}; + +CTASSERT(offsetof(struct bpf_if, bif_ext) == 0); + #if defined(DEV_BPF) || defined(NETGRAPH_BPF) #define PRINET 26 /* interruptible */ @@ -1892,7 +1905,7 @@ bpf_setif(struct bpf_d *d, struct ifreq /* Check if interface is not being detached from BPF */ BPFIF_RLOCK(bp); - if (bp->flags & BPFIF_FLAG_DYING) { + if (bp->bif_flags & BPFIF_FLAG_DYING) { BPFIF_RUNLOCK(bp); return (ENXIO); } @@ -2561,7 +2574,7 @@ bpfdetach(struct ifnet *ifp) * Mark bp as detached to restrict new consumers. */ BPFIF_WLOCK(bp); - bp->flags |= BPFIF_FLAG_DYING; + bp->bif_flags |= BPFIF_FLAG_DYING; BPFIF_WUNLOCK(bp); CTR4(KTR_NET, "%s: sheduling free for encap %d (%p) for if %p", Modified: head/sys/net/bpf.h ============================================================================== --- head/sys/net/bpf.h Mon Apr 20 21:45:38 2015 (r281796) +++ head/sys/net/bpf.h Mon Apr 20 22:08:11 2015 (r281797) @@ -1451,21 +1451,14 @@ SYSCTL_DECL(_net_bpf); /* * Descriptor associated with each attached hardware interface. - * FIXME: this structure is exposed to external callers to speed up - * bpf_peers_present() call. However we cover all fields not needed by - * this function via BPF_INTERNAL define + * Part of this structure is exposed to external callers to speed up + * bpf_peers_present() calls. */ -struct bpf_if { +struct bpf_if; + +struct bpf_if_ext { LIST_ENTRY(bpf_if) bif_next; /* list of all interfaces */ LIST_HEAD(, bpf_d) bif_dlist; /* descriptor list */ -#ifdef BPF_INTERNAL - u_int bif_dlt; /* link layer type */ - u_int bif_hdrlen; /* length of link header */ - struct ifnet *bif_ifp; /* corresponding interface */ - struct rwlock bif_lock; /* interface lock */ - LIST_HEAD(, bpf_d) bif_wlist; /* writer-only list */ - int flags; /* Interface flags */ -#endif }; void bpf_bufheld(struct bpf_d *d); @@ -1483,8 +1476,10 @@ u_int bpf_filter(const struct bpf_insn static __inline int bpf_peers_present(struct bpf_if *bpf) { + struct bpf_if_ext *ext; - if (!LIST_EMPTY(&bpf->bif_dlist)) + ext = (struct bpf_if_ext *)bpf; + if (!LIST_EMPTY(&ext->bif_dlist)) return (1); return (0); }