From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ani Sinha Subject: Re: [tcpdump-workers] vlan tagged packets and libpcap breakage Date: Mon, 17 Dec 2012 11:49:15 -0800 Message-ID: References: <3246.1351717319@obiwan.sandelman.ca> <21992.1351723328@obiwan.sandelman.ca> <50C9936B.2000201@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT Cc: David Laight , Daniel Borkmann , netdev@vger.kernel.org, Michael Richardson , tcpdump-workers@lists.tcpdump.org, Francesco Ruggeri To: Guy Harris Return-path: Received: from mail-vc0-f174.google.com ([209.85.220.174]:48966 "EHLO mail-vc0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752559Ab2LQTtQ convert rfc822-to-8bit (ORCPT ); Mon, 17 Dec 2012 14:49:16 -0500 Received: by mail-vc0-f174.google.com with SMTP id d16so7752708vcd.19 for ; Mon, 17 Dec 2012 11:49:15 -0800 (PST) In-Reply-To: Sender: netdev-owner@vger.kernel.org List-ID: On Mon, Dec 17, 2012 at 2:35 AM, Guy Harris wrote: > > On Dec 17, 2012, at 1:50 AM, "David Laight" wrote: > >> How are you going to tell whether a feature is present in a non-Linux >> kernel ? > > The Linux memory-mapped capture mechanism is not present in a non-Linux kernel, so all the libpcap work involved here would, if necessary on other platforms, have to be done >differently on those platforms. Those platforms would have to have their own mechanisms to indicate whether any changes to filter code, processing of VLAN tags supplied out of >band, etc. would need to be done. Actually lib-pcap has these pcap-.c files that are kind of like platform specific drivers that plug into platform independent code like gencode.c or bpf_filter.c. These platform specific drivers are responsible for getting packets from the kernel and running filters (kernel or userland) on it. So all linux specific code to get a packet and packet metadata from the kernel can neatly reside in pcap-linux.c. Unfortunately though, in this specific problem involving filtering with vlan tags, both code generation (gentags.c) and code running the filter (bpf_filter.c) will have to be aware of linux specific semantics. Due to the issues that Bill had explained earlier in the thread, we can not rely on post processing before installing the kernel filter. Therefore, we need to generate a filter that can be directly installed in the kernel. For the same reason, bpf_filter() code also needs to change - be aware of linux specific semantics.