From owner-freebsd-net@FreeBSD.ORG Fri Jul 17 23:01:05 2009 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 12C291065670 for ; Fri, 17 Jul 2009 23:01:05 +0000 (UTC) (envelope-from seklecki@noc.cfi.pgh.pa.us) Received: from mx04.pub.collaborativefusion.com (mx04.pub.collaborativefusion.com [206.210.72.84]) by mx1.freebsd.org (Postfix) with ESMTP id B3A148FC12 for ; Fri, 17 Jul 2009 23:01:04 +0000 (UTC) (envelope-from seklecki@noc.cfi.pgh.pa.us) Received: from [192.168.2.161] ([206.210.89.202]) by mx04.pub.collaborativefusion.com (StrongMail Enterprise 4.1.1.4(4.1.1.4-47689)); Fri, 17 Jul 2009 18:29:43 -0400 X-VirtualServerGroup: Default X-MailingID: 00000::00000::00000::00000::::1 X-SMHeaderMap: mid="X-MailingID" X-Destination-ID: freebsd-net@freebsd.org X-SMFBL: ZnJlZWJzZC1uZXRAZnJlZWJzZC5vcmc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=noc.cfi.pgh.pa.us; s=noc_cfi_pgh_pa_us_key_dkim; l=2668; t=1247869783; i=@noc.cfi.pgh.pa.us; h=Subject:From:To: Content-Type:Date:Message-Id:Mime-Version:X-Mailer: Content-Transfer-Encoding; bh=yfYz0YhAunQ85ZXvt+5AUI+oZdE=; b=d1 pHP24k7QQc89rua+HOmcyQ3kRkbnFsjb/dDOmRG3KafOCm+x3u+DIW+swyjvq1DR 5Vj4g+wIGXSXJTuJQBoAQRiSr0wrvyVAFVQ1AHzdnuRMZHxE8NyTQr2b4+iPAC From: "Brian A. Seklecki" To: freebsd-net@freebsd.org Content-Type: text/plain Date: Fri, 17 Jul 2009 18:46:02 -0400 Message-Id: <1247870762.10382.14770.camel@soundwave.ws.pitbpa0.priv.collaborativefusion.com> Mime-Version: 1.0 X-Mailer: Evolution 2.26.2 (2.26.2-1.fc11) Content-Transfer-Encoding: 7bit Subject: Dropped/Duplicate SYN, Cisco PIX/ASA, and and random ISN w/ net.inet.ip.random_id=1 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jul 2009 23:01:05 -0000 All: We recently worked closely with some FreeBSD developers to track down an illusive bug in the stack. In a high performance environment, we observed dropped (or extreme delayed) SYN packets, but were unable to easily reproduce the problem using test case scenarios. Our environment: - FreeBSD 7.x Servers - FreeBSD 6.x clients - PIX/ASA 7.2.x stateful firewalls - pf(4) on the server with lots of jails - PHP clients and server with SOAP framework, so lots and lots of sockets, often thousands between any given client->server, in various TCP states. Getting to the heart of the matter, see: http://fxr.watson.org/fxr/source/netinet/tcp_timewait.c#L385 Here we drop SYN's from [client:source_ephemeral_socket] if: 1) We already have that exact combination in CLOSE_WAIT 2) The ISN of the new incoming SYN is lower than that of the existing socket in CLOSE_WAIT Those conditions are _highly_ unlikely, until you start hedging your bets. net.inet.ip.random_id=1 in sysctl.conf(5) is one way to exacerbate the problem. So are the magic scrubbing bubbles in pf.conf(5): scrub all random-id. Also, the PIX/ASA code randomizes IDs by default as well(*). net.inet.ip.portrange.randomized is another; since truly randomized numbers can involved duplicates. Additionally, the default random port ephemeral source port range is way too small for these HPC environments, leading to more likely collisions, so that can be increased: net.inet.ip.random_id=0 net.inet.ip.portrange.randomized=1 net.inet.ip.portrange.first=2048 Anyway, this discussion strictly for the benefit of the mailing list archives, in case, further down the road, someone else finds them self tcpdump(8)'ing duplicate SYNs and starting at netstat(8) -s output and beginning to doubt their own existence. ~Brian A. Seklecki (*) To disable port randomization on the Cisco PIX: tcp-map verify-chksum check-retransmission checksum-verification exceed-mss drop syn-data drop tcp-options selective-ack allow urgent-flag clear no ttl-evasion-protection ! icmp unreachable rate-limit 1 burst-size 1 timeout xlate 3:00:00 timeout conn 12:00:00 half-closed 0:10:00 udp 0:01:00 icmp 0:00:02 timeout sunrpc 0:10:00 h323 0:05:00 h225 1:00:00 mgcp 0:05:00 ! policy-map global_policy class my_inspection_tcp set connection embryonic-conn-max 2048 per-client-max 1024\ per-client-embryonic-max 1024 random-sequence-number disable set connection timeout embryonic 0:02:00 tcp 1:30:00 dcd 24:00:00 5 set connection advanced-options verify-chksum ! service-policy global_policy interface [WhateverIF]