diff options
author | sam <sam@FreeBSD.org> | 2004-01-02 17:27:39 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2004-01-02 17:27:39 +0000 |
commit | ca1ce6605dedaebcf4fdfa7453684f809c1c2bc7 (patch) | |
tree | 4f499fb76444ae8b187c84e1672035e7f7069371 /sys/kern/uipc_mbuf2.c | |
parent | d4d6be2b788a91178f08777aabe1e8a0acba3fef (diff) | |
download | FreeBSD-src-ca1ce6605dedaebcf4fdfa7453684f809c1c2bc7.zip FreeBSD-src-ca1ce6605dedaebcf4fdfa7453684f809c1c2bc7.tar.gz |
m_tag fixups in preparation for heavier use:
o promote several m_tag_* routines to inline
o add an m_tag_setup inline to set the fixed fields in a packet tag
o add an m_tag_free method pointer to each mtag to support, for example,
allocating tags from zones
o have m_tag_find check if the tag list is not empty before calling
m_tag_locate to search
Reviewed by: brooks, silence from others
Diffstat (limited to 'sys/kern/uipc_mbuf2.c')
-rw-r--r-- | sys/kern/uipc_mbuf2.c | 64 |
1 files changed, 13 insertions, 51 deletions
diff --git a/sys/kern/uipc_mbuf2.c b/sys/kern/uipc_mbuf2.c index 1b579e3..4d59447 100644 --- a/sys/kern/uipc_mbuf2.c +++ b/sys/kern/uipc_mbuf2.c @@ -310,6 +310,17 @@ m_dup1(struct mbuf *m, int off, int len, int wait) return n; } +/* Free a packet tag. */ +static void +_m_tag_free(struct m_tag *t) +{ +#ifdef MAC + if (t->m_tag_id == PACKET_TAG_MACLABEL) + mac_destroy_mbuf_tag(t); +#endif + free(t, M_PACKET_TAGS); +} + /* Get a packet tag structure along with specified data following. */ struct m_tag * m_tag_alloc(u_int32_t cookie, int type, int len, int wait) @@ -321,39 +332,11 @@ m_tag_alloc(u_int32_t cookie, int type, int len, int wait) t = malloc(len + sizeof(struct m_tag), M_PACKET_TAGS, wait); if (t == NULL) return NULL; - t->m_tag_id = type; - t->m_tag_len = len; - t->m_tag_cookie = cookie; + m_tag_setup(t, cookie, type, len); + t->m_tag_free = _m_tag_free; return t; } -/* Free a packet tag. */ -void -m_tag_free(struct m_tag *t) -{ -#ifdef MAC - if (t->m_tag_id == PACKET_TAG_MACLABEL) - mac_destroy_mbuf_tag(t); -#endif - free(t, M_PACKET_TAGS); -} - -/* Prepend a packet tag. */ -void -m_tag_prepend(struct mbuf *m, struct m_tag *t) -{ - KASSERT(m && t, ("m_tag_prepend: null argument, m %p t %p", m, t)); - SLIST_INSERT_HEAD(&m->m_pkthdr.tags, t, m_tag_link); -} - -/* Unlink a packet tag. */ -void -m_tag_unlink(struct mbuf *m, struct m_tag *t) -{ - KASSERT(m && t, ("m_tag_unlink: null argument, m %p t %p", m, t)); - SLIST_REMOVE(&m->m_pkthdr.tags, t, m_tag, m_tag_link); -} - /* Unlink and free a packet tag. */ void m_tag_delete(struct mbuf *m, struct m_tag *t) @@ -473,24 +456,3 @@ m_tag_copy_chain(struct mbuf *to, struct mbuf *from, int how) } return 1; } - -/* Initialize tags on an mbuf. */ -void -m_tag_init(struct mbuf *m) -{ - SLIST_INIT(&m->m_pkthdr.tags); -} - -/* Get first tag in chain. */ -struct m_tag * -m_tag_first(struct mbuf *m) -{ - return SLIST_FIRST(&m->m_pkthdr.tags); -} - -/* Get next tag in chain. */ -struct m_tag * -m_tag_next(struct mbuf *m, struct m_tag *t) -{ - return SLIST_NEXT(t, m_tag_link); -} |