net: sched: Add the invalid handle check in qdisc_class_find
authorGao Feng <gfree.wind@vip.163.com>
Fri, 18 Aug 2017 07:23:24 +0000 (15:23 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 21 Aug 2017 20:40:31 +0000 (13:40 -0700)
Add the invalid handle "0" check to avoid unnecessary search, because
the qdisc uses the skb->priority as the handle value to look up, and
it is "0" usually.

Signed-off-by: Gao Feng <gfree.wind@vip.163.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/sch_generic.h

index 5865db91976b552ee7ccaa71639f50b9a027b0c8..107c5243224507144d53363b04a303ecf3397090 100644 (file)
@@ -393,6 +393,9 @@ qdisc_class_find(const struct Qdisc_class_hash *hash, u32 id)
        struct Qdisc_class_common *cl;
        unsigned int h;
 
+       if (!id)
+               return NULL;
+
        h = qdisc_class_hash(id, hash->hashmask);
        hlist_for_each_entry(cl, &hash->hash[h], hnode) {
                if (cl->classid == id)