From owner-freebsd-net Tue May 14 18:29: 4 2002 Delivered-To: freebsd-net@freebsd.org Received: from Awfulhak.org (gw.Awfulhak.org [217.204.245.18]) by hub.freebsd.org (Postfix) with ESMTP id 2091437B405 for ; Tue, 14 May 2002 18:28:47 -0700 (PDT) Received: from hak.lan.Awfulhak.org (root@hak.lan.Awfulhak.org [IPv6:fec0::1:12]) by Awfulhak.org (8.12.3/8.12.3) with ESMTP id g4F1SifK089637; Wed, 15 May 2002 02:28:44 +0100 (BST) (envelope-from brian@Awfulhak.org) Received: from hak.lan.Awfulhak.org (brian@localhost [127.0.0.1]) by hak.lan.Awfulhak.org (8.12.3/8.12.3) with ESMTP id g4F1Sf20006584; Wed, 15 May 2002 02:28:41 +0100 (BST) (envelope-from brian@hak.lan.Awfulhak.org) Message-Id: <200205150128.g4F1Sf20006584@hak.lan.Awfulhak.org> X-Mailer: exmh version 2.5 07/13/2001 with nmh-1.0.4 To: snap-users@kame.net Cc: net@freebsd.org Subject: Re: (KAME-snap 6381) tun device & IPv6 In-Reply-To: Message from Lars Eggert of "Tue, 14 May 2002 16:50:24 PDT." <3CE1A2C0.8050201@isi.edu> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <6579.1021426120.1@hak.lan.Awfulhak.org> Date: Wed, 15 May 2002 02:28:41 +0100 From: Brian Somers Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org > Hi, > > could someone with more knowledge of the tun device please take a look > at the code around line 387 in net/if_tun.c? It looks like tunoutput() > drops all packets here that aren't of the AF_INET family - most notably, > it drops IPv6 packets. > > We hacked around this with the simple fix below, but I'm not sure if > there are any drawbacks... > > --- if_tun.c.old Tue May 14 15:40:30 2002 > +++ if_tun.c Tue May 14 15:48:15 2002 > @@ -384,7 +384,7 @@ > *(u_int32_t *)m0->m_data = htonl(dst->sa_family); > } else { > #ifdef INET > - if (dst->sa_family != AF_INET) > + if (dst->sa_family != AF_INET && dst->sa_family != AF_INET6) > #endif > { > m_freem(m0); > > Thanks, > Lars > -- > Lars Eggert USC Information Sciences Institute If you look at the larger picture.... if (tp->tun_flags & TUN_IFHEAD) { /* Prepend the address family */ M_PREPEND(m0, 4, M_DONTWAIT); /* if allocation failed drop packet */ if (m0 == NULL) { ifp->if_iqdrops++; ifp->if_oerrors++; return (ENOBUFS); } else *(u_int32_t *)m0->m_data = htonl(dst->sa_family); } else { #ifdef INET if (dst->sa_family != AF_INET) #endif { m_freem(m0); return (EAFNOSUPPORT); } } The tun device, when given the TUNSIFHEAD ioctl, will prepend the address family. If TUNSIFHEAD is turned off, it will drop non IPv4 packets. This was done for backwards compatibility. To use IPv6 with tun, you must use the TUNSIFHEAD ioctl and prepend/strip the address family on the front of each packet (see bundle_Create() in src/usr.sbin/ppp/bundle.c). -- Brian http://www.freebsd-services.com/ Don't _EVER_ lose your sense of humour ! To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message