Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F146008421
D9367.id24525.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
8 KB
Referenced Files
None
Subscribers
None
D9367.id24525.diff
View Options
Index: sys/compat/cloudabi/cloudabi_fd.c
===================================================================
--- sys/compat/cloudabi/cloudabi_fd.c
+++ sys/compat/cloudabi/cloudabi_fd.c
@@ -100,9 +100,6 @@
struct cloudabi_sys_fd_create1_args *uap)
{
struct filecaps fcaps = {};
- struct socket_args socket_args = {
- .domain = AF_UNIX,
- };
switch (uap->type) {
case CLOUDABI_FILETYPE_POLL:
@@ -113,14 +110,11 @@
CAP_MMAP_RWX);
return (kern_shm_open(td, SHM_ANON, O_RDWR, 0, &fcaps));
case CLOUDABI_FILETYPE_SOCKET_DGRAM:
- socket_args.type = SOCK_DGRAM;
- return (sys_socket(td, &socket_args));
+ return (kern_socket(td, AF_UNIX, SOCK_DGRAM, 0 /* XXX */));
case CLOUDABI_FILETYPE_SOCKET_SEQPACKET:
- socket_args.type = SOCK_SEQPACKET;
- return (sys_socket(td, &socket_args));
+ return (kern_socket(td, AF_UNIX, SOCK_SEQPACKET, 0 /* XXX */));
case CLOUDABI_FILETYPE_SOCKET_STREAM:
- socket_args.type = SOCK_STREAM;
- return (sys_socket(td, &socket_args));
+ return (kern_socket(td, AF_UNIX, SOCK_STREAM, 0 /* XXX */));
default:
return (EINVAL);
}
Index: sys/compat/cloudabi/cloudabi_sock.c
===================================================================
--- sys/compat/cloudabi/cloudabi_sock.c
+++ sys/compat/cloudabi/cloudabi_sock.c
@@ -35,7 +35,6 @@
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/syscallsubr.h>
-#include <sys/sysproto.h>
#include <sys/systm.h>
#include <sys/un.h>
@@ -165,37 +164,31 @@
cloudabi_sys_sock_listen(struct thread *td,
struct cloudabi_sys_sock_listen_args *uap)
{
- struct listen_args listen_args = {
- .s = uap->sock,
- .backlog = uap->backlog,
- };
- return (sys_listen(td, &listen_args));
+ return (kern_listen(td, uap->sock, uap->backlog));
}
int
cloudabi_sys_sock_shutdown(struct thread *td,
struct cloudabi_sys_sock_shutdown_args *uap)
{
- struct shutdown_args shutdown_args = {
- .s = uap->sock,
- };
+ int how;
switch (uap->how) {
case CLOUDABI_SHUT_RD:
- shutdown_args.how = SHUT_RD;
+ how = SHUT_RD;
break;
case CLOUDABI_SHUT_WR:
- shutdown_args.how = SHUT_WR;
+ how = SHUT_WR;
break;
case CLOUDABI_SHUT_RD | CLOUDABI_SHUT_WR:
- shutdown_args.how = SHUT_RDWR;
+ how = SHUT_RDWR;
break;
default:
return (EINVAL);
}
- return (sys_shutdown(td, &shutdown_args));
+ return (kern_shutdown(td, uap->sock, how));
}
int
Index: sys/compat/linux/linux_socket.c
===================================================================
--- sys/compat/linux/linux_socket.c
+++ sys/compat/linux/linux_socket.c
@@ -697,32 +697,26 @@
int
linux_socket(struct thread *td, struct linux_socket_args *args)
{
- struct socket_args /* {
- int domain;
- int type;
- int protocol;
- } */ bsd_args;
- int retval_socket;
+ int domain, retval_socket, type;
- bsd_args.protocol = args->protocol;
- bsd_args.type = args->type & LINUX_SOCK_TYPE_MASK;
- if (bsd_args.type < 0 || bsd_args.type > LINUX_SOCK_MAX)
+ type = args->type & LINUX_SOCK_TYPE_MASK;
+ if (type < 0 || type > LINUX_SOCK_MAX)
return (EINVAL);
retval_socket = linux_set_socket_flags(args->type & ~LINUX_SOCK_TYPE_MASK,
- &bsd_args.type);
+ &type);
if (retval_socket != 0)
return (retval_socket);
- bsd_args.domain = linux_to_bsd_domain(args->domain);
- if (bsd_args.domain == -1)
+ domain = linux_to_bsd_domain(args->domain);
+ if (domain == -1)
return (EAFNOSUPPORT);
- retval_socket = sys_socket(td, &bsd_args);
+ retval_socket = kern_socket(td, domain, type, args->protocol);
if (retval_socket)
return (retval_socket);
- if (bsd_args.type == SOCK_RAW
- && (bsd_args.protocol == IPPROTO_RAW || bsd_args.protocol == 0)
- && bsd_args.domain == PF_INET) {
+ if (type == SOCK_RAW
+ && (args->protocol == IPPROTO_RAW || args->protocol == 0)
+ && domain == PF_INET) {
/* It's a raw IP socket: set the IP_HDRINCL option. */
int hdrincl;
@@ -738,7 +732,7 @@
* For simplicity we do this unconditionally of the net.inet6.ip6.v6only
* sysctl value.
*/
- if (bsd_args.domain == PF_INET6) {
+ if (domain == PF_INET6) {
int v6only;
v6only = 0;
@@ -816,14 +810,8 @@
int
linux_listen(struct thread *td, struct linux_listen_args *args)
{
- struct listen_args /* {
- int s;
- int backlog;
- } */ bsd_args;
- bsd_args.s = args->s;
- bsd_args.backlog = args->backlog;
- return (sys_listen(td, &bsd_args));
+ return (kern_listen(td, args->s, args->backlog));
}
static int
@@ -1524,14 +1512,8 @@
int
linux_shutdown(struct thread *td, struct linux_shutdown_args *args)
{
- struct shutdown_args /* {
- int s;
- int how;
- } */ bsd_args;
- bsd_args.s = args->s;
- bsd_args.how = args->how;
- return (sys_shutdown(td, &bsd_args));
+ return (kern_shutdown(td, args->s, args->how));
}
int
Index: sys/kern/uipc_syscalls.c
===================================================================
--- sys/kern/uipc_syscalls.c
+++ sys/kern/uipc_syscalls.c
@@ -124,13 +124,19 @@
int
sys_socket(struct thread *td, struct socket_args *uap)
{
+
+ return (kern_socket(td, uap->domain, uap->type, uap->protocol));
+}
+
+int
+kern_socket(struct thread *td, int domain, int type, int protocol)
+{
struct socket *so;
struct file *fp;
- int fd, error, type, oflag, fflag;
+ int fd, error, oflag, fflag;
- AUDIT_ARG_SOCKET(uap->domain, uap->type, uap->protocol);
+ AUDIT_ARG_SOCKET(domain, type, protocol);
- type = uap->type;
oflag = 0;
fflag = 0;
if ((type & SOCK_CLOEXEC) != 0) {
@@ -143,8 +149,7 @@
}
#ifdef MAC
- error = mac_socket_check_create(td->td_ucred, uap->domain, type,
- uap->protocol);
+ error = mac_socket_check_create(td->td_ucred, domain, type, protocol);
if (error != 0)
return (error);
#endif
@@ -152,8 +157,7 @@
if (error != 0)
return (error);
/* An extra reference on `fp' has been held for us by falloc(). */
- error = socreate(uap->domain, &so, type, uap->protocol,
- td->td_ucred, td);
+ error = socreate(domain, &so, type, protocol, td->td_ucred, td);
if (error != 0) {
fdclose(td, fp, fd);
} else {
@@ -231,13 +235,20 @@
int
sys_listen(struct thread *td, struct listen_args *uap)
{
+
+ return (kern_listen(td, uap->s, uap->backlog));
+}
+
+int
+kern_listen(struct thread *td, int s, int backlog)
+{
struct socket *so;
struct file *fp;
cap_rights_t rights;
int error;
- AUDIT_ARG_FD(uap->s);
- error = getsock_cap(td, uap->s, cap_rights_init(&rights, CAP_LISTEN),
+ AUDIT_ARG_FD(s);
+ error = getsock_cap(td, s, cap_rights_init(&rights, CAP_LISTEN),
&fp, NULL, NULL);
if (error == 0) {
so = fp->f_data;
@@ -245,10 +256,10 @@
error = mac_socket_check_listen(td->td_ucred, so);
if (error == 0)
#endif
- error = solisten(so, uap->backlog, td);
+ error = solisten(so, backlog, td);
fdrop(fp, td);
}
- return(error);
+ return (error);
}
/*
@@ -1205,17 +1216,24 @@
int
sys_shutdown(struct thread *td, struct shutdown_args *uap)
{
+
+ return (kern_shutdown(td, uap->s, uap->how));
+}
+
+int
+kern_shutdown(struct thread *td, int s, int how)
+{
struct socket *so;
struct file *fp;
cap_rights_t rights;
int error;
- AUDIT_ARG_FD(uap->s);
- error = getsock_cap(td, uap->s, cap_rights_init(&rights, CAP_SHUTDOWN),
+ AUDIT_ARG_FD(s);
+ error = getsock_cap(td, s, cap_rights_init(&rights, CAP_SHUTDOWN),
&fp, NULL, NULL);
if (error == 0) {
so = fp->f_data;
- error = soshutdown(so, uap->how);
+ error = soshutdown(so, how);
/*
* Previous versions did not return ENOTCONN, but 0 in
* case the socket was not connected. Some important
Index: sys/sys/syscallsubr.h
===================================================================
--- sys/sys/syscallsubr.h
+++ sys/sys/syscallsubr.h
@@ -136,6 +136,7 @@
int kern_kldunload(struct thread *td, int fileid, int flags);
int kern_linkat(struct thread *td, int fd1, int fd2, char *path1,
char *path2, enum uio_seg segflg, int follow);
+int kern_listen(struct thread *td, int s, int backlog);
int kern_lutimes(struct thread *td, char *path, enum uio_seg pathseg,
struct timeval *tptr, enum uio_seg tptrseg);
int kern_mkdirat(struct thread *td, int fd, char *path,
@@ -215,6 +216,7 @@
int shmflg);
int kern_shmctl(struct thread *td, int shmid, int cmd, void *buf,
size_t *bufsz);
+int kern_shutdown(struct thread *td, int s, int how);
int kern_sigaction(struct thread *td, int sig, const struct sigaction *act,
struct sigaction *oact, int flags);
int kern_sigaltstack(struct thread *td, stack_t *ss, stack_t *oss);
@@ -223,6 +225,7 @@
int kern_sigsuspend(struct thread *td, sigset_t mask);
int kern_sigtimedwait(struct thread *td, sigset_t waitset,
struct ksiginfo *ksi, struct timespec *timeout);
+int kern_socket(struct thread *td, int domain, int type, int protocol);
int kern_statat(struct thread *td, int flag, int fd, char *path,
enum uio_seg pathseg, struct stat *sbp,
void (*hook)(struct vnode *vp, struct stat *sbp));
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Feb 27, 11:54 PM (10 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29022184
Default Alt Text
D9367.id24525.diff (8 KB)
Attached To
Mode
D9367: Add kern_listen(), kern_shutdown(), and kern_socket().
Attached
Detach File
Event Timeline
Log In to Comment