Deleted Added
full compact
uipc_mbuf2.c (129062) uipc_mbuf2.c (129906)
1/* $KAME: uipc_mbuf2.c,v 1.31 2001/11/28 11:08:53 itojun Exp $ */
2/* $NetBSD: uipc_mbuf.c,v 1.40 1999/04/01 00:23:25 thorpej Exp $ */
3
4/*
5 * Copyright (C) 1999 WIDE Project.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE.
59 *
60 * @(#)uipc_mbuf.c 8.4 (Berkeley) 2/14/95
61 */
62
63#include <sys/cdefs.h>
1/* $KAME: uipc_mbuf2.c,v 1.31 2001/11/28 11:08:53 itojun Exp $ */
2/* $NetBSD: uipc_mbuf.c,v 1.40 1999/04/01 00:23:25 thorpej Exp $ */
3
4/*
5 * Copyright (C) 1999 WIDE Project.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE.
59 *
60 * @(#)uipc_mbuf.c 8.4 (Berkeley) 2/14/95
61 */
62
63#include <sys/cdefs.h>
64__FBSDID("$FreeBSD: head/sys/kern/uipc_mbuf2.c 129062 2004-05-09 05:57:58Z sam $");
64__FBSDID("$FreeBSD: head/sys/kern/uipc_mbuf2.c 129906 2004-05-31 21:46:06Z bmilekic $");
65
66/*#define PULLDOWN_DEBUG*/
67
68#include "opt_mac.h"
69
70#include <sys/param.h>
71#include <sys/systm.h>
72#include <sys/kernel.h>

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

225 off = 0;
226 goto ok;
227 }
228
229 /*
230 * now, we need to do the hard way. don't m_copy as there's no room
231 * on both end.
232 */
65
66/*#define PULLDOWN_DEBUG*/
67
68#include "opt_mac.h"
69
70#include <sys/param.h>
71#include <sys/systm.h>
72#include <sys/kernel.h>

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

225 off = 0;
226 goto ok;
227 }
228
229 /*
230 * now, we need to do the hard way. don't m_copy as there's no room
231 * on both end.
232 */
233 MGET(o, M_DONTWAIT, m->m_type);
234 if (o && len > MLEN) {
235 MCLGET(o, M_DONTWAIT);
236 if ((o->m_flags & M_EXT) == 0) {
237 m_free(o);
238 o = NULL;
239 }
240 }
233 if (len > MLEN)
234 o = m_getcl(M_DONTWAIT, m->m_type, 0);
235 else
236 o = m_get(M_DONTWAIT, m->m_type);
241 if (!o) {
242 m_freem(m);
243 return NULL; /* ENOBUFS */
244 }
245 /* get hlen from <n, off> into <o, 0> */
246 o->m_len = hlen;
247 bcopy(mtod(n, caddr_t) + off, mtod(o, caddr_t), hlen);
248 n->m_len -= hlen;

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

269 *offp = off;
270 return n;
271}
272
273static struct mbuf *
274m_dup1(struct mbuf *m, int off, int len, int wait)
275{
276 struct mbuf *n;
237 if (!o) {
238 m_freem(m);
239 return NULL; /* ENOBUFS */
240 }
241 /* get hlen from <n, off> into <o, 0> */
242 o->m_len = hlen;
243 bcopy(mtod(n, caddr_t) + off, mtod(o, caddr_t), hlen);
244 n->m_len -= hlen;

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

265 *offp = off;
266 return n;
267}
268
269static struct mbuf *
270m_dup1(struct mbuf *m, int off, int len, int wait)
271{
272 struct mbuf *n;
277 int l;
278 int copyhdr;
279
280 if (len > MCLBYTES)
281 return NULL;
273 int copyhdr;
274
275 if (len > MCLBYTES)
276 return NULL;
282 if (off == 0 && (m->m_flags & M_PKTHDR) != 0) {
277 if (off == 0 && (m->m_flags & M_PKTHDR) != 0)
283 copyhdr = 1;
278 copyhdr = 1;
284 MGETHDR(n, wait, m->m_type);
285 l = MHLEN;
286 } else {
279 else
287 copyhdr = 0;
280 copyhdr = 0;
288 MGET(n, wait, m->m_type);
289 l = MLEN;
281 if (len >= MINCLSIZE) {
282 if (copyhdr == 1)
283 n = m_getcl(wait, m->m_type, M_PKTHDR);
284 else
285 n = m_getcl(wait, m->m_type, 0);
286 } else {
287 if (copyhdr == 1)
288 n = m_gethdr(wait, m->m_type);
289 else
290 n = m_get(wait, m->m_type);
290 }
291 }
291 if (n && len > l) {
292 MCLGET(n, wait);
293 if ((n->m_flags & M_EXT) == 0) {
294 m_free(n);
295 n = NULL;
296 }
297 }
298 if (!n)
292 if (!n)
299 return NULL;
293 return NULL; /* ENOBUFS */
300
301 if (copyhdr && !m_dup_pkthdr(n, m, wait)) {
302 m_free(n);
303 return NULL;
304 }
305 m_copydata(m, off, len, mtod(n, caddr_t));
306 n->m_len = len;
307 return n;

--- 148 unchanged lines hidden ---
294
295 if (copyhdr && !m_dup_pkthdr(n, m, wait)) {
296 m_free(n);
297 return NULL;
298 }
299 m_copydata(m, off, len, mtod(n, caddr_t));
300 n->m_len = len;
301 return n;

--- 148 unchanged lines hidden ---