Date: Tue, 7 Jun 2005 08:40:12 +1200 From: Matthew Luckie <mjl@luckie.org.nz> To: Bruce M Simpson <bms@spc.org> Cc: freebsd-net@freebsd.org Subject: Re: bpf writes on tun device Message-ID: <20050606204008.GA91353@lycra.luckie.org.nz> In-Reply-To: <20050606120851.GD734@empiric.icir.org> References: <4295A6CA.8080409@luckie.org.nz> <20050606081637.GA73886@lycra.luckie.org.nz> <20050606120851.GD734@empiric.icir.org>
next in thread | previous in thread | raw e-mail | index | archive | help
> > If I was to pursue this, would someone on this list consider committing the > > work to current? > ... > > + case DLT_NULL: > > + sockp->sa_family = AF_UNSPEC; > > + if(strcmp(ifp->if_name, "tun") == 0) > > + hlen = sizeof(int); > > + else > > + hlen = 0; > > + break; > > Maybe this won't work if an instance of tun is renamed? I'd compare "tun" > with ifp->if_dname (driver name) to be on the safe side. right. although the patch was against 4.11 which does not have if_dname. does 4.11 support renaming interfaces? it doesn't appear to. i wasn't really suggesting that we'd add a series of strcmp to see which driver corresponds to the DLT_NULL, just that if if_tun was handled specially then bpf writes would work correctly on it. > Another way of dealing with this would be to ask the tcpdump.org guys to > define a DLT type for tun interfaces, rather than special-casing it for > DLT_NULL. is there a good reason why _all_ DLT_NULL bpf devices could not simply have writes supported? the user space application would pass the address family in the first 4 bytes of the packet; this is currently done anyway for if_disc, if_loop, if_tun, if_faith, and ng_iface. ip_carp could get bpf writes for free with AF_UNSPEC added to the carp_looutput() switch statement. [mjl@mylar sys]$ egrep -r 'bpfattach.+DLT_NULL' * dev/iicbus/if_ic.c: bpfattach(ifp, DLT_NULL, ICHDRLEN); dev/ppbus/if_plip.c: bpfattach(ifp, DLT_NULL, sizeof(u_int32_t)); i4b/driver/i4b_ipr.c: bpfattach(&sc->sc_if, DLT_NULL, sizeof(u_int)); net/if_disc.c: bpfattach(ifp, DLT_NULL, sizeof(u_int)); net/if_faith.c: bpfattach(&sc->sc_if, DLT_NULL, sizeof(u_int)); net/if_gif.c: bpfattach(&sc->gif_if, DLT_NULL, sizeof(u_int)); net/if_gre.c: bpfattach(&sc->sc_if, DLT_NULL, sizeof(u_int32_t)); net/if_loop.c: bpfattach(&sc->sc_if, DLT_NULL, sizeof(u_int)); net/if_stf.c: bpfattach(ifp, DLT_NULL, sizeof(u_int)); net/if_tun.c: bpfattach(ifp, DLT_NULL, sizeof(u_int)); netgraph/ng_iface.c: bpfattach(ifp, DLT_NULL, sizeof(u_int)); netgraph/ng_sppp.c: bpfattach (&pp->pp_if, DLT_NULL, sizeof(u_int)); netinet/ip_carp.c: bpfattach(&sc->sc_if, DLT_NULL, sizeof(u_int32_t)); Matthew
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050606204008.GA91353>