[PKT_SCHED]: vlan tag match
authorStephen Hemminger <shemminger@vyatta.com>
Tue, 5 Feb 2008 11:20:13 +0000 (03:20 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 5 Feb 2008 11:20:13 +0000 (03:20 -0800)
Provide a way to use tc filters on vlan tag even if tag is buried in
skb due to hardware acceleration.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/pkt_cls.h
include/linux/tc_ematch/tc_em_meta.h
net/sched/em_meta.c

index 1c1dba9ea5fba9f0f2916b26e51da13ed14286a9..40fac8c4559d3c081f07cd35f7bb8c3e5dedf09b 100644 (file)
@@ -459,7 +459,8 @@ enum
 #define        TCF_EM_U32              3
 #define        TCF_EM_META             4
 #define        TCF_EM_TEXT             5
-#define        TCF_EM_MAX              5
+#define        TCF_EM_VLAN             6
+#define        TCF_EM_MAX              6
 
 enum
 {
index e21937cf91d0e4510659566215260b13a9c9b6b8..c50d2ba5caf004ea9b8a33a12d27fa859a4e4864 100644 (file)
@@ -81,6 +81,7 @@ enum
        TCF_META_ID_SK_SNDTIMEO,
        TCF_META_ID_SK_SENDMSG_OFF,
        TCF_META_ID_SK_WRITE_PENDING,
+       TCF_META_ID_VLAN_TAG,
        __TCF_META_ID_MAX
 };
 #define TCF_META_ID_MAX (__TCF_META_ID_MAX - 1)
index a1e5619b1876c8477c85a07936f85806159ea290..9c2ec1992a2a0f8a95d21957c1171ab06f59959c 100644 (file)
@@ -65,6 +65,7 @@
 #include <linux/string.h>
 #include <linux/skbuff.h>
 #include <linux/random.h>
+#include <linux/if_vlan.h>
 #include <linux/tc_ematch/tc_em_meta.h>
 #include <net/dst.h>
 #include <net/route.h>
@@ -169,6 +170,21 @@ META_COLLECTOR(var_dev)
        *err = var_dev(skb->dev, dst);
 }
 
+/**************************************************************************
+ * vlan tag
+ **************************************************************************/
+
+META_COLLECTOR(int_vlan_tag)
+{
+       unsigned short tag;
+       if (vlan_get_tag(skb, &tag) < 0)
+               *err = -1;
+       else
+               dst->value = tag;
+}
+
+
+
 /**************************************************************************
  * skb attributes
  **************************************************************************/
@@ -520,6 +536,7 @@ static struct meta_ops __meta_ops[TCF_META_TYPE_MAX+1][TCF_META_ID_MAX+1] = {
                [META_ID(SK_SNDTIMEO)]          = META_FUNC(int_sk_sndtimeo),
                [META_ID(SK_SENDMSG_OFF)]       = META_FUNC(int_sk_sendmsg_off),
                [META_ID(SK_WRITE_PENDING)]     = META_FUNC(int_sk_write_pend),
+               [META_ID(VLAN_TAG)]             = META_FUNC(int_vlan_tag),
        }
 };