Module Name: src
Committed By: njoly
Date: Tue Jun 16 23:17:02 UTC 2009
Modified Files:
src/sys/compat/linux/common: linux_socket.c linux_socket.h
Log Message:
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).
To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/sys/compat/linux/common/linux_socket.c
cvs rdiff -u -r1.16 -r1.17 src/sys/compat/linux/common/linux_socket.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/compat/linux/common/linux_socket.c
diff -u src/sys/compat/linux/common/linux_socket.c:1.102 src/sys/compat/linux/common/linux_socket.c:1.103
--- src/sys/compat/linux/common/linux_socket.c:1.102 Tue Jun 16 22:56:49 2009
+++ src/sys/compat/linux/common/linux_socket.c Tue Jun 16 23:17:02 2009
@@ -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 @@
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:
Index: src/sys/compat/linux/common/linux_socket.h
diff -u src/sys/compat/linux/common/linux_socket.h:1.16 src/sys/compat/linux/common/linux_socket.h:1.17
--- src/sys/compat/linux/common/linux_socket.h:1.16 Mon Apr 28 20:23:44 2008
+++ src/sys/compat/linux/common/linux_socket.h Tue Jun 16 23:17:02 2009
@@ -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 @@
((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.