Date: Mon, 24 Aug 2020 16:36:36 +0000 (UTC) From: Edward Tomasz Napierala <trasz@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r364708 - stable/12/sys/compat/linux Message-ID: <202008241636.07OGaa5o080554@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: trasz Date: Mon Aug 24 16:36:35 2020 New Revision: 364708 URL: https://svnweb.freebsd.org/changeset/base/364708 Log: MFC r356728: Make linux(4) use kern_getsockopt(9) instead of going through sys_getsockopt(). It's a cleanup; no functional changes. Sponsored by: The FreeBSD Foundation Modified: stable/12/sys/compat/linux/linux_socket.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/compat/linux/linux_socket.c ============================================================================== --- stable/12/sys/compat/linux/linux_socket.c Mon Aug 24 16:27:51 2020 (r364707) +++ stable/12/sys/compat/linux/linux_socket.c Mon Aug 24 16:36:35 2020 (r364708) @@ -1511,13 +1511,6 @@ linux_setsockopt(struct thread *td, struct linux_setso int linux_getsockopt(struct thread *td, struct linux_getsockopt_args *args) { - struct getsockopt_args /* { - int s; - int level; - int name; - caddr_t val; - int *avalsize; - } */ bsd_args; l_timeval linux_tv; struct timeval tv; socklen_t tv_len, xulen, len; @@ -1525,11 +1518,10 @@ linux_getsockopt(struct thread *td, struct linux_getso struct sockaddr *sa; struct xucred xu; struct l_ucred lxu; - int error, name, newval; + int error, level, name, newval; - bsd_args.s = args->s; - bsd_args.level = linux_to_bsd_sockopt_level(args->level); - switch (bsd_args.level) { + level = linux_to_bsd_sockopt_level(args->level); + switch (level) { case SOL_SOCKET: name = linux_to_bsd_so_sockopt(args->optname); switch (name) { @@ -1537,7 +1529,7 @@ linux_getsockopt(struct thread *td, struct linux_getso /* FALLTHROUGH */ case SO_SNDTIMEO: tv_len = sizeof(tv); - error = kern_getsockopt(td, args->s, bsd_args.level, + error = kern_getsockopt(td, args->s, level, name, &tv, UIO_SYSSPACE, &tv_len); if (error != 0) return (error); @@ -1553,9 +1545,9 @@ linux_getsockopt(struct thread *td, struct linux_getso * LOCAL_PEERCRED is not served at the SOL_SOCKET level, * but by the Unix socket's level 0. */ - bsd_args.level = 0; + level = 0; xulen = sizeof(xu); - error = kern_getsockopt(td, args->s, bsd_args.level, + error = kern_getsockopt(td, args->s, level, name, &xu, UIO_SYSSPACE, &xulen); if (error != 0) return (error); @@ -1569,7 +1561,7 @@ linux_getsockopt(struct thread *td, struct linux_getso /* NOTREACHED */ case SO_ERROR: len = sizeof(newval); - error = kern_getsockopt(td, args->s, bsd_args.level, + error = kern_getsockopt(td, args->s, level, name, &newval, UIO_SYSSPACE, &len); if (error != 0) return (error); @@ -1596,16 +1588,13 @@ linux_getsockopt(struct thread *td, struct linux_getso if (name == -1) return (EINVAL); - bsd_args.name = name; - bsd_args.avalsize = PTRIN(args->optlen); - if (name == IPV6_NEXTHOP) { error = copyin(PTRIN(args->optlen), &len, sizeof(len)); if (error != 0) return (error); sa = malloc(len, M_SONAME, M_WAITOK); - error = kern_getsockopt(td, args->s, bsd_args.level, + error = kern_getsockopt(td, args->s, level, name, sa, UIO_SYSSPACE, &len); if (error != 0) goto out; @@ -1620,8 +1609,16 @@ linux_getsockopt(struct thread *td, struct linux_getso out: free(sa, M_SONAME); } else { - bsd_args.val = PTRIN(args->optval); - error = sys_getsockopt(td, &bsd_args); + if (args->optval) { + error = copyin(PTRIN(args->optlen), &len, sizeof(len)); + if (error != 0) + return (error); + } + error = kern_getsockopt(td, args->s, level, + name, PTRIN(args->optval), UIO_USERSPACE, &len); + if (error == 0) + error = copyout(&len, PTRIN(args->optlen), + sizeof(len)); } return (error);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008241636.07OGaa5o080554>