svn commit: r194515 - in head/sys: kern sys
Kip Macy
kmacy at FreeBSD.org
Fri Jun 19 21:14:40 UTC 2009
Author: kmacy
Date: Fri Jun 19 21:14:39 2009
New Revision: 194515
URL: http://svn.freebsd.org/changeset/base/194515
Log:
define helper routines for deferred mbuf initialization
Modified:
head/sys/kern/kern_mbuf.c
head/sys/sys/mbuf.h
Modified: head/sys/kern/kern_mbuf.c
==============================================================================
--- head/sys/kern/kern_mbuf.c Fri Jun 19 21:11:09 2009 (r194514)
+++ head/sys/kern/kern_mbuf.c Fri Jun 19 21:14:39 2009 (r194515)
@@ -645,6 +645,32 @@ mb_ctor_pack(void *mem, int size, void *
return (0);
}
+int
+m_pkthdr_init(struct mbuf *m, int how)
+{
+#ifdef MAC
+ int error;
+#endif
+ m->m_data = m->m_pktdat;
+ SLIST_INIT(&m->m_pkthdr.tags);
+ m->m_pkthdr.rcvif = NULL;
+ m->m_pkthdr.header = NULL;
+ m->m_pkthdr.len = 0;
+ m->m_pkthdr.flowid = 0;
+ m->m_pkthdr.csum_flags = 0;
+ m->m_pkthdr.csum_data = 0;
+ m->m_pkthdr.tso_segsz = 0;
+ m->m_pkthdr.ether_vtag = 0;
+#ifdef MAC
+ /* If the label init fails, fail the alloc */
+ error = mac_mbuf_init(m, how);
+ if (error)
+ return (error);
+#endif
+
+ return (0);
+}
+
/*
* This is the protocol drain routine.
*
Modified: head/sys/sys/mbuf.h
==============================================================================
--- head/sys/sys/mbuf.h Fri Jun 19 21:11:09 2009 (r194514)
+++ head/sys/sys/mbuf.h Fri Jun 19 21:14:39 2009 (r194515)
@@ -366,12 +366,15 @@ static __inline struct mbuf *m_gethdr(in
static __inline struct mbuf *m_getjcl(int how, short type, int flags,
int size);
static __inline struct mbuf *m_getclr(int how, short type); /* XXX */
+static __inline int m_init(struct mbuf *m, uma_zone_t zone,
+ int size, int how, short type, int flags);
static __inline struct mbuf *m_free(struct mbuf *m);
static __inline void m_clget(struct mbuf *m, int how);
static __inline void *m_cljget(struct mbuf *m, int how, int size);
static __inline void m_chtype(struct mbuf *m, short new_type);
void mb_free_ext(struct mbuf *);
static __inline struct mbuf *m_last(struct mbuf *m);
+int m_pkthdr_init(struct mbuf *m, int how);
static __inline int
m_gettype(int size)
@@ -433,6 +436,33 @@ m_getzone(int size)
return (zone);
}
+/*
+ * Initialize an mbuf with linear storage.
+ *
+ * Inline because the consumer text overhead will be roughly the same to
+ * initialize or call a function with this many parameters and M_PKTHDR
+ * should go away with constant propagation for !MGETHDR.
+ */
+static __inline int
+m_init(struct mbuf *m, uma_zone_t zone, int size, int how, short type,
+ int flags)
+{
+ int error;
+
+ m->m_next = NULL;
+ m->m_nextpkt = NULL;
+ m->m_data = m->m_dat;
+ m->m_len = 0;
+ m->m_flags = flags;
+ m->m_type = type;
+ if (flags & M_PKTHDR) {
+ if ((error = m_pkthdr_init(m, how)) != 0)
+ return (error);
+ }
+
+ return (0);
+}
+
static __inline struct mbuf *
m_get(int how, short type)
{
More information about the svn-src-all
mailing list