diff options
author | 2009-06-02 00:05:13 +0000 | |
---|---|---|
committer | 2009-06-02 00:05:13 +0000 | |
commit | f7548409e86c5d429b00cb589dc63f7c6ff99b1e (patch) | |
tree | fed63fb5b717a7328501f0e94f497336905237a5 | |
parent | Use only one list to queue the dump contextes on. Use the list in struct (diff) | |
download | wireguard-openbsd-f7548409e86c5d429b00cb589dc63f7c6ff99b1e.tar.xz wireguard-openbsd-f7548409e86c5d429b00cb589dc63f7c6ff99b1e.zip |
Move M_PREPEND macro code to be entirely into m_prepend the function;
calling M_PREPEND is now #define'd to be calling m_prepend.
Shaves an unknown but assumed-to-be-nontrivial amount from the kernel.
ok claudio@ henning@(who may have had to okay this twice to get me to notice)
-rw-r--r-- | sys/kern/uipc_mbuf.c | 31 | ||||
-rw-r--r-- | sys/sys/mbuf.h | 13 |
2 files changed, 21 insertions, 23 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 1d12b78d771..acd7a7f4330 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_mbuf.c,v 1.119 2009/03/02 23:52:18 dlg Exp $ */ +/* $OpenBSD: uipc_mbuf.c,v 1.120 2009/06/02 00:05:13 blambert Exp $ */ /* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */ /* @@ -540,9 +540,7 @@ m_defrag(struct mbuf *m, int how) */ /* - * Lesser-used path for M_PREPEND: - * allocate new mbuf to prepend to chain, - * copy junk along. + * Ensure len bytes of contiguous space at the beginning of the mbuf chain */ struct mbuf * m_prepend(struct mbuf *m, int len, int how) @@ -552,17 +550,24 @@ m_prepend(struct mbuf *m, int len, int how) if (len > MHLEN) panic("mbuf prepend length too big"); - MGET(mn, how, m->m_type); - if (mn == NULL) { - m_freem(m); - return (NULL); + if (M_LEADINGSPACE(m) >= len) { + m->m_data -= len; + m->m_len += len; + } else { + MGET(mn, how, m->m_type); + if (mn == NULL) { + m_freem(m); + return (NULL); + } + if (m->m_flags & M_PKTHDR) + M_MOVE_PKTHDR(mn, m); + mn->m_next = m; + m = mn; + MH_ALIGN(m, len); + m->m_len = len; } if (m->m_flags & M_PKTHDR) - M_MOVE_PKTHDR(mn, m); - mn->m_next = m; - m = mn; - MH_ALIGN(m, len); - m->m_len = len; + m->m_pkthdr.len += len; return (m); } diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index 2a6420be5b9..75d73b52c1f 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mbuf.h,v 1.121 2009/01/27 09:17:51 dlg Exp $ */ +/* $OpenBSD: mbuf.h,v 1.122 2009/06/02 00:05:13 blambert Exp $ */ /* $NetBSD: mbuf.h,v 1.19 1996/02/09 18:25:14 christos Exp $ */ /* @@ -360,15 +360,8 @@ struct mbuf { * If how is M_DONTWAIT and allocation fails, the original mbuf chain * is freed and m is set to NULL. */ -#define M_PREPEND(m, plen, how) do { \ - if (M_LEADINGSPACE(m) >= (plen)) { \ - (m)->m_data -= (plen); \ - (m)->m_len += (plen); \ - } else \ - (m) = m_prepend((m), (plen), (how)); \ - if ((m) && (m)->m_flags & M_PKTHDR) \ - (m)->m_pkthdr.len += (plen); \ -} while (/* CONSTCOND */ 0) +#define M_PREPEND(m, plen, how) \ + (m) = m_prepend((m), (plen), (how)) /* length to m_copy to copy all */ #define M_COPYALL 1000000000 |