From owner-svn-src-head@freebsd.org Mon Feb 10 13:24:15 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0389823A417; Mon, 10 Feb 2020 13:24:15 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48GRSt5zSQz4TbZ; Mon, 10 Feb 2020 13:24:14 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AE2DF1FBCB; Mon, 10 Feb 2020 13:24:14 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 01ADOEfL021577; Mon, 10 Feb 2020 13:24:14 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 01ADOEcD021576; Mon, 10 Feb 2020 13:24:14 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <202002101324.01ADOEcD021576@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Mon, 10 Feb 2020 13:24:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r357727 - head/sys/compat/linux X-SVN-Group: head X-SVN-Commit-Author: trasz X-SVN-Commit-Paths: head/sys/compat/linux X-SVN-Commit-Revision: 357727 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Feb 2020 13:24:15 -0000 Author: trasz Date: Mon Feb 10 13:24:14 2020 New Revision: 357727 URL: https://svnweb.freebsd.org/changeset/base/357727 Log: 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 Modified: head/sys/compat/linux/linux_socket.c Modified: head/sys/compat/linux/linux_socket.c ============================================================================== --- head/sys/compat/linux/linux_socket.c Mon Feb 10 11:09:56 2020 (r357726) +++ head/sys/compat/linux/linux_socket.c Mon Feb 10 13:24:14 2020 (r357727) @@ -753,25 +753,19 @@ linux_getpeername(struct thread *td, struct linux_getp int linux_socketpair(struct thread *td, struct linux_socketpair_args *args) { - struct socketpair_args /* { - int domain; - int type; - int protocol; - int *rsv; - } */ bsd_args; - int error; + int domain, error, sv[2], type; - bsd_args.domain = linux_to_bsd_domain(args->domain); - if (bsd_args.domain != PF_LOCAL) + domain = linux_to_bsd_domain(args->domain); + if (domain != PF_LOCAL) return (EAFNOSUPPORT); - 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); error = linux_set_socket_flags(args->type & ~LINUX_SOCK_TYPE_MASK, - &bsd_args.type); + &type); if (error != 0) 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, @@ -780,10 +774,16 @@ linux_socketpair(struct thread *td, struct linux_socke * to FreeBSD one. */ return (EPROTONOSUPPORT); - else - bsd_args.protocol = 0; - bsd_args.rsv = (int *)PTRIN(args->rsv); - return (sys_socketpair(td, &bsd_args)); + } + error = kern_socketpair(td, domain, type, 0, sv); + if (error != 0) + 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))