From owner-freebsd-net@FreeBSD.ORG Fri Jul 18 19:43:54 2008 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 B46F2106566B for ; Fri, 18 Jul 2008 19:43:54 +0000 (UTC) (envelope-from mgrooms@shrew.net) Received: from shrew.net (shrew.net [206.223.169.85]) by mx1.freebsd.org (Postfix) with ESMTP id 9299F8FC17 for ; Fri, 18 Jul 2008 19:43:54 +0000 (UTC) (envelope-from mgrooms@shrew.net) Received: from localhost (wm-ca.hub.org [206.223.169.82]) by shrew.net (Postfix) with ESMTP id 5C28179E30A for ; Fri, 18 Jul 2008 14:43:53 -0500 (CDT) Received: from shrew.net ([206.223.169.85]) by localhost (mx1.hub.org [206.223.169.82]) (amavisd-new, port 10024) with ESMTP id 86393-10 for ; Fri, 18 Jul 2008 19:43:53 +0000 (UTC) Received: from hole.shrew.net (cpe-70-113-206-103.austin.res.rr.com [70.113.206.103]) by shrew.net (Postfix) with ESMTP id B4E0979E26A for ; Fri, 18 Jul 2008 14:43:52 -0500 (CDT) Received: from [10.22.200.30] ([10.22.200.30]) by hole.shrew.net (8.14.2/8.14.2) with ESMTP id m6IJhnB5046162 for ; Fri, 18 Jul 2008 14:43:49 -0500 (CDT) (envelope-from mgrooms@shrew.net) Message-ID: <4880F273.1090802@shrew.net> Date: Fri, 18 Jul 2008 14:43:47 -0500 From: Matthew Grooms User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 To: freebsd-net@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Help with tap device configuration oddity 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, 18 Jul 2008 19:43:54 -0000 All, I noticed a problem with some software I wrote for FreeBSD using tap devices. It would appear that you get inconsistent results from ioctl calls SIOCSIFADDR and SIOCSIFNETMASK when used with tap than when used with a real Ethernet device. I wrote a quick test program to demonstrate this which can be found at the following url ... http://hole.shrew.net/~mgrooms/files/taptest.cpp g++ taptest.cpp -o taptest USAGE : taptest
[ifname] Specify the ifname parameter to configure an existing adapter. Omit the ifname paramter to create a tap device and configure it instead. When I use this with an Ethernet device on CURRENT, I get normal results ... # ./taptest 10.1.2.3 255.255.255.0 1350 le1 ii : configured adapter le1 [10.1.2.3/255.255.255.0 MTU 1350] le1: flags=8843 metric 0 mtu 1350 options=8 ether 00:0c:29:bd:60:2b inet 10.1.2.3 netmask 0xffffff00 broadcast 10.1.2.255 media: Ethernet autoselect status: active # netstat -rn Routing tables Internet: Destination Gateway Flags Refs Use Netif Expire default 10.aa.bbb.c UGS 0 89 le0 10.1.2.0/24 link#2 UC 0 0 le1 ... When I use this with a tap device on CURRENT, I always get a wacky 10/8 route added and no 10.2.3/24 route like you would expect ... # ./taptest 10.2.3.4 255.255.255.0 1350 creating tap device ii : opened tap device /dev/tap0 ii : configured adapter tap0 [10.2.3.4/255.255.255.0 MTU 1350] tap0: flags=8843 metric 0 mtu 1350 ether 00:bd:59:d2:02:00 inet 10.1.2.3 netmask 0xffffff00 broadcast 10.1.2.255 Opened by PID 1497 # netstat -rn Routing tables Internet: Destination Gateway Flags Refs Use Netif Expire default 10.aa.bbb.c UGS 0 89 le0 10.0.0.0/8 link#5 UC 0 0 tap0 This really messes with traffic that should go out the default route. I tested this on 6.2-RELEASE as well and got similar results ... # netstat -rn Routing tables Internet: Destination Gateway Flags Refs Use Netif Expire default 10.a.b.c UGS 0 5940 lnc0 10 link#7 UC 0 0 tap0 Can someone please explain this to me? Thanks in advance, -Matthew