]> Pileus Git - ~andy/linux/blobdiff - net/sched/sch_api.c
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target...
[~andy/linux] / net / sched / sch_api.c
index dca6c1a576f77e70ee7cab5c187946c96a7219d2..3d8981fde3019ae09130528c3f08e4d632385f2f 100644 (file)
@@ -618,20 +618,24 @@ void qdisc_class_hash_remove(struct Qdisc_class_hash *clhash,
 }
 EXPORT_SYMBOL(qdisc_class_hash_remove);
 
-/* Allocate an unique handle from space managed by kernel */
-
+/* Allocate an unique handle from space managed by kernel
+ * Possible range is [8000-FFFF]:0000 (0x8000 values)
+ */
 static u32 qdisc_alloc_handle(struct net_device *dev)
 {
-       int i = 0x10000;
+       int i = 0x8000;
        static u32 autohandle = TC_H_MAKE(0x80000000U, 0);
 
        do {
                autohandle += TC_H_MAKE(0x10000U, 0);
                if (autohandle == TC_H_MAKE(TC_H_ROOT, 0))
                        autohandle = TC_H_MAKE(0x80000000U, 0);
-       } while (qdisc_lookup(dev, autohandle) && --i > 0);
+               if (!qdisc_lookup(dev, autohandle))
+                       return autohandle;
+               cond_resched();
+       } while (--i > 0);
 
-       return i > 0 ? autohandle : 0;
+       return 0;
 }
 
 void qdisc_tree_decrease_qlen(struct Qdisc *sch, unsigned int n)