Date: Tue, 22 Oct 2013 15:06:25 +0000 (UTC) From: Andre Oppermann <andre@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r256909 - user/andre/mbuf_staging/net Message-ID: <201310221506.r9MF6PnS062692@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: andre Date: Tue Oct 22 15:06:24 2013 New Revision: 256909 URL: http://svnweb.freebsd.org/changeset/base/256909 Log: Make struct ifnet comprehensible by grouping related fields and variables together. Quantify the structure size and how bloated it has become. This is only a mechanical change. Obvious first candidates for slimming by externalizing are: - char if_xname[IFNAMSIZ] - struct ifaltq if_snd - struct if_data if_data - void *if_afdata[AF_MAX] Sponsored by: The FreeBSD Foundation Modified: user/andre/mbuf_staging/net/if_var.h Modified: user/andre/mbuf_staging/net/if_var.h ============================================================================== --- user/andre/mbuf_staging/net/if_var.h Tue Oct 22 14:55:04 2013 (r256908) +++ user/andre/mbuf_staging/net/if_var.h Tue Oct 22 15:06:24 2013 (r256909) @@ -120,18 +120,41 @@ struct ifqueue { /* * Structure defining a network interface. * - * (Would like to call this struct ``if'', but C isn't PL/1.) + * Size ILP32: 592 (approx) + * LP64: 1048 (approx) */ - struct ifnet { + /* General book keeping of interface lists. */ + TAILQ_ENTRY(ifnet) if_link; /* all struct ifnets are chained */ + LIST_ENTRY(ifnet) if_clones; /* interfaces of a cloner */ + TAILQ_HEAD(, ifg_list) if_groups; /* linked list of groups per if */ + /* protected by if_addr_lock */ + u_char if_alloctype; /* if_type at time of allocation */ + + /* Driver and protocol specific information that remains stable. */ void *if_softc; /* pointer to driver state */ + void *if_llsoftc; /* link layer softc */ void *if_l2com; /* pointer to protocol bits */ - struct vnet *if_vnet; /* pointer to network stack instance */ - TAILQ_ENTRY(ifnet) if_link; /* all struct ifnets are chained */ - char if_xname[IFNAMSIZ]; /* external name (name + unit) */ const char *if_dname; /* driver name */ int if_dunit; /* unit or IF_DUNIT_NONE */ + u_short if_index; /* numeric abbreviation for this if */ + short if_index_reserved; /* spare space to grow if_index */ + char if_xname[IFNAMSIZ]; /* external name (name + unit) */ + char *if_description; /* interface description */ + + /* Variable fields that are touched by the drivers. */ + int if_flags; /* up/down, broadcast, etc. */ + int if_capabilities; /* interface features & capabilities */ + int if_capenable; /* enabled features & capabilities */ + void *if_linkmib; /* link-type-specific MIB data */ + size_t if_linkmiblen; /* length of above data */ + int if_drv_flags; /* driver-managed status flags */ u_int if_refcount; /* reference count */ + struct ifaltq if_snd; /* output queue (includes altq) */ + struct if_data if_data; + struct task if_linktask; /* task for link change events */ + + /* Addresses of different protocol families assigned to this if. */ struct ifaddrhead if_addrhead; /* linked list of addresses per if */ /* * if_addrhead is the list of all addresses associated to @@ -143,21 +166,29 @@ struct ifnet { * However, access to the AF_LINK address through this * field is deprecated. Use if_addr or ifaddr_byindex() instead. */ + struct ifmultihead if_multiaddrs; /* multicast addresses configured */ + int if_amcount; /* number of all-multicast requests */ + struct ifaddr *if_addr; /* pointer to link-level address */ + const u_int8_t *if_broadcastaddr; /* linklevel broadcast bytestring */ + struct rwlock if_addr_lock; /* lock to protect address lists */ + void *if_afdata[AF_MAX]; + int if_afdata_initialized; + struct rwlock if_afdata_lock; + + /* Additional interface features. */ + struct bpf_if *if_bpf; /* packet filter structure */ int if_pcount; /* number of promiscuous listeners */ + void *if_bridge; /* bridge glue */ + void *if_lagg; /* lagg glue */ + void *if_pf_kif; /* pf glue */ struct carp_if *if_carp; /* carp interface structure */ - struct bpf_if *if_bpf; /* packet filter structure */ - u_short if_index; /* numeric abbreviation for this if */ - short if_index_reserved; /* spare space to grow if_index */ struct ifvlantrunk *if_vlantrunk; /* pointer to 802.1q data */ - int if_flags; /* up/down, broadcast, etc. */ - int if_capabilities; /* interface features & capabilities */ - int if_capenable; /* enabled features & capabilities */ - void *if_linkmib; /* link-type-specific MIB data */ - size_t if_linkmiblen; /* length of above data */ - struct if_data if_data; - struct ifmultihead if_multiaddrs; /* multicast addresses configured */ - int if_amcount; /* number of all-multicast requests */ -/* procedure handles */ + struct vnet *if_vnet; /* pointer to network stack instance */ + struct vnet *if_home_vnet; /* where this ifnet originates from */ + u_int if_fib; /* interface FIB */ + struct label *if_label; /* interface MAC label */ + + /* Various procedures of the layer2 encapsulation and drivers. */ int (*if_output) /* output routine (enqueue) */ (struct ifnet *, struct mbuf *, const struct sockaddr *, struct route *); @@ -177,39 +208,12 @@ struct ifnet { (struct ifnet *, struct mbuf *); void (*if_reassign) /* reassign to vnet routine */ (struct ifnet *, struct vnet *, char *); - struct vnet *if_home_vnet; /* where this ifnet originates from */ - struct ifaddr *if_addr; /* pointer to link-level address */ - void *if_llsoftc; /* link layer softc */ - int if_drv_flags; /* driver-managed status flags */ - struct ifaltq if_snd; /* output queue (includes altq) */ - const u_int8_t *if_broadcastaddr; /* linklevel broadcast bytestring */ - - void *if_bridge; /* bridge glue */ - - struct label *if_label; /* interface MAC label */ - - /* these are only used by IPv6 */ - void *if_unused[2]; - void *if_afdata[AF_MAX]; - int if_afdata_initialized; - struct rwlock if_afdata_lock; - struct task if_linktask; /* task for link change events */ - struct rwlock if_addr_lock; /* lock to protect address lists */ - - LIST_ENTRY(ifnet) if_clones; /* interfaces of a cloner */ - TAILQ_HEAD(, ifg_list) if_groups; /* linked list of groups per if */ - /* protected by if_addr_lock */ - void *if_pf_kif; - void *if_lagg; /* lagg glue */ - char *if_description; /* interface description */ - u_int if_fib; /* interface FIB */ - u_char if_alloctype; /* if_type at time of allocation */ + /* Stuff that's only temporary and doesn't belong here. */ u_int if_hw_tsomax; /* tso burst length limit, the minimum * is (IP_MAXPACKET / 8). * XXXAO: Have to find a better place * for it eventually. */ - /* * Spare fields are added so that we can modify sensitive data * structures without changing the kernel binary interface, and must @@ -217,6 +221,7 @@ struct ifnet { */ char if_cspare[3]; int if_ispare[4]; + void *if_unused[2]; void *if_pspare[8]; /* 1 netmap, 7 TDB */ };
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201310221506.r9MF6PnS062692>