Skip to contentSkip to conversation

: Two fixes + cls_flow VLAN tag based classification

PATCH Applied Patrick McHardy 2 participants 9 messages Feb 5, 2008 – Feb 6, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover : Two fixes + cls_flow VLAN tag based classification

These patches fix a compile warning in em_meta, an invalid check in the flow classifier and add VLAN tag based classification to cls_flow. Please apply, thanks.

 include/linux/if_vlan.h |    7 ++++---
 include/linux/pkt_cls.h |    1 +
 net/sched/cls_flow.c    |   17 +++++++++++++++--
 net/sched/em_meta.c     |    2 +-
 4 files changed, 21 insertions(+), 6 deletions(-)

Patrick McHardy (4):
[NET_SCHED]: em_meta: fix compile warning [NET_SCHED]: cls_flow: fix key mask validity check [VLAN]: Constify skb argument to vlan_get_tag() [NET_SCHED]: cls_flow: support classification based on VLAN tag

#1 lore raw

PATCH 1/4 : em_meta: fix compile warning

[NET_SCHED]: em_meta: fix compile warning

net/sched/em_meta.c: In function 'meta_int_vlan_tag':
net/sched/em_meta.c:179: warning: 'tag' may be used uninitialized in this function

---
commit adfab462c5e0a32ffff274927bba4eec3afc6e35
tree bfac456798152d7ea6bedcca4a03b4f045605d3d
parent fb1c15ba9ebcab6478a409051ad26d7d180fe286
author Patrick McHardy <[email protected]> Tue, 05 Feb 2008 15:22:21 +0100 committer Patrick McHardy <[email protected]> Tue, 05 Feb 2008 15:22:21 +0100

 net/sched/em_meta.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/sched/em_meta.c +1 -1
index 9c2ec19..2a7e648 100644
@@ -176,7 +176,7 @@ META_COLLECTOR(var_dev)
 
 META_COLLECTOR(int_vlan_tag)
 {
-	unsigned short tag;
+	unsigned short uninitialized_var(tag);
 	if (vlan_get_tag(skb, &tag) < 0)
 		*err = -1;
 	else
maintainer Applied
#2 lore raw

Re: [NET_SCHED 01/04]: em_meta: fix compile warning

From: Patrick McHardy <[email protected]>
Date: Tue, 5 Feb 2008 15:29:40 +0100 (MET)

Quoted 6 lines

[NET_SCHED]: em_meta: fix compile warning

net/sched/em_meta.c: In function 'meta_int_vlan_tag':
net/sched/em_meta.c:179: warning: 'tag' may be used uninitialized in this function

Applied.

#3 lore raw

PATCH 2/4 : cls_flow: fix key mask validity check

In reply to Patrick McHardy

[NET_SCHED]: cls_flow: fix key mask validity check

Since we're using fls(), we need to check whether the value is non-zero first.

---
commit 2e5915ef51e55135522e59e041bb176432857d82
tree 9a42fac3d1646a378acdc91b55642b68c9d97dde
parent adfab462c5e0a32ffff274927bba4eec3afc6e35
author Patrick McHardy <[email protected]> Tue, 05 Feb 2008 15:22:23 +0100 committer Patrick McHardy <[email protected]> Tue, 05 Feb 2008 15:22:23 +0100

 net/sched/cls_flow.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
net/sched/cls_flow.c +3 -2
index 8d76986..eeb223c 100644
@@ -402,12 +402,13 @@ static int flow_change(struct tcf_proto *tp, unsigned long base,
 
 	if (tb[TCA_FLOW_KEYS]) {
 		keymask = nla_get_u32(tb[TCA_FLOW_KEYS]);
-		if (fls(keymask) - 1 > FLOW_KEY_MAX)
-			return -EOPNOTSUPP;
 
 		nkeys = hweight32(keymask);
 		if (nkeys == 0)
 			return -EINVAL;
+
+		if (fls(keymask) - 1 > FLOW_KEY_MAX)
+			return -EOPNOTSUPP;
 	}
 
 	err = tcf_exts_validate(tp, tb, tca[TCA_RATE], &e, &flow_ext_map);
maintainer Applied
#4 lore raw

Re: [NET_SCHED 02/04]: cls_flow: fix key mask validity check

From: Patrick McHardy <[email protected]>
Date: Tue, 5 Feb 2008 15:29:41 +0100 (MET)

Quoted 5 lines

[NET_SCHED]: cls_flow: fix key mask validity check

Since we're using fls(), we need to check whether the value is non-zero first.

Applied.

#5 lore raw

PATCH 3/4 : Constify skb argument to vlan_get_tag()

In reply to Patrick McHardy

[VLAN]: Constify skb argument to vlan_get_tag()

Required by next patch to use it from the flow classifier.

---
commit 03faf81b8195be455c3c7592d76d712ea9d80b13
tree 9da377d2bd44421494a4c4d7cf6c705d199c26ce
parent 2e5915ef51e55135522e59e041bb176432857d82
author Patrick McHardy <[email protected]> Tue, 05 Feb 2008 15:22:23 +0100 committer Patrick McHardy <[email protected]> Tue, 05 Feb 2008 15:22:23 +0100

 include/linux/if_vlan.h |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
include/linux/if_vlan.h +4 -3
index 34f40ef..79504b2 100644
@@ -327,7 +327,7 @@ static inline struct sk_buff *vlan_put_tag(struct sk_buff *skb, unsigned short t
  * 
  * Returns error if the skb is not of VLAN type
  */
-static inline int __vlan_get_tag(struct sk_buff *skb, unsigned short *tag)
+static inline int __vlan_get_tag(const struct sk_buff *skb, unsigned short *tag)
 {
 	struct vlan_ethhdr *veth = (struct vlan_ethhdr *)skb->data;
 
@@ -347,7 +347,8 @@ static inline int __vlan_get_tag(struct sk_buff *skb, unsigned short *tag)
  * 
  * Returns error if @skb->cb[] is not set correctly
  */
-static inline int __vlan_hwaccel_get_tag(struct sk_buff *skb, unsigned short *tag)
+static inline int __vlan_hwaccel_get_tag(const struct sk_buff *skb,
+					 unsigned short *tag)
 {
 	struct vlan_skb_tx_cookie *cookie;
 
@@ -370,7 +371,7 @@ static inline int __vlan_hwaccel_get_tag(struct sk_buff *skb, unsigned short *ta
  * 
  * Returns error if the skb is not VLAN tagged
  */
-static inline int vlan_get_tag(struct sk_buff *skb, unsigned short *tag)
+static inline int vlan_get_tag(const struct sk_buff *skb, unsigned short *tag)
 {
 	if (skb->dev->features & NETIF_F_HW_VLAN_TX) {
 		return __vlan_hwaccel_get_tag(skb, tag);
maintainer Applied
#6 lore raw

Re: [VLAN 03/04]: Constify skb argument to vlan_get_tag()

From: Patrick McHardy <[email protected]>
Date: Tue, 5 Feb 2008 15:29:43 +0100 (MET)

Quoted 5 lines

[VLAN]: Constify skb argument to vlan_get_tag()

Required by next patch to use it from the flow classifier.

Applied.

#7 lore raw

PATCH 4/4 : cls_flow: support classification based on VLAN tag

In reply to Patrick McHardy

[NET_SCHED]: cls_flow: support classification based on VLAN tag

---
commit 104092e6d90cba5fa00902a3154155872d693f42
tree 0e3fd5871a861fa022bbc2f34d314bb8672b556a
parent 03faf81b8195be455c3c7592d76d712ea9d80b13
author Patrick McHardy <[email protected]> Tue, 05 Feb 2008 15:22:23 +0100 committer Patrick McHardy <[email protected]> Tue, 05 Feb 2008 15:22:23 +0100

 include/linux/pkt_cls.h |    1 +
 net/sched/cls_flow.c    |   12 ++++++++++++
 2 files changed, 13 insertions(+), 0 deletions(-)
include/linux/pkt_cls.h +1 -0
index 40fac8c..28dfc61 100644
@@ -348,6 +348,7 @@ enum
 	FLOW_KEY_RTCLASSID,
 	FLOW_KEY_SKUID,
 	FLOW_KEY_SKGID,
+	FLOW_KEY_VLAN_TAG,
 	__FLOW_KEY_MAX,
 };
 
net/sched/cls_flow.c +12 -0
index eeb223c..971b867 100644
@@ -19,6 +19,7 @@
 #include <linux/in.h>
 #include <linux/ip.h>
 #include <linux/ipv6.h>
+#include <linux/if_vlan.h>
 
 #include <net/pkt_cls.h>
 #include <net/ip.h>
@@ -270,6 +271,15 @@ static u32 flow_get_skgid(const struct sk_buff *skb)
 	return 0;
 }
 
+static u32 flow_get_vlan_tag(const struct sk_buff *skb)
+{
+	u16 uninitialized_var(tag);
+
+	if (vlan_get_tag(skb, &tag) < 0)
+		return 0;
+	return tag & VLAN_VID_MASK;
+}
+
 static u32 flow_key_get(const struct sk_buff *skb, int key)
 {
 	switch (key) {
@@ -305,6 +315,8 @@ static u32 flow_key_get(const struct sk_buff *skb, int key)
 		return flow_get_skuid(skb);
 	case FLOW_KEY_SKGID:
 		return flow_get_skgid(skb);
+	case FLOW_KEY_VLAN_TAG:
+		return flow_get_vlan_tag(skb);
 	default:
 		WARN_ON(1);
 		return 0;