summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/ic/elink3.c4
-rw-r--r--sys/dev/ic/malo.c6
-rw-r--r--sys/dev/pci/if_bge.c10
-rw-r--r--sys/dev/pci/if_nep.c4
-rw-r--r--sys/dev/pci/if_vte.c4
-rw-r--r--sys/dev/sdmmc/if_bwfm_sdio.c4
-rw-r--r--sys/kern/uipc_mbuf.c29
-rw-r--r--sys/kern/uipc_mbuf2.c8
-rw-r--r--sys/kern/uipc_socket2.c6
-rw-r--r--sys/kern/uipc_usrreq.c6
-rw-r--r--sys/net/bsd-comp.c10
-rw-r--r--sys/net/if_ppp.c7
-rw-r--r--sys/net/ppp-deflate.c10
-rw-r--r--sys/net/ppp_tty.c4
-rw-r--r--sys/net/switchctl.c6
-rw-r--r--sys/net80211/ieee80211_crypto_bip.c4
-rw-r--r--sys/net80211/ieee80211_crypto_ccmp.c4
-rw-r--r--sys/net80211/ieee80211_crypto_tkip.c4
-rw-r--r--sys/net80211/ieee80211_crypto_wep.c4
-rw-r--r--sys/netinet/tcp_output.c4
-rw-r--r--sys/netinet6/icmp6.c4
-rw-r--r--sys/netinet6/ip6_input.c4
-rw-r--r--sys/netinet6/ip6_output.c6
-rw-r--r--sys/nfs/nfs_serv.c6
-rw-r--r--sys/nfs/nfs_socket.c4
-rw-r--r--sys/nfs/nfs_subs.c8
-rw-r--r--sys/sys/mbuf.h14
27 files changed, 89 insertions, 95 deletions
diff --git a/sys/dev/ic/elink3.c b/sys/dev/ic/elink3.c
index 34db83599a4..5b722b758c5 100644
--- a/sys/dev/ic/elink3.c
+++ b/sys/dev/ic/elink3.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: elink3.c,v 1.95 2017/01/22 10:17:38 dlg Exp $ */
+/* $OpenBSD: elink3.c,v 1.96 2018/11/09 14:14:31 claudio Exp $ */
/* $NetBSD: elink3.c,v 1.32 1997/05/14 00:22:00 thorpej Exp $ */
/*
@@ -1371,7 +1371,7 @@ epget(struct ep_softc *sc, int totlen)
off = 0;
while (totlen) {
- len = min(totlen, M_TRAILINGSPACE(m));
+ len = min(totlen, m_trailingspace(m));
if (len == 0)
panic("ep_get: packet does not fit in MCLBYTES");
diff --git a/sys/dev/ic/malo.c b/sys/dev/ic/malo.c
index 5f7e233818d..6a8c5646f0b 100644
--- a/sys/dev/ic/malo.c
+++ b/sys/dev/ic/malo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: malo.c,v 1.117 2018/01/03 23:11:06 dlg Exp $ */
+/* $OpenBSD: malo.c,v 1.118 2018/11/09 14:14:31 claudio Exp $ */
/*
* Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org>
@@ -1411,8 +1411,8 @@ malo_tx_mgt(struct malo_softc *sc, struct mbuf *m0, struct ieee80211_node *ni)
* 6 bytes addr4 (inject)
* n bytes 802.11 frame body
*/
- if (M_LEADINGSPACE(m0) < 8) {
- if (M_TRAILINGSPACE(m0) < 8)
+ if (m_leadingspace(m0) < 8) {
+ if (m_trailingspace(m0) < 8)
panic("%s: not enough space for mbuf dance",
sc->sc_dev.dv_xname);
bcopy(m0->m_data, m0->m_data + 8, m0->m_len);
diff --git a/sys/dev/pci/if_bge.c b/sys/dev/pci/if_bge.c
index 44ec0c9c260..7a50c8457a4 100644
--- a/sys/dev/pci/if_bge.c
+++ b/sys/dev/pci/if_bge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_bge.c,v 1.387 2018/05/17 05:17:44 yasuoka Exp $ */
+/* $OpenBSD: if_bge.c,v 1.388 2018/11/09 14:14:31 claudio Exp $ */
/*
* Copyright (c) 2001 Wind River Systems
@@ -3909,7 +3909,7 @@ bge_compact_dma_runt(struct mbuf *pkt)
*/
/* Internal frag. If fits in prev, copy it there. */
- if (prev && M_TRAILINGSPACE(prev) >= m->m_len) {
+ if (prev && m_trailingspace(prev) >= m->m_len) {
bcopy(m->m_data, prev->m_data+prev->m_len, mlen);
prev->m_len += mlen;
m->m_len = 0;
@@ -3918,7 +3918,7 @@ bge_compact_dma_runt(struct mbuf *pkt)
m = prev;
continue;
} else if (m->m_next != NULL &&
- M_TRAILINGSPACE(m) >= shortfall &&
+ m_trailingspace(m) >= shortfall &&
m->m_next->m_len >= (8 + shortfall)) {
/* m is writable and have enough data in next, pull up. */
@@ -3989,7 +3989,7 @@ bge_cksum_pad(struct mbuf *m)
struct mbuf *last;
/* If there's only the packet-header and we can pad there, use it. */
- if (m->m_pkthdr.len == m->m_len && M_TRAILINGSPACE(m) >= padlen) {
+ if (m->m_pkthdr.len == m->m_len && m_trailingspace(m) >= padlen) {
last = m;
} else {
/*
@@ -3997,7 +3997,7 @@ bge_cksum_pad(struct mbuf *m)
* pad there, or append a new mbuf and pad it.
*/
for (last = m; last->m_next != NULL; last = last->m_next);
- if (M_TRAILINGSPACE(last) < padlen) {
+ if (m_trailingspace(last) < padlen) {
/* Allocate new empty mbuf, pad it. Compact later. */
struct mbuf *n;
diff --git a/sys/dev/pci/if_nep.c b/sys/dev/pci/if_nep.c
index 3104b8c63af..2705b9a3db0 100644
--- a/sys/dev/pci/if_nep.c
+++ b/sys/dev/pci/if_nep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_nep.c,v 1.30 2017/04/11 14:43:49 dhill Exp $ */
+/* $OpenBSD: if_nep.c,v 1.31 2018/11/09 14:14:31 claudio Exp $ */
/*
* Copyright (c) 2014, 2015 Mark Kettenis
*
@@ -1803,7 +1803,7 @@ nep_encap(struct nep_softc *sc, struct mbuf **m0, int *idx)
m->m_pkthdr.len += padlen;
}
- if (M_LEADINGSPACE(m) < 16)
+ if (m_leadingspace(m) < 16)
pad = 0;
else
pad = mtod(m, u_long) % 16;
diff --git a/sys/dev/pci/if_vte.c b/sys/dev/pci/if_vte.c
index a02e59b9ccb..497bc58aa27 100644
--- a/sys/dev/pci/if_vte.c
+++ b/sys/dev/pci/if_vte.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_vte.c,v 1.21 2017/09/08 05:36:52 deraadt Exp $ */
+/* $OpenBSD: if_vte.c,v 1.22 2018/11/09 14:14:31 claudio Exp $ */
/*-
* Copyright (c) 2010, Pyun YongHyeon <yongari@FreeBSD.org>
* All rights reserved.
@@ -603,7 +603,7 @@ vte_encap(struct vte_softc *sc, struct mbuf **m_head)
copy = 0;
if (m->m_next != NULL)
copy++;
- if (padlen > 0 && (padlen > M_TRAILINGSPACE(m)))
+ if (padlen > 0 && (padlen > m_trailingspace(m)))
copy++;
if (copy != 0) {
/* Avoid expensive m_defrag(9) and do deep copy. */
diff --git a/sys/dev/sdmmc/if_bwfm_sdio.c b/sys/dev/sdmmc/if_bwfm_sdio.c
index 5ec512ce5f5..f28c78f5b20 100644
--- a/sys/dev/sdmmc/if_bwfm_sdio.c
+++ b/sys/dev/sdmmc/if_bwfm_sdio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_bwfm_sdio.c,v 1.25 2018/08/09 14:23:50 patrick Exp $ */
+/* $OpenBSD: if_bwfm_sdio.c,v 1.26 2018/11/09 14:14:31 claudio Exp $ */
/*
* Copyright (c) 2010-2016 Broadcom Corporation
* Copyright (c) 2016,2017 Patrick Wildt <patrick@blueri.se>
@@ -1452,7 +1452,7 @@ bwfm_sdio_txctl(struct bwfm_softc *bwfm, void *arg)
struct mbuf *m;
MGET(m, M_DONTWAIT, MT_CONTROL);
- if (m == NULL || M_TRAILINGSPACE(m) < ctl->len) {
+ if (m == NULL || m_trailingspace(m) < ctl->len) {
free(ctl->buf, M_TEMP, ctl->len);
free(ctl, M_TEMP, sizeof(*ctl));
return 1;
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index a506d8e575a..8661509b9d8 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_mbuf.c,v 1.259 2018/09/13 19:53:58 bluhm Exp $ */
+/* $OpenBSD: uipc_mbuf.c,v 1.260 2018/11/09 14:14:31 claudio Exp $ */
/* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */
/*
@@ -600,7 +600,7 @@ m_prepend(struct mbuf *m, int len, int how)
if (len > MHLEN)
panic("mbuf prepend length too big");
- if (M_LEADINGSPACE(m) >= len) {
+ if (m_leadingspace(m) >= len) {
m->m_data -= len;
m->m_len += len;
} else {
@@ -759,7 +759,7 @@ m_copyback(struct mbuf *m0, int off, int len, const void *_cp, int wait)
/* extend last packet to be filled fully */
if (m->m_next == NULL && (len > m->m_len - off))
m->m_len += min(len - (m->m_len - off),
- M_TRAILINGSPACE(m));
+ m_trailingspace(m));
mlen = min(m->m_len - off, len);
memmove(mtod(m, caddr_t) + off, cp, mlen);
cp += mlen;
@@ -808,7 +808,7 @@ m_cat(struct mbuf *m, struct mbuf *n)
while (m->m_next)
m = m->m_next;
while (n) {
- if (M_READONLY(m) || n->m_len > M_TRAILINGSPACE(m)) {
+ if (M_READONLY(m) || n->m_len > m_trailingspace(m)) {
/* just join the two chains */
m->m_next = n;
return;
@@ -915,8 +915,8 @@ m_pullup(struct mbuf *n, int len)
return (n);
adj = (unsigned long)n->m_data & ALIGNBYTES;
- head = (caddr_t)ALIGN(mtod(n, caddr_t) - M_LEADINGSPACE(n)) + adj;
- tail = mtod(n, caddr_t) + n->m_len + M_TRAILINGSPACE(n);
+ head = (caddr_t)ALIGN(mtod(n, caddr_t) - m_leadingspace(n)) + adj;
+ tail = mtod(n, caddr_t) + n->m_len + m_trailingspace(n);
if (head < tail && len <= tail - head) {
/* there's enough space in the first mbuf */
@@ -955,7 +955,7 @@ m_pullup(struct mbuf *n, int len)
m->m_data += adj;
}
- KASSERT(M_TRAILINGSPACE(m) >= len);
+ KASSERT(m_trailingspace(m) >= len);
do {
if (n == NULL) {
@@ -1125,13 +1125,13 @@ m_makespace(struct mbuf *m0, int skip, int hlen, int *off)
* the contents of m as needed.
*/
remain = m->m_len - skip; /* data to move */
- if (skip < remain && hlen <= M_LEADINGSPACE(m)) {
+ if (skip < remain && hlen <= m_leadingspace(m)) {
if (skip)
memmove(m->m_data-hlen, m->m_data, skip);
m->m_data -= hlen;
m->m_len += hlen;
*off = skip;
- } else if (hlen > M_TRAILINGSPACE(m)) {
+ } else if (hlen > m_trailingspace(m)) {
struct mbuf *n;
if (remain > 0) {
@@ -1154,7 +1154,7 @@ m_makespace(struct mbuf *m0, int skip, int hlen, int *off)
m->m_next = n;
}
- if (hlen <= M_TRAILINGSPACE(m)) {
+ if (hlen <= m_trailingspace(m)) {
m->m_len += hlen;
*off = skip;
} else {
@@ -1312,6 +1312,10 @@ m_apply(struct mbuf *m, int off, int len,
return (0);
}
+/*
+ * Compute the amount of space available before the current start of data
+ * in an mbuf. Read-only clusters never have space available.
+ */
int
m_leadingspace(struct mbuf *m)
{
@@ -1322,6 +1326,10 @@ m_leadingspace(struct mbuf *m)
m->m_data - m->m_dat);
}
+/*
+ * Compute the amount of space available after the end of data in an mbuf.
+ * Read-only clusters never have space available.
+ */
int
m_trailingspace(struct mbuf *m)
{
@@ -1332,7 +1340,6 @@ m_trailingspace(struct mbuf *m)
&m->m_dat[MLEN] - (m->m_data + m->m_len));
}
-
/*
* Duplicate mbuf pkthdr from from to to.
* from must have M_PKTHDR set, and to must be empty.
diff --git a/sys/kern/uipc_mbuf2.c b/sys/kern/uipc_mbuf2.c
index 4e9c25c221f..b3e6771c4f5 100644
--- a/sys/kern/uipc_mbuf2.c
+++ b/sys/kern/uipc_mbuf2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_mbuf2.c,v 1.42 2015/11/13 10:12:39 mpi Exp $ */
+/* $OpenBSD: uipc_mbuf2.c,v 1.43 2018/11/09 14:14:31 claudio Exp $ */
/* $KAME: uipc_mbuf2.c,v 1.29 2001/02/14 13:42:10 itojun Exp $ */
/* $NetBSD: uipc_mbuf.c,v 1.40 1999/04/01 00:23:25 thorpej Exp $ */
@@ -81,7 +81,7 @@ static struct mbuf *m_dup1(struct mbuf *, int, int, int);
*
* on error return (NULL return value), original "m" will be freed.
*
- * XXX M_TRAILINGSPACE/M_LEADINGSPACE on shared cluster (sharedcluster)
+ * XXX m_trailingspace/m_leadingspace on shared cluster (sharedcluster)
*/
struct mbuf *
m_pulldown(struct mbuf *m, int off, int len, int *offp)
@@ -156,14 +156,14 @@ m_pulldown(struct mbuf *m, int off, int len, int *offp)
* easy cases first.
* we need to use m_copydata() to get data from <n->m_next, 0>.
*/
- if ((off == 0 || offp) && M_TRAILINGSPACE(n) >= tlen &&
+ if ((off == 0 || offp) && m_trailingspace(n) >= tlen &&
!sharedcluster) {
m_copydata(n->m_next, 0, tlen, mtod(n, caddr_t) + n->m_len);
n->m_len += tlen;
m_adj(n->m_next, tlen);
goto ok;
}
- if ((off == 0 || offp) && M_LEADINGSPACE(n->m_next) >= hlen &&
+ if ((off == 0 || offp) && m_leadingspace(n->m_next) >= hlen &&
!sharedcluster && n->m_next->m_len >= tlen) {
n->m_next->m_data -= hlen;
n->m_next->m_len += hlen;
diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c
index a4ab80ea3be..fcd93f8f26c 100644
--- a/sys/kern/uipc_socket2.c
+++ b/sys/kern/uipc_socket2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_socket2.c,v 1.97 2018/10/29 12:12:27 claudio Exp $ */
+/* $OpenBSD: uipc_socket2.c,v 1.98 2018/11/09 14:14:31 claudio Exp $ */
/* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */
/*
@@ -884,9 +884,9 @@ sbcompress(struct sockbuf *sb, struct mbuf *m, struct mbuf *n)
continue;
}
if (n && (n->m_flags & M_EOR) == 0 &&
- /* M_TRAILINGSPACE() checks buffer writeability */
+ /* m_trailingspace() checks buffer writeability */
m->m_len <= MCLBYTES / 4 && /* XXX Don't copy too much */
- m->m_len <= M_TRAILINGSPACE(n) &&
+ m->m_len <= m_trailingspace(n) &&
n->m_type == m->m_type) {
memcpy(mtod(n, caddr_t) + n->m_len, mtod(m, caddr_t),
m->m_len);
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index 24485c92dde..e9a6167c6f3 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_usrreq.c,v 1.134 2018/07/09 10:58:21 claudio Exp $ */
+/* $OpenBSD: uipc_usrreq.c,v 1.135 2018/11/09 14:14:31 claudio Exp $ */
/* $NetBSD: uipc_usrreq.c,v 1.18 1996/02/09 19:00:50 christos Exp $ */
/*
@@ -813,7 +813,7 @@ unp_internalize(struct mbuf *control, struct proc *p)
morespace:
neededspace = CMSG_SPACE(nfds * sizeof(struct fdpass)) -
control->m_len;
- if (neededspace > M_TRAILINGSPACE(control)) {
+ if (neededspace > m_trailingspace(control)) {
char *tmp;
/* if we already have a cluster, the message is just too big */
if (control->m_flags & M_EXT)
@@ -1089,7 +1089,7 @@ unp_nam2sun(struct mbuf *nam, struct sockaddr_un **sun, size_t *pathlen)
if (len == sizeof((*sun)->sun_path))
return EINVAL;
if (len == size) {
- if (M_TRAILINGSPACE(nam) == 0)
+ if (m_trailingspace(nam) == 0)
return EINVAL;
nam->m_len++;
(*sun)->sun_len++;
diff --git a/sys/net/bsd-comp.c b/sys/net/bsd-comp.c
index fa4dfe2773c..16aeae4409a 100644
--- a/sys/net/bsd-comp.c
+++ b/sys/net/bsd-comp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bsd-comp.c,v 1.15 2017/09/08 05:36:53 deraadt Exp $ */
+/* $OpenBSD: bsd-comp.c,v 1.16 2018/11/09 14:14:31 claudio Exp $ */
/* $NetBSD: bsd-comp.c,v 1.6 1996/10/13 02:10:58 christos Exp $ */
/* Because this code is derived from the 4.3BSD compress source:
@@ -499,7 +499,7 @@ bsd_compress(state, mret, mp, slen, maxolen)
if (maxolen - olen > MLEN) \
MCLGET(m, M_DONTWAIT); \
wptr = mtod(m, u_char *); \
- cp_end = wptr + M_TRAILINGSPACE(m); \
+ cp_end = wptr + m_trailingspace(m); \
} else \
wptr = NULL; \
} \
@@ -542,7 +542,7 @@ bsd_compress(state, mret, mp, slen, maxolen)
MCLGET(m, M_DONTWAIT);
m->m_data += db->hdrlen;
wptr = mtod(m, u_char *);
- cp_end = wptr + M_TRAILINGSPACE(m);
+ cp_end = wptr + m_trailingspace(m);
} else
wptr = cp_end = NULL;
@@ -876,7 +876,7 @@ bsd_decompress(state, cmp, dmpp)
MCLGET(dmp, M_DONTWAIT);
dmp->m_data += db->hdrlen;
wptr = mtod(dmp, u_char *);
- space = M_TRAILINGSPACE(dmp) - PPP_HDRLEN + 1;
+ space = m_trailingspace(dmp) - PPP_HDRLEN + 1;
/*
* Fill in the ppp header, but not the last byte of the protocol
@@ -988,7 +988,7 @@ bsd_decompress(state, cmp, dmpp)
m->m_next = NULL;
dmp->m_next = m;
MCLGET(m, M_DONTWAIT);
- space = M_TRAILINGSPACE(m) - (codelen + extra);
+ space = m_trailingspace(m) - (codelen + extra);
if (space < 0) {
/* now that's what I call *compression*. */
m_freem(mret);
diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c
index 5c2ad53602d..192ec7c91e0 100644
--- a/sys/net/if_ppp.c
+++ b/sys/net/if_ppp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ppp.c,v 1.111 2018/02/19 08:59:52 mpi Exp $ */
+/* $OpenBSD: if_ppp.c,v 1.112 2018/11/09 14:14:31 claudio Exp $ */
/* $NetBSD: if_ppp.c,v 1.39 1997/05/17 21:11:59 christos Exp $ */
/*
@@ -700,7 +700,6 @@ pppoutput(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst,
/*
* Add PPP header. If no space in first mbuf, allocate another.
- * (This assumes M_LEADINGSPACE is always 0 for a cluster mbuf.)
*/
M_PREPEND(m0, PPP_HDRLEN, M_DONTWAIT);
if (m0 == NULL) {
@@ -1279,7 +1278,7 @@ ppp_inproc(struct ppp_softc *sc, struct mbuf *m)
mp->m_next = NULL;
if (hlen + PPP_HDRLEN > MHLEN) {
MCLGET(mp, M_DONTWAIT);
- if (M_TRAILINGSPACE(mp) < hlen + PPP_HDRLEN) {
+ if (m_trailingspace(mp) < hlen + PPP_HDRLEN) {
m_freem(mp);
/* lose if big headers and no clusters */
goto bad;
@@ -1302,7 +1301,7 @@ ppp_inproc(struct ppp_softc *sc, struct mbuf *m)
*/
m->m_data += PPP_HDRLEN + xlen;
m->m_len -= PPP_HDRLEN + xlen;
- if (m->m_len <= M_TRAILINGSPACE(mp)) {
+ if (m->m_len <= m_trailingspace(mp)) {
bcopy(mtod(m, u_char *),
mtod(mp, u_char *) + mp->m_len, m->m_len);
mp->m_len += m->m_len;
diff --git a/sys/net/ppp-deflate.c b/sys/net/ppp-deflate.c
index 384e30a0f8e..05bdb5d2aa0 100644
--- a/sys/net/ppp-deflate.c
+++ b/sys/net/ppp-deflate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ppp-deflate.c,v 1.14 2017/09/08 05:36:53 deraadt Exp $ */
+/* $OpenBSD: ppp-deflate.c,v 1.15 2018/11/09 14:14:31 claudio Exp $ */
/* $NetBSD: ppp-deflate.c,v 1.1 1996/03/15 02:28:09 paulus Exp $ */
/*
@@ -258,7 +258,7 @@ z_compress(arg, mret, mp, orig_len, maxolen)
m->m_len = 0;
if (maxolen + state->hdrlen > MLEN)
MCLGET(m, M_DONTWAIT);
- wspace = M_TRAILINGSPACE(m);
+ wspace = m_trailingspace(m);
if (state->hdrlen + PPP_HDRLEN + 2 < wspace) {
m->m_data += state->hdrlen;
wspace -= state->hdrlen;
@@ -319,7 +319,7 @@ z_compress(arg, mret, mp, orig_len, maxolen)
if (maxolen - olen > MLEN)
MCLGET(m, M_DONTWAIT);
state->strm.next_out = mtod(m, u_char *);
- state->strm.avail_out = wspace = M_TRAILINGSPACE(m);
+ state->strm.avail_out = wspace = m_trailingspace(m);
}
}
if (m == NULL) {
@@ -518,7 +518,7 @@ z_decompress(arg, mi, mop)
mo->m_len = 0;
mo->m_next = NULL;
MCLGET(mo, M_DONTWAIT);
- ospace = M_TRAILINGSPACE(mo);
+ ospace = m_trailingspace(mo);
if (state->hdrlen + PPP_HDRLEN < ospace) {
mo->m_data += state->hdrlen;
ospace -= state->hdrlen;
@@ -594,7 +594,7 @@ z_decompress(arg, mi, mop)
}
MCLGET(mo, M_DONTWAIT);
state->strm.next_out = mtod(mo, u_char *);
- state->strm.avail_out = ospace = M_TRAILINGSPACE(mo);
+ state->strm.avail_out = ospace = m_trailingspace(mo);
}
}
}
diff --git a/sys/net/ppp_tty.c b/sys/net/ppp_tty.c
index 0fda9199fc5..2bd7d37d68e 100644
--- a/sys/net/ppp_tty.c
+++ b/sys/net/ppp_tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ppp_tty.c,v 1.50 2018/05/15 09:21:52 mikeb Exp $ */
+/* $OpenBSD: ppp_tty.c,v 1.51 2018/11/09 14:14:31 claudio Exp $ */
/* $NetBSD: ppp_tty.c,v 1.12 1997/03/24 21:23:10 christos Exp $ */
/*
@@ -358,7 +358,7 @@ pppwrite(struct tty *tp, struct uio *uio, int flag)
m->m_len = 0;
if (uio->uio_resid >= MCLBYTES / 2)
MCLGET(m, M_DONTWAIT);
- len = M_TRAILINGSPACE(m);
+ len = m_trailingspace(m);
if (len > uio->uio_resid)
len = uio->uio_resid;
if ((error = uiomove(mtod(m, u_char *), len, uio)) != 0) {
diff --git a/sys/net/switchctl.c b/sys/net/switchctl.c
index 9365260ad52..c1f67416d38 100644
--- a/sys/net/switchctl.c
+++ b/sys/net/switchctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: switchctl.c,v 1.12 2017/08/11 21:24:19 mpi Exp $ */
+/* $OpenBSD: switchctl.c,v 1.13 2018/11/09 14:14:31 claudio Exp $ */
/*
* Copyright (c) 2016 Kazuya GODA <goda@openbsd.org>
@@ -226,7 +226,7 @@ switchwrite(dev_t dev, struct uio *uio, int ioflag)
}
mhead = m;
- /* M_TRAILINGSPACE() uses this to calculate space. */
+ /* m_trailingspace() uses this to calculate space. */
m->m_len = 0;
} else {
/* Recover the mbuf from the last write and get its tail. */
@@ -238,7 +238,7 @@ switchwrite(dev_t dev, struct uio *uio, int ioflag)
}
while (len) {
- trailing = ulmin(M_TRAILINGSPACE(m), len);
+ trailing = ulmin(m_trailingspace(m), len);
if ((error = uiomove(mtod(m, caddr_t), trailing, uio)) != 0)
goto save_return;
diff --git a/sys/net80211/ieee80211_crypto_bip.c b/sys/net80211/ieee80211_crypto_bip.c
index 8dc83a8a7c8..a6015496220 100644
--- a/sys/net80211/ieee80211_crypto_bip.c
+++ b/sys/net80211/ieee80211_crypto_bip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_crypto_bip.c,v 1.9 2017/05/02 17:07:06 mikeb Exp $ */
+/* $OpenBSD: ieee80211_crypto_bip.c,v 1.10 2018/11/09 14:14:31 claudio Exp $ */
/*-
* Copyright (c) 2008 Damien Bergamini <damien.bergamini@free.fr>
@@ -115,7 +115,7 @@ ieee80211_bip_encap(struct ieee80211com *ic, struct mbuf *m0,
m = m0;
/* reserve trailing space for MMIE */
- if (M_TRAILINGSPACE(m) < IEEE80211_MMIE_LEN) {
+ if (m_trailingspace(m) < IEEE80211_MMIE_LEN) {
MGET(m->m_next, M_DONTWAIT, m->m_type);
if (m->m_next == NULL)
goto nospace;
diff --git a/sys/net80211/ieee80211_crypto_ccmp.c b/sys/net80211/ieee80211_crypto_ccmp.c
index a7e913a8ab1..f4c8748602f 100644
--- a/sys/net80211/ieee80211_crypto_ccmp.c
+++ b/sys/net80211/ieee80211_crypto_ccmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_crypto_ccmp.c,v 1.20 2017/05/02 17:07:06 mikeb Exp $ */
+/* $OpenBSD: ieee80211_crypto_ccmp.c,v 1.21 2018/11/09 14:14:31 claudio Exp $ */
/*-
* Copyright (c) 2008 Damien Bergamini <damien.bergamini@free.fr>
@@ -277,7 +277,7 @@ ieee80211_ccmp_encrypt(struct ieee80211com *ic, struct mbuf *m0,
AES_Encrypt(&ctx->aesctx, b, b);
/* reserve trailing space for MIC */
- if (M_TRAILINGSPACE(n) < IEEE80211_CCMP_MICLEN) {
+ if (m_trailingspace(n) < IEEE80211_CCMP_MICLEN) {
MGET(n->m_next, M_DONTWAIT, n->m_type);
if (n->m_next == NULL)
goto nospace;
diff --git a/sys/net80211/ieee80211_crypto_tkip.c b/sys/net80211/ieee80211_crypto_tkip.c
index d1b44a4f3f9..70fbe7c9769 100644
--- a/sys/net80211/ieee80211_crypto_tkip.c
+++ b/sys/net80211/ieee80211_crypto_tkip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_crypto_tkip.c,v 1.29 2017/06/03 11:58:10 tb Exp $ */
+/* $OpenBSD: ieee80211_crypto_tkip.c,v 1.30 2018/11/09 14:14:31 claudio Exp $ */
/*-
* Copyright (c) 2008 Damien Bergamini <damien.bergamini@free.fr>
@@ -277,7 +277,7 @@ ieee80211_tkip_encrypt(struct ieee80211com *ic, struct mbuf *m0,
}
/* reserve trailing space for TKIP MIC and WEP ICV */
- if (M_TRAILINGSPACE(n) < IEEE80211_TKIP_TAILLEN) {
+ if (m_trailingspace(n) < IEEE80211_TKIP_TAILLEN) {
MGET(n->m_next, M_DONTWAIT, n->m_type);
if (n->m_next == NULL)
goto nospace;
diff --git a/sys/net80211/ieee80211_crypto_wep.c b/sys/net80211/ieee80211_crypto_wep.c
index 6bd1ff7702d..1f6c0487a10 100644
--- a/sys/net80211/ieee80211_crypto_wep.c
+++ b/sys/net80211/ieee80211_crypto_wep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_crypto_wep.c,v 1.16 2017/06/03 11:58:10 tb Exp $ */
+/* $OpenBSD: ieee80211_crypto_wep.c,v 1.17 2018/11/09 14:14:31 claudio Exp $ */
/*-
* Copyright (c) 2008 Damien Bergamini <damien.bergamini@free.fr>
@@ -168,7 +168,7 @@ ieee80211_wep_encrypt(struct ieee80211com *ic, struct mbuf *m0,
}
/* reserve trailing space for WEP ICV */
- if (M_TRAILINGSPACE(n) < IEEE80211_WEP_CRCLEN) {
+ if (m_trailingspace(n) < IEEE80211_WEP_CRCLEN) {
MGET(n->m_next, M_DONTWAIT, n->m_type);
if (n->m_next == NULL)
goto nospace;
diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c
index 0584c0c2060..ea25d06c7e9 100644
--- a/sys/netinet/tcp_output.c
+++ b/sys/netinet/tcp_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_output.c,v 1.126 2018/09/13 19:53:58 bluhm Exp $ */
+/* $OpenBSD: tcp_output.c,v 1.127 2018/11/09 14:14:31 claudio Exp $ */
/* $NetBSD: tcp_output.c,v 1.16 1997/06/03 16:17:09 kml Exp $ */
/*
@@ -665,7 +665,7 @@ send:
}
m->m_data += max_linkhdr;
m->m_len = hdrlen;
- if (len <= M_TRAILINGSPACE(m)) {
+ if (len <= m_trailingspace(m)) {
m_copydata(so->so_snd.sb_mb, off, (int) len,
mtod(m, caddr_t) + hdrlen);
m->m_len += len;
diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c
index 37e12ad7e5f..678f10ecc31 100644
--- a/sys/netinet6/icmp6.c
+++ b/sys/netinet6/icmp6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: icmp6.c,v 1.226 2018/09/05 09:47:18 miko Exp $ */
+/* $OpenBSD: icmp6.c,v 1.227 2018/11/09 14:14:32 claudio Exp $ */
/* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */
/*
@@ -1473,7 +1473,7 @@ icmp6_redirect_output(struct mbuf *m0, struct rtentry *rt)
goto fail;
m->m_pkthdr.ph_ifidx = 0;
m->m_len = 0;
- maxlen = M_TRAILINGSPACE(m);
+ maxlen = m_trailingspace(m);
maxlen = min(IPV6_MMTU, maxlen);
/* just for safety */
if (maxlen < sizeof(struct ip6_hdr) + sizeof(struct icmp6_hdr) +
diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c
index 527a8f70298..310e53b4257 100644
--- a/sys/netinet6/ip6_input.c
+++ b/sys/netinet6/ip6_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_input.c,v 1.215 2018/05/21 15:52:22 bluhm Exp $ */
+/* $OpenBSD: ip6_input.c,v 1.216 2018/11/09 14:14:32 claudio Exp $ */
/* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */
/*
@@ -1180,7 +1180,7 @@ ip6_pullexthdr(struct mbuf *m, size_t off, int nxt)
return NULL;
n->m_len = 0;
- if (elen >= M_TRAILINGSPACE(n)) {
+ if (elen >= m_trailingspace(n)) {
m_free(n);
return NULL;
}
diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c
index e6177f44346..35f6b42311e 100644
--- a/sys/netinet6/ip6_output.c
+++ b/sys/netinet6/ip6_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_output.c,v 1.239 2018/08/28 15:15:02 mpi Exp $ */
+/* $OpenBSD: ip6_output.c,v 1.240 2018/11/09 14:14:32 claudio Exp $ */
/* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */
/*
@@ -897,7 +897,7 @@ ip6_insert_jumboopt(struct ip6_exthdrs *exthdrs, u_int32_t plen)
struct ip6_hbh *hbh;
mopt = exthdrs->ip6e_hbh;
- if (M_TRAILINGSPACE(mopt) < JUMBOOPTLEN) {
+ if (m_trailingspace(mopt) < JUMBOOPTLEN) {
/*
* XXX assumption:
* - exthdrs->ip6e_hbh is not referenced from places
@@ -985,7 +985,7 @@ ip6_insertfraghdr(struct mbuf *m0, struct mbuf *m, int hlen,
;
if ((mlast->m_flags & M_EXT) == 0 &&
- M_TRAILINGSPACE(mlast) >= sizeof(struct ip6_frag)) {
+ m_trailingspace(mlast) >= sizeof(struct ip6_frag)) {
/* use the trailing space of the last mbuf for the fragment hdr */
*frghdrp = (struct ip6_frag *)(mtod(mlast, caddr_t) +
mlast->m_len);
diff --git a/sys/nfs/nfs_serv.c b/sys/nfs/nfs_serv.c
index 0710a594c37..cf1ed7733dd 100644
--- a/sys/nfs/nfs_serv.c
+++ b/sys/nfs/nfs_serv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_serv.c,v 1.116 2018/06/13 14:57:24 visa Exp $ */
+/* $OpenBSD: nfs_serv.c,v 1.117 2018/11/09 14:14:32 claudio Exp $ */
/* $NetBSD: nfs_serv.c,v 1.34 1997/05/12 23:37:12 fvdl Exp $ */
/*
@@ -596,7 +596,7 @@ nfsrv_read(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
i = 0;
m = m2 = info.nmi_mb;
while (left > 0) {
- siz = min(M_TRAILINGSPACE(m), left);
+ siz = min(m_trailingspace(m), left);
if (siz > 0) {
left -= siz;
i++;
@@ -619,7 +619,7 @@ nfsrv_read(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
while (left > 0) {
if (m == NULL)
panic("nfsrv_read iov");
- siz = min(M_TRAILINGSPACE(m), left);
+ siz = min(m_trailingspace(m), left);
if (siz > 0) {
iv->iov_base = mtod(m, caddr_t) + m->m_len;
iv->iov_len = siz;
diff --git a/sys/nfs/nfs_socket.c b/sys/nfs/nfs_socket.c
index 7b2c59b5668..bbde6883301 100644
--- a/sys/nfs/nfs_socket.c
+++ b/sys/nfs/nfs_socket.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_socket.c,v 1.131 2018/09/10 16:14:08 bluhm Exp $ */
+/* $OpenBSD: nfs_socket.c,v 1.132 2018/11/09 14:14:32 claudio Exp $ */
/* $NetBSD: nfs_socket.c,v 1.27 1996/04/15 20:20:00 thorpej Exp $ */
/*
@@ -1355,7 +1355,7 @@ nfs_realign_fixup(struct mbuf *m, struct mbuf *n, unsigned int *off)
return;
padding = min(ALIGN(n->m_len) - n->m_len, m->m_len);
- if (padding > M_TRAILINGSPACE(n))
+ if (padding > m_trailingspace(n))
panic("nfs_realign_fixup: no memory to pad to");
bcopy(mtod(m, void *), mtod(n, char *) + n->m_len, padding);
diff --git a/sys/nfs/nfs_subs.c b/sys/nfs/nfs_subs.c
index 20b848ca847..608b4131412 100644
--- a/sys/nfs/nfs_subs.c
+++ b/sys/nfs/nfs_subs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_subs.c,v 1.137 2018/07/02 20:56:22 bluhm Exp $ */
+/* $OpenBSD: nfs_subs.c,v 1.138 2018/11/09 14:14:32 claudio Exp $ */
/* $NetBSD: nfs_subs.c,v 1.27.4.3 1996/07/08 20:34:24 jtc Exp $ */
/*
@@ -713,7 +713,7 @@ nfsm_uiotombuf(struct mbuf **mp, struct uio *uiop, size_t len)
uiop->uio_rw = UIO_WRITE;
while (len) {
- xfer = ulmin(len, M_TRAILINGSPACE(mb));
+ xfer = ulmin(len, m_trailingspace(mb));
uiomove(mb_offset(mb), xfer, uiop);
mb->m_len += xfer;
len -= xfer;
@@ -728,7 +728,7 @@ nfsm_uiotombuf(struct mbuf **mp, struct uio *uiop, size_t len)
}
if (pad > 0) {
- if (pad > M_TRAILINGSPACE(mb)) {
+ if (pad > m_trailingspace(mb)) {
MGET(mb2, M_WAIT, MT_DATA);
mb2->m_len = 0;
mb->m_next = mb2;
@@ -1793,7 +1793,7 @@ nfsm_build(struct mbuf **mp, u_int len)
mb = *mp;
bpos = mb_offset(mb);
- if (len > M_TRAILINGSPACE(mb)) {
+ if (len > m_trailingspace(mb)) {
MGET(mb2, M_WAIT, MT_DATA);
if (len > MLEN)
panic("build > MLEN");
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
index 2513c484922..64ef9fab147 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mbuf.h,v 1.238 2018/09/10 16:14:08 bluhm Exp $ */
+/* $OpenBSD: mbuf.h,v 1.239 2018/11/09 14:14:32 claudio Exp $ */
/* $NetBSD: mbuf.h,v 1.19 1996/02/09 18:25:14 christos Exp $ */
/*
@@ -367,18 +367,6 @@ u_int mextfree_register(void (*)(caddr_t, u_int, void *));
(((m)->m_flags & M_EXTWR) == 0 || MCLISREFERENCED(m)))
/*
- * Compute the amount of space available
- * before the current start of data in an mbuf.
- */
-#define M_LEADINGSPACE(m) m_leadingspace(m)
-
-/*
- * Compute the amount of space available
- * after the end of data in an mbuf.
- */
-#define M_TRAILINGSPACE(m) m_trailingspace(m)
-
-/*
* Arrange to prepend space of size plen to mbuf m.
* If a new mbuf must be allocated, how specifies whether to wait.
* If how is M_DONTWAIT and allocation fails, the original mbuf chain