Subject: Re: the size of an argument for set/getsockopt(2)
To: Hitoshi Asaeda <>
From: None <>
List: tech-kern
Date: 05/29/2002 17:19:26
>I felt the change of sys_setsockopt() in uipc_syscalls.c as well as
>sosetopt() in uipc_socket.c affected many parts.
>I don't prefer making users change mbuf size using sysctl after my
>code is comitted.
>Also, in fact, changing the size of mbuf is not a solution, since when
>we encounter "shorter storage for setsockopt()" after we change it, we
>again expand the size?

	i am not talking about changing mbuf size.  i am talking about
	ading support for cluster mbuf in sys_setsockopt().

	users won't notice the change.  the change i meant is perfectly
	internal to the kernel.  see below.


Index: uipc_syscalls.c
RCS file: /cvsroot/syssrc/sys/kern/uipc_syscalls.c,v
retrieving revision 1.68
diff -u -r1.68 uipc_syscalls.c
--- uipc_syscalls.c	2002/02/11 18:11:43	1.68
+++ uipc_syscalls.c	2002/05/29 08:19:11
@@ -241,6 +241,7 @@
 	if (error) {
 		fdremove(fdp, fd);
+		soclose(so);
@@ -777,19 +778,22 @@
 	struct file	*fp;
 	struct mbuf	*m;
 	int		error;
+	unsigned int	l;
 	m = NULL;
 	/* getsock() will use the descriptor for us */
 	if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
 		return (error);
-	if (SCARG(uap, valsize) > MLEN) {
+	l = SCARG(uap, valsize);
+	if (l > MCLBYTES) {
 		error = EINVAL;
 		goto out;
 	if (SCARG(uap, val)) {
 		m = m_get(M_WAIT, MT_SOOPTS);
-		error = copyin(SCARG(uap, val), mtod(m, caddr_t),
-			       SCARG(uap, valsize));
+		if (l > MLEN)
+			MCLGET(m, M_WAIT);
+		error = copyin(SCARG(uap, val), mtod(m, caddr_t), l);
 		if (error) {
 			(void) m_free(m);
 			goto out;