From: Jesse Gross <jesse@nicira.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org
Subject: [RFC PATCH 1/7] ebtables: Allow filtering of hardware accelerated vlan frames.
Date: Wed, 13 Oct 2010 13:02:51 -0700 [thread overview]
Message-ID: <1287000177-7126-2-git-send-email-jesse@nicira.com> (raw)
In-Reply-To: <1287000177-7126-1-git-send-email-jesse@nicira.com>
An upcoming commit will allow packets with hardware vlan acceleration
information to be passed though more parts of the network stack, including
packets trunked through the bridge. This adds support for matching and
filtering those packets through ebtables.
Signed-off-by: Jesse Gross <jesse@nicira.com>
---
net/bridge/br_netfilter.c | 16 +++++++++-------
net/bridge/netfilter/ebt_vlan.c | 38 +++++++++++++++++++++++---------------
net/bridge/netfilter/ebtables.c | 15 +++++++++++----
3 files changed, 43 insertions(+), 26 deletions(-)
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index 7f9ce96..d6a4fec 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -64,22 +64,24 @@ static int brnf_filter_pppoe_tagged __read_mostly = 0;
static inline __be16 vlan_proto(const struct sk_buff *skb)
{
- return vlan_eth_hdr(skb)->h_vlan_encapsulated_proto;
+ if (skb->protocol == htons(ETH_P_8021Q))
+ return vlan_eth_hdr(skb)->h_vlan_encapsulated_proto;
+ else if (vlan_tx_tag_present(skb))
+ return skb->protocol;
+ else
+ return 0;
}
#define IS_VLAN_IP(skb) \
- (skb->protocol == htons(ETH_P_8021Q) && \
- vlan_proto(skb) == htons(ETH_P_IP) && \
+ (vlan_proto(skb) == htons(ETH_P_IP) && \
brnf_filter_vlan_tagged)
#define IS_VLAN_IPV6(skb) \
- (skb->protocol == htons(ETH_P_8021Q) && \
- vlan_proto(skb) == htons(ETH_P_IPV6) &&\
+ (vlan_proto(skb) == htons(ETH_P_IPV6) &&\
brnf_filter_vlan_tagged)
#define IS_VLAN_ARP(skb) \
- (skb->protocol == htons(ETH_P_8021Q) && \
- vlan_proto(skb) == htons(ETH_P_ARP) && \
+ (vlan_proto(skb) == htons(ETH_P_ARP) && \
brnf_filter_vlan_tagged)
static inline __be16 pppoe_proto(const struct sk_buff *skb)
diff --git a/net/bridge/netfilter/ebt_vlan.c b/net/bridge/netfilter/ebt_vlan.c
index 87b53b3..a39d92d 100644
--- a/net/bridge/netfilter/ebt_vlan.c
+++ b/net/bridge/netfilter/ebt_vlan.c
@@ -39,8 +39,6 @@ static bool
ebt_vlan_mt(const struct sk_buff *skb, struct xt_action_param *par)
{
const struct ebt_vlan_info *info = par->matchinfo;
- const struct vlan_hdr *fp;
- struct vlan_hdr _frame;
unsigned short TCI; /* Whole TCI, given from parsed frame */
unsigned short id; /* VLAN ID, given from frame TCI */
@@ -48,21 +46,31 @@ ebt_vlan_mt(const struct sk_buff *skb, struct xt_action_param *par)
/* VLAN encapsulated Type/Length field, given from orig frame */
__be16 encap;
- fp = skb_header_pointer(skb, 0, sizeof(_frame), &_frame);
- if (fp == NULL)
- return false;
-
- /* Tag Control Information (TCI) consists of the following elements:
- * - User_priority. The user_priority field is three bits in length,
- * interpreted as a binary number.
- * - Canonical Format Indicator (CFI). The Canonical Format Indicator
- * (CFI) is a single bit flag value. Currently ignored.
- * - VLAN Identifier (VID). The VID is encoded as
- * an unsigned binary number. */
- TCI = ntohs(fp->h_vlan_TCI);
+ if (skb->protocol == htons(ETH_P_8021Q)) {
+ const struct vlan_hdr *fp;
+ struct vlan_hdr _frame;
+
+ fp = skb_header_pointer(skb, 0, sizeof(_frame), &_frame);
+ if (fp == NULL)
+ return false;
+
+ /* Tag Control Information (TCI) consists of the following elements:
+ * - User_priority. The user_priority field is three bits in length,
+ * interpreted as a binary number.
+ * - Canonical Format Indicator (CFI). The Canonical Format Indicator
+ * (CFI) is a single bit flag value. Currently ignored.
+ * - VLAN Identifier (VID). The VID is encoded as
+ * an unsigned binary number. */
+ TCI = ntohs(fp->h_vlan_TCI);
+
+ encap = fp->h_vlan_encapsulated_proto;
+ } else {
+ TCI = vlan_tx_tag_get(skb);
+ encap = skb->protocol;
+ }
+
id = TCI & VLAN_VID_MASK;
prio = (TCI >> 13) & 0x7;
- encap = fp->h_vlan_encapsulated_proto;
/* Checking VLAN Identifier (VID) */
if (GET_BITMASK(EBT_VLAN_ID))
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index bcc102e..a1dcf83 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -124,16 +124,23 @@ ebt_dev_check(const char *entry, const struct net_device *device)
#define FWINV2(bool,invflg) ((bool) ^ !!(e->invflags & invflg))
/* process standard matches */
static inline int
-ebt_basic_match(const struct ebt_entry *e, const struct ethhdr *h,
+ebt_basic_match(const struct ebt_entry *e, const struct sk_buff *skb,
const struct net_device *in, const struct net_device *out)
{
+ const struct ethhdr *h = eth_hdr(skb);
+ __be16 ethproto;
int verdict, i;
+ if (vlan_tx_tag_present(skb))
+ ethproto = htons(ETH_P_8021Q);
+ else
+ ethproto = h->h_proto;
+
if (e->bitmask & EBT_802_3) {
- if (FWINV2(ntohs(h->h_proto) >= 1536, EBT_IPROTO))
+ if (FWINV2(ntohs(ethproto) >= 1536, EBT_IPROTO))
return 1;
} else if (!(e->bitmask & EBT_NOPROTO) &&
- FWINV2(e->ethproto != h->h_proto, EBT_IPROTO))
+ FWINV2(e->ethproto != ethproto, EBT_IPROTO))
return 1;
if (FWINV2(ebt_dev_check(e->in, in), EBT_IIN))
@@ -213,7 +220,7 @@ unsigned int ebt_do_table (unsigned int hook, struct sk_buff *skb,
base = private->entries;
i = 0;
while (i < nentries) {
- if (ebt_basic_match(point, eth_hdr(skb), in, out))
+ if (ebt_basic_match(point, skb, in, out))
goto letscontinue;
if (EBT_MATCH_ITERATE(point, ebt_do_match, skb, &acpar) != 0)
--
1.7.0.4
next prev parent reply other threads:[~2010-10-13 20:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-13 20:02 [RFC PATCH 0/7] Move vlan acceleration into networking core Jesse Gross
2010-10-13 20:02 ` Jesse Gross [this message]
2010-10-18 19:58 ` [RFC PATCH 1/7] ebtables: Allow filtering of hardware accelerated vlan frames Ben Hutchings
2010-10-19 3:14 ` Jesse Gross
2010-10-13 20:02 ` [RFC PATCH 2/7] vlan: Centralize handling of hardware acceleration Jesse Gross
2010-10-13 21:12 ` Eric Dumazet
2010-10-14 22:23 ` Jesse Gross
2010-10-13 20:02 ` [RFC PATCH 3/7] bnx2: Update bnx2 to use new vlan accleration Jesse Gross
2010-10-14 22:56 ` Michael Chan
2010-10-15 1:36 ` Jesse Gross
2010-10-13 20:02 ` [RFC PATCH 4/7] ixgbe: Update ixgbe " Jesse Gross
2010-10-13 20:02 ` [RFC PATCH 5/7] lro: Remove explicit vlan support Jesse Gross
2010-10-13 20:02 ` [RFC PATCH 6/7] bonding: Update bonding for new vlan model Jesse Gross
2010-10-13 20:02 ` [RFC PATCH 7/7] vlan: Remove accleration legacy functions Jesse Gross
2010-10-19 9:50 ` [RFC PATCH 0/7] Move vlan acceleration into networking core David Miller
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=1287000177-7126-2-git-send-email-jesse@nicira.com \
--to=jesse@nicira.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.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).