summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2007-01-03 18:39:57 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2007-01-03 18:39:57 +0000
commit3c06cae61abedff44f961de3bea1f802e150b7d0 (patch)
tree9d9f67957bfae6228f243ea815cdcbbe60c0db9b /sys
parentd8ed1054415585ff91573c64d88c0c2a67483a28 (diff)
Remove two "unused" mbuf tag functions and kill the superfluous argument
to the m_tag_delete_chain() function. m_tag_free() and m_tag_unlink() are only used by m_tag_delete() and I see no need to have these functions around. m_tag_delete_chain() has a second argument to specifiy a starting point from where the chain should be deleted. This feature is never used and is more complex because it is not possible to remove a SLIST element without doing a list walk. Instead use SLIST_FIRST() and SLIST_REMOVE_HEAD() to remove all items from the list. OK dhartmei@
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/uipc_mbuf2.c43
-rw-r--r--sys/netinet/ip_icmp.c8
-rw-r--r--sys/sys/mbuf.h8
3 files changed, 19 insertions, 40 deletions
diff --git a/sys/kern/uipc_mbuf2.c b/sys/kern/uipc_mbuf2.c
index dce50e93814..68c10a969d5 100644
--- a/sys/kern/uipc_mbuf2.c
+++ b/sys/kern/uipc_mbuf2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_mbuf2.c,v 1.25 2006/11/18 08:20:51 jmc Exp $ */
+/* $OpenBSD: uipc_mbuf2.c,v 1.26 2007/01/03 18:39:56 claudio 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 $ */
@@ -273,13 +273,6 @@ m_tag_get(int type, int len, int wait)
return (t);
}
-/* Free a packet tag. */
-void
-m_tag_free(struct m_tag *t)
-{
- free(t, M_PACKET_TAGS);
-}
-
/* Prepend a packet tag. */
void
m_tag_prepend(struct mbuf *m, struct m_tag *t)
@@ -287,36 +280,24 @@ m_tag_prepend(struct mbuf *m, struct m_tag *t)
SLIST_INSERT_HEAD(&m->m_pkthdr.tags, t, m_tag_link);
}
-/* Unlink a packet tag. */
-void
-m_tag_unlink(struct mbuf *m, struct m_tag *t)
-{
- SLIST_REMOVE(&m->m_pkthdr.tags, t, m_tag, m_tag_link);
-}
-
/* Unlink and free a packet tag. */
void
m_tag_delete(struct mbuf *m, struct m_tag *t)
{
- m_tag_unlink(m, t);
- m_tag_free(t);
+ SLIST_REMOVE(&m->m_pkthdr.tags, t, m_tag, m_tag_link);
+ free(t, M_PACKET_TAGS);
}
-/* Unlink and free a packet tag chain, starting from given tag. */
+/* Unlink and free a packet tag chain. */
void
-m_tag_delete_chain(struct mbuf *m, struct m_tag *t)
+m_tag_delete_chain(struct mbuf *m)
{
- struct m_tag *p, *q;
+ struct m_tag *p;
- if (t != NULL)
- p = t;
- else
- p = SLIST_FIRST(&m->m_pkthdr.tags);
- if (p == NULL)
- return;
- while ((q = SLIST_NEXT(p, m_tag_link)) != NULL)
- m_tag_delete(m, q);
- m_tag_delete(m, p);
+ while ((p = SLIST_FIRST(&m->m_pkthdr.tags)) != NULL) {
+ SLIST_REMOVE_HEAD(&m->m_pkthdr.tags, m_tag_link);
+ free(p, M_PACKET_TAGS);
+ }
}
/* Find a tag, starting from a given position. */
@@ -361,11 +342,11 @@ m_tag_copy_chain(struct mbuf *to, struct mbuf *from)
{
struct m_tag *p, *t, *tprev = NULL;
- m_tag_delete_chain(to, NULL);
+ m_tag_delete_chain(to);
SLIST_FOREACH(p, &from->m_pkthdr.tags, m_tag_link) {
t = m_tag_copy(p);
if (t == NULL) {
- m_tag_delete_chain(to, NULL);
+ m_tag_delete_chain(to);
return (0);
}
if (tprev == NULL)
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c
index f32d3cf5e22..08861700058 100644
--- a/sys/netinet/ip_icmp.c
+++ b/sys/netinet/ip_icmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_icmp.c,v 1.71 2006/06/16 16:49:40 henning Exp $ */
+/* $OpenBSD: ip_icmp.c,v 1.72 2007/01/03 18:39:56 claudio Exp $ */
/* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */
/*
@@ -414,7 +414,7 @@ icmp_input(struct mbuf *m, ...)
deliver:
/* Free packet atttributes */
if (m->m_flags & M_PKTHDR)
- m_tag_delete_chain(m, NULL);
+ m_tag_delete_chain(m);
/*
* Problem with datagram; advise higher level routines.
@@ -523,7 +523,7 @@ icmp_input(struct mbuf *m, ...)
reflect:
/* Free packet atttributes */
if (m->m_flags & M_PKTHDR)
- m_tag_delete_chain(m, NULL);
+ m_tag_delete_chain(m);
icmpstat.icps_reflect++;
icmpstat.icps_outhist[icp->icmp_type]++;
@@ -533,7 +533,7 @@ reflect:
case ICMP_REDIRECT:
/* Free packet atttributes */
if (m->m_flags & M_PKTHDR)
- m_tag_delete_chain(m, NULL);
+ m_tag_delete_chain(m);
if (icmp_rediraccept == 0)
goto freeit;
if (code > 3)
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
index c9ad117008e..20cd9ad6e2c 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mbuf.h,v 1.85 2005/11/12 20:27:46 brad Exp $ */
+/* $OpenBSD: mbuf.h,v 1.86 2007/01/03 18:39:56 claudio Exp $ */
/* $NetBSD: mbuf.h,v 1.19 1996/02/09 18:25:14 christos Exp $ */
/*
@@ -383,7 +383,7 @@ void _sk_mclget(struct mbuf *, int);
MBUFLOCK( \
mbstat.m_mtypes[(m)->m_type]--; \
if ((m)->m_flags & M_PKTHDR) \
- m_tag_delete_chain((m), NULL); \
+ m_tag_delete_chain((m)); \
if ((m)->m_flags & M_EXT) { \
_MEXTREMOVE((m)); \
} \
@@ -562,11 +562,9 @@ int m_apply(struct mbuf *, int, int,
/* Packet tag routines */
struct m_tag *m_tag_get(int, int, int);
-void m_tag_free(struct m_tag *);
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_chain(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 *);