Sat Dec 22 13:55:56 2018 UTC ()
Move m_align() back into the kernel, and switch M_ALIGN and MH_ALIGN to it.
Forcing a distinction between M_ALIGN and MH_ALIGN is too bug-friendly and
serves no particular purpose.


(maxv)
diff -r1.226 -r1.227 src/sys/kern/uipc_mbuf.c
diff -r1.32 -r1.33 src/sys/net80211/ieee80211_netbsd.c
diff -r1.21 -r1.22 src/sys/net80211/ieee80211_netbsd.h
diff -r1.215 -r1.216 src/sys/sys/mbuf.h

cvs diff -r1.226 -r1.227 src/sys/kern/uipc_mbuf.c (expand / switch to unified diff)

--- src/sys/kern/uipc_mbuf.c 2018/12/22 13:11:37 1.226
+++ src/sys/kern/uipc_mbuf.c 2018/12/22 13:55:56 1.227
@@ -1,22 +1,22 @@ @@ -1,22 +1,22 @@
1/* $NetBSD: uipc_mbuf.c,v 1.226 2018/12/22 13:11:37 maxv Exp $ */ 1/* $NetBSD: uipc_mbuf.c,v 1.227 2018/12/22 13:55:56 maxv Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1999, 2001 The NetBSD Foundation, Inc. 4 * Copyright (c) 1999, 2001, 2018 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center. 9 * NASA Ames Research Center, and Maxime Villard.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer. 15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright 16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the 17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution. 18 * documentation and/or other materials provided with the distribution.
19 * 19 *
20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
@@ -52,27 +52,27 @@ @@ -52,27 +52,27 @@
52 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 52 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
53 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 53 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
54 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 54 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
55 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 55 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
56 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 56 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
57 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 57 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
58 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 58 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
59 * SUCH DAMAGE. 59 * SUCH DAMAGE.
60 * 60 *
61 * @(#)uipc_mbuf.c 8.4 (Berkeley) 2/14/95 61 * @(#)uipc_mbuf.c 8.4 (Berkeley) 2/14/95
62 */ 62 */
63 63
64#include <sys/cdefs.h> 64#include <sys/cdefs.h>
65__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.226 2018/12/22 13:11:37 maxv Exp $"); 65__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.227 2018/12/22 13:55:56 maxv Exp $");
66 66
67#ifdef _KERNEL_OPT 67#ifdef _KERNEL_OPT
68#include "opt_mbuftrace.h" 68#include "opt_mbuftrace.h"
69#include "opt_nmbclusters.h" 69#include "opt_nmbclusters.h"
70#include "opt_ddb.h" 70#include "opt_ddb.h"
71#include "ether.h" 71#include "ether.h"
72#endif 72#endif
73 73
74#include <sys/param.h> 74#include <sys/param.h>
75#include <sys/systm.h> 75#include <sys/systm.h>
76#include <sys/atomic.h> 76#include <sys/atomic.h>
77#include <sys/cpu.h> 77#include <sys/cpu.h>
78#include <sys/proc.h> 78#include <sys/proc.h>
@@ -1744,26 +1744,50 @@ m_move_pkthdr(struct mbuf *to, struct mb @@ -1744,26 +1744,50 @@ m_move_pkthdr(struct mbuf *to, struct mb
1744 KASSERT((to->m_flags & M_EXT) == 0); 1744 KASSERT((to->m_flags & M_EXT) == 0);
1745 KASSERT((to->m_flags & M_PKTHDR) == 0 || 1745 KASSERT((to->m_flags & M_PKTHDR) == 0 ||
1746 SLIST_FIRST(&to->m_pkthdr.tags) == NULL); 1746 SLIST_FIRST(&to->m_pkthdr.tags) == NULL);
1747 KASSERT((from->m_flags & M_PKTHDR) != 0); 1747 KASSERT((from->m_flags & M_PKTHDR) != 0);
1748 1748
1749 to->m_pkthdr = from->m_pkthdr; 1749 to->m_pkthdr = from->m_pkthdr;
1750 to->m_flags = from->m_flags & M_COPYFLAGS; 1750 to->m_flags = from->m_flags & M_COPYFLAGS;
1751 to->m_data = to->m_pktdat; 1751 to->m_data = to->m_pktdat;
1752 1752
1753 from->m_flags &= ~M_PKTHDR; 1753 from->m_flags &= ~M_PKTHDR;
1754} 1754}
1755 1755
1756/* 1756/*
 1757 * Set the m_data pointer of a newly-allocated mbuf to place an object of the
 1758 * specified size at the end of the mbuf, longword aligned.
 1759 */
 1760void
 1761m_align(struct mbuf *m, int len)
 1762{
 1763 int buflen, adjust;
 1764
 1765 KASSERT(len != M_COPYALL);
 1766 KASSERT(M_LEADINGSPACE(m) == 0);
 1767
 1768 if (m->m_flags & M_EXT)
 1769 buflen = m->m_ext.ext_size;
 1770 else if (m->m_flags & M_PKTHDR)
 1771 buflen = MHLEN;
 1772 else
 1773 buflen = MLEN;
 1774
 1775 KASSERT(len <= buflen);
 1776 adjust = buflen - len;
 1777 m->m_data += adjust &~ (sizeof(long)-1);
 1778}
 1779
 1780/*
1757 * Apply function f to the data in an mbuf chain starting "off" bytes from the 1781 * Apply function f to the data in an mbuf chain starting "off" bytes from the
1758 * beginning, continuing for "len" bytes. 1782 * beginning, continuing for "len" bytes.
1759 */ 1783 */
1760int 1784int
1761m_apply(struct mbuf *m, int off, int len, 1785m_apply(struct mbuf *m, int off, int len,
1762 int (*f)(void *, void *, unsigned int), void *arg) 1786 int (*f)(void *, void *, unsigned int), void *arg)
1763{ 1787{
1764 unsigned int count; 1788 unsigned int count;
1765 int rval; 1789 int rval;
1766 1790
1767 KASSERT(len != M_COPYALL); 1791 KASSERT(len != M_COPYALL);
1768 KASSERT(len >= 0); 1792 KASSERT(len >= 0);
1769 KASSERT(off >= 0); 1793 KASSERT(off >= 0);

cvs diff -r1.32 -r1.33 src/sys/net80211/ieee80211_netbsd.c (expand / switch to unified diff)

--- src/sys/net80211/ieee80211_netbsd.c 2018/09/03 16:29:36 1.32
+++ src/sys/net80211/ieee80211_netbsd.c 2018/12/22 13:55:56 1.33
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ieee80211_netbsd.c,v 1.32 2018/09/03 16:29:36 riastradh Exp $ */ 1/* $NetBSD: ieee80211_netbsd.c,v 1.33 2018/12/22 13:55:56 maxv Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2003-2005 Sam Leffler, Errno Consulting 4 * Copyright (c) 2003-2005 Sam Leffler, Errno Consulting
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -21,27 +21,27 @@ @@ -21,27 +21,27 @@
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29 29
30#include <sys/cdefs.h> 30#include <sys/cdefs.h>
31#ifdef __FreeBSD__ 31#ifdef __FreeBSD__
32__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_freebsd.c,v 1.8 2005/08/08 18:46:35 sam Exp $"); 32__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_freebsd.c,v 1.8 2005/08/08 18:46:35 sam Exp $");
33#else 33#else
34__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.32 2018/09/03 16:29:36 riastradh Exp $"); 34__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.33 2018/12/22 13:55:56 maxv Exp $");
35#endif 35#endif
36 36
37/* 37/*
38 * IEEE 802.11 support (NetBSD-specific code) 38 * IEEE 802.11 support (NetBSD-specific code)
39 */ 39 */
40#include <sys/param.h> 40#include <sys/param.h>
41#include <sys/kernel.h> 41#include <sys/kernel.h>
42#include <sys/systm.h> 42#include <sys/systm.h>
43#include <sys/mbuf.h> 43#include <sys/mbuf.h>
44#include <sys/proc.h> 44#include <sys/proc.h>
45#include <sys/sysctl.h> 45#include <sys/sysctl.h>
46#include <sys/once.h> 46#include <sys/once.h>
47 47
@@ -714,47 +714,26 @@ ieee80211_load_module(const char *modnam @@ -714,47 +714,26 @@ ieee80211_load_module(const char *modnam
714 if (suser(td) == 0 && securelevel_gt(td->td_ucred, 0) == 0) { 714 if (suser(td) == 0 && securelevel_gt(td->td_ucred, 0) == 0) {
715 mtx_lock(&Giant); 715 mtx_lock(&Giant);
716 (void) linker_load_module(modname, NULL, NULL, NULL, NULL); 716 (void) linker_load_module(modname, NULL, NULL, NULL, NULL);
717 mtx_unlock(&Giant); 717 mtx_unlock(&Giant);
718 } 718 }
719#else 719#else
720 printf("%s: load the %s module by hand for now.\n", __func__, modname); 720 printf("%s: load the %s module by hand for now.\n", __func__, modname);
721#endif 721#endif
722} 722}
723 723
724/* -------------------------------------------------------------------------- */ 724/* -------------------------------------------------------------------------- */
725 725
726/* 726/*
727 * Set the m_data pointer of a newly-allocated mbuf 
728 * to place an object of the specified size at the 
729 * end of the mbuf, longword aligned. 
730 */ 
731void 
732m_align(struct mbuf *m, int len) 
733{ 
734 int adjust; 
735 
736 KASSERT(len != M_COPYALL); 
737 
738 if (m->m_flags & M_EXT) 
739 adjust = m->m_ext.ext_size - len; 
740 else if (m->m_flags & M_PKTHDR) 
741 adjust = MHLEN - len; 
742 else 
743 adjust = MLEN - len; 
744 m->m_data += adjust &~ (sizeof(long)-1); 
745} 
746 
747/* 
748 * Append the specified data to the indicated mbuf chain, 727 * Append the specified data to the indicated mbuf chain,
749 * Extend the mbuf chain if the new data does not fit in 728 * Extend the mbuf chain if the new data does not fit in
750 * existing space. 729 * existing space.
751 * 730 *
752 * Return 1 if able to complete the job; otherwise 0. 731 * Return 1 if able to complete the job; otherwise 0.
753 */ 732 */
754int 733int
755m_append(struct mbuf *m0, int len, const void *cpv) 734m_append(struct mbuf *m0, int len, const void *cpv)
756{ 735{
757 struct mbuf *m, *n; 736 struct mbuf *m, *n;
758 int remainder, space; 737 int remainder, space;
759 const char *cp = cpv; 738 const char *cp = cpv;
760 739

cvs diff -r1.21 -r1.22 src/sys/net80211/ieee80211_netbsd.h (expand / switch to unified diff)

--- src/sys/net80211/ieee80211_netbsd.h 2018/05/03 17:14:37 1.21
+++ src/sys/net80211/ieee80211_netbsd.h 2018/12/22 13:55:56 1.22
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ieee80211_netbsd.h,v 1.21 2018/05/03 17:14:37 maxv Exp $ */ 1/* $NetBSD: ieee80211_netbsd.h,v 1.22 2018/12/22 13:55:56 maxv Exp $ */
2/*- 2/*-
3 * Copyright (c) 2003-2005 Sam Leffler, Errno Consulting 3 * Copyright (c) 2003-2005 Sam Leffler, Errno Consulting
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products 14 * 3. The name of the author may not be used to endorse or promote products
@@ -238,17 +238,16 @@ void get_random_bytes(void *, size_t); @@ -238,17 +238,16 @@ void get_random_bytes(void *, size_t);
238void ieee80211_sysctl_attach(struct ieee80211com *); 238void ieee80211_sysctl_attach(struct ieee80211com *);
239void ieee80211_sysctl_detach(struct ieee80211com *); 239void ieee80211_sysctl_detach(struct ieee80211com *);
240void ieee80211_load_module(const char *); 240void ieee80211_load_module(const char *);
241 241
242void ieee80211_rssadapt_sysctl_setup(struct sysctllog **); 242void ieee80211_rssadapt_sysctl_setup(struct sysctllog **);
243 243
244void ieee80211_init(void); 244void ieee80211_init(void);
245#define IEEE80211_CRYPTO_SETUP(name) \ 245#define IEEE80211_CRYPTO_SETUP(name) \
246 static void name(void); \ 246 static void name(void); \
247 __link_set_add_text(ieee80211_funcs, name); \ 247 __link_set_add_text(ieee80211_funcs, name); \
248 static void name(void) 248 static void name(void)
249#endif 249#endif
250 250
251void m_align(struct mbuf *, int); 
252int m_append(struct mbuf *, int, const void *); 251int m_append(struct mbuf *, int, const void *);
253 252
254#endif /* !_NET80211_IEEE80211_NETBSD_H_ */ 253#endif /* !_NET80211_IEEE80211_NETBSD_H_ */

cvs diff -r1.215 -r1.216 src/sys/sys/mbuf.h (expand / switch to unified diff)

--- src/sys/sys/mbuf.h 2018/11/15 11:18:33 1.215
+++ src/sys/sys/mbuf.h 2018/12/22 13:55:56 1.216
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: mbuf.h,v 1.215 2018/11/15 11:18:33 maxv Exp $ */ 1/* $NetBSD: mbuf.h,v 1.216 2018/12/22 13:55:56 maxv Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996, 1997, 1999, 2001, 2007 The NetBSD Foundation, Inc. 4 * Copyright (c) 1996, 1997, 1999, 2001, 2007 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center and Matt Thomas of 3am Software Foundry. 9 * NASA Ames Research Center and Matt Thomas of 3am Software Foundry.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -507,48 +507,28 @@ do { \ @@ -507,48 +507,28 @@ do { \
507#define MRESETDATA(m) \ 507#define MRESETDATA(m) \
508do { \ 508do { \
509 if ((m)->m_flags & M_EXT) \ 509 if ((m)->m_flags & M_EXT) \
510 (m)->m_data = (m)->m_ext.ext_buf; \ 510 (m)->m_data = (m)->m_ext.ext_buf; \
511 else if ((m)->m_flags & M_PKTHDR) \ 511 else if ((m)->m_flags & M_PKTHDR) \
512 (m)->m_data = (m)->m_pktdat; \ 512 (m)->m_data = (m)->m_pktdat; \
513 else \ 513 else \
514 (m)->m_data = (m)->m_dat; \ 514 (m)->m_data = (m)->m_dat; \
515} while (/* CONSTCOND */ 0) 515} while (/* CONSTCOND */ 0)
516 516
517#define M_COPY_PKTHDR(to, from) m_copy_pkthdr(to, from) 517#define M_COPY_PKTHDR(to, from) m_copy_pkthdr(to, from)
518#define M_MOVE_PKTHDR(to, from) m_move_pkthdr(to, from) 518#define M_MOVE_PKTHDR(to, from) m_move_pkthdr(to, from)
519 519
520/* 520#define M_ALIGN(m, len) m_align(m, len)
521 * Set the m_data pointer of a newly-allocated mbuf (m_get/MGET) to place 521#define MH_ALIGN(m, len) m_align(m, len)
522 * an object of the specified size at the end of the mbuf, longword aligned. 
523 */ 
524#define M_ALIGN(m, len) \ 
525do { \ 
526 KASSERT(((m)->m_flags & (M_PKTHDR|M_EXT)) == 0); \ 
527 KASSERT(M_LEADINGSPACE(m) == 0); \ 
528 (m)->m_data += (MLEN - (len)) &~ (sizeof(long) - 1); \ 
529} while (/* CONSTCOND */ 0) 
530 
531/* 
532 * As above, for mbufs allocated with m_gethdr/MGETHDR 
533 * or initialized by M_COPY_PKTHDR. 
534 */ 
535#define MH_ALIGN(m, len) \ 
536do { \ 
537 KASSERT(((m)->m_flags & M_PKTHDR) != 0); \ 
538 KASSERT(((m)->m_flags & M_EXT) == 0); \ 
539 KASSERT(M_LEADINGSPACE(m) == 0); \ 
540 (m)->m_data += (MHLEN - (len)) &~ (sizeof(long) - 1); \ 
541} while (/* CONSTCOND */ 0) 
542 522
543/* 523/*
544 * Determine if an mbuf's data area is read-only. This is true 524 * Determine if an mbuf's data area is read-only. This is true
545 * if external storage is read-only mapped, or not marked as R/W, 525 * if external storage is read-only mapped, or not marked as R/W,
546 * or referenced by more than one mbuf. 526 * or referenced by more than one mbuf.
547 */ 527 */
548#define M_READONLY(m) \ 528#define M_READONLY(m) \
549 (((m)->m_flags & M_EXT) != 0 && \ 529 (((m)->m_flags & M_EXT) != 0 && \
550 (((m)->m_flags & (M_EXT_ROMAP|M_EXT_RW)) != M_EXT_RW || \ 530 (((m)->m_flags & (M_EXT_ROMAP|M_EXT_RW)) != M_EXT_RW || \
551 (m)->m_ext.ext_refcnt > 1)) 531 (m)->m_ext.ext_refcnt > 1))
552 532
553#define M_UNWRITABLE(__m, __len) \ 533#define M_UNWRITABLE(__m, __len) \
554 ((__m)->m_len < (__len) || M_READONLY((__m))) 534 ((__m)->m_len < (__len) || M_READONLY((__m)))
@@ -791,26 +771,27 @@ void m_cat(struct mbuf *,struct mbuf *); @@ -791,26 +771,27 @@ void m_cat(struct mbuf *,struct mbuf *);
791void m_clget(struct mbuf *, int); 771void m_clget(struct mbuf *, int);
792void m_copyback(struct mbuf *, int, int, const void *); 772void m_copyback(struct mbuf *, int, int, const void *);
793struct mbuf *m_copyback_cow(struct mbuf *, int, int, const void *, int); 773struct mbuf *m_copyback_cow(struct mbuf *, int, int, const void *, int);
794int m_makewritable(struct mbuf **, int, int, int); 774int m_makewritable(struct mbuf **, int, int, int);
795struct mbuf *m_getcl(int, int, int); 775struct mbuf *m_getcl(int, int, int);
796void m_copydata(struct mbuf *, int, int, void *); 776void m_copydata(struct mbuf *, int, int, void *);
797void m_verify_packet(struct mbuf *); 777void m_verify_packet(struct mbuf *);
798struct mbuf *m_free(struct mbuf *); 778struct mbuf *m_free(struct mbuf *);
799void m_freem(struct mbuf *); 779void m_freem(struct mbuf *);
800void mbinit(void); 780void mbinit(void);
801void m_remove_pkthdr(struct mbuf *); 781void m_remove_pkthdr(struct mbuf *);
802void m_copy_pkthdr(struct mbuf *, struct mbuf *); 782void m_copy_pkthdr(struct mbuf *, struct mbuf *);
803void m_move_pkthdr(struct mbuf *, struct mbuf *); 783void m_move_pkthdr(struct mbuf *, struct mbuf *);
 784void m_align(struct mbuf *, int);
804 785
805bool m_ensure_contig(struct mbuf **, int); 786bool m_ensure_contig(struct mbuf **, int);
806struct mbuf *m_add(struct mbuf *, struct mbuf *); 787struct mbuf *m_add(struct mbuf *, struct mbuf *);
807 788
808/* Inline routines. */ 789/* Inline routines. */
809static __inline u_int m_length(const struct mbuf *) __unused; 790static __inline u_int m_length(const struct mbuf *) __unused;
810 791
811/* Statistics */ 792/* Statistics */
812void mbstat_type_add(int, int); 793void mbstat_type_add(int, int);
813 794
814/* Packet tag routines */ 795/* Packet tag routines */
815struct m_tag *m_tag_get(int, int, int); 796struct m_tag *m_tag_get(int, int, int);
816void m_tag_free(struct m_tag *); 797void m_tag_free(struct m_tag *);