From owner-p4-projects@FreeBSD.ORG Tue Oct 7 12:04:09 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 1DFCC16A4C0; Tue, 7 Oct 2003 12:04:09 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D036C16A4B3 for ; Tue, 7 Oct 2003 12:04:08 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 53EA843FE3 for ; Tue, 7 Oct 2003 12:04:07 -0700 (PDT) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id h97J47XJ069441 for ; Tue, 7 Oct 2003 12:04:07 -0700 (PDT) (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id h97J461F069438 for perforce@freebsd.org; Tue, 7 Oct 2003 12:04:06 -0700 (PDT) (envelope-from sam@freebsd.org) Date: Tue, 7 Oct 2003 12:04:06 -0700 (PDT) Message-Id: <200310071904.h97J461F069438@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Subject: PERFORCE change 39325 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Oct 2003 19:04:09 -0000 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 */