netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, Patrick McHardy <kaber@trash.net>
Subject: [NET_SCHED 02/04]: cls_flow: fix key mask validity check
Date: Tue,  5 Feb 2008 15:29:41 +0100 (MET)	[thread overview]
Message-ID: <20080205142904.13543.34586.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20080205142902.13543.88604.sendpatchset@localhost.localdomain>

[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.

Signed-off-by: Patrick McHardy <kaber@trash.net>

---
commit 2e5915ef51e55135522e59e041bb176432857d82
tree 9a42fac3d1646a378acdc91b55642b68c9d97dde
parent adfab462c5e0a32ffff274927bba4eec3afc6e35
author Patrick McHardy <kaber@trash.net> Tue, 05 Feb 2008 15:22:23 +0100
committer Patrick McHardy <kaber@trash.net> Tue, 05 Feb 2008 15:22:23 +0100

 net/sched/cls_flow.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/sched/cls_flow.c b/net/sched/cls_flow.c
index 8d76986..eeb223c 100644
--- a/net/sched/cls_flow.c
+++ b/net/sched/cls_flow.c
@@ -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);

  parent reply	other threads:[~2008-02-05 14:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-05 14:29 [NET_SCHED 00/04]: Two fixes + cls_flow VLAN tag based classification Patrick McHardy
2008-02-05 14:29 ` [NET_SCHED 01/04]: em_meta: fix compile warning Patrick McHardy
2008-02-06  0:19   ` David Miller
2008-02-05 14:29 ` Patrick McHardy [this message]
2008-02-06  0:20   ` [NET_SCHED 02/04]: cls_flow: fix key mask validity check David Miller
2008-02-05 14:29 ` [VLAN 03/04]: Constify skb argument to vlan_get_tag() Patrick McHardy
2008-02-06  0:20   ` David Miller
2008-02-05 14:29 ` [NET_SCHED 04/04]: cls_flow: support classification based on VLAN tag Patrick McHardy
2008-02-06  0:21   ` 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=20080205142904.13543.34586.sendpatchset@localhost.localdomain \
    --to=kaber@trash.net \
    --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).