Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-8]: src/sys/net Pull up following revision(s) (requested by knaka...
details: https://anonhg.NetBSD.org/src/rev/6dcd889a9aeb
branches: netbsd-8
changeset: 434875:6dcd889a9aeb
user: martin <martin%NetBSD.org@localhost>
date: Wed Apr 11 14:15:45 2018 +0000
description:
Pull up following revision(s) (requested by knakahara in ticket #730):
sys/net/if_l2tp.c: revision 1.22
sys/net/if_l2tp.c: revision 1.23
Improve comment. Pointed out by maxv@n.o, thanks.
Fix previous my mistake and odd unaligned case. Pointed out by maxv@n.o, thanks.
It must be rare case to be required this copy routine...
diffstat:
sys/net/if_l2tp.c | 25 +++++++++++++++++++++----
1 files changed, 21 insertions(+), 4 deletions(-)
diffs (57 lines):
diff -r cbb8a4ec9ffa -r 6dcd889a9aeb sys/net/if_l2tp.c
--- a/sys/net/if_l2tp.c Wed Apr 11 03:00:03 2018 +0000
+++ b/sys/net/if_l2tp.c Wed Apr 11 14:15:45 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_l2tp.c,v 1.11.2.6 2018/04/09 13:40:20 bouyer Exp $ */
+/* $NetBSD: if_l2tp.c,v 1.11.2.7 2018/04/11 14:15:45 martin Exp $ */
/*
* Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.11.2.6 2018/04/09 13:40:20 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.11.2.7 2018/04/11 14:15:45 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -477,11 +477,16 @@
return;
}
+ /*
+ * If the head of the payload is not aligned, align it.
+ */
addr = mtod(m, vaddr_t);
- if ((addr & 0x03) == 0) {
+ if ((addr & 0x03) != 0x2) {
/* copy and align head of payload */
struct mbuf *m_head;
int copy_length;
+ u_int pad = roundup(sizeof(struct ether_header), 4)
+ - sizeof(struct ether_header);
#define L2TP_COPY_LENGTH 60
@@ -504,7 +509,19 @@
}
M_COPY_PKTHDR(m_head, m);
- MH_ALIGN(m_head, L2TP_COPY_LENGTH);
+ /*
+ * m_head should be:
+ * L2TP_COPY_LENGTH
+ * <- + roundup(pad, 4) - pad ->
+ * +-------+--------+-----+--------------+-------------+
+ * | m_hdr | pkthdr | ... | ether header | payload |
+ * +-------+--------+-----+--------------+-------------+
+ * ^ ^
+ * m_data 4 byte aligned
+ */
+ MH_ALIGN(m_head, L2TP_COPY_LENGTH + roundup(pad, 4));
+ m_head->m_data += pad;
+
memcpy(mtod(m_head, void *), mtod(m, void *), copy_length);
m_head->m_len = copy_length;
m->m_data += copy_length;
Home |
Main Index |
Thread Index |
Old Index