From patchwork Tue Oct 16 06:46:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 191730 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 DACEE2C008D for ; Tue, 16 Oct 2012 17:46:56 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754208Ab2JPGqy (ORCPT ); Tue, 16 Oct 2012 02:46:54 -0400 Received: from mail-ee0-f46.google.com ([74.125.83.46]:42034 "EHLO mail-ee0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754171Ab2JPGqy (ORCPT ); Tue, 16 Oct 2012 02:46:54 -0400 Received: by mail-ee0-f46.google.com with SMTP id b15so3309823eek.19 for ; Mon, 15 Oct 2012 23:46:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:x-mailer:content-transfer-encoding; bh=0eXr4o5hkFgkZWNBSTCq+vBa1d/Vtm6R6cZiwq8f6vw=; b=VjjdrG5lDkfUYhLYVmrIcnYBhC/tloKH+8lVwsR82s6K6L+hUbA6GOQ2ivRHdCd2Sl 8KOd7vkWFCyG+b6uU5EC5OkSdiQmRkz4ljRjGi4019XOfp96xnXNK2yY3ch+QnWV0WF9 dgdxcTJ9GI1MRQG1ELR0C5IkiibZfBqr5u5d/7k2JYs3SzmWbv1CZjkvlvrV3Xo7ETPp wEh+tVihwgi1B0uMEiLjswxB2hVL5XAVnlpMeruaEKcwMYGQQ/cMvPOH2o/1WvK2l2i9 8OzVLjAtCznD1+OoUFQN5zwTsqoGsoVCQsNdWRCNNvtqZkwo3yibTZX/1oVOWqDZj9Ee FWsg== Received: by 10.14.179.1 with SMTP id g1mr19394117eem.14.1350370012771; Mon, 15 Oct 2012 23:46:52 -0700 (PDT) Received: from [172.28.90.82] ([172.28.90.82]) by mx.google.com with ESMTPS id o47sm9624409eem.11.2012.10.15.23.46.39 (version=SSLv3 cipher=OTHER); Mon, 15 Oct 2012 23:46:40 -0700 (PDT) Subject: Re: bpf filter : support for vlan tag From: Eric Dumazet To: Ani Sinha Cc: netdev@vger.kernel.org In-Reply-To: References: Date: Tue, 16 Oct 2012 08:46:38 +0200 Message-ID: <1350369998.3954.563.camel@edumazet-glaptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Mon, 2012-10-15 at 19:10 -0700, Ani Sinha wrote: > Hi : > > I was looking at the kernel side implementation of the BPF filter. I > do not see any code that supports filtering of packets based on > provided vlan tag information from the skbuff. This will make it > impossible to provide any filter to tcpdump that will filter packets > based on the tag information if libpcap uses the kernel filter. > > Any help will be much appreciated. Right, we need a basic support, using a new ancillary definition. Is the following patch enough to address your need, or do you also need access to vlan_tx_tag_present() ? --- 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 24d251f..0218e41 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -123,6 +123,7 @@ enum { BPF_S_ANC_CPU, BPF_S_ANC_ALU_XOR_X, BPF_S_ANC_SECCOMP_LD_W, + BPF_S_ANC_VLAN_TAG, }; #endif /* __LINUX_FILTER_H__ */ diff --git a/net/core/filter.c b/net/core/filter.c index 3d92ebb..de4a5dc 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -341,6 +341,9 @@ load_b: case BPF_S_ANC_CPU: A = raw_smp_processor_id(); continue; + case BPF_S_ANC_VLAN_TAG: + A = vlan_tx_tag_get(skb); + continue; case BPF_S_ANC_NLATTR: { struct nlattr *nla; @@ -600,6 +603,7 @@ int sk_chk_filter(struct sock_filter *filter, unsigned int flen) ANCILLARY(RXHASH); ANCILLARY(CPU); ANCILLARY(ALU_XOR_X); + ANCILLARY(VLAN_TAG); } } ftest->code = code;