summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/sys/mbuf.h325
1 files changed, 163 insertions, 162 deletions
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
index d2aef51053e9..6350e3ed9972 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -1,6 +1,7 @@
/*-
* Copyright (c) 1982, 1986, 1988, 1993
- * The Regents of the University of California. All rights reserved.
+ * The Regents of the University of California.
+ * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -44,13 +45,13 @@
#endif
/*
- * Mbufs are of a single size, MSIZE (sys/param.h), which
- * includes overhead. An mbuf may add a single "mbuf cluster" of size
- * MCLBYTES (also in sys/param.h), which has no additional overhead
- * and is used instead of the internal data area; this is done when
- * at least MINCLSIZE of data must be stored. Additionally, it is possible
- * to allocate a separate buffer externally and attach it to the mbuf in
- * a way similar to that of mbuf clusters.
+ * Mbufs are of a single size, MSIZE (sys/param.h), which includes overhead.
+ * An mbuf may add a single "mbuf cluster" of size MCLBYTES (also in
+ * sys/param.h), which has no additional overhead and is used instead of the
+ * internal data area; this is done when at least MINCLSIZE of data must be
+ * stored. Additionally, it is possible to allocate a separate buffer
+ * externally and attach it to the mbuf in a way similar to that of mbuf
+ * clusters.
*/
#define MLEN (MSIZE - sizeof(struct m_hdr)) /* normal data len */
#define MHLEN (MLEN - sizeof(struct pkthdr)) /* data len w/pkthdr */
@@ -80,12 +81,12 @@ struct mb_args {
* Header present at the beginning of every mbuf.
*/
struct m_hdr {
- struct mbuf *mh_next; /* next buffer in chain */
- struct mbuf *mh_nextpkt; /* next chain in queue/record */
- caddr_t mh_data; /* location of data */
- int mh_len; /* amount of data in this mbuf */
- int mh_flags; /* flags; see below */
- short mh_type; /* type of data in this mbuf */
+ struct mbuf *mh_next; /* next buffer in chain */
+ struct mbuf *mh_nextpkt; /* next chain in queue/record */
+ caddr_t mh_data; /* location of data */
+ int mh_len; /* amount of data in this mbuf */
+ int mh_flags; /* flags; see below */
+ short mh_type; /* type of data in this mbuf */
};
/*
@@ -103,43 +104,44 @@ struct m_tag {
* Record/packet header in first mbuf of chain; valid only if M_PKTHDR is set.
*/
struct pkthdr {
- struct ifnet *rcvif; /* rcv interface */
- int len; /* total packet length */
+ struct ifnet *rcvif; /* rcv interface */
+ int len; /* total packet length */
/* variables for ip and tcp reassembly */
- void *header; /* pointer to packet header */
+ void *header; /* pointer to packet header */
/* variables for hardware checksum */
- int csum_flags; /* flags regarding checksum */
- int csum_data; /* data field used by csum routines */
- u_int16_t tso_segsz; /* TSO segment size */
- u_int16_t ether_vtag; /* Ethernet 802.1p+q vlan tag */
+ int csum_flags; /* flags regarding checksum */
+ int csum_data; /* data field used by csum routines */
+ u_int16_t tso_segsz; /* TSO segment size */
+ u_int16_t ether_vtag; /* Ethernet 802.1p+q vlan tag */
SLIST_HEAD(packet_tags, m_tag) tags; /* list of packet tags */
};
/*
- * Description of external storage mapped into mbuf; valid only if M_EXT is set.
+ * Description of external storage mapped into mbuf; valid only if M_EXT is
+ * set.
*/
struct m_ext {
- caddr_t ext_buf; /* start of buffer */
- void (*ext_free) /* free routine if not the usual */
- (void *, void *);
- void *ext_args; /* optional argument pointer */
- u_int ext_size; /* size of buffer, for ext_free */
- volatile u_int *ref_cnt; /* pointer to ref count info */
- int ext_type; /* type of external storage */
+ caddr_t ext_buf; /* start of buffer */
+ void (*ext_free) /* free routine if not the usual */
+ (void *, void *);
+ void *ext_args; /* optional argument pointer */
+ u_int ext_size; /* size of buffer, for ext_free */
+ volatile u_int *ref_cnt; /* pointer to ref count info */
+ int ext_type; /* type of external storage */
};
/*
- * The core of the mbuf object along with some shortcut defines for
- * practical purposes.
+ * The core of the mbuf object along with some shortcut defines for practical
+ * purposes.
*/
struct mbuf {
- struct m_hdr m_hdr;
+ struct m_hdr m_hdr;
union {
struct {
- struct pkthdr MH_pkthdr; /* M_PKTHDR set */
+ struct pkthdr MH_pkthdr; /* M_PKTHDR set */
union {
- struct m_ext MH_ext; /* M_EXT set */
- char MH_databuf[MHLEN];
+ struct m_ext MH_ext; /* M_EXT set */
+ char MH_databuf[MHLEN];
} MH_dat;
} MH;
char M_databuf[MLEN]; /* !M_PKTHDR, !M_EXT */
@@ -212,8 +214,8 @@ struct mbuf {
#define M_PROTOFLAGS (M_PROTO1|M_PROTO2|M_PROTO3|M_PROTO4|M_PROTO5)
/*
- * Flags indicating hw checksum support and sw checksum requirements.
- * This field can be directly tested against if_data.ifi_hwassist.
+ * Flags indicating hw checksum support and sw checksum requirements. This
+ * field can be directly tested against if_data.ifi_hwassist.
*/
#define CSUM_IP 0x0001 /* will csum IP */
#define CSUM_TCP 0x0002 /* will csum TCP */
@@ -279,11 +281,10 @@ struct mbstat {
* - M_DONTWAIT or M_NOWAIT from an interrupt handler to not block allocation.
* - M_WAIT or M_WAITOK or M_TRYWAIT from wherever it is safe to block.
*
- * M_DONTWAIT/M_NOWAIT means that we will not block the thread explicitly
- * and if we cannot allocate immediately we may return NULL,
- * whereas M_WAIT/M_WAITOK/M_TRYWAIT means that if we cannot allocate
- * resources we will block until they are available, and thus never
- * return NULL.
+ * M_DONTWAIT/M_NOWAIT means that we will not block the thread explicitly and
+ * if we cannot allocate immediately we may return NULL, whereas
+ * M_WAIT/M_WAITOK/M_TRYWAIT means that if we cannot allocate resources we
+ * will block until they are available, and thus never return NULL.
*
* XXX Eventually just phase this out to use M_WAITOK/M_NOWAIT.
*/
@@ -309,13 +310,13 @@ struct mbstat {
#ifdef _KERNEL
#ifdef WITNESS
-#define MBUF_CHECKSLEEP(how) do { \
+#define MBUF_CHECKSLEEP(how) do { \
if (how == M_WAITOK) \
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, \
"Sleeping in \"%s\"", __func__); \
} while (0)
#else
-#define MBUF_CHECKSLEEP(how)
+#define MBUF_CHECKSLEEP(how)
#endif
/*
@@ -335,7 +336,8 @@ extern uma_zone_t zone_ext_refcnt;
static __inline struct mbuf *m_get(int how, short type);
static __inline struct mbuf *m_gethdr(int how, short type);
static __inline struct mbuf *m_getcl(int how, short type, int flags);
-static __inline struct mbuf *m_getjcl(int how, short type, int flags, int size);
+static __inline struct mbuf *m_getjcl(int how, short type, int flags,
+ int size);
static __inline struct mbuf *m_getclr(int how, short type); /* XXX */
static __inline struct mbuf *m_free(struct mbuf *m);
static __inline void m_clget(struct mbuf *m, int how);
@@ -343,20 +345,20 @@ static __inline void *m_cljget(struct mbuf *m, int how, int size);
static __inline void m_chtype(struct mbuf *m, short new_type);
void mb_free_ext(struct mbuf *);
-static __inline
-struct mbuf *
+static __inline struct mbuf *
m_get(int how, short type)
{
struct mb_args args;
args.flags = 0;
args.type = type;
- return (struct mbuf *)(uma_zalloc_arg(zone_mbuf, &args, how));
+ return ((struct mbuf *)(uma_zalloc_arg(zone_mbuf, &args, how)));
}
-/* XXX This should be depracated, very little use */
-static __inline
-struct mbuf *
+/*
+ * XXX This should be deprecated, very little use.
+ */
+static __inline struct mbuf *
m_getclr(int how, short type)
{
struct mbuf *m;
@@ -367,37 +369,36 @@ m_getclr(int how, short type)
m = uma_zalloc_arg(zone_mbuf, &args, how);
if (m != NULL)
bzero(m->m_data, MLEN);
- return m;
+ return (m);
}
-static __inline
-struct mbuf *
+static __inline struct mbuf *
m_gethdr(int how, short type)
{
struct mb_args args;
args.flags = M_PKTHDR;
args.type = type;
- return (struct mbuf *)(uma_zalloc_arg(zone_mbuf, &args, how));
+ return ((struct mbuf *)(uma_zalloc_arg(zone_mbuf, &args, how)));
}
-static __inline
-struct mbuf *
+static __inline struct mbuf *
m_getcl(int how, short type, int flags)
{
struct mb_args args;
args.flags = flags;
args.type = type;
- return (struct mbuf *)(uma_zalloc_arg(zone_pack, &args, how));
+ return ((struct mbuf *)(uma_zalloc_arg(zone_pack, &args, how)));
}
/*
* m_getjcl() returns an mbuf with a cluster of the specified size attached.
* For size it takes MCLBYTES, MJUMPAGESIZE, MJUM9BYTES, MJUM16BYTES.
+ *
+ * XXX: This is rather large, should be real function maybe.
*/
-static __inline /* XXX: This is rather large, should be real function maybe. */
-struct mbuf *
+static __inline struct mbuf *
m_getjcl(int how, short type, int flags, int size)
{
struct mb_args args;
@@ -409,7 +410,7 @@ m_getjcl(int how, short type, int flags, int size)
m = uma_zalloc_arg(zone_mbuf, &args, how);
if (m == NULL)
- return NULL;
+ return (NULL);
switch (size) {
case MCLBYTES:
@@ -432,13 +433,12 @@ m_getjcl(int how, short type, int flags, int size)
n = uma_zalloc_arg(zone, m, how);
if (n == NULL) {
uma_zfree(zone_mbuf, m);
- return NULL;
+ return (NULL);
}
- return m;
+ return (m);
}
-static __inline
-struct mbuf *
+static __inline struct mbuf *
m_free(struct mbuf *m)
{
struct mbuf *n = m->m_next;
@@ -447,13 +447,13 @@ m_free(struct mbuf *m)
mb_free_ext(m);
else
uma_zfree(zone_mbuf, m);
- return n;
+ return (n);
}
-static __inline
-void
+static __inline void
m_clget(struct mbuf *m, int how)
{
+
if (m->m_flags & M_EXT)
printf("%s: %p mbuf already has cluster\n", __func__, m);
m->m_ext.ext_buf = (char *)NULL;
@@ -469,15 +469,13 @@ m_clget(struct mbuf *m, int how)
}
/*
- * m_cljget() is different from m_clget() as it can allocate clusters
- * without attaching them to an mbuf. In that case the return value
- * is the pointer to the cluster of the requested size. If an mbuf was
- * specified, it gets the cluster attached to it and the return value
- * can be safely ignored.
+ * m_cljget() is different from m_clget() as it can allocate clusters without
+ * attaching them to an mbuf. In that case the return value is the pointer
+ * to the cluster of the requested size. If an mbuf was specified, it gets
+ * the cluster attached to it and the return value can be safely ignored.
* For size it takes MCLBYTES, MJUMPAGESIZE, MJUM9BYTES, MJUM16BYTES.
*/
-static __inline
-void *
+static __inline void *
m_cljget(struct mbuf *m, int how, int size)
{
uma_zone_t zone;
@@ -505,22 +503,21 @@ m_cljget(struct mbuf *m, int how, int size)
default:
panic("%s: m_getjcl: invalid cluster type", __func__);
}
-
+
return (uma_zalloc_arg(zone, m, how));
}
-static __inline
-void
+static __inline void
m_chtype(struct mbuf *m, short new_type)
{
+
m->m_type = new_type;
}
/*
- * mbuf, cluster, and external object allocation macros
- * (for compatibility purposes).
+ * mbuf, cluster, and external object allocation macros (for compatibility
+ * purposes).
*/
-/* NB: M_COPY_PKTHDR is deprecated. Use M_MOVE_PKTHDR or m_dup_pktdr. */
#define M_MOVE_PKTHDR(to, from) m_move_pkthdr((to), (from))
#define MGET(m, how, type) ((m) = m_get((how), (type)))
#define MGETHDR(m, how, type) ((m) = m_gethdr((how), (type)))
@@ -531,9 +528,9 @@ m_chtype(struct mbuf *m, short new_type)
m_getm2((m), (len), (how), (type), M_PKTHDR)
/*
- * Evaluate TRUE if it's safe to write to the mbuf m's data region (this
- * can be both the local data payload, or an external buffer area,
- * depending on whether M_EXT is set).
+ * Evaluate TRUE if it's safe to write to the mbuf m's data region (this can
+ * be both the local data payload, or an external buffer area, depending on
+ * whether M_EXT is set).
*/
#define M_WRITABLE(m) (!((m)->m_flags & M_RDONLY) && \
(!(((m)->m_flags & M_EXT)) || \
@@ -544,15 +541,18 @@ m_chtype(struct mbuf *m, short new_type)
KASSERT(m != NULL && m->m_flags & M_PKTHDR, \
("%s: no mbuf packet header!", __func__))
-/* Ensure that the supplied mbuf is a valid, non-free mbuf. */
-/* XXX: Broken at the moment. Need some UMA magic to make it work again. */
+/*
+ * Ensure that the supplied mbuf is a valid, non-free mbuf.
+ *
+ * XXX: Broken at the moment. Need some UMA magic to make it work again.
+ */
#define M_ASSERTVALID(m) \
KASSERT((((struct mbuf *)m)->m_flags & 0) == 0, \
("%s: attempted use of a free mbuf!", __func__))
/*
- * Set the m_data pointer of a newly-allocated mbuf (m_get/MGET) to place
- * an object of the specified size at the end of the mbuf, longword aligned.
+ * Set the m_data pointer of a newly-allocated mbuf (m_get/MGET) to place an
+ * object of the specified size at the end of the mbuf, longword aligned.
*/
#define M_ALIGN(m, len) do { \
KASSERT(!((m)->m_flags & (M_PKTHDR|M_EXT)), \
@@ -563,8 +563,8 @@ m_chtype(struct mbuf *m, short new_type)
} while (0)
/*
- * As above, for mbufs allocated with m_gethdr/MGETHDR
- * or initialized by M_COPY_PKTHDR.
+ * As above, for mbufs allocated with m_gethdr/MGETHDR or initialized by
+ * M_DUP/MOVE_PKTHDR.
*/
#define MH_ALIGN(m, len) do { \
KASSERT((m)->m_flags & M_PKTHDR && !((m)->m_flags & M_EXT), \
@@ -575,8 +575,8 @@ m_chtype(struct mbuf *m, short new_type)
} while (0)
/*
- * Compute the amount of space available
- * before the current start of data in an mbuf.
+ * Compute the amount of space available before the current start of data in
+ * an mbuf.
*
* The M_WRITABLE() is a temporary, conservative safety measure: the burden
* of checking writability of the mbuf data area rests solely with the caller.
@@ -588,8 +588,7 @@ m_chtype(struct mbuf *m, short new_type)
(m)->m_data - (m)->m_dat)
/*
- * Compute the amount of space available
- * after the end of data in an mbuf.
+ * Compute the amount of space available after the end of data in an mbuf.
*
* The M_WRITABLE() is a temporary, conservative safety measure: the burden
* of checking writability of the mbuf data area rests solely with the caller.
@@ -601,10 +600,9 @@ m_chtype(struct mbuf *m, short new_type)
&(m)->m_dat[MLEN] - ((m)->m_data + (m)->m_len))
/*
- * Arrange to prepend space of size plen to mbuf m.
- * If a new mbuf must be allocated, how specifies whether to wait.
- * If the allocation fails, the original mbuf chain is freed and m is
- * set to NULL.
+ * Arrange to prepend space of size plen to mbuf m. If a new mbuf must be
+ * allocated, how specifies whether to wait. If the allocation fails, the
+ * original mbuf chain is freed and m is set to NULL.
*/
#define M_PREPEND(m, plen, how) do { \
struct mbuf **_mmp = &(m); \
@@ -624,8 +622,8 @@ m_chtype(struct mbuf *m, short new_type)
} while (0)
/*
- * Change mbuf to new type.
- * This is a relatively expensive operation and should be avoided.
+ * Change mbuf to new type. This is a relatively expensive operation and
+ * should be avoided.
*/
#define MCHTYPE(m, t) m_chtype((m), (t))
@@ -635,12 +633,12 @@ m_chtype(struct mbuf *m, short new_type)
/* Compatibility with 4.3. */
#define m_copy(m, o, l) m_copym((m), (o), (l), M_DONTWAIT)
-extern int max_datalen; /* MHLEN - max_hdr */
-extern int max_hdr; /* Largest link + protocol header */
-extern int max_linkhdr; /* Largest link-level header */
-extern int max_protohdr; /* Largest protocol header */
-extern struct mbstat mbstat; /* General mbuf stats/infos */
-extern int nmbclusters; /* Maximum number of clusters */
+extern int max_datalen; /* MHLEN - max_hdr */
+extern int max_hdr; /* Largest link + protocol header */
+extern int max_linkhdr; /* Largest link-level header */
+extern int max_protohdr; /* Largest protocol header */
+extern struct mbstat mbstat; /* General mbuf stats/infos */
+extern int nmbclusters; /* Maximum number of clusters */
struct uio;
@@ -654,63 +652,61 @@ void m_extadd(struct mbuf *, caddr_t, u_int,
void (*)(void *, void *), void *, int, int);
void m_copyback(struct mbuf *, int, int, c_caddr_t);
void m_copydata(const struct mbuf *, int, int, caddr_t);
-struct mbuf *m_copym(struct mbuf *, int, int, int);
-struct mbuf *m_copymdata(struct mbuf *, struct mbuf *,
+struct mbuf *m_copym(struct mbuf *, int, int, int);
+struct mbuf *m_copymdata(struct mbuf *, struct mbuf *,
int, int, int, int);
-struct mbuf *m_copypacket(struct mbuf *, int);
+struct mbuf *m_copypacket(struct mbuf *, int);
void m_copy_pkthdr(struct mbuf *, struct mbuf *);
-struct mbuf *m_copyup(struct mbuf *n, int len, int dstoff);
-struct mbuf *m_defrag(struct mbuf *, int);
+struct mbuf *m_copyup(struct mbuf *n, int len, int dstoff);
+struct mbuf *m_defrag(struct mbuf *, int);
void m_demote(struct mbuf *, int);
-struct mbuf *m_devget(char *, int, int, struct ifnet *,
+struct mbuf *m_devget(char *, int, int, struct ifnet *,
void (*)(char *, caddr_t, u_int));
-struct mbuf *m_dup(struct mbuf *, int);
+struct mbuf *m_dup(struct mbuf *, int);
int m_dup_pkthdr(struct mbuf *, struct mbuf *, int);
u_int m_fixhdr(struct mbuf *);
-struct mbuf *m_fragment(struct mbuf *, int, int);
+struct mbuf *m_fragment(struct mbuf *, int, int);
void m_freem(struct mbuf *);
-struct mbuf *m_getm2(struct mbuf *, int, int, short, int);
-struct mbuf *m_getptr(struct mbuf *, int, int *);
+struct mbuf *m_getm2(struct mbuf *, int, int, short, int);
+struct mbuf *m_getptr(struct mbuf *, int, int *);
u_int m_length(struct mbuf *, struct mbuf **);
void m_move_pkthdr(struct mbuf *, struct mbuf *);
-struct mbuf *m_prepend(struct mbuf *, int, int);
+struct mbuf *m_prepend(struct mbuf *, int, int);
void m_print(const struct mbuf *, int);
-struct mbuf *m_pulldown(struct mbuf *, int, int, int *);
-struct mbuf *m_pullup(struct mbuf *, int);
+struct mbuf *m_pulldown(struct mbuf *, int, int, int *);
+struct mbuf *m_pullup(struct mbuf *, int);
int m_sanity(struct mbuf *, int);
-struct mbuf *m_split(struct mbuf *, int, int);
-struct mbuf *m_uiotombuf(struct uio *, int, int, int, int);
-struct mbuf *m_unshare(struct mbuf *, int how);
+struct mbuf *m_split(struct mbuf *, int, int);
+struct mbuf *m_uiotombuf(struct uio *, int, int, int, int);
+struct mbuf *m_unshare(struct mbuf *, int how);
/*-
- * Network packets may have annotations attached by affixing a list
- * of "packet tags" to the pkthdr structure. Packet tags are
- * dynamically allocated semi-opaque data structures that have
- * a fixed header (struct m_tag) that specifies the size of the
- * memory block and a <cookie,type> pair that identifies it.
- * The cookie is a 32-bit unique unsigned value used to identify
- * a module or ABI. By convention this value is chosen as the
- * date+time that the module is created, expressed as the number of
- * seconds since the epoch (e.g., using date -u +'%s'). The type value
- * is an ABI/module-specific value that identifies a particular annotation
- * and is private to the module. For compatibility with systems
- * like OpenBSD that define packet tags w/o an ABI/module cookie,
- * the value PACKET_ABI_COMPAT is used to implement m_tag_get and
- * m_tag_find compatibility shim functions and several tag types are
- * defined below. Users that do not require compatibility should use
- * a private cookie value so that packet tag-related definitions
- * can be maintained privately.
+ * Network packets may have annotations attached by affixing a list of
+ * "packet tags" to the pkthdr structure. Packet tags are dynamically
+ * allocated semi-opaque data structures that have a fixed header
+ * (struct m_tag) that specifies the size of the memory block and a
+ * <cookie,type> pair that identifies it. The cookie is a 32-bit unique
+ * unsigned value used to identify a module or ABI. By convention this value
+ * is chosen as the date+time that the module is created, expressed as the
+ * number of seconds since the epoch (e.g., using date -u +'%s'). The type
+ * value is an ABI/module-specific value that identifies a particular
+ * annotation and is private to the module. For compatibility with systems
+ * like OpenBSD that define packet tags w/o an ABI/module cookie, the value
+ * PACKET_ABI_COMPAT is used to implement m_tag_get and m_tag_find
+ * compatibility shim functions and several tag types are defined below.
+ * Users that do not require compatibility should use a private cookie value
+ * so that packet tag-related definitions can be maintained privately.
*
- * Note that the packet tag returned by m_tag_alloc has the default
- * memory alignment implemented by malloc. To reference private data
- * one can use a construct like:
+ * Note that the packet tag returned by m_tag_alloc has the default memory
+ * alignment implemented by malloc. To reference private data one can use a
+ * construct like:
*
* struct m_tag *mtag = m_tag_alloc(...);
* struct foo *p = (struct foo *)(mtag+1);
*
- * if the alignment of struct m_tag is sufficient for referencing members
- * of struct foo. Otherwise it is necessary to embed struct m_tag within
- * the private data structure to insure proper alignment; e.g.,
+ * if the alignment of struct m_tag is sufficient for referencing members of
+ * struct foo. Otherwise it is necessary to embed struct m_tag within the
+ * private data structure to insure proper alignment; e.g.,
*
* struct foo {
* struct m_tag tag;
@@ -721,17 +717,16 @@ struct mbuf *m_unshare(struct mbuf *, int how);
*/
/*
- * Persistent tags stay with an mbuf until the mbuf is reclaimed.
- * Otherwise tags are expected to ``vanish'' when they pass through
- * a network interface. For most interfaces this happens normally
- * as the tags are reclaimed when the mbuf is free'd. However in
- * some special cases reclaiming must be done manually. An example
- * is packets that pass through the loopback interface. Also, one
- * must be careful to do this when ``turning around'' packets (e.g.,
- * icmp_reflect).
+ * Persistent tags stay with an mbuf until the mbuf is reclaimed. Otherwise
+ * tags are expected to ``vanish'' when they pass through a network
+ * interface. For most interfaces this happens normally as the tags are
+ * reclaimed when the mbuf is free'd. However in some special cases
+ * reclaiming must be done manually. An example is packets that pass through
+ * the loopback interface. Also, one must be careful to do this when
+ * ``turning around'' packets (e.g., icmp_reflect).
*
- * To mark a tag persistent bit-or this flag in when defining the
- * tag id. The tag will then be treated as described above.
+ * To mark a tag persistent bit-or this flag in when defining the tag id.
+ * The tag will then be treated as described above.
*/
#define MTAG_PERSISTENT 0x800
@@ -768,12 +763,12 @@ struct mbuf *m_unshare(struct mbuf *, int how);
/* Specific cookies and tags. */
/* Packet tag routines. */
-struct m_tag *m_tag_alloc(u_int32_t, int, int, int);
+struct m_tag *m_tag_alloc(u_int32_t, int, int, int);
void m_tag_delete(struct mbuf *, struct m_tag *);
void m_tag_delete_chain(struct mbuf *, struct m_tag *);
void m_tag_free_default(struct m_tag *);
-struct m_tag *m_tag_locate(struct mbuf *, u_int32_t, int, struct m_tag *);
-struct m_tag *m_tag_copy(struct m_tag *, int);
+struct m_tag *m_tag_locate(struct mbuf *, u_int32_t, int, struct m_tag *);
+struct m_tag *m_tag_copy(struct m_tag *, int);
int m_tag_copy_chain(struct mbuf *, struct mbuf *, int);
void m_tag_delete_nonpersistent(struct mbuf *);
@@ -783,19 +778,20 @@ void m_tag_delete_nonpersistent(struct mbuf *);
static __inline void
m_tag_init(struct mbuf *m)
{
+
SLIST_INIT(&m->m_pkthdr.tags);
}
/*
- * Set up the contents of a tag. Note that this does not
- * fill in the free method; the caller is expected to do that.
+ * Set up the contents of a tag. Note that this does not fill in the free
+ * method; the caller is expected to do that.
*
- * XXX probably should be called m_tag_init, but that was
- * already taken.
+ * XXX probably should be called m_tag_init, but that was already taken.
*/
static __inline void
m_tag_setup(struct m_tag *t, u_int32_t cookie, int type, int len)
{
+
t->m_tag_id = type;
t->m_tag_len = len;
t->m_tag_cookie = cookie;
@@ -807,6 +803,7 @@ m_tag_setup(struct m_tag *t, u_int32_t cookie, int type, int len)
static __inline void
m_tag_free(struct m_tag *t)
{
+
(*t->m_tag_free)(t);
}
@@ -816,6 +813,7 @@ m_tag_free(struct m_tag *t)
static __inline struct m_tag *
m_tag_first(struct mbuf *m)
{
+
return (SLIST_FIRST(&m->m_pkthdr.tags));
}
@@ -825,6 +823,7 @@ m_tag_first(struct mbuf *m)
static __inline struct m_tag *
m_tag_next(struct mbuf *m, struct m_tag *t)
{
+
return (SLIST_NEXT(t, m_tag_link));
}
@@ -834,6 +833,7 @@ m_tag_next(struct mbuf *m, struct m_tag *t)
static __inline void
m_tag_prepend(struct mbuf *m, struct m_tag *t)
{
+
SLIST_INSERT_HEAD(&m->m_pkthdr.tags, t, m_tag_link);
}
@@ -843,6 +843,7 @@ m_tag_prepend(struct mbuf *m, struct m_tag *t)
static __inline void
m_tag_unlink(struct mbuf *m, struct m_tag *t)
{
+
SLIST_REMOVE(&m->m_pkthdr.tags, t, m_tag, m_tag_link);
}