Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Jul 2007 00:20:49 -0500 (CDT)
From:      Mike Silbersack <silby@silby.com>
To:        current@freebsd.org, net@freebsd.org
Cc:        Robert Watson <rwatson@freebsd.org>, Andre Oppermann <andre@freebsd.org>
Subject:   FreeBSD 7 TCP syncache fix: request for testers
Message-ID:  <20070709234401.S29353@odysseus.silby.com>

next in thread | raw e-mail | index | archive | help
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

--0-1185318269-1184043945=:29353
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII; FORMAT=flowed
Content-ID: <20070710000720.U29353@odysseus.silby.com>


I've found one of the causes of the network instability of FreeBSD 7; the 
tcp syncache fails to retransmit SYN-ACK packets.  This causes interesting 
problems when packet loss is experienced during connection setup.  The 
symptoms that I have witnessed are twofold:

1.  If the third part of the 3WHS is lost, the client will believe that 
the connection is in the ESTABLISHED state, while the server will still 
have the connection in the syncache.
2.  Subsequently, the above syncache entry will stay stuck in the syncache 
forever.  If you attempt to re-use that same 4-tuple, the syncache will 
ack the new SYN with the old sequence number.

Anyway, the attached patch simplifies the syncache structure a bit and 
makes it retransmit properly.  I'd appreciate testing from anyone who has 
experienced TCP problems with FreeBSD 7, as well as anyone who is pushing 
significant traffic through FreeBSD 7.

I'm not interested in FreeBSD 6 testers, since the FreeBSD 6 syncache has 
a different structure and is not affected by this bug.

FWIW, here's how to prove the existence of the bug.  Install nemesis from 
ports, then use it to send SYN packets at your FreeBSD 7 machine.  As of 
now, you should see only one SYN-ACK reply, and you should also notice 
that the sysctl net.inet.tcp.syncache.count goes up, but does not come 
back down.

Once you have applied the patch, you should see the behavior demonstrated 
below:

>From your client machine:  (nemesis will pick an IP to spoof, change that 
if you wish.)
nemesis tcp -y 80 -D 10.1.1.6

TCP Packet Injected

On your FreeBSD 7 machine:

patrocles# tcpdump -n port 80
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on nve0, link-type EN10MB (Ethernet), capture size 96 bytes
23:49:02.075118 IP 133.120.85.92.48922 > 10.1.1.6.80: S 1519649939:1519649939(0) win 4096
23:49:02.075165 IP 10.1.1.6.80 > 133.120.85.92.48922: S 269601671:269601671(0) ack 1519649940 win 65535 <mss 1460>
23:49:05.164195 IP 10.1.1.6.80 > 133.120.85.92.48922: S 269601671:269601671(0) ack 1519649940 win 65535 <mss 1460>
23:49:11.264245 IP 10.1.1.6.80 > 133.120.85.92.48922: S 269601671:269601671(0) ack 1519649940 win 65535 <mss 1460>
23:49:23.364342 IP 10.1.1.6.80 > 133.120.85.92.48922: S 269601671:269601671(0) ack 1519649940 win 65535 <mss 1460>

Thanks,

Mike "Silby" Silbersack
--0-1185318269-1184043945=:29353
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII; NAME=tcp_syncache.c-timerfix.patch
Content-Transfer-Encoding: BASE64
Content-ID: <20070710000545.B29353@odysseus.silby.com>
Content-Description: 
Content-Disposition: ATTACHMENT; FILENAME=tcp_syncache.c-timerfix.patch

LS0tIC91c3Ivc3JjL3N5cy5vbGQvbmV0aW5ldC90Y3Bfc3luY2FjaGUuYwky
MDA3LTA2LTI0IDIwOjE3OjMxLjAwMDAwMDAwMCAtMDUwMA0KKysrIC91c3Iv
c3JjL3N5cy9uZXRpbmV0L3RjcF9zeW5jYWNoZS5jCTIwMDctMDctMDkgMDA6
NDY6MTguMDAwMDAwMDAwIC0wNTAwDQpAQCAtMTQ5LDcgKzE1MCw2IEBADQog
CXN0cnVjdCBtdHgJc2NoX210eDsNCiAJVEFJTFFfSEVBRChzY2hfaGVhZCwg
c3luY2FjaGUpCXNjaF9idWNrZXQ7DQogCXN0cnVjdCBjYWxsb3V0CXNjaF90
aW1lcjsNCi0JaW50CQlzY2hfbmV4dGM7DQogCXVfaW50CQlzY2hfbGVuZ3Ro
Ow0KIAl1X2ludAkJc2NoX29kZGV2ZW47DQogCXVfaW50MzJfdAlzY2hfc2Vj
Yml0c19vZGRbU1lOQ09PS0lFX1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Z1
bmNfXykpOw0KICNlbmRpZg0KIAkJaWYgKHN5bmNhY2hlX3Jlc3BvbmQoc2Mp
ID09IDApIHsNCi0JCQlTWU5DQUNIRV9USU1FT1VUKHNjLCBzY2gsIDEpOw0K
KwkJCVNZTkNBQ0hFX1RJTUVPVVQoc2MpOw0KIAkJCXRjcHN0YXQudGNwc19z
bmRhY2tzKys7DQogCQkJdGNwc3RhdC50Y3BzX3NuZHRvdGFsKys7DQogCQl9
DQo=

--0-1185318269-1184043945=:29353--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070709234401.S29353>