FYI, the tcpdump I sent previously was with one of our previously-discussed 
patches in place:

    if (!proxy->client_proxy && net_geterror(proxy->fd_ssl) == EBADF) {

I'm attaching that dump again (as tcpdump_output_witholdpatch_headeronly.txt), 
as well as a dump without any of the patches 
(tcpdump_output_withoutpatches_headeronly.txt) in case there is any difference.

On December 4, 2012 6:18:23 AM PST, Ben Morrow <b...@morrow.me.uk> wrote:
> At 12PM +0000 on  4/12/12 Ben Morrow wrote:
>> Well, it looks to me as though xnu/bsd/kern/uipc_socket.c:soreceive will
>> indeed return ENOTCONN for a socket which was once successfully
>> connected but has now been disconnected. This happens when the socket is
>> in the DEFUNCT state, which is a state that doesn't exist in FreeBSD;
>> it's not completely clear but I suspect firewalls may be able to put
>> arbitrary sockets into that state.
> 
> Investigating a little further, it should be possible to test for this
> situation directly. Assuming I'm correct about what's going on here,
> this should be both cleaner and safer than mucking about looking for
> ENOTCONN and guessing about what's happening.
> 
> Erik, does this make the problem go away? I left out the
> proxy->client_proxy test, since AFAICT this is just as likely to happen
> on a client socket.
> 
> Ben
> 
> #ifdef SO_ISDEFUNCT
> +                if (getsockopt(proxy->fd_ssl, SOL_SOCKET, SO_ISDEFUNCT,
> +                    (void *)&err, sizeof(err)) == 0 && err) {
> +                        errstr = t_strdup_printf(
> +                            "%s: socket is defunct", func_name);
> +                        break;
> +                }
> +#endif

Nope, SO_ISDEFUNCT isn't defined.


02:40:58.721596 IP (tos 0x0, ttl 64, id 17809, offset 0, flags [DF], proto TCP 
(6), length 64)
    CLIENT.51819 > SERVER.imaps: Flags [S], cksum 0xe780 (correct), seq 
2439614483, win 65535, options [mss 1460,nop,wscale 3,nop,nop,TS val 1051593167 
ecr 0,sackOK,eol], length 0
02:40:58.721803 IP (tos 0x0, ttl 64, id 55036, offset 0, flags [DF], proto TCP 
(6), length 64)
    SERVER.imaps > CLIENT.51819: Flags [S.], cksum 0x277c (correct), seq 
947774533, ack 2439614484, win 65535, options [mss 1460,nop,wscale 4,nop,nop,TS 
val 877424355 ecr 1051593167,sackOK,eol], length 0
02:40:58.726646 IP (tos 0x0, ttl 64, id 34733, offset 0, flags [DF], proto TCP 
(6), length 52)
    CLIENT.51819 > SERVER.imaps: Flags [.], cksum 0x6748 (correct), seq 1, ack 
1, win 65535, options [nop,nop,TS val 1051593169 ecr 877424355], length 0
02:40:58.726754 IP (tos 0x0, ttl 64, id 6073, offset 0, flags [DF], proto TCP 
(6), length 52)
    SERVER.imaps > CLIENT.51819: Flags [.], cksum 0x4718 (correct), seq 1, ack 
1, win 8235, options [nop,nop,TS val 877424360 ecr 1051593169], length 0
02:40:58.732338 IP (tos 0x0, ttl 64, id 20960, offset 0, flags [DF], proto TCP 
(6), length 52)
    SERVER.imaps > CLIENT.51819: Flags [F.], cksum 0x4712 (correct), seq 1, ack 
1, win 8235, options [nop,nop,TS val 877424365 ecr 1051593169], length 0
02:40:58.746788 IP (tos 0x0, ttl 64, id 37781, offset 0, flags [DF], proto TCP 
(6), length 182)
    CLIENT.51819 > SERVER.imaps: Flags [P.], cksum 0xfb11 (correct), seq 1:131, 
ack 1, win 65535, options [nop,nop,TS val 1051593169 ecr 877424355], length 130
02:40:58.746793 IP (tos 0x0, ttl 64, id 50564, offset 0, flags [DF], proto TCP 
(6), length 52)
    CLIENT.51819 > SERVER.imaps: Flags [.], cksum 0x66ba (correct), seq 131, 
ack 2, win 65535, options [nop,nop,TS val 1051593170 ecr 877424365], length 0
02:40:58.746842 IP (tos 0x0, ttl 64, id 49645, offset 0, flags [DF], proto TCP 
(6), length 40)
    SERVER.imaps > CLIENT.51819: Flags [R], cksum 0xad98 (correct), seq 
947774534, win 0, length 0
02:40:58.746843 IP (tos 0x0, ttl 64, id 42942, offset 0, flags [DF], proto TCP 
(6), length 40)
    SERVER.imaps > CLIENT.51819: Flags [R], cksum 0xad97 (correct), seq 
947774535, win 0, length 0
02:40:58.747318 IP (tos 0x0, ttl 64, id 27131, offset 0, flags [DF], proto TCP 
(6), length 52)
    CLIENT.51819 > SERVER.imaps: Flags [F.], cksum 0x66b9 (correct), seq 131, 
ack 2, win 65535, options [nop,nop,TS val 1051593170 ecr 877424365], length 0
02:40:58.747335 IP (tos 0x0, ttl 64, id 48383, offset 0, flags [DF], proto TCP 
(6), length 40)
    SERVER.imaps > CLIENT.51819: Flags [R], cksum 0xad97 (correct), seq 
947774535, win 0, length 0
00:16:20.326450 IP (tos 0x0, ttl 64, id 51763, offset 0, flags [DF], proto TCP 
(6), length 64)
    CLIENT.54746 > SERVER.imaps: Flags [S], cksum 0x34d4 (correct), seq 
3842628554, win 65535, options [mss 1460,nop,wscale 3,nop,nop,TS val 1053233564 
ecr 0,sackOK,eol], length 0
00:16:20.326627 IP (tos 0x0, ttl 64, id 59987, offset 0, flags [DF], proto TCP 
(6), length 64)
    SERVER.imaps > CLIENT.54746: Flags [S.], cksum 0x3cd6 (correct), seq 
1319342818, ack 3842628555, win 65535, options [mss 1460,nop,wscale 
4,nop,nop,TS val 930864874 ecr 1053233564,sackOK,eol], length 0
00:16:20.331353 IP (tos 0x0, ttl 64, id 42556, offset 0, flags [DF], proto TCP 
(6), length 52)
    CLIENT.54746 > SERVER.imaps: Flags [.], cksum 0x7ca2 (correct), seq 1, ack 
1, win 65535, options [nop,nop,TS val 1053233566 ecr 930864874], length 0
00:16:20.331530 IP (tos 0x0, ttl 64, id 20835, offset 0, flags [DF], proto TCP 
(6), length 52)
    SERVER.imaps > CLIENT.54746: Flags [.], cksum 0x5c73 (correct), seq 1, ack 
1, win 8235, options [nop,nop,TS val 930864878 ecr 1053233566], length 0
00:16:20.332322 IP (tos 0x0, ttl 64, id 25630, offset 0, flags [DF], proto TCP 
(6), length 182)
    CLIENT.54746 > SERVER.imaps: Flags [P.], cksum 0xb7cc (correct), seq 1:131, 
ack 1, win 65535, options [nop,nop,TS val 1053233566 ecr 930864874], length 130
00:16:20.332384 IP (tos 0x0, ttl 64, id 49451, offset 0, flags [DF], proto TCP 
(6), length 52)
    SERVER.imaps > CLIENT.54746: Flags [.], cksum 0x5bf1 (correct), seq 1, ack 
131, win 8235, options [nop,nop,TS val 930864878 ecr 1053233566], length 0
00:16:20.336998 IP (tos 0x0, ttl 64, id 34820, offset 0, flags [DF], proto TCP 
(6), length 52)
    SERVER.imaps > CLIENT.54746: Flags [F.], cksum 0x5beb (correct), seq 1, ack 
131, win 8235, options [nop,nop,TS val 930864883 ecr 1053233566], length 0
00:16:20.342139 IP (tos 0x0, ttl 64, id 40495, offset 0, flags [DF], proto TCP 
(6), length 52)
    CLIENT.54746 > SERVER.imaps: Flags [.], cksum 0x7c16 (correct), seq 131, 
ack 2, win 65535, options [nop,nop,TS val 1053233566 ecr 930864883], length 0
00:16:20.342216 IP (tos 0x0, ttl 64, id 23878, offset 0, flags [DF], proto TCP 
(6), length 52)
    SERVER.imaps > CLIENT.54746: Flags [.], cksum 0x5be6 (correct), seq 2, ack 
131, win 8235, options [nop,nop,TS val 930864888 ecr 1053233566], length 0
00:16:20.343148 IP (tos 0x0, ttl 64, id 55398, offset 0, flags [DF], proto TCP 
(6), length 52)
    CLIENT.54746 > SERVER.imaps: Flags [F.], cksum 0x7c15 (correct), seq 131, 
ack 2, win 65535, options [nop,nop,TS val 1053233566 ecr 930864883], length 0
00:16:20.343207 IP (tos 0x0, ttl 64, id 59247, offset 0, flags [DF], proto TCP 
(6), length 52)
    SERVER.imaps > CLIENT.54746: Flags [.], cksum 0x5be4 (correct), seq 2, ack 
132, win 8235, options [nop,nop,TS val 930864889 ecr 1053233566], length 0

Reply via email to