From nobody@FreeBSD.org  Fri Feb 25 19:49:38 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 6B7BD1065672
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 25 Feb 2011 19:49:38 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 5BC8A8FC15
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 25 Feb 2011 19:49:38 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p1PJnbl7002462
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 25 Feb 2011 19:49:37 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p1PJnbFs002460;
	Fri, 25 Feb 2011 19:49:37 GMT
	(envelope-from nobody)
Message-Id: <201102251949.p1PJnbFs002460@red.freebsd.org>
Date: Fri, 25 Feb 2011 19:49:37 GMT
From: Simon Walton <simonw@matteworld.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] Linux recvfrom doesn't handle proto family
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         155040
>Category:       kern
>Synopsis:       [linux] [patch] Linux recvfrom doesn't handle proto family
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-emulation
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Feb 25 19:50:07 UTC 2011
>Closed-Date:    
>Last-Modified:  Sat Feb 26 09:20:40 UTC 2011
>Originator:     Simon Walton
>Release:        8.1
>Organization:
Matte World Digital
>Environment:
FreeBSD mongo 8.1-RELEASE FreeBSD 8.1-RELEASE #3: Thu Jan 27 09:56:08 PST 2011
>Description:
In the linux socket recvfrom emulation the incoming socket address family is
not converted to BSD values, although the reverse conversion is done. The values
for local and inet are identical so this still works, but inet6 values differ.
>How-To-Repeat:

>Fix:
Apply patch. This also defaults unknown families to inet as apparently linux
ignores bad values in this syscall. This was necessary to get a linux
binary to work.

Alternatively maybe just force the address family to AF_UNSPEC.


Patch attached with submission follows:

--- /sys/compat/linux/linux_socket.c.orig	2011-02-17 11:29:14.000000000 -0800
+++ /sys/compat/linux/linux_socket.c	2011-02-24 17:19:01.000000000 -0800
@@ -198,7 +198,7 @@
 	case LINUX_AF_APPLETALK:
 		return (AF_APPLETALK);
 	}
-	return (-1);
+	return (AF_INET);
 }
 
 static int
@@ -393,6 +393,7 @@
 
 	sa.sa_family = *(sa_family_t *)&sa;
 	sa.sa_len = len;
+	sa.sa_family = linux_to_bsd_domain (sa.sa_family);
 
 	error = copyout(&sa, arg, sa_len);
 


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-emulation 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sat Feb 26 09:20:23 UTC 2011 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=155040 
>Unformatted:
