Deleted Added
full compact
uipc_mbuf.c (108466) uipc_mbuf.c (109623)
1/*
2 * Copyright (c) 1982, 1986, 1988, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)uipc_mbuf.c 8.2 (Berkeley) 1/4/94
1/*
2 * Copyright (c) 1982, 1986, 1988, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)uipc_mbuf.c 8.2 (Berkeley) 1/4/94
34 * $FreeBSD: head/sys/kern/uipc_mbuf.c 108466 2002-12-30 20:22:40Z sam $
34 * $FreeBSD: head/sys/kern/uipc_mbuf.c 109623 2003-01-21 08:56:16Z alfred $
35 */
36
37#include "opt_mac.h"
38#include "opt_param.h"
39
40#include <sys/param.h>
41#include <sys/systm.h>
42#include <sys/kernel.h>

--- 116 unchanged lines hidden (view full) ---

159 MH_ALIGN(m, len);
160 m->m_len = len;
161 return (m);
162}
163
164/*
165 * Make a copy of an mbuf chain starting "off0" bytes from the beginning,
166 * continuing for "len" bytes. If len is M_COPYALL, copy to end of mbuf.
35 */
36
37#include "opt_mac.h"
38#include "opt_param.h"
39
40#include <sys/param.h>
41#include <sys/systm.h>
42#include <sys/kernel.h>

--- 116 unchanged lines hidden (view full) ---

159 MH_ALIGN(m, len);
160 m->m_len = len;
161 return (m);
162}
163
164/*
165 * Make a copy of an mbuf chain starting "off0" bytes from the beginning,
166 * continuing for "len" bytes. If len is M_COPYALL, copy to end of mbuf.
167 * The wait parameter is a choice of M_TRYWAIT/M_DONTWAIT from caller.
167 * The wait parameter is a choice of 0/M_NOWAIT from caller.
168 * Note that the copy is read-only, because clusters are not copied,
169 * only their reference counts are incremented.
170 */
171struct mbuf *
172m_copym(struct mbuf *m, int off0, int len, int wait)
173{
174 struct mbuf *n, **np;
175 int off = off0;

--- 341 unchanged lines hidden (view full) ---

517 if (n->m_len >= len)
518 return (n);
519 m = n;
520 n = n->m_next;
521 len -= m->m_len;
522 } else {
523 if (len > MHLEN)
524 goto bad;
168 * Note that the copy is read-only, because clusters are not copied,
169 * only their reference counts are incremented.
170 */
171struct mbuf *
172m_copym(struct mbuf *m, int off0, int len, int wait)
173{
174 struct mbuf *n, **np;
175 int off = off0;

--- 341 unchanged lines hidden (view full) ---

517 if (n->m_len >= len)
518 return (n);
519 m = n;
520 n = n->m_next;
521 len -= m->m_len;
522 } else {
523 if (len > MHLEN)
524 goto bad;
525 MGET(m, M_DONTWAIT, n->m_type);
525 MGET(m, M_NOWAIT, n->m_type);
526 if (m == NULL)
527 goto bad;
528 m->m_len = 0;
529 if (n->m_flags & M_PKTHDR)
530 M_MOVE_PKTHDR(m, n);
531 }
532 space = &m->m_dat[MLEN] - (m->m_data + m->m_len);
533 do {

--- 100 unchanged lines hidden (view full) ---

634{
635 struct mbuf *m;
636 struct mbuf *top = 0, **mp = &top;
637 int len;
638
639 if (off < 0 || off > MHLEN)
640 return (NULL);
641
526 if (m == NULL)
527 goto bad;
528 m->m_len = 0;
529 if (n->m_flags & M_PKTHDR)
530 M_MOVE_PKTHDR(m, n);
531 }
532 space = &m->m_dat[MLEN] - (m->m_data + m->m_len);
533 do {

--- 100 unchanged lines hidden (view full) ---

634{
635 struct mbuf *m;
636 struct mbuf *top = 0, **mp = &top;
637 int len;
638
639 if (off < 0 || off > MHLEN)
640 return (NULL);
641
642 MGETHDR(m, M_DONTWAIT, MT_DATA);
642 MGETHDR(m, M_NOWAIT, MT_DATA);
643 if (m == NULL)
644 return (NULL);
645 m->m_pkthdr.rcvif = ifp;
646 m->m_pkthdr.len = totlen;
647 len = MHLEN;
648
649 while (totlen > 0) {
650 if (top) {
643 if (m == NULL)
644 return (NULL);
645 m->m_pkthdr.rcvif = ifp;
646 m->m_pkthdr.len = totlen;
647 len = MHLEN;
648
649 while (totlen > 0) {
650 if (top) {
651 MGET(m, M_DONTWAIT, MT_DATA);
651 MGET(m, M_NOWAIT, MT_DATA);
652 if (m == NULL) {
653 m_freem(top);
654 return (NULL);
655 }
656 len = MLEN;
657 }
658 if (totlen + off >= MINCLSIZE) {
652 if (m == NULL) {
653 m_freem(top);
654 return (NULL);
655 }
656 len = MLEN;
657 }
658 if (totlen + off >= MINCLSIZE) {
659 MCLGET(m, M_DONTWAIT);
659 MCLGET(m, M_NOWAIT);
660 if (m->m_flags & M_EXT)
661 len = MCLBYTES;
662 } else {
663 /*
664 * Place initial small packet/header at end of mbuf.
665 */
666 if (top == NULL && totlen + off + max_linkhdr <= len) {
667 m->m_data += max_linkhdr;

--- 31 unchanged lines hidden (view full) ---

699 int totlen = 0;
700
701 if (m0 == NULL)
702 return;
703 while (off > (mlen = m->m_len)) {
704 off -= mlen;
705 totlen += mlen;
706 if (m->m_next == NULL) {
660 if (m->m_flags & M_EXT)
661 len = MCLBYTES;
662 } else {
663 /*
664 * Place initial small packet/header at end of mbuf.
665 */
666 if (top == NULL && totlen + off + max_linkhdr <= len) {
667 m->m_data += max_linkhdr;

--- 31 unchanged lines hidden (view full) ---

699 int totlen = 0;
700
701 if (m0 == NULL)
702 return;
703 while (off > (mlen = m->m_len)) {
704 off -= mlen;
705 totlen += mlen;
706 if (m->m_next == NULL) {
707 n = m_get_clrd(M_DONTWAIT, m->m_type);
707 n = m_get_clrd(M_NOWAIT, m->m_type);
708 if (n == NULL)
709 goto out;
710 n->m_len = min(MLEN, len + off);
711 m->m_next = n;
712 }
713 m = m->m_next;
714 }
715 while (len > 0) {
716 mlen = min (m->m_len - off, len);
717 bcopy(cp, off + mtod(m, caddr_t), (u_int)mlen);
718 cp += mlen;
719 len -= mlen;
720 mlen += off;
721 off = 0;
722 totlen += mlen;
723 if (len == 0)
724 break;
725 if (m->m_next == NULL) {
708 if (n == NULL)
709 goto out;
710 n->m_len = min(MLEN, len + off);
711 m->m_next = n;
712 }
713 m = m->m_next;
714 }
715 while (len > 0) {
716 mlen = min (m->m_len - off, len);
717 bcopy(cp, off + mtod(m, caddr_t), (u_int)mlen);
718 cp += mlen;
719 len -= mlen;
720 mlen += off;
721 off = 0;
722 totlen += mlen;
723 if (len == 0)
724 break;
725 if (m->m_next == NULL) {
726 n = m_get(M_DONTWAIT, m->m_type);
726 n = m_get(M_NOWAIT, m->m_type);
727 if (n == NULL)
728 break;
729 n->m_len = min(MLEN, len);
730 m->m_next = n;
731 }
732 m = m->m_next;
733 }
734out: if (((m = m0)->m_flags & M_PKTHDR) && (m->m_pkthdr.len < totlen))

--- 45 unchanged lines hidden ---
727 if (n == NULL)
728 break;
729 n->m_len = min(MLEN, len);
730 m->m_next = n;
731 }
732 m = m->m_next;
733 }
734out: if (((m = m0)->m_flags & M_PKTHDR) && (m->m_pkthdr.len < totlen))

--- 45 unchanged lines hidden ---