summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_mbuf.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2015-01-10 10:41:23 +0000
committerrwatson <rwatson@FreeBSD.org>2015-01-10 10:41:23 +0000
commitac02dc452c17f4503acbf317c5993b555331c279 (patch)
treee2c4a653f5897e721b48a89820effe52e0a52f68 /sys/kern/uipc_mbuf.c
parent0a9f24e1b998314e1c92737e36f18579457531b7 (diff)
downloadFreeBSD-src-ac02dc452c17f4503acbf317c5993b555331c279.zip
FreeBSD-src-ac02dc452c17f4503acbf317c5993b555331c279.tar.gz
Garbage collect m_copymdata(), an mbuf utility routine introduced
in FreeBSD 7 that has not been used since. It contains a number of unresolved bugs including an inverted bcopy() and incorrect handling of read-only mbufs using internal storage. Removing this unused code is substantially essier than fixing it in order to update it to the coming mbuf world order -- but it can always be restored from revision history if it turns out to prove useful for future work. Pointed out by: jmallett Sponsored by: EMC / Isilon Storage Division
Diffstat (limited to 'sys/kern/uipc_mbuf.c')
-rw-r--r--sys/kern/uipc_mbuf.c146
1 files changed, 0 insertions, 146 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index 9022faa..0c583d7 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -648,152 +648,6 @@ nospace:
}
/*
- * Returns mbuf chain with new head for the prepending case.
- * Copies from mbuf (chain) n from off for len to mbuf (chain) m
- * either prepending or appending the data.
- * The resulting mbuf (chain) m is fully writeable.
- * m is destination (is made writeable)
- * n is source, off is offset in source, len is len from offset
- * dir, 0 append, 1 prepend
- * how, wait or nowait
- */
-
-static int
-m_bcopyxxx(void *s, void *t, u_int len)
-{
- bcopy(s, t, (size_t)len);
- return 0;
-}
-
-struct mbuf *
-m_copymdata(struct mbuf *m, struct mbuf *n, int off, int len,
- int prep, int how)
-{
- struct mbuf *mm, *x, *z, *prev = NULL;
- caddr_t p;
- int i, nlen = 0;
- caddr_t buf[MLEN];
-
- KASSERT(m != NULL && n != NULL, ("m_copymdata, no target or source"));
- KASSERT(off >= 0, ("m_copymdata, negative off %d", off));
- KASSERT(len >= 0, ("m_copymdata, negative len %d", len));
- KASSERT(prep == 0 || prep == 1, ("m_copymdata, unknown direction %d", prep));
-
- mm = m;
- if (!prep) {
- while(mm->m_next) {
- prev = mm;
- mm = mm->m_next;
- }
- }
- for (z = n; z != NULL; z = z->m_next)
- nlen += z->m_len;
- if (len == M_COPYALL)
- len = nlen - off;
- if (off + len > nlen || len < 1)
- return NULL;
-
- if (!M_WRITABLE(mm)) {
- /* XXX: Use proper m_xxx function instead. */
- x = m_getcl(how, MT_DATA, mm->m_flags);
- if (x == NULL)
- return NULL;
- bcopy(mm->m_ext.ext_buf, x->m_ext.ext_buf, x->m_ext.ext_size);
- p = x->m_ext.ext_buf + (mm->m_data - mm->m_ext.ext_buf);
- x->m_data = p;
- mm->m_next = NULL;
- if (mm != m)
- prev->m_next = x;
- m_free(mm);
- mm = x;
- }
-
- /*
- * Append/prepend the data. Allocating mbufs as necessary.
- */
- /* Shortcut if enough free space in first/last mbuf. */
- if (!prep && M_TRAILINGSPACE(mm) >= len) {
- m_apply(n, off, len, m_bcopyxxx, mtod(mm, caddr_t) +
- mm->m_len);
- mm->m_len += len;
- mm->m_pkthdr.len += len;
- return m;
- }
- if (prep && M_LEADINGSPACE(mm) >= len) {
- mm->m_data = mtod(mm, caddr_t) - len;
- m_apply(n, off, len, m_bcopyxxx, mtod(mm, caddr_t));
- mm->m_len += len;
- mm->m_pkthdr.len += len;
- return mm;
- }
-
- /* Expand first/last mbuf to cluster if possible. */
- if (!prep && !(mm->m_flags & M_EXT) && len > M_TRAILINGSPACE(mm)) {
- bcopy(mm->m_data, &buf, mm->m_len);
- m_clget(mm, how);
- if (!(mm->m_flags & M_EXT))
- return NULL;
- bcopy(&buf, mm->m_ext.ext_buf, mm->m_len);
- mm->m_data = mm->m_ext.ext_buf;
- }
- if (prep && !(mm->m_flags & M_EXT) && len > M_LEADINGSPACE(mm)) {
- bcopy(mm->m_data, &buf, mm->m_len);
- m_clget(mm, how);
- if (!(mm->m_flags & M_EXT))
- return NULL;
- bcopy(&buf, (caddr_t *)mm->m_ext.ext_buf +
- mm->m_ext.ext_size - mm->m_len, mm->m_len);
- mm->m_data = (caddr_t)mm->m_ext.ext_buf +
- mm->m_ext.ext_size - mm->m_len;
- }
-
- /* Append/prepend as many mbuf (clusters) as necessary to fit len. */
- if (!prep && len > M_TRAILINGSPACE(mm)) {
- if (!m_getm(mm, len - M_TRAILINGSPACE(mm), how, MT_DATA))
- return NULL;
- }
- if (prep && len > M_LEADINGSPACE(mm)) {
- if (!(z = m_getm(NULL, len - M_LEADINGSPACE(mm), how, MT_DATA)))
- return NULL;
- i = 0;
- for (x = z; x != NULL; x = x->m_next) {
- i += x->m_flags & M_EXT ? x->m_ext.ext_size :
- (x->m_flags & M_PKTHDR ? MHLEN : MLEN);
- if (!x->m_next)
- break;
- }
- z->m_data += i - len;
- m_move_pkthdr(mm, z);
- x->m_next = mm;
- mm = z;
- }
-
- /* Seek to start position in source mbuf. Optimization for long chains. */
- while (off > 0) {
- if (off < n->m_len)
- break;
- off -= n->m_len;
- n = n->m_next;
- }
-
- /* Copy data into target mbuf. */
- z = mm;
- while (len > 0) {
- KASSERT(z != NULL, ("m_copymdata, falling off target edge"));
- i = M_TRAILINGSPACE(z);
- m_apply(n, off, i, m_bcopyxxx, mtod(z, caddr_t) + z->m_len);
- z->m_len += i;
- /* fixup pkthdr.len if necessary */
- if ((prep ? mm : m)->m_flags & M_PKTHDR)
- (prep ? mm : m)->m_pkthdr.len += i;
- off += i;
- len -= i;
- z = z->m_next;
- }
- return (prep ? mm : m);
-}
-
-/*
* Copy an entire packet, including header (which must be present).
* An optimization of the common case `m_copym(m, 0, M_COPYALL, how)'.
* Note that the copy is read-only, because clusters are not copied,
OpenPOWER on IntegriCloud