summaryrefslogtreecommitdiff
path: root/sys/netinet
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2010-10-28 16:36:17 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2010-10-28 16:36:17 +0000
commit05baaf8a666796a6727dba0db2ba624d889368ba (patch)
treeffbbd18eee56177ce557fdbaabe6ef550392aa87 /sys/netinet
parent85efe138be045a66de391641d357536cd029c4ae (diff)
Normalize mbuf after prepending space for the header since the data
in the mbuf my be improperly aligned. Whenever a function is reinjecting packets from low level output functions into high level output functions (like ip_output) it must be guaranteed that the mbuf data is properliy aligned. OK blambert@, deraadt@
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/ip_ether.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/sys/netinet/ip_ether.c b/sys/netinet/ip_ether.c
index cf52c76e011..b030ec4bdd7 100644
--- a/sys/netinet/ip_ether.c
+++ b/sys/netinet/ip_ether.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ether.c,v 1.55 2010/07/02 02:40:16 blambert Exp $ */
+/* $OpenBSD: ip_ether.c,v 1.56 2010/10/28 16:36:16 claudio Exp $ */
/*
* The author of this code is Angelos D. Keromytis (kermit@adk.gr)
*
@@ -501,6 +501,18 @@ etherip_output(struct mbuf *m, struct tdb *tdb, struct mbuf **mp, int proto)
return ENOBUFS;
}
+ /*
+ * Normalize mbuf so that it can be reinjected into higherlevel
+ * output functions (alignment also required in this function).
+ */
+ if ((long)mtod(m, caddr_t) & 0x03) {
+ int off = (long)mtod(m, caddr_t) & 0x03;
+ if (M_LEADINGSPACE(m) < off)
+ panic("etherip_output: no space for align fixup");
+ m->m_data -= off;
+ bcopy(mtod(m, caddr_t) + off, mtod(m, caddr_t), m->m_len);
+ }
+
/* Statistics */
etheripstat.etherip_opackets++;
etheripstat.etherip_obytes += m->m_pkthdr.len - hlen;