netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ani Sinha <ani@aristanetworks.com>
To: Michael Richardson <mcr@sandelman.ca>,
	"Eric W. Biederman" <ebiederm@xmission.com>
Cc: netdev@vger.kernel.org,
	Francesco Ruggeri <fruggeri@aristanetworks.com>,
	tcpdump-workers@lists.tcpdump.org
Subject: Re: vlan tagged packets and libpcap breakage
Date: Wed, 12 Dec 2012 14:16:28 -0800	[thread overview]
Message-ID: <CAOxq_8ML1P7JQCD1-xhYSWP_XHcS_M26GfFxpJ-jyQ+ebOV9SA@mail.gmail.com> (raw)
In-Reply-To: <alpine.OSX.2.00.1212121205040.78903@animac.local>

+ Eric B.


On Wed, Dec 12, 2012 at 1:53 PM, Ani Sinha <ani@aristanetworks.com> wrote:
>
>>
>> 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 <edumazet@google.com>
> 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.
>
>
> 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 <linux/seccomp.h>
>  #include <linux/if_vlan.h>
>
> +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 <linux/init.h>
>  #include <linux/slab.h>
>  #include <linux/kmemleak.h>
> +#include <linux/filter.h>
>
>  #include <net/ip.h>
>  #include <net/sock.h>
> @@ -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
> +       },
>         { }
>  };
>
_______________________________________________
tcpdump-workers mailing list
tcpdump-workers@lists.tcpdump.org
https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers

  reply	other threads:[~2012-12-12 22:16 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAOxq_8Nd8VP3MaNBfUt9v82nmGDpxZz5_5QMdsruET1tjwuQPw@mail.gmail.com>
     [not found] ` <3246.1351717319@obiwan.sandelman.ca>
2012-10-31 21:50   ` [tcpdump-workers] vlan tagged packets and libpcap breakage Ani Sinha
2012-10-31 22:20     ` Guy Harris
2012-10-31 22:35       ` Ani Sinha
2012-11-01  0:50         ` [tcpdump-workers] " Guy Harris
2012-11-01  1:22           ` Ani Sinha
2012-12-06 21:20           ` Ani Sinha
2012-11-02 16:13       ` Bill Fenner
2012-11-13 22:41         ` Ani Sinha
2012-11-13 22:42           ` [tcpdump-workers] " Ani Sinha
2012-11-14 18:58           ` Michael Richardson
2012-10-31 22:42     ` [tcpdump-workers] " Michael Richardson
2012-12-12 21:53       ` Ani Sinha
2012-12-12 22:16         ` Ani Sinha [this message]
2012-12-13  8:35         ` Daniel Borkmann
2012-12-13 17:34           ` Ani Sinha
2012-12-13 21:49             ` Daniel Borkmann
2012-12-13 22:07               ` Ani Sinha
2012-12-17  9:50               ` David Laight
2012-12-17 10:35                 ` Guy Harris
2012-12-17 11:08                   ` Daniel Borkmann
2012-12-17 19:49                   ` [tcpdump-workers] " Ani Sinha
2012-11-16  6:51     ` Eric W. Biederman
2012-11-17 22:14       ` Michael Richardson
2012-11-17 23:16         ` Daniel Borkmann
2012-11-17 23:37           ` Eric W. Biederman
2012-11-17 23:33         ` Eric W. Biederman
2012-12-06 21:22           ` Ani Sinha
2012-12-06 22:19             ` Eric W. Biederman
2012-12-06 22:40               ` Ani Sinha
2012-12-07  0:55               ` Ani Sinha
2012-12-07  1:03                 ` [tcpdump-workers] " Eric W. Biederman
2012-12-07  1:28                   ` Ani Sinha
2012-12-07  1:31                   ` Ani Sinha
2012-12-07  1:41                     ` Eric W. Biederman
2012-12-07  1:59                       ` Michael Richardson
2012-12-11  0:11                         ` [tcpdump-workers] " Ani Sinha
2012-12-11 22:36       ` Ani Sinha
2012-12-11 23:04         ` Eric Dumazet
2012-12-12  0:46           ` Ani Sinha
2012-12-12  0:50           ` [tcpdump-workers] " Ani Sinha
2012-12-11 23:12         ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAOxq_8ML1P7JQCD1-xhYSWP_XHcS_M26GfFxpJ-jyQ+ebOV9SA@mail.gmail.com \
    --to=ani@aristanetworks.com \
    --cc=ebiederm@xmission.com \
    --cc=fruggeri@aristanetworks.com \
    --cc=mcr@sandelman.ca \
    --cc=netdev@vger.kernel.org \
    --cc=tcpdump-workers@lists.tcpdump.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).