uipc_mbuf2.c (129906) | uipc_mbuf2.c (132488) |
---|---|
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 129906 2004-05-31 21:46:06Z bmilekic $"); | 64__FBSDID("$FreeBSD: head/sys/kern/uipc_mbuf2.c 132488 2004-07-21 07:12:24Z alfred $"); |
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> --- 240 unchanged lines hidden (view full) --- 313} 314 315/* Get a packet tag structure along with specified data following. */ 316struct m_tag * 317m_tag_alloc(u_int32_t cookie, int type, int len, int wait) 318{ 319 struct m_tag *t; 320 | 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> --- 240 unchanged lines hidden (view full) --- 313} 314 315/* Get a packet tag structure along with specified data following. */ 316struct m_tag * 317m_tag_alloc(u_int32_t cookie, int type, int len, int wait) 318{ 319 struct m_tag *t; 320 |
321 MBUF_CHECKSLEEP(wait); |
|
321 if (len < 0) 322 return NULL; 323 t = malloc(len + sizeof(struct m_tag), M_PACKET_TAGS, wait); 324 if (t == NULL) 325 return NULL; 326 m_tag_setup(t, cookie, type, len); 327 t->m_tag_free = _m_tag_free; 328 return t; 329} 330 331/* Unlink and free a packet tag. */ 332void 333m_tag_delete(struct mbuf *m, struct m_tag *t) 334{ | 322 if (len < 0) 323 return NULL; 324 t = malloc(len + sizeof(struct m_tag), M_PACKET_TAGS, wait); 325 if (t == NULL) 326 return NULL; 327 m_tag_setup(t, cookie, type, len); 328 t->m_tag_free = _m_tag_free; 329 return t; 330} 331 332/* Unlink and free a packet tag. */ 333void 334m_tag_delete(struct mbuf *m, struct m_tag *t) 335{ |
336 |
|
335 KASSERT(m && t, ("m_tag_delete: null argument, m %p t %p", m, t)); 336 m_tag_unlink(m, t); 337 m_tag_free(t); 338} 339 340/* Unlink and free a packet tag chain, starting from given tag. */ 341void 342m_tag_delete_chain(struct mbuf *m, struct m_tag *t) --- 49 unchanged lines hidden (view full) --- 392} 393 394/* Copy a single tag. */ 395struct m_tag * 396m_tag_copy(struct m_tag *t, int how) 397{ 398 struct m_tag *p; 399 | 337 KASSERT(m && t, ("m_tag_delete: null argument, m %p t %p", m, t)); 338 m_tag_unlink(m, t); 339 m_tag_free(t); 340} 341 342/* Unlink and free a packet tag chain, starting from given tag. */ 343void 344m_tag_delete_chain(struct mbuf *m, struct m_tag *t) --- 49 unchanged lines hidden (view full) --- 394} 395 396/* Copy a single tag. */ 397struct m_tag * 398m_tag_copy(struct m_tag *t, int how) 399{ 400 struct m_tag *p; 401 |
402 MBUF_CHECKSLEEP(how); |
|
400 KASSERT(t, ("m_tag_copy: null tag")); 401 p = m_tag_alloc(t->m_tag_cookie, t->m_tag_id, t->m_tag_len, how); 402 if (p == NULL) 403 return (NULL); 404#ifdef MAC 405 /* 406 * XXXMAC: we should probably pass off the initialization, and 407 * copying here? can we hide that PACKET_TAG_MACLABEL is --- 17 unchanged lines hidden (view full) --- 425 * m_tag_copy_chain() is typically called with a newly-allocated 426 * destination mbuf. 427 */ 428int 429m_tag_copy_chain(struct mbuf *to, struct mbuf *from, int how) 430{ 431 struct m_tag *p, *t, *tprev = NULL; 432 | 403 KASSERT(t, ("m_tag_copy: null tag")); 404 p = m_tag_alloc(t->m_tag_cookie, t->m_tag_id, t->m_tag_len, how); 405 if (p == NULL) 406 return (NULL); 407#ifdef MAC 408 /* 409 * XXXMAC: we should probably pass off the initialization, and 410 * copying here? can we hide that PACKET_TAG_MACLABEL is --- 17 unchanged lines hidden (view full) --- 428 * m_tag_copy_chain() is typically called with a newly-allocated 429 * destination mbuf. 430 */ 431int 432m_tag_copy_chain(struct mbuf *to, struct mbuf *from, int how) 433{ 434 struct m_tag *p, *t, *tprev = NULL; 435 |
436 MBUF_CHECKSLEEP(how); |
|
433 KASSERT(to && from, 434 ("m_tag_copy_chain: null argument, to %p from %p", to, from)); 435 m_tag_delete_chain(to, NULL); 436 SLIST_FOREACH(p, &from->m_pkthdr.tags, m_tag_link) { 437 t = m_tag_copy(p, how); 438 if (t == NULL) { 439 m_tag_delete_chain(to, NULL); 440 return 0; 441 } 442 if (tprev == NULL) 443 SLIST_INSERT_HEAD(&to->m_pkthdr.tags, t, m_tag_link); 444 else 445 SLIST_INSERT_AFTER(tprev, t, m_tag_link); 446 tprev = t; 447 } 448 return 1; 449} | 437 KASSERT(to && from, 438 ("m_tag_copy_chain: null argument, to %p from %p", to, from)); 439 m_tag_delete_chain(to, NULL); 440 SLIST_FOREACH(p, &from->m_pkthdr.tags, m_tag_link) { 441 t = m_tag_copy(p, how); 442 if (t == NULL) { 443 m_tag_delete_chain(to, NULL); 444 return 0; 445 } 446 if (tprev == NULL) 447 SLIST_INSERT_HEAD(&to->m_pkthdr.tags, t, m_tag_link); 448 else 449 SLIST_INSERT_AFTER(tprev, t, m_tag_link); 450 tprev = t; 451 } 452 return 1; 453} |