Date: Sun, 22 Apr 2001 20:09:39 +0200 From: Thomas Moestl <tmoestl@gmx.net> To: freebsd-net@FreeBSD.org Cc: Robert Watson <rwatson@FreeBSD.org> Subject: Making getsockname return sensible data for unbound AF_UNIX sockets Message-ID: <20010422200939.A4797@crow.dom2ip.de>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --] 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 [-- Attachment #2 --] 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; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010422200939.A4797>
