Date: Wed, 15 May 2002 02:28:41 +0100 From: Brian Somers <brian@Awfulhak.org> To: snap-users@kame.net Cc: net@freebsd.org Subject: Re: (KAME-snap 6381) tun device & IPv6 Message-ID: <200205150128.g4F1Sf20006584@hak.lan.Awfulhak.org> In-Reply-To: Message from Lars Eggert <larse@ISI.EDU> of "Tue, 14 May 2002 16:50:24 PDT." <3CE1A2C0.8050201@isi.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
> 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 <larse@isi.edu> 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 <brian@freebsd-services.com> <brian@Awfulhak.org> http://www.freebsd-services.com/ <brian@[uk.]FreeBSD.org> Don't _EVER_ lose your sense of humour ! <brian@[uk.]OpenBSD.org> To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200205150128.g4F1Sf20006584>