Allow 32bit get/setsockopt with SO_SNDTIMEO or SO_RECVTIMEO to work.

This commit is contained in:
ps 2005-10-27 04:26:35 +00:00
parent b1106892d7
commit 8a276ee2c3

View File

@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
#include "opt_inet.h"
#include "opt_mac.h"
#include "opt_zero.h"
#include "opt_compat.h"
#include <sys/param.h>
#include <sys/systm.h>
@ -64,6 +65,12 @@ __FBSDID("$FreeBSD$");
#include <vm/uma.h>
#ifdef COMPAT_IA32
#include <sys/mount.h>
#include <compat/freebsd32/freebsd32.h>
extern struct sysentvec ia32_freebsd_sysvec;
#endif
static int soreceive_rcvoob(struct socket *so, struct uio *uio,
int flags);
@ -1647,8 +1654,18 @@ sosetopt(so, sopt)
case SO_SNDTIMEO:
case SO_RCVTIMEO:
error = sooptcopyin(sopt, &tv, sizeof tv,
sizeof tv);
#ifdef COMPAT_IA32
if (curthread->td_proc->p_sysent == &ia32_freebsd_sysvec) {
struct timeval32 tv32;
error = sooptcopyin(sopt, &tv32, sizeof tv32,
sizeof tv32);
CP(tv32, tv, tv_sec);
CP(tv32, tv, tv_usec);
} else
#endif
error = sooptcopyin(sopt, &tv, sizeof tv,
sizeof tv);
if (error)
goto bad;
@ -1817,7 +1834,16 @@ integer:
tv.tv_sec = optval / hz;
tv.tv_usec = (optval % hz) * tick;
error = sooptcopyout(sopt, &tv, sizeof tv);
#ifdef COMPAT_IA32
if (curthread->td_proc->p_sysent == &ia32_freebsd_sysvec) {
struct timeval32 tv32;
CP(tv, tv32, tv_sec);
CP(tv, tv32, tv_usec);
error = sooptcopyout(sopt, &tv32, sizeof tv32);
} else
#endif
error = sooptcopyout(sopt, &tv, sizeof tv);
break;
case SO_LABEL: