From simon@comsys.ntu-kpi.kiev.ua  Mon Dec 19 11:13:41 2005
Return-Path: <simon@comsys.ntu-kpi.kiev.ua>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id DEFD716A41F
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 19 Dec 2005 11:13:41 +0000 (GMT)
	(envelope-from simon@comsys.ntu-kpi.kiev.ua)
Received: from comsys.ntu-kpi.kiev.ua (comsys.ntu-kpi.kiev.ua [195.245.194.142])
	by mx1.FreeBSD.org (Postfix) with ESMTP id EE19F43D5D
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 19 Dec 2005 11:13:37 +0000 (GMT)
	(envelope-from simon@comsys.ntu-kpi.kiev.ua)
Received: from pm513-1.comsys.ntu-kpi.kiev.ua (pm513-1.comsys.ntu-kpi.kiev.ua [10.18.52.101])
	(authenticated bits=0)
	by comsys.ntu-kpi.kiev.ua (8.12.10/8.12.10) with ESMTP id jBJBOVVO004321
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL)
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 19 Dec 2005 13:24:31 +0200 (EET)
Received: by pm513-1.comsys.ntu-kpi.kiev.ua (Postfix, from userid 1001)
	id 06B275C020; Mon, 19 Dec 2005 13:13:42 +0200 (EET)
Message-Id: <20051219111342.GA995@pm513-1.comsys.ntu-kpi.kiev.ua>
Date: Mon, 19 Dec 2005 13:13:42 +0200
From: Andrey Simonenko <simon@comsys.ntu-kpi.kiev.ua>
To: FreeBSD-gnats-submit@freebsd.org
Subject: [patch] inherit LOCAL_CREDS option for accepted sockets from listen socket

>Number:         90644
>Category:       kern
>Synopsis:       [kernel] [patch] inherit LOCAL_CREDS option for accepted sockets from listen socket
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    maxim
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Dec 19 11:20:02 GMT 2005
>Closed-Date:    Sun May 21 09:15:00 GMT 2006
>Last-Modified:  Sun May 21 09:15:00 GMT 2006
>Originator:     Andrey Simonenko
>Release:        FreeBSD 6.0-STABLE i386
>Organization:
>Environment:

FreeBSD 6.0-STABLE, sys/kern/uipc_usrreq.c,v 1.155.2.1

>Description:

Sockets returned by the accept(2) system call do not inherit
LOCAL_CREDS option from their listen socket.  As the result it
is necessary to call setsockopt(LOCAL_CREDS) for each accepted
socket, what gives overhead.

In NetBSD accepted sockets inherit LOCAL_CREDS option from their
listen socket.

Shouldn't __FreeBSD_version be incremented if this patch is committed ?

>How-To-Repeat:

Try to run src/regress/sys/kern/unfdpass/unfdpass.c from NetBSD 2.0
on FreeBSD, before and after patch.

>Fix:
--- uipc_usrreq.c.orig	Thu Nov 24 09:07:51 2005
+++ uipc_usrreq.c	Sun Dec 18 20:26:09 2005
@@ -1010,6 +1010,8 @@
 		memcpy(&unp->unp_peercred, &unp2->unp_peercred,
 		    sizeof(unp->unp_peercred));
 		unp->unp_flags |= UNP_HAVEPC;
+		if (unp2->unp_flags & UNP_WANTCRED)
+			unp3->unp_flags |= UNP_WANTCRED;
 #ifdef MAC
 		SOCK_LOCK(so);
 		mac_set_socket_peer_from_socket(so, so3);
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->maxim 
Responsible-Changed-By: maxim 
Responsible-Changed-When: Wed Dec 21 09:30:33 UTC 2005 
Responsible-Changed-Why:  
mdodd@ OKed your patch.  I'll work on its intergations to the tree 
and the regression test.  Thanks for the contibution! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=90644 
State-Changed-From-To: open->patched 
State-Changed-By: maxim 
State-Changed-When: Mon Apr 24 19:09:39 UTC 2006 
State-Changed-Why:  
Committed to HEAD.  Thanks for the patch! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=90644 
State-Changed-From-To: patched->closed 
State-Changed-By: maxim 
State-Changed-When: Sun May 21 09:14:46 UTC 2006 
State-Changed-Why:  
MFC'ed to RELENG_6. 

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