Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Add m_tag_delete_nonpesrsistent(), for deleting all pack...



details:   https://anonhg.NetBSD.org/src/rev/151d0fa3f845
branches:  trunk
changeset: 555264:151d0fa3f845
user:      jonathan <jonathan%NetBSD.org@localhost>
date:      Thu Nov 13 01:48:12 2003 +0000

description:
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.

diffstat:

 sys/kern/uipc_mbuf2.c |  21 ++++++++++++++++++---
 sys/net/if_loop.c     |   6 ++++--
 sys/netinet/ip_icmp.c |   5 +++--
 sys/sys/mbuf.h        |   3 ++-
 4 files changed, 27 insertions(+), 8 deletions(-)

diffs (119 lines):

diff -r 17e5d544c42a -r 151d0fa3f845 sys/kern/uipc_mbuf2.c
--- a/sys/kern/uipc_mbuf2.c     Thu Nov 13 01:44:36 2003 +0000
+++ b/sys/kern/uipc_mbuf2.c     Thu Nov 13 01:48:12 2003 +0000
@@ -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 @@
 }
 
 /* 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(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)
diff -r 17e5d544c42a -r 151d0fa3f845 sys/net/if_loop.c
--- a/sys/net/if_loop.c Thu Nov 13 01:44:36 2003 +0000
+++ b/sys/net/if_loop.c Thu Nov 13 01:48:12 2003 +0000
@@ -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 @@
        }
 #endif /* ALTQ */
 
+       m_tag_delete_nonpersistent(m);
+
        switch (dst->sa_family) {
 
 #ifdef INET
diff -r 17e5d544c42a -r 151d0fa3f845 sys/netinet/ip_icmp.c
--- a/sys/netinet/ip_icmp.c     Thu Nov 13 01:44:36 2003 +0000
+++ b/sys/netinet/ip_icmp.c     Thu Nov 13 01:48:12 2003 +0000
@@ -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 @@
                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);
 
        /*      
diff -r 17e5d544c42a -r 151d0fa3f845 sys/sys/mbuf.h
--- a/sys/sys/mbuf.h    Thu Nov 13 01:44:36 2003 +0000
+++ b/sys/sys/mbuf.h    Thu Nov 13 01:48:12 2003 +0000
@@ -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_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 *);



Home | Main Index | Thread Index | Old Index