From owner-svn-src-head@FreeBSD.ORG Thu May 7 03:23:22 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DAA24106564A; Thu, 7 May 2009 03:23:22 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C93118FC13; Thu, 7 May 2009 03:23:22 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n473NM71038830; Thu, 7 May 2009 03:23:22 GMT (envelope-from dchagin@svn.freebsd.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n473NM0o038829; Thu, 7 May 2009 03:23:22 GMT (envelope-from dchagin@svn.freebsd.org) Message-Id: <200905070323.n473NM0o038829@svn.freebsd.org> From: Dmitry Chagin Date: Thu, 7 May 2009 03:23:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r191871 - head/sys/compat/linux X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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: Thu, 07 May 2009 03:23:23 -0000 Author: dchagin Date: Thu May 7 03:23:22 2009 New Revision: 191871 URL: http://svn.freebsd.org/changeset/base/191871 Log: Rework r191742. Use the protocol family constants for the domain argument validation. Return EAFNOSUPPORT in case when the incorrect domain argument is specified. Return EPROTONOSUPPORT instead of passing values that are not 0 to the BSD layer. Suggested by: rwatson Approved by: kib (mentor) MFC after: 1 month Modified: head/sys/compat/linux/linux_socket.c Modified: head/sys/compat/linux/linux_socket.c ============================================================================== --- head/sys/compat/linux/linux_socket.c Thu May 7 02:17:09 2009 (r191870) +++ head/sys/compat/linux/linux_socket.c Thu May 7 03:23:22 2009 (r191871) @@ -855,14 +855,21 @@ linux_socketpair(struct thread *td, stru } */ bsd_args; bsd_args.domain = linux_to_bsd_domain(args->domain); - if (bsd_args.domain == -1) - return (EINVAL); + if (bsd_args.domain != PF_LOCAL) + return (EAFNOSUPPORT); bsd_args.type = args->type; - if (bsd_args.domain == AF_LOCAL && args->protocol == PF_UNIX) - bsd_args.protocol = 0; + if (args->protocol != 0 && args->protocol != PF_UNIX) + + /* + * Use of PF_UNIX as protocol argument is not right, + * but Linux does it. + * Do not map PF_UNIX as its Linux value is identical + * to FreeBSD one. + */ + return (EPROTONOSUPPORT); else - bsd_args.protocol = args->protocol; + bsd_args.protocol = 0; bsd_args.rsv = (int *)PTRIN(args->rsv); return (socketpair(td, &bsd_args)); }