summaryrefslogtreecommitdiff
path: root/sys/compat/linux/common
diff options
context:
space:
mode:
authornjoly <njoly@NetBSD.org>2009-06-16 23:17:02 +0000
committernjoly <njoly@NetBSD.org>2009-06-16 23:17:02 +0000
commitcb90fdddc481aa9a4a04fc5fd5240f7ad5ff7e68 (patch)
tree1d52e6f315651370fd9c20fd186429af5a9f0ac9 /sys/compat/linux/common
parent83618982c2c3340d1aa26b03643c2bc412227b35 (diff)
Add LINUX_CMSG_{SPACE,LEN} macros. Use then when calculating the
msg_controllen size, when converting the control message buffer from native (previous version was missing the linux_cmsghdr size).
Diffstat (limited to 'sys/compat/linux/common')
-rw-r--r--sys/compat/linux/common/linux_socket.c10
-rw-r--r--sys/compat/linux/common/linux_socket.h6
2 files changed, 10 insertions, 6 deletions
diff --git a/sys/compat/linux/common/linux_socket.c b/sys/compat/linux/common/linux_socket.c
index 120b3578ab6..af834c68007 100644
--- a/sys/compat/linux/common/linux_socket.c
+++ b/sys/compat/linux/common/linux_socket.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_socket.c,v 1.102 2009/06/16 22:56:49 njoly Exp $ */
+/* $NetBSD: linux_socket.c,v 1.103 2009/06/16 23:17:02 njoly Exp $ */
/*-
* Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.102 2009/06/16 22:56:49 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.103 2009/06/16 23:17:02 njoly Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -669,11 +669,11 @@ linux_copyout_msg_control(struct lwp *l, struct msghdr *mp, struct mbuf *control
break;
}
m = m->m_next;
- if (m == NULL || q + LINUX_CMSG_ALIGN(dlen) > q_end) {
- q += dlen;
+ if (m == NULL || q + LINUX_CMSG_SPACE(dlen) > q_end) {
+ q += LINUX_CMSG_LEN(dlen);
break;
}
- q += LINUX_CMSG_ALIGN(dlen);
+ q += LINUX_CMSG_SPACE(dlen);
}
done:
diff --git a/sys/compat/linux/common/linux_socket.h b/sys/compat/linux/common/linux_socket.h
index e7ebd15fd90..e59fe712aa1 100644
--- a/sys/compat/linux/common/linux_socket.h
+++ b/sys/compat/linux/common/linux_socket.h
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_socket.h,v 1.16 2008/04/28 20:23:44 martin Exp $ */
+/* $NetBSD: linux_socket.h,v 1.17 2009/06/16 23:17:02 njoly Exp $ */
/*-
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -179,6 +179,10 @@ struct linux_cmsghdr {
((mhdr)->msg_controllen >= sizeof(struct linux_cmsghdr) ? \
(struct linux_cmsghdr *)(mhdr)->msg_control : NULL)
+#define LINUX_CMSG_SPACE(l) \
+ (sizeof(struct linux_cmsghdr) + LINUX_CMSG_ALIGN(l))
+#define LINUX_CMSG_LEN(l) \
+ (sizeof(struct linux_cmsghdr) + (l))
/*
* Machine specific definitions.