Date: Wed, 7 Feb 2001 19:40:40 -0600 From: Jonathan Lemon <jlemon@flugsvamp.com> To: net@freebsd.org Subject: Re: [itojun@iijlab.net: accept(2) behavior with tcp RST right after handshake] Message-ID: <20010207194040.O650@prism.flugsvamp.com> In-Reply-To: <9619.981596009@coconut.itojun.org> References: <9384.981594820@coconut.itojun.org> <9619.981596009@coconut.itojun.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Current updated patch for comments is below. Jayanth did make one point that an application could assume that the error return from accept was in regards to the listening socket instead of the new socket, so that may be a concern. -- Jonathan Index: uipc_socket.c =================================================================== RCS file: /ncvs/src/sys/kern/uipc_socket.c,v retrieving revision 1.68.2.11 diff -u -r1.68.2.11 uipc_socket.c --- uipc_socket.c 2000/12/22 10:25:21 1.68.2.11 +++ uipc_socket.c 2001/02/07 20:30:29 @@ -365,11 +365,8 @@ so->so_state &= ~SS_NOFDREF; if ((so->so_state & SS_ISDISCONNECTED) == 0) error = (*so->so_proto->pr_usrreqs->pru_accept)(so, nam); - else { - if (nam) - *nam = 0; - error = 0; - } + else + error = ECONNABORTED; splx(s); return (error); } Index: uipc_syscalls.c =================================================================== RCS file: /ncvs/src/sys/kern/uipc_syscalls.c,v retrieving revision 1.65.2.6 diff -u -r1.65.2.6 uipc_syscalls.c --- uipc_syscalls.c 2000/12/02 00:47:50 1.65.2.6 +++ uipc_syscalls.c 2001/02/07 21:27:03 @@ -283,7 +283,19 @@ nfp->f_ops = &socketops; nfp->f_type = DTYPE_SOCKET; sa = 0; - (void) soaccept(so, &sa); + error = soaccept(so, &sa); + if (error) { + /* + * return a namelen of zero for older code which might + * ignore the return value from accept. + */ + if (uap->name != NULL) { + namelen = 0; + (void) copyout((caddr_t)&namelen, + (caddr_t)uap->anamelen, sizeof(*uap->anamelen)); + } + goto noconnection; + } if (sa == NULL) { namelen = 0; if (uap->name) @@ -307,6 +319,7 @@ error = copyout((caddr_t)&namelen, (caddr_t)uap->anamelen, sizeof (*uap->anamelen)); } +noconnection: if (sa) FREE(sa, M_SONAME); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010207194040.O650>