Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Add 'kernsa' parameter for sendit()/recvit(); if nonzero...
details: https://anonhg.NetBSD.org/src/rev/9163fbbaa38c
branches: trunk
changeset: 511724:9163fbbaa38c
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Mon Jun 25 19:24:02 2001 +0000
description:
Add 'kernsa' parameter for sendit()/recvit(); if nonzero, msg->msg_name
is supposed to point directly to struct mbuf or struct sockaddr in kernel
space as appropriate, rather than being a pointer to memory in userland.
This is to be used by compat/* when emulation needs to wrap
send{to|msg}(2)/recv{from|msg}(2) and modify the passed struct
sockaddr.
diffstat:
sys/compat/common/uipc_syscalls_43.c | 10 +++++-----
sys/compat/netbsd32/netbsd32_socket.c | 6 +++---
sys/compat/svr4/svr4_stream.c | 7 ++++---
sys/compat/svr4_32/svr4_32_stream.c | 7 ++++---
sys/kern/uipc_syscalls.c | 35 ++++++++++++++++++++++-------------
sys/sys/socketvar.h | 6 +++---
6 files changed, 41 insertions(+), 30 deletions(-)
diffs (246 lines):
diff -r 7bcdcc426d21 -r 9163fbbaa38c sys/compat/common/uipc_syscalls_43.c
--- a/sys/compat/common/uipc_syscalls_43.c Mon Jun 25 18:33:14 2001 +0000
+++ b/sys/compat/common/uipc_syscalls_43.c Mon Jun 25 19:24:02 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_syscalls_43.c,v 1.11 2000/03/30 11:27:15 augustss Exp $ */
+/* $NetBSD: uipc_syscalls_43.c,v 1.12 2001/06/25 19:24:02 jdolecek Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1990, 1993
@@ -166,7 +166,7 @@
aiov.iov_len = SCARG(uap, len);
msg.msg_control = 0;
msg.msg_flags = SCARG(uap, flags);
- return (recvit(p, SCARG(uap, s), &msg, (caddr_t)0, retval));
+ return (recvit(p, SCARG(uap, s), &msg, (caddr_t)0, retval, 0));
}
int
@@ -227,7 +227,7 @@
goto done;
msg.msg_iov = iov;
error = recvit(p, SCARG(uap, s), &msg,
- (caddr_t)&SCARG(uap, msg)->msg_namelen, retval);
+ (caddr_t)&SCARG(uap, msg)->msg_namelen, retval, 0);
if (msg.msg_controllen && error == 0)
error = copyout((caddr_t)&msg.msg_controllen,
@@ -261,7 +261,7 @@
aiov.iov_len = SCARG(uap, len);
msg.msg_control = 0;
msg.msg_flags = 0;
- return (sendit(p, SCARG(uap, s), &msg, SCARG(uap, flags), retval));
+ return (sendit(p, SCARG(uap, s), &msg, SCARG(uap, flags), retval, 0));
}
int
@@ -297,7 +297,7 @@
goto done;
msg.msg_flags = MSG_COMPAT;
msg.msg_iov = iov;
- error = sendit(p, SCARG(uap, s), &msg, SCARG(uap, flags), retval);
+ error = sendit(p, SCARG(uap, s), &msg, SCARG(uap, flags), retval, 0);
done:
if (iov != aiov)
FREE(iov, M_IOV);
diff -r 7bcdcc426d21 -r 9163fbbaa38c sys/compat/netbsd32/netbsd32_socket.c
--- a/sys/compat/netbsd32/netbsd32_socket.c Mon Jun 25 18:33:14 2001 +0000
+++ b/sys/compat/netbsd32/netbsd32_socket.c Mon Jun 25 19:24:02 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_socket.c,v 1.2 2001/05/30 11:37:28 mrg Exp $ */
+/* $NetBSD: netbsd32_socket.c,v 1.3 2001/06/25 19:24:02 jdolecek Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@@ -314,7 +314,7 @@
msg.msg_flags = 0;
#endif
/* Luckily we can use this directly */
- error = sendit(p, SCARG(uap, s), &msg, SCARG(uap, flags), retval);
+ error = sendit(p, SCARG(uap, s), &msg, SCARG(uap, flags), retval, 0);
done:
if (iov != aiov)
FREE(iov, M_IOV);
@@ -385,5 +385,5 @@
#endif
aiov.iov_base = (char *)(u_long)SCARG(uap, buf); /* XXX kills const */
aiov.iov_len = SCARG(uap, len);
- return (sendit(p, SCARG(uap, s), &msg, SCARG(uap, flags), retval));
+ return (sendit(p, SCARG(uap, s), &msg, SCARG(uap, flags), retval, 0));
}
diff -r 7bcdcc426d21 -r 9163fbbaa38c sys/compat/svr4/svr4_stream.c
--- a/sys/compat/svr4/svr4_stream.c Mon Jun 25 18:33:14 2001 +0000
+++ b/sys/compat/svr4/svr4_stream.c Mon Jun 25 19:24:02 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: svr4_stream.c,v 1.43 2001/06/14 20:32:46 thorpej Exp $ */
+/* $NetBSD: svr4_stream.c,v 1.44 2001/06/25 19:24:03 jdolecek Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
@@ -1634,7 +1634,7 @@
aiov.iov_base = dat.buf;
aiov.iov_len = dat.len;
error = sendit(p, SCARG(uap, fd), &msg,
- SCARG(uap, flags), retval);
+ SCARG(uap, flags), retval, 0);
*retval = 0;
return error;
@@ -1897,7 +1897,8 @@
aiov.iov_len = dat.maxlen;
msg.msg_flags = 0;
- error = recvit(p, SCARG(uap, fd), &msg, (caddr_t) flen, retval);
+ error = recvit(p, SCARG(uap, fd), &msg, (caddr_t) flen,
+ retval, 0);
if (error) {
DPRINTF(("getmsg: recvit failed %d\n", error));
diff -r 7bcdcc426d21 -r 9163fbbaa38c sys/compat/svr4_32/svr4_32_stream.c
--- a/sys/compat/svr4_32/svr4_32_stream.c Mon Jun 25 18:33:14 2001 +0000
+++ b/sys/compat/svr4_32/svr4_32_stream.c Mon Jun 25 19:24:02 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: svr4_32_stream.c,v 1.4 2001/06/14 20:32:46 thorpej Exp $ */
+/* $NetBSD: svr4_32_stream.c,v 1.5 2001/06/25 19:24:03 jdolecek Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
@@ -1637,7 +1637,7 @@
aiov.iov_base = (caddr_t)(u_long)dat.buf;
aiov.iov_len = dat.len;
error = sendit(p, SCARG(uap, fd), &msg,
- SCARG(uap, flags), retval);
+ SCARG(uap, flags), retval, 0);
*retval = 0;
return error;
@@ -1902,7 +1902,8 @@
aiov.iov_len = dat.maxlen;
msg.msg_flags = 0;
- error = recvit(p, SCARG(uap, fd), &msg, (caddr_t) flen, retval);
+ error = recvit(p, SCARG(uap, fd), &msg, (caddr_t) flen,
+ retval, 0);
if (error) {
DPRINTF(("getmsg: recvit failed %d\n", error));
diff -r 7bcdcc426d21 -r 9163fbbaa38c sys/kern/uipc_syscalls.c
--- a/sys/kern/uipc_syscalls.c Mon Jun 25 18:33:14 2001 +0000
+++ b/sys/kern/uipc_syscalls.c Mon Jun 25 19:24:02 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_syscalls.c,v 1.60 2001/06/16 12:00:02 jdolecek Exp $ */
+/* $NetBSD: uipc_syscalls.c,v 1.61 2001/06/25 19:24:03 jdolecek Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1990, 1993
@@ -397,7 +397,7 @@
#endif
aiov.iov_base = (char *)SCARG(uap, buf); /* XXX kills const */
aiov.iov_len = SCARG(uap, len);
- return (sendit(p, SCARG(uap, s), &msg, SCARG(uap, flags), retval));
+ return (sendit(p, SCARG(uap, s), &msg, SCARG(uap, flags), retval, 0));
}
int
@@ -432,7 +432,7 @@
#ifdef COMPAT_OLDSOCK
msg.msg_flags = 0;
#endif
- error = sendit(p, SCARG(uap, s), &msg, SCARG(uap, flags), retval);
+ error = sendit(p, SCARG(uap, s), &msg, SCARG(uap, flags), retval, 0);
done:
if (iov != aiov)
free(iov, M_IOV);
@@ -440,7 +440,8 @@
}
int
-sendit(struct proc *p, int s, struct msghdr *mp, int flags, register_t *retsize)
+sendit(struct proc *p, int s, struct msghdr *mp, int flags, register_t *retsize,
+ int kernsa)
{
struct file *fp;
struct uio auio;
@@ -486,10 +487,14 @@
}
}
if (mp->msg_name) {
- error = sockargs(&to, mp->msg_name, mp->msg_namelen,
+ if (kernsa)
+ to = (struct mbuf *) mp->msg_name;
+ else {
+ error = sockargs(&to, mp->msg_name, mp->msg_namelen,
MT_SONAME);
- if (error)
- goto out;
+ if (error)
+ goto out;
+ }
} else
to = 0;
if (mp->msg_control) {
@@ -589,7 +594,7 @@
msg.msg_control = 0;
msg.msg_flags = SCARG(uap, flags);
return (recvit(p, SCARG(uap, s), &msg,
- (caddr_t)SCARG(uap, fromlenaddr), retval));
+ (caddr_t)SCARG(uap, fromlenaddr), retval, 0));
}
int
@@ -628,7 +633,7 @@
#else
msg.msg_flags = SCARG(uap, flags);
#endif
- if ((error = recvit(p, SCARG(uap, s), &msg, (caddr_t)0, retval)) == 0) {
+ if ((error = recvit(p, SCARG(uap, s), &msg, (caddr_t)0, retval,0)) ==0){
msg.msg_iov = uiov;
error = copyout((caddr_t)&msg, (caddr_t)SCARG(uap, msg),
sizeof(msg));
@@ -641,7 +646,7 @@
int
recvit(struct proc *p, int s, struct msghdr *mp, caddr_t namelenp,
- register_t *retsize)
+ register_t *retsize, int kernsa)
{
struct file *fp;
struct uio auio;
@@ -730,10 +735,14 @@
if (len > from->m_len)
len = from->m_len;
/* else if len < from->m_len ??? */
- error = copyout(mtod(from, caddr_t),
+ if (kernsa)
+ memcpy(mp->msg_name, mtod(from, caddr_t), len);
+ else {
+ error = copyout(mtod(from, caddr_t),
(caddr_t)mp->msg_name, (unsigned)len);
- if (error)
- goto out;
+ if (error)
+ goto out;
+ }
}
mp->msg_namelen = len;
if (namelenp &&
diff -r 7bcdcc426d21 -r 9163fbbaa38c sys/sys/socketvar.h
--- a/sys/sys/socketvar.h Mon Jun 25 18:33:14 2001 +0000
+++ b/sys/sys/socketvar.h Mon Jun 25 19:24:02 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: socketvar.h,v 1.46 2001/05/06 19:22:33 manu Exp $ */
+/* $NetBSD: socketvar.h,v 1.47 2001/06/25 19:24:03 jdolecek Exp $ */
/*-
* Copyright (c) 1982, 1986, 1990, 1993
@@ -317,8 +317,8 @@
void sowakeup(struct socket *so, struct sockbuf *sb);
int sockargs(struct mbuf **, const void *, int, int);
-int sendit(struct proc *, int, struct msghdr *, int, register_t *);
-int recvit(struct proc *, int, struct msghdr *, caddr_t, register_t *);
+int sendit(struct proc *, int, struct msghdr *, int, register_t *, int);
+int recvit(struct proc *, int, struct msghdr *, caddr_t, register_t *, int);
#endif /* _KERNEL */
Home |
Main Index |
Thread Index |
Old Index