From owner-freebsd-net Sun Apr 22 11: 9:43 2001 Delivered-To: freebsd-net@freebsd.org Received: from mail.gmx.net (pop.gmx.net [194.221.183.20]) by hub.freebsd.org (Postfix) with SMTP id AE0D037B424 for ; Sun, 22 Apr 2001 11:09:37 -0700 (PDT) (envelope-from tmoestl@gmx.net) Received: (qmail 26817 invoked by uid 0); 22 Apr 2001 18:09:36 -0000 Received: from pd900c687.dip.t-dialin.net (HELO forge.local) (217.0.198.135) by mail.gmx.net (mail06) with SMTP; 22 Apr 2001 18:09:36 -0000 Received: from tmm by forge.local with local (Exim 3.20 #1) id 14rOIm-0001LH-00; Sun, 22 Apr 2001 20:09:40 +0200 Date: Sun, 22 Apr 2001 20:09:39 +0200 From: Thomas Moestl To: freebsd-net@FreeBSD.org Cc: Robert Watson Subject: Making getsockname return sensible data for unbound AF_UNIX sockets Message-ID: <20010422200939.A4797@crow.dom2ip.de> Mail-Followup-To: Thomas Moestl , freebsd-net@FreeBSD.org, Robert Watson Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="OXfL5xGRrasGEqWY" Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org --OXfL5xGRrasGEqWY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hello, I would like to commit a really small patch that makes getsockname fill the sockaddr for non-bound PF_LOCAL sockets with sun_noname, instead of just setting the length parameter to 0 and return (without an error) like it does now. PF_INET and PF_INET6 sockets, for example, behave like this, and it is useful to get the address family of a socket, for example in the RPC library. SUSv2 says wrt getsockname: If the socket has not been bound to a local name, the value stored in the object pointed to by address is unspecified. So this does not break standard conformity (using this feature however could, of course, OTOH e.g. the RPC code is anyway specific to FreeBSD to a certain extent). From a quick glance, it seems that NetBSD implements the behaviour this patch would give use, while OpenBSD uses the other one. Patch attached. Any comments or objections? - thomas --OXfL5xGRrasGEqWY Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="unp.diff" Index: sys/kern/uipc_usrreq.c =================================================================== RCS file: /home/ncvs/src/sys/kern/uipc_usrreq.c,v retrieving revision 1.63 diff -u -r1.63 uipc_usrreq.c --- sys/kern/uipc_usrreq.c 2001/02/21 06:39:55 1.63 +++ sys/kern/uipc_usrreq.c 2001/04/22 12:51:24 @@ -420,6 +420,8 @@ return EINVAL; if (unp->unp_addr) *nam = dup_sockaddr((struct sockaddr *)unp->unp_addr, 1); + else + *nam = dup_sockaddr((struct sockaddr *)&sun_noname, 1); return 0; } --OXfL5xGRrasGEqWY-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message