From owner-freebsd-net@FreeBSD.ORG Wed Feb 14 07:55:14 2007 Return-Path: X-Original-To: freebsd-net@freebsd.org Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B59A216A400 for ; Wed, 14 Feb 2007 07:55:14 +0000 (UTC) (envelope-from tomas@tutus.se) Received: from fw-y.tutus.se (static-213-115-50-13.sme.bredbandsbolaget.se [213.115.50.13]) by mx1.freebsd.org (Postfix) with ESMTP id 4D40513C48E for ; Wed, 14 Feb 2007 07:55:13 +0000 (UTC) (envelope-from tomas@tutus.se) Received: from munin.tutus.se (munin.tutus.se [193.181.0.67]) by fw-y.tutus.se (omb_smtp 1.7) with ESMTP; (cipher=AES256-SHA from= verify=NO) Wed, 14 Feb 2007 08:55:45 +0100 (CET) Received: from [193.181.0.105] ([193.181.0.105]) by munin.tutus.se (8.13.6.20060614/8.13.6) with ESMTP id l1E7t8df090367 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Wed, 14 Feb 2007 08:55:09 +0100 (CET) Message-ID: <45D2C05D.7000707@tutus.se> Date: Wed, 14 Feb 2007 08:55:09 +0100 From: Tomas Svensson User-Agent: Thunderbird 1.5.0.9 (X11/20070102) MIME-Version: 1.0 To: Julian Elischer References: <45CC686F.1050409@tutus.se> <45CCDF66.90505@elischer.org> In-Reply-To: <45CCDF66.90505@elischer.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-net@freebsd.org Subject: Re: problem with ng_device as tun replacement 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: Wed, 14 Feb 2007 07:55:14 -0000 Julian Elischer wrote: > Tomas Svensson wrote: >> Hi, >> >> I am trying to replace the tun interface using netgraph by linking >> ng_device and ng_iface: >> >> ngctl mkpeer iface dummy inet >> ngctl mkpeer ng0: device inet inet >> >> then I try to use it as a drop-in replacement for tun, but it doesn't >> really work: >> >> 1. If I send an IP packet through /dev/ngd0 (after doing a normal >> open()), the packet doesn't get sent until I write a second packet to >> the device. > > Do you know it the ng-device device is hanging onto it, or the > ng_iface device is getting it but not passing it on? > > If you don't know, you can put a 'tee' node between them > and use nghook(8) to see when the packet is passed between the nodes. > Thanks, I checked with tee and nghook(8) and found the follwing two cases: 1. Packets are arriving from the ng_iface (ng0) via the hook to ng_device (dev/ngd0), but the packets are just queuing up and the descriptor that opened /dev/ngd0 is not marked as readable until there is a number of packets queued. 2. A packet first arrives on /dev/ngd0 and is sent via the hook to ng0. A response packet is later arriving on the interface and is sent back to the device via the hook. Now the packet is stuck. Yet another packet arrives on /dev/ngd0 which makes it let go of the first packet (the first packet is sent out /dev/ngd0 and the new packet is sent via the hook to ng0). I send normal ICMP echo packets and the code works fine with tun(4). -Tomas