Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys - introduce M_MOVE_PKTHDR and use it where appropriate.
details: https://anonhg.NetBSD.org/src/rev/2531cc1b6c17
branches: trunk
changeset: 583652:2531cc1b6c17
user: yamt <yamt%NetBSD.org@localhost>
date: Thu Aug 18 00:30:58 2005 +0000
description:
- introduce M_MOVE_PKTHDR and use it where appropriate.
intended to be mostly API compatible with openbsd/freebsd.
- remove a glue #define in netipsec/ipsec_osdep.h.
diffstat:
sys/kern/uipc_mbuf.c | 34 +++++++++++++++++++++-------------
sys/net/if_ecosubr.c | 10 +++++-----
sys/net/if_sl.c | 11 ++++++-----
sys/net/if_strip.c | 11 ++++++-----
sys/net80211/ieee80211_input.c | 6 +++---
sys/net80211/ieee80211_output.c | 6 +++---
sys/netinet/ip_output.c | 8 +++-----
sys/netinet6/icmp6.c | 9 ++++-----
sys/netinet6/ip6_output.c | 8 +++-----
sys/netinet6/ipsec.c | 14 +++++---------
sys/netipsec/ipsec_osdep.h | 17 ++++-------------
sys/sys/mbuf.h | 9 ++++++++-
12 files changed, 71 insertions(+), 72 deletions(-)
diffs (truncated from 466 to 300 lines):
diff -r 0de1bd6d38b1 -r 2531cc1b6c17 sys/kern/uipc_mbuf.c
--- a/sys/kern/uipc_mbuf.c Thu Aug 18 00:19:28 2005 +0000
+++ b/sys/kern/uipc_mbuf.c Thu Aug 18 00:30:58 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_mbuf.c,v 1.100 2005/06/06 06:06:50 martin Exp $ */
+/* $NetBSD: uipc_mbuf.c,v 1.101 2005/08/18 00:30:58 yamt Exp $ */
/*-
* Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.100 2005/06/06 06:06:50 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.101 2005/08/18 00:30:58 yamt Exp $");
#include "opt_mbuftrace.h"
@@ -489,9 +489,7 @@
return ((struct mbuf *)NULL);
}
if (m->m_flags & M_PKTHDR) {
- M_COPY_PKTHDR(mn, m);
- m_tag_delete_chain(m, NULL);
- m->m_flags &= ~M_PKTHDR;
+ M_MOVE_PKTHDR(mn, m);
} else {
MCLAIM(mn, m->m_owner);
}
@@ -831,9 +829,7 @@
MCLAIM(m, n->m_owner);
m->m_len = 0;
if (n->m_flags & M_PKTHDR) {
- M_COPY_PKTHDR(m, n);
- m_tag_delete_chain(n, NULL);
- n->m_flags &= ~M_PKTHDR;
+ M_MOVE_PKTHDR(m, n);
}
}
space = &m->m_dat[MLEN] - (m->m_data + m->m_len);
@@ -883,9 +879,7 @@
MCLAIM(m, n->m_owner);
m->m_len = 0;
if (n->m_flags & M_PKTHDR) {
- M_COPY_PKTHDR(m, n);
- m_tag_delete_chain(n, NULL);
- n->m_flags &= ~M_PKTHDR;
+ M_MOVE_PKTHDR(m, n);
}
m->m_data += dstoff;
space = &m->m_dat[MLEN] - (m->m_data + m->m_len);
@@ -1218,8 +1212,7 @@
goto enobufs;
MCLAIM(n, m->m_owner);
if (off == 0 && (m->m_flags & M_PKTHDR) != 0) {
- /* XXX M_MOVE_PKTHDR */
- M_COPY_PKTHDR(n, m);
+ M_MOVE_PKTHDR(n, m);
n->m_len = MHLEN;
} else {
if (len >= MINCLSIZE)
@@ -1303,6 +1296,21 @@
return ENOBUFS;
}
+void
+m_move_pkthdr(struct mbuf *to, struct mbuf *from)
+{
+
+ KASSERT((to->m_flags & M_EXT) == 0);
+ KASSERT((to->m_flags & M_PKTHDR) == 0 || m_tag_first(to) == NULL);
+ KASSERT((from->m_flags & M_PKTHDR) != 0);
+
+ to->m_pkthdr = from->m_pkthdr;
+ to->m_flags = from->m_flags & M_COPYFLAGS;
+ to->m_data = to->m_pktdat;
+
+ from->m_flags &= ~M_PKTHDR;
+}
+
/*
* Apply function f to the data in an mbuf chain starting "off" bytes from the
* beginning, continuing for "len" bytes.
diff -r 0de1bd6d38b1 -r 2531cc1b6c17 sys/net/if_ecosubr.c
--- a/sys/net/if_ecosubr.c Thu Aug 18 00:19:28 2005 +0000
+++ b/sys/net/if_ecosubr.c Thu Aug 18 00:30:58 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ecosubr.c,v 1.16 2005/03/31 15:48:13 christos Exp $ */
+/* $NetBSD: if_ecosubr.c,v 1.17 2005/08/18 00:30:58 yamt Exp $ */
/*-
* Copyright (c) 2001 Ben Harris
@@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ecosubr.c,v 1.16 2005/03/31 15:48:13 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ecosubr.c,v 1.17 2005/08/18 00:30:58 yamt Exp $");
#include "bpfilter.h"
#include "opt_inet.h"
@@ -66,7 +66,7 @@
#include <sys/param.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ecosubr.c,v 1.16 2005/03/31 15:48:13 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ecosubr.c,v 1.17 2005/08/18 00:30:58 yamt Exp $");
#include <sys/errno.h>
#include <sys/kernel.h>
@@ -274,7 +274,7 @@
MGETHDR(m1, M_DONTWAIT, MT_DATA);
if (m1 == NULL)
senderr(ENOBUFS);
- M_COPY_PKTHDR(m1, m);
+ M_MOVE_PKTHDR(m1, m);
m1->m_len = sizeof(*ecah);
m1->m_pkthdr.len = m1->m_len;
MH_ALIGN(m1, m1->m_len);
@@ -413,7 +413,7 @@
MGETHDR(m1, M_DONTWAIT, MT_DATA);
if (m1 == NULL)
goto drop;
- M_COPY_PKTHDR(m1, m);
+ M_MOVE_PKTHDR(m1, m);
m1->m_len = sizeof(*ah) + 2*sizeof(struct in_addr) +
2*ifp->if_data.ifi_addrlen;
m1->m_pkthdr.len = m1->m_len;
diff -r 0de1bd6d38b1 -r 2531cc1b6c17 sys/net/if_sl.c
--- a/sys/net/if_sl.c Thu Aug 18 00:19:28 2005 +0000
+++ b/sys/net/if_sl.c Thu Aug 18 00:30:58 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_sl.c,v 1.91 2005/03/31 15:48:13 christos Exp $ */
+/* $NetBSD: if_sl.c,v 1.92 2005/08/18 00:30:58 yamt Exp $ */
/*
* Copyright (c) 1987, 1989, 1992, 1993
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_sl.c,v 1.91 2005/03/31 15:48:13 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_sl.c,v 1.92 2005/08/18 00:30:58 yamt Exp $");
#include "opt_inet.h"
#include "bpfilter.h"
@@ -964,11 +964,12 @@
*/
if (m->m_pkthdr.len < MHLEN) {
struct mbuf *n;
+ int pktlen;
MGETHDR(n, M_DONTWAIT, MT_DATA);
- M_COPY_PKTHDR(n, m);
- memcpy(mtod(n, caddr_t), mtod(m, caddr_t),
- m->m_pkthdr.len);
+ pktlen = m->m_pkthdr.len;
+ M_MOVE_PKTHDR(n, m);
+ memcpy(mtod(n, caddr_t), mtod(m, caddr_t), pktlen);
n->m_len = m->m_len;
m_freem(m);
m = n;
diff -r 0de1bd6d38b1 -r 2531cc1b6c17 sys/net/if_strip.c
--- a/sys/net/if_strip.c Thu Aug 18 00:19:28 2005 +0000
+++ b/sys/net/if_strip.c Thu Aug 18 00:30:58 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_strip.c,v 1.60 2005/05/29 21:22:53 christos Exp $ */
+/* $NetBSD: if_strip.c,v 1.61 2005/08/18 00:30:58 yamt Exp $ */
/* from: NetBSD: if_sl.c,v 1.38 1996/02/13 22:00:23 christos Exp $ */
/*
@@ -87,7 +87,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_strip.c,v 1.60 2005/05/29 21:22:53 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_strip.c,v 1.61 2005/08/18 00:30:58 yamt Exp $");
#include "opt_inet.h"
#include "bpfilter.h"
@@ -1271,11 +1271,12 @@
*/
if (m->m_pkthdr.len < MHLEN) {
struct mbuf *n;
+ int pktlen;
MGETHDR(n, M_DONTWAIT, MT_DATA);
- M_COPY_PKTHDR(n, m);
- memcpy(mtod(n, caddr_t), mtod(m, caddr_t),
- m->m_pkthdr.len);
+ pktlen = m->m_pkthdr.len;
+ M_MOVE_PKTHDR(n, m);
+ memcpy(mtod(n, caddr_t), mtod(m, caddr_t), pktlen);
n->m_len = m->m_len;
m_freem(m);
m = n;
diff -r 0de1bd6d38b1 -r 2531cc1b6c17 sys/net80211/ieee80211_input.c
--- a/sys/net80211/ieee80211_input.c Thu Aug 18 00:19:28 2005 +0000
+++ b/sys/net80211/ieee80211_input.c Thu Aug 18 00:30:58 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ieee80211_input.c,v 1.44 2005/07/26 22:52:48 dyoung Exp $ */
+/* $NetBSD: ieee80211_input.c,v 1.45 2005/08/18 00:30:59 yamt Exp $ */
/*-
* Copyright (c) 2001 Atsushi Onoe
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@@ -36,7 +36,7 @@
__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_input.c,v 1.62 2005/07/11 03:00:20 sam Exp $");
#endif
#ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_input.c,v 1.44 2005/07/26 22:52:48 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_input.c,v 1.45 2005/08/18 00:30:59 yamt Exp $");
#endif
#include "opt_inet.h"
@@ -826,7 +826,7 @@
m_freem(m);
return NULL;
}
- M_COPY_PKTHDR(n, m);
+ M_MOVE_PKTHDR(n, m);
n->m_len = MHLEN;
} else {
MGET(n, M_DONTWAIT, MT_DATA);
diff -r 0de1bd6d38b1 -r 2531cc1b6c17 sys/net80211/ieee80211_output.c
--- a/sys/net80211/ieee80211_output.c Thu Aug 18 00:19:28 2005 +0000
+++ b/sys/net80211/ieee80211_output.c Thu Aug 18 00:30:58 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ieee80211_output.c,v 1.35 2005/08/16 02:12:58 dyoung Exp $ */
+/* $NetBSD: ieee80211_output.c,v 1.36 2005/08/18 00:30:59 yamt Exp $ */
/*-
* Copyright (c) 2001 Atsushi Onoe
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@@ -36,7 +36,7 @@
__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_output.c,v 1.26 2005/07/06 01:55:17 sam Exp $");
#endif
#ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_output.c,v 1.35 2005/08/16 02:12:58 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_output.c,v 1.36 2005/08/18 00:30:59 yamt Exp $");
#endif
#include "opt_inet.h"
@@ -386,7 +386,7 @@
* back to ieee80211_crypto_encap to do crypto encapsulation).
*/
/* NB: must be first 'cuz it clobbers m_data */
- M_COPY_PKTHDR(n, m);
+ M_MOVE_PKTHDR(n, m);
n->m_len = 0; /* NB: m_gethdr does not set */
n->m_data += needed_space;
/*
diff -r 0de1bd6d38b1 -r 2531cc1b6c17 sys/netinet/ip_output.c
--- a/sys/netinet/ip_output.c Thu Aug 18 00:19:28 2005 +0000
+++ b/sys/netinet/ip_output.c Thu Aug 18 00:30:58 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_output.c,v 1.154 2005/08/10 13:06:49 yamt Exp $ */
+/* $NetBSD: ip_output.c,v 1.155 2005/08/18 00:30:59 yamt Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -98,7 +98,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.154 2005/08/10 13:06:49 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.155 2005/08/18 00:30:59 yamt Exp $");
#include "opt_pfil_hooks.h"
#include "opt_inet.h"
@@ -1175,9 +1175,7 @@
if (n == 0)
return (m);
MCLAIM(n, m->m_owner);
- M_COPY_PKTHDR(n, m);
- m_tag_delete_chain(m, NULL);
- m->m_flags &= ~M_PKTHDR;
+ M_MOVE_PKTHDR(n, m);
m->m_len -= sizeof(struct ip);
m->m_data += sizeof(struct ip);
n->m_next = m;
diff -r 0de1bd6d38b1 -r 2531cc1b6c17 sys/netinet6/icmp6.c
--- a/sys/netinet6/icmp6.c Thu Aug 18 00:19:28 2005 +0000
+++ b/sys/netinet6/icmp6.c Thu Aug 18 00:30:58 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: icmp6.c,v 1.109 2005/05/29 21:43:51 christos Exp $ */
+/* $NetBSD: icmp6.c,v 1.110 2005/08/18 00:30:59 yamt Exp $ */
/* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.109 2005/05/29 21:43:51 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.110 2005/08/18 00:30:59 yamt Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@@ -601,7 +601,7 @@
m = NULL;
goto deliverecho;
Home |
Main Index |
Thread Index |
Old Index