Add m_tag_delete_nonpesrsistent(), for deleting all packet tags on

mbuf chains which are recycled (e.g., ICMP reflection, loopback
interface).  A consensus was reached that such recycled packets should
behave (more-or-less) the same way if a new chain had been allocated
and the contents copied to that chain.

Some packet tags may in future be marked as "persistent" (e.g., for
mandatory access controls) and should persist across such deletion.
NetBSD as yet hos no persistent tags, so m_tag_delete_nonpersistent()
just deletes all tags. This should not be relied upon.
This commit is contained in:
jonathan 2003-11-13 01:48:12 +00:00
parent a0e314dfe4
commit fa24e6f3f8
4 changed files with 27 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: uipc_mbuf2.c,v 1.15 2003/08/07 16:31:58 agc Exp $ */
/* $NetBSD: uipc_mbuf2.c,v 1.16 2003/11/13 01:48:12 jonathan Exp $ */
/* $KAME: uipc_mbuf2.c,v 1.29 2001/02/14 13:42:10 itojun Exp $ */
/*
@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf2.c,v 1.15 2003/08/07 16:31:58 agc Exp $");
__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf2.c,v 1.16 2003/11/13 01:48:12 jonathan Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -268,7 +268,7 @@ m_tag_delete(struct mbuf *m, struct m_tag *t)
}
/* Unlink and free a packet tag chain, starting from given tag. */
void
__inline void
m_tag_delete_chain(struct mbuf *m, struct m_tag *t)
{
struct m_tag *p, *q;
@ -284,6 +284,21 @@ m_tag_delete_chain(struct mbuf *m, struct m_tag *t)
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)
{
/* NetBSD has no persistent tags yet, so just delete all tags. */
return m_tag_delete_chain(m, NULL);
}
/* Find a tag, starting from a given position. */
struct m_tag *
m_tag_find(struct mbuf *m, int type, struct m_tag *t)

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_loop.c,v 1.48 2003/08/15 19:22:08 jonathan Exp $ */
/* $NetBSD: if_loop.c,v 1.49 2003/11/13 01:48:13 jonathan Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.48 2003/08/15 19:22:08 jonathan Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.49 2003/11/13 01:48:13 jonathan Exp $");
#include "opt_inet.h"
#include "opt_atalk.h"
@ -259,6 +259,8 @@ looutput(ifp, m, dst, rt)
}
#endif /* ALTQ */
m_tag_delete_nonpersistent(m);
switch (dst->sa_family) {
#ifdef INET

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_icmp.c,v 1.79 2003/11/11 20:25:26 jonathan Exp $ */
/* $NetBSD: ip_icmp.c,v 1.80 2003/11/13 01:48:13 jonathan Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -101,7 +101,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.79 2003/11/11 20:25:26 jonathan Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.80 2003/11/13 01:48:13 jonathan Exp $");
#include "opt_ipsec.h"
@ -835,6 +835,7 @@ icmp_reflect(m)
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);
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: mbuf.h,v 1.87 2003/08/07 16:34:08 agc Exp $ */
/* $NetBSD: mbuf.h,v 1.88 2003/11/13 01:48:12 jonathan Exp $ */
/*-
* Copyright (c) 1996, 1997, 1999, 2001 The NetBSD Foundation, Inc.
@ -892,6 +892,7 @@ void m_tag_prepend(struct mbuf *, struct m_tag *);
void m_tag_unlink(struct mbuf *, struct m_tag *);
void m_tag_delete(struct mbuf *, struct m_tag *);
void m_tag_delete_chain(struct mbuf *, struct m_tag *);
void m_tag_delete_nonpersistent(struct mbuf *);
struct m_tag *m_tag_find(struct mbuf *, int, struct m_tag *);
struct m_tag *m_tag_copy(struct m_tag *);
int m_tag_copy_chain(struct mbuf *, struct mbuf *);