diff options
-rw-r--r-- | sys/kern/uipc_mbuf.c | 4 | ||||
-rw-r--r-- | sys/kern/uipc_mbuf2.c | 16 | ||||
-rw-r--r-- | sys/sys/mbuf.h | 27 |
3 files changed, 31 insertions, 16 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 3d4f7547b86..77832fc86fb 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_mbuf.c,v 1.125 2009/08/09 12:42:11 deraadt Exp $ */ +/* $OpenBSD: uipc_mbuf.c,v 1.126 2009/08/09 12:50:09 henning Exp $ */ /* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */ /* @@ -226,6 +226,7 @@ m_gethdr(int nowait, int type) m->m_pkthdr.rcvif = NULL; m->m_pkthdr.rdomain = 0; SLIST_INIT(&m->m_pkthdr.tags); + m->m_pkthdr.tagsset = 0; m->m_pkthdr.csum_flags = 0; m->m_pkthdr.ether_vtag = 0; m->m_pkthdr.pf.hdr = NULL; @@ -250,6 +251,7 @@ m_inithdr(struct mbuf *m) m->m_pkthdr.rcvif = NULL; m->m_pkthdr.rdomain = 0; SLIST_INIT(&m->m_pkthdr.tags); + m->m_pkthdr.tagsset = 0; m->m_pkthdr.csum_flags = 0; m->m_pkthdr.ether_vtag = 0; m->m_pkthdr.pf.hdr = NULL; diff --git a/sys/kern/uipc_mbuf2.c b/sys/kern/uipc_mbuf2.c index 60d3182fc7c..11b45a64d20 100644 --- a/sys/kern/uipc_mbuf2.c +++ b/sys/kern/uipc_mbuf2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_mbuf2.c,v 1.29 2008/11/30 18:22:15 deraadt Exp $ */ +/* $OpenBSD: uipc_mbuf2.c,v 1.30 2009/08/09 12:50:09 henning Exp $ */ /* $KAME: uipc_mbuf2.c,v 1.29 2001/02/14 13:42:10 itojun Exp $ */ /* $NetBSD: uipc_mbuf.c,v 1.40 1999/04/01 00:23:25 thorpej Exp $ */ @@ -276,14 +276,23 @@ void m_tag_prepend(struct mbuf *m, struct m_tag *t) { SLIST_INSERT_HEAD(&m->m_pkthdr.tags, t, m_tag_link); + m->m_pkthdr.tagsset |= t->m_tag_id; } /* Unlink and free a packet tag. */ void m_tag_delete(struct mbuf *m, struct m_tag *t) { + u_int32_t tagsset = 0; + struct m_tag *p; + SLIST_REMOVE(&m->m_pkthdr.tags, t, m_tag, m_tag_link); free(t, M_PACKET_TAGS); + + SLIST_FOREACH(p, &m->m_pkthdr.tags, m_tag_link) + tagsset |= p->m_tag_id; + m->m_pkthdr.tagsset = tagsset; + } /* Unlink and free a packet tag chain. */ @@ -296,6 +305,7 @@ m_tag_delete_chain(struct mbuf *m) SLIST_REMOVE_HEAD(&m->m_pkthdr.tags, m_tag_link); free(p, M_PACKET_TAGS); } + m->m_pkthdr.tagsset = 0; } /* Find a tag, starting from a given position. */ @@ -304,6 +314,9 @@ m_tag_find(struct mbuf *m, int type, struct m_tag *t) { struct m_tag *p; + if (!(m->m_pkthdr.tagsset & type)) + return (NULL); + if (t == NULL) p = SLIST_FIRST(&m->m_pkthdr.tags); else @@ -352,6 +365,7 @@ m_tag_copy_chain(struct mbuf *to, struct mbuf *from) else SLIST_INSERT_AFTER(tprev, t, m_tag_link); tprev = t; + to->m_pkthdr.tagsset |= t->m_tag_id; } return (1); } diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index f13314cc666..2a21c83412a 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mbuf.h,v 1.126 2009/08/09 12:42:09 deraadt Exp $ */ +/* $OpenBSD: mbuf.h,v 1.127 2009/08/09 12:50:09 henning Exp $ */ /* $NetBSD: mbuf.h,v 1.19 1996/02/09 18:25:14 christos Exp $ */ /* @@ -96,6 +96,7 @@ struct pkthdr { struct ifnet *rcvif; /* rcv interface */ SLIST_HEAD(packet_tags, m_tag) tags; /* list of packet tags */ int len; /* total packet length */ + u_int32_t tagsset; /* mtags attached */ u_int16_t csum_flags; /* checksum flags */ u_int16_t ether_vtag; /* Ethernet 802.1p+Q vlan tag */ u_int rdomain; /* routing domain id */ @@ -453,19 +454,17 @@ struct m_tag *m_tag_first(struct mbuf *); struct m_tag *m_tag_next(struct mbuf *, struct m_tag *); /* Packet tag types */ -#define PACKET_TAG_NONE 0 /* Nadda */ -#define PACKET_TAG_IPSEC_IN_DONE 1 /* IPsec applied, in */ -#define PACKET_TAG_IPSEC_OUT_DONE 2 /* IPsec applied, out */ -#define PACKET_TAG_IPSEC_IN_CRYPTO_DONE 3 /* NIC IPsec crypto done */ -#define PACKET_TAG_IPSEC_OUT_CRYPTO_NEEDED 4 /* NIC IPsec crypto req'ed */ -#define PACKET_TAG_IPSEC_IN_COULD_DO_CRYPTO 5 /* NIC notifies IPsec */ -#define PACKET_TAG_IPSEC_PENDING_TDB 6 /* Reminder to do IPsec */ -#define PACKET_TAG_BRIDGE 7 /* Bridge processing done */ -#define PACKET_TAG_GIF 8 /* GIF processing done */ -#define PACKET_TAG_GRE 9 /* GRE processing done */ -#define PACKET_TAG_IN_PACKET_CHECKSUM 10 /* NIC checksumming done */ -#define PACKET_TAG_DLT 17 /* data link layer type */ -#define PACKET_TAG_PF_DIVERT 18 /* pf(4) diverted packet */ +#define PACKET_TAG_NONE 0x0000 /* Nadda */ +#define PACKET_TAG_IPSEC_IN_DONE 0x0001 /* IPsec applied, in */ +#define PACKET_TAG_IPSEC_OUT_DONE 0x0002 /* IPsec applied, out */ +#define PACKET_TAG_IPSEC_IN_CRYPTO_DONE 0x0004 /* NIC IPsec crypto done */ +#define PACKET_TAG_IPSEC_OUT_CRYPTO_NEEDED 0x0008 /* NIC IPsec crypto req'ed */ +#define PACKET_TAG_IPSEC_PENDING_TDB 0x0010 /* Reminder to do IPsec */ +#define PACKET_TAG_BRIDGE 0x0020 /* Bridge processing done */ +#define PACKET_TAG_GIF 0x0040 /* GIF processing done */ +#define PACKET_TAG_GRE 0x0080 /* GRE processing done */ +#define PACKET_TAG_DLT 0x0100 /* data link layer type */ +#define PACKET_TAG_PF_DIVERT 0x0200 /* pf(4) diverted packet */ #ifdef MBTYPES int mbtypes[] = { /* XXX */ |