Make linux(4) use kern_socketpair(9) instead of going through
sys_socketpair(). It's a cleanup; no functional changes. Reviewed by: kib MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D22814
This commit is contained in:
parent
830cec2e06
commit
1c619be1ef
@ -753,25 +753,19 @@ linux_getpeername(struct thread *td, struct linux_getpeername_args *args)
|
|||||||
int
|
int
|
||||||
linux_socketpair(struct thread *td, struct linux_socketpair_args *args)
|
linux_socketpair(struct thread *td, struct linux_socketpair_args *args)
|
||||||
{
|
{
|
||||||
struct socketpair_args /* {
|
int domain, error, sv[2], type;
|
||||||
int domain;
|
|
||||||
int type;
|
|
||||||
int protocol;
|
|
||||||
int *rsv;
|
|
||||||
} */ bsd_args;
|
|
||||||
int error;
|
|
||||||
|
|
||||||
bsd_args.domain = linux_to_bsd_domain(args->domain);
|
domain = linux_to_bsd_domain(args->domain);
|
||||||
if (bsd_args.domain != PF_LOCAL)
|
if (domain != PF_LOCAL)
|
||||||
return (EAFNOSUPPORT);
|
return (EAFNOSUPPORT);
|
||||||
bsd_args.type = args->type & LINUX_SOCK_TYPE_MASK;
|
type = args->type & LINUX_SOCK_TYPE_MASK;
|
||||||
if (bsd_args.type < 0 || bsd_args.type > LINUX_SOCK_MAX)
|
if (type < 0 || type > LINUX_SOCK_MAX)
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
error = linux_set_socket_flags(args->type & ~LINUX_SOCK_TYPE_MASK,
|
error = linux_set_socket_flags(args->type & ~LINUX_SOCK_TYPE_MASK,
|
||||||
&bsd_args.type);
|
&type);
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
return (error);
|
return (error);
|
||||||
if (args->protocol != 0 && args->protocol != PF_UNIX)
|
if (args->protocol != 0 && args->protocol != PF_UNIX) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use of PF_UNIX as protocol argument is not right,
|
* Use of PF_UNIX as protocol argument is not right,
|
||||||
@ -780,10 +774,16 @@ linux_socketpair(struct thread *td, struct linux_socketpair_args *args)
|
|||||||
* to FreeBSD one.
|
* to FreeBSD one.
|
||||||
*/
|
*/
|
||||||
return (EPROTONOSUPPORT);
|
return (EPROTONOSUPPORT);
|
||||||
else
|
}
|
||||||
bsd_args.protocol = 0;
|
error = kern_socketpair(td, domain, type, 0, sv);
|
||||||
bsd_args.rsv = (int *)PTRIN(args->rsv);
|
if (error != 0)
|
||||||
return (sys_socketpair(td, &bsd_args));
|
return (error);
|
||||||
|
error = copyout(sv, PTRIN(args->rsv), 2 * sizeof(int));
|
||||||
|
if (error != 0) {
|
||||||
|
(void)kern_close(td, sv[0]);
|
||||||
|
(void)kern_close(td, sv[1]);
|
||||||
|
}
|
||||||
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
|
#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user