Date: Tue, 7 Oct 2003 12:04:06 -0700 (PDT) From: Sam Leffler <sam@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 39325 for review Message-ID: <200310071904.h97J461F069438@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=39325 Change 39325 by sam@sam_ebb on 2003/10/07 12:03:33 Add notion of persistent tags and strip all non-persistent tags when mbufs are "turned around" through the loopback interface or in ICMP. Affected files ... .. //depot/projects/netperf/sys/kern/uipc_mbuf2.c#2 edit .. //depot/projects/netperf/sys/net/if_loop.c#6 edit .. //depot/projects/netperf/sys/netinet/ip_icmp.c#5 edit .. //depot/projects/netperf/sys/sys/mbuf.h#3 edit Differences ... ==== //depot/projects/netperf/sys/kern/uipc_mbuf2.c#2 (text+ko) ==== @@ -381,6 +381,23 @@ m_tag_delete(m, p); } +/* + * Strip off all tags that would normally vanish when + * passing through a network interface. Only persistent + * tags will exist after this; these are expected to remain + * so long as the mbuf chain exists, regardless of the + * path the mbufs take. + */ +void +m_tag_delete_nonpersistent(struct mbuf *m) +{ + struct m_tag *p, *q; + + SLIST_FOREACH_SAFE(p, &m->m_pkthdr.tags, m_tag_link, q) + if ((p->m_tag_id & MTAG_PERSISTENT) == 0) + m_tag_delete(m, p); +} + /* Find a tag, starting from a given position. */ struct m_tag * m_tag_locate(struct mbuf *m, u_int32_t cookie, int type, struct m_tag *t) ==== //depot/projects/netperf/sys/net/if_loop.c#6 (text+ko) ==== @@ -266,6 +266,7 @@ int isr; M_ASSERTPKTHDR(m); + m_tag_delete_nonpersistent(m); m->m_pkthdr.rcvif = ifp; /* BPF write needs to be handled specially */ ==== //depot/projects/netperf/sys/netinet/ip_icmp.c#5 (text+ko) ==== @@ -728,6 +728,7 @@ bcopy((caddr_t)ip + optlen, (caddr_t)(ip + 1), (unsigned)(m->m_len - sizeof(struct ip))); } + m_tag_delete_nonpersistent(m); m->m_flags &= ~(M_BCAST|M_MCAST); icmp_send(m, opts, ro); done: ==== //depot/projects/netperf/sys/sys/mbuf.h#3 (text+ko) ==== @@ -498,6 +498,21 @@ * struct m_tag *mtag = &p->tag; */ +/* + * 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. + */ +#define MTAG_PERSISTENT 0x800 + #define PACKET_TAG_NONE 0 /* Nadda */ /* Packet tag for use with PACKET_ABI_COMPAT */ @@ -535,7 +550,7 @@ #define PACKET_TAG_IPFW 16 /* ipfw classification */ #define PACKET_TAG_DIVERT 17 /* divert info */ #define PACKET_TAG_IPFORWARD 18 /* ipforward info */ -#define PACKET_TAG_MACLABEL 19 /* MAC label */ +#define PACKET_TAG_MACLABEL (19 | MTAG_PERSISTENT) /* MAC label */ /* Packet tag routines */ struct m_tag *m_tag_alloc(u_int32_t, int, int, int); @@ -550,6 +565,7 @@ void m_tag_init(struct mbuf *); struct m_tag *m_tag_first(struct mbuf *); struct m_tag *m_tag_next(struct mbuf *, struct m_tag *); +void m_tag_delete_nonpersistent(struct mbuf *); /* these are for openbsd compatibility */ #define MTAG_ABI_COMPAT 0 /* compatibility ABI */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200310071904.h97J461F069438>