tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

getsockopt(2)



Does anyone know why we don't use the input 'optlen' parameter to the
getsockopt(2) syscall, we do write back to it on return.

In ip_output() there is this, which suggests that someone had come
across this before.

#if 0   /* defined(IPSEC) */
                case IP_IPSEC_POLICY:
                {
                        struct mbuf *m = NULL;

                        /* XXX this will return EINVAL as sopt is empty */
                        error = ipsec4_get_policy(inp, sopt->sopt_data,
                            sopt->sopt_size, &m);
                        if (error == 0)
                                error = sockopt_setmbuf(sopt, m);
                        break;
                }       
#endif /*IPSEC*/  

There are also lots of places in sctp_usrreq that want to use it.

I can set it with the following patch (line numbers will be slightly
out), but wondered if there was a reason for the current behaviour.

Index: uipc_syscalls.c
===================================================================
RCS file: /cvsroot/src/sys/kern/uipc_syscalls.c,v
retrieving revision 1.187
diff -u -r1.187 uipc_syscalls.c
--- uipc_syscalls.c	20 Jun 2017 20:34:49 -0000	1.187
+++ uipc_syscalls.c	14 Oct 2017 21:33:09 -0000
@@ -1235,7 +1240,7 @@
 	if ((error = fd_getsock1(SCARG(uap, s), &so, &fp)) != 0)
 		return (error);
 
-	sockopt_init(&sopt, SCARG(uap, level), SCARG(uap, name), 0);
+	sockopt_init(&sopt, SCARG(uap, level), SCARG(uap, name), valsize);
 
 	if (fp->f_flag & FNOSIGPIPE)
 		so->so_options |= SO_NOSIGPIPE;



Home | Main Index | Thread Index | Old Index