From patchwork Wed Dec 12 21:53:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ani Sinha X-Patchwork-Id: 205664 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3010E2C008E for ; Thu, 13 Dec 2012 08:53:23 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755304Ab2LLVxV (ORCPT ); Wed, 12 Dec 2012 16:53:21 -0500 Received: from mail-pb0-f46.google.com ([209.85.160.46]:49177 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754756Ab2LLVxT (ORCPT ); Wed, 12 Dec 2012 16:53:19 -0500 Received: by mail-pb0-f46.google.com with SMTP id wy7so956700pbc.19 for ; Wed, 12 Dec 2012 13:53:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:reply-to:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version:content-type:x-gm-message-state; bh=VfBlOM+q9+hOCgNL42sOcmtkPRVm1YIVYWPrcVcOOMw=; b=LbLxv0Z90ItEmGJ0QopMPlxiD/f5RTBOcwkDc5HsN7wgVsW4kiaF+NlO+HorIE5C1V xT8I2zkLSUl1GliFVatKDcWp51k6oA2beRmqTEg5kOsyd9AFb5Cljm7a7g5wBV9C32lj zZRmrgbXamufPeTO2uGSlaYOauSjT8Dv5o5jciOfgkCD16tpiz7RQ5v+V5VKvqYTHSO8 cJNcFNkmQ2ZgyFQw/jyhHx0zL03ieRvjmU3cNJdf5jhVKcrcXDE+QE56KajLTNn5g5nT 78yjRtlIfWUIygs60DMMDFhxi/BQNHySKCnuReyO0CoX7coghcjbQU+t6KJ+FzuHloH+ k1lQ== Received: by 10.66.89.42 with SMTP id bl10mr225917pab.2.1355349199360; Wed, 12 Dec 2012 13:53:19 -0800 (PST) Received: from [172.18.5.9] ([208.181.219.34]) by mx.google.com with ESMTPS id rk9sm1927898pbc.24.2012.12.12.13.53.18 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Dec 2012 13:53:18 -0800 (PST) Date: Wed, 12 Dec 2012 13:53:16 -0800 (PST) From: Ani Sinha Reply-To: ani@aristanetworks.com To: Michael Richardson cc: netdev@vger.kernel.org, tcpdump-workers@lists.tcpdump.org, Francesco Ruggeri Subject: Re: [tcpdump-workers] vlan tagged packets and libpcap breakage In-Reply-To: <21992.1351723328@obiwan.sandelman.ca> Message-ID: References: <3246.1351717319@obiwan.sandelman.ca> <21992.1351723328@obiwan.sandelman.ca> User-Agent: Alpine 2.00 (OSX 1167 2008-08-23) MIME-Version: 1.0 X-Gm-Message-State: ALoCoQmyYbTGsCp26z+vURicRE87NSSQWl+dWZmyITdpvxPIKj/009CvYoy2ciEBvMUzscxzxR+z Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org > > unsigned int netdev_8021q_inskb = 1; > > ... > { > .ctl_name = NET_CORE_8021q_INSKB, > .procname = "netdev_8021q_inskb", > .data = &netdev_8021q_inskb, > .maxlen = sizeof(int), > .mode = 0444, > .proc_handler = proc_dointvec > }, > > would seem to do it to me. > Then pcap can fopen("/proc/sys/net/core/netdev_8021q_inskb") and if it > finds it, and it is >0, then do the cmsg thing. > Does this work? This is just an experimental patch and by no means final. I just want to have an idea what everyone thought about it. Once we debate and discusss, I can cook up a final patch that would be worth commiting. Also instead of having this /proc interface, we can perhaps check for a specific kernel version that : (a) has the vlan tag info in the skb metadata (as opposed to in the packet itself) (b) has the following patch that adds the capability to generate a filter based on the tag value : commit f3335031b9452baebfe49b8b5e55d3fe0c4677d1 Author: Eric Dumazet Date: Sat Oct 27 02:26:17 2012 +0000 net: filter: add vlan tag access WE need both of the above two things for the userland to generate a filter code that compares vlan tag values in the skb metadata. For kernels that has the vlan tag in the skb metadata but does not have the above commit (b), there is nothing that can be done. For older kernels that had the vlan tag info in the packet itself, the filter code can be generated differently to look at specific offsets within the packet (something that libpcap does currently). We have already ruled out the idea of generating a filter and trying to load and see if that fails (see previous emails on this thread). Hope this makes sense. --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/linux/filter.h b/include/linux/filter.h index c45eabc..91e2ba3 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -36,6 +36,7 @@ static inline unsigned int sk_filter_len(const struct sk_filter *fp) return fp->len * sizeof(struct sock_filter) + sizeof(*fp); } +extern bool sysctl_8021q_inskb; extern int sk_filter(struct sock *sk, struct sk_buff *skb); extern unsigned int sk_run_filter(const struct sk_buff *skb, const struct sock_filter *filter); diff --git a/net/core/filter.c b/net/core/filter.c index c23543c..4f5a657 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -41,6 +41,8 @@ #include #include +bool sysctl_8021q_inskb = 1; + /* No hurry in this branch * * Exported for the bpf jit load helper. diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c index d1b0804..f9a3700 100644 --- a/net/core/sysctl_net_core.c +++ b/net/core/sysctl_net_core.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -189,6 +190,13 @@ static struct ctl_table net_core_table[] = { .mode = 0644, .proc_handler = proc_dointvec }, + { + .procname = "8021q_inskb", + .data = &sysctl_8021q_inskb, + .maxlen = sizeof(bool), + .mode = 0444, + .proc_handler = proc_dointvec + }, { } };