From owner-freebsd-net@FreeBSD.ORG Mon Sep 11 22:30:59 2006 Return-Path: X-Original-To: net@FreeBSD.org Delivered-To: freebsd-net@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D520E16A47B; Mon, 11 Sep 2006 22:30:59 +0000 (UTC) (envelope-from FreeBSD-gnats-submit@FreeBSD.org) Received: from mail.borderware.com (mail.borderware.com [207.236.65.231]) by mx1.FreeBSD.org (Postfix) with ESMTP id 317E043D76; Mon, 11 Sep 2006 22:30:50 +0000 (GMT) (envelope-from FreeBSD-gnats-submit@FreeBSD.org) Delivered-To: cmills@borderware.com X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Resent-Date: Mon, 11 Sep 2006 13:50:17 GMT Resent-Message-Id: <200609111350.k8BDoHFP086858@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Eugene Grosbein Message-Id: <200609111341.k8BDfneZ020221@nkz.delikates-nk.ru> Date: Mon, 11 Sep 2006 21:41:49 +0800 (KRAST) From: Eugene Grosbein To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Sender: owner-freebsd-bugs@freebsd.org Errors-To: owner-freebsd-bugs@freebsd.org X-STA-Metric: 0 (engine=022) X-STA-NotSpam: url:mailman from:addr:eugen url:listinfo skip:__ 40 workaround X-STA-Spam: kern $2, tcpdump diverting breaking X-BTI-AntiSpam: score:0, sta:0/022, dcc:passed, dnsbl:passed, sw:passed, bsn:50/passed, spf:off, dk:off, pbmf:none, ipr:0/7, trusted:no, ts:no, ubl:passed X-OriginalArrivalTime: 11 Sep 2006 13:51:05.0220 (UTC) FILETIME=[5368BC40:01C6D5A9] Cc: net@FreeBSD.org Subject: kern/103135: ipsec with ipfw divert (not NAT) encodes a packet twice breaking PMTUD X-BeenThere: freebsd-net@freebsd.org List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Sep 2006 22:31:00 -0000 >Number: 103135 >Category: kern >Synopsis: ipsec with ipfw divert (not NAT) encodes a packet twice breaking PMTUD >Confidential: no >Severity: serious >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Sep 11 13:50:16 GMT 2006 >Closed-Date: >Last-Modified: >Originator: Eugene Grosbein >Release: FreeBSD 6.1-STABLE i386 >Organization: Svyaz Service JSC >Environment: System: FreeBSD nkz.delikates-nk.ru 6.1-STABLE FreeBSD 6.1-STABLE #1: Thu Sep 7 13:31:53 KRAST 2006 root@nkz.delikates-nk.ru:/home/obj/home/src/sys/NKZ i386 options IPDIVERT options IPSEC options IPSEC_ESP >Description: When outgoing packet encoded due to corresponding IPSEC policy is passed to divert socket (f.e. to ipacctd for accounting), it is encoded second time with IPSEC then. Besides obvious logic error, this also results in broken Path MTU Discovery. >How-To-Repeat: Use a kernel with options IPDIVERT, IPSEC, IPSEC_ESP (my kernel also contains IPSEC_FILTERGIF, but this should not matter). Suppose there are two local nets numbered 192.168.1.0/24 and 192.168.2.0/24, each has a FreeBSD router (192.168.1.1 and 192.168.2.1). Routers make gif(4) tunnel between and use IPSEC transport mode to encrypt its contents. Their external IP addresses are 1.1.1.1 and 2.2.2.2 Here is /etc/ipsec.conf: add 1.1.1.1 81.16.143.102 esp 1007 -m transport -E blowfish-cbc "xxx"; add 2.2.2.2 1.1.1.1 esp 2007 -m transport -E blowfish-cbc "yyy"; spdadd 1.1.1.1/32 2.2.2.2/32 any -P in ipsec esp/transport/1.1.1.1-2.2.2.2/require; spdadd 2.2.2.2/32 1.1.1.1/32 any -P out ipsec esp/transport/2.2.2.2-1.1.1.1/require; Another router has similar /etc/ipsec.conf. Use this script to prepare IPSEC keys for tcpdump: #!/bin/sh setkey -D | awk ' /^[1-9]/ { ip=$2; } $1=="esp" { sub(/spi=[^(]+\(/, "", $3); sub(/\)/, "", $3); printf"%s@%s ",$3,ip; } $1=="E:" { printf "%s:0x%s%s%s%s\n", $2, $3, $4, $5, $6; } ' > /tmp/keys.txt When we use one of the routers to run "tcpdump -s0 -n -p -i $iface -E /tmp/keys.txt esp", we see that traffic is encoded with ESP and decoded properly, still good. Now install ports/net-mgmt/ipacctd, run it manually with "ipacctd -p 4000", then command: "ipfw add 10 divert 4000 ip from any to any out" and rerun tcpdump command shown above. You'll see that outgoing packets are encapsulated with ESP twice. The same you'll see at the other side for incoming packets. >Fix: Unknown. The only known workaround is to avoid diverting ESP. This workaroung is not always acceptable. Eugene Grosbein >Release-Note: >Audit-Trail: >Unformatted: _______________________________________________ freebsd-bugs@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-bugs To unsubscribe, send any mail to "freebsd-bugs-unsubscribe@freebsd.org"