Re: getpeername returning ENOTCONN for a connected socket

2014-06-21 Thread Sean Bruno
On Fri, 2014-06-20 at 16:21 -0700, hiren panchasara wrote:
> Reviving an old thread where Steve found this problem: A call to
> getpeername on a connected tcp socket returns ENOTCONN with no prior
> errors being reported by previous socket calls.
> 
> Please look at 
> http://lists.freebsd.org/pipermail/freebsd-net/2011-January/027647.html
> for more details.
> 
> Here is a proposed patch derived from
> $src/sys/netsmb/smb_trantcp.c:nbssn_recv()'s way of handling a similar
> situation:
> 
> Index: sys/kern/uipc_syscalls.c
> ===
> --- sys/kern/uipc_syscalls.c(revision 267693)
> +++ sys/kern/uipc_syscalls.c(working copy)
> @@ -1755,6 +1755,12 @@
> if (error != 0)
> return (error);
> so = fp->f_data;
> +   if ((so->so_state & (SS_ISDISCONNECTED|SS_ISDISCONNECTING)) ||
> +   (so->so_rcv.sb_state & SBS_CANTRCVMORE)) {
> +   error = ECONNRESET;
> +   goto done;
> +   }
> if ((so->so_state & (SS_ISCONNECTED|SS_ISCONFIRMING)) == 0) {
> error = ENOTCONN;
> goto done;
> 
> Does this look correct?
> 
> cheers,
> Hiren

Has this been tested in "anger" anywhere?

sean

___
freebsd-net@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


Re: getpeername returning ENOTCONN for a connected socket

2014-06-21 Thread hiren panchasara
On Sat, Jun 21, 2014 at 9:00 AM, Sean Bruno  wrote:
> On Fri, 2014-06-20 at 16:21 -0700, hiren panchasara wrote:
>> Reviving an old thread where Steve found this problem: A call to
>> getpeername on a connected tcp socket returns ENOTCONN with no prior
>> errors being reported by previous socket calls.
>>
>> Please look at 
>> http://lists.freebsd.org/pipermail/freebsd-net/2011-January/027647.html
>> for more details.
>>
>> Here is a proposed patch derived from
>> $src/sys/netsmb/smb_trantcp.c:nbssn_recv()'s way of handling a similar
>> situation:
>>
>> Index: sys/kern/uipc_syscalls.c
>> ===
>> --- sys/kern/uipc_syscalls.c(revision 267693)
>> +++ sys/kern/uipc_syscalls.c(working copy)
>> @@ -1755,6 +1755,12 @@
>> if (error != 0)
>> return (error);
>> so = fp->f_data;
>> +   if ((so->so_state & (SS_ISDISCONNECTED|SS_ISDISCONNECTING)) ||
>> +   (so->so_rcv.sb_state & SBS_CANTRCVMORE)) {
>> +   error = ECONNRESET;
>> +   goto done;
>> +   }
>> if ((so->so_state & (SS_ISCONNECTED|SS_ISCONFIRMING)) == 0) {
>> error = ENOTCONN;
>> goto done;
>>
>> Does this look correct?
>>
>> cheers,
>> Hiren
>
> Has this been tested in "anger" anywhere?

No. This patch is from code observation after looking at the problem.
I should at least writeup a small module to do local testing as Steve
did in original report. I'll do that and get back.
I'd appreciate if someone can point me to a better way of testing
this. (specially in "anger" ;-))

cheers,
Hiren
___
freebsd-net@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"