From: Al Viro <v...@zeniv.linux.org.uk> A series of net/sched/cls_u32.c cleanups and fixes: 1) fix hnode refcounting. Refcounting for tc_u_hnode is broken; it's not hard to trigger oopsen (including one inside an interrupt handler, with resulting panic) as well as memory corruption. Definitely -stable fodder. 2) mark root hnode explicitly. Consistent errors on attempts to delete root hnodes. Less serious than 1/13. 3) disallow linking to root hnode. Prohibit creating links to root hnodes; not critical (nothing actually breaks if we do allow those), but gets rid of surprising cases. 4) make sure that divisor is a power of 2. Missing validation - divisor is documented as power of 2, but that's not actually enforced. Results are moderately bogus (i.e. the kernel doesn't break), but rather surprising.
Those are fixes, or at least can be argued to be such. The rest are pure cleanups: 5) get rid of unused argument of u32_destroy_key() 6) get rid of tc_u_knode ->tp 7) get rid of tc_u_common ->rcu Eliminate some unused fields. 8) clean tc_u_common hashtable. Hash lookups are best done with minimum of calculations per chain element - comparing the field in each candidate with f(key) where f() is actually a pure function is not nice, especially when compiler doesn't see f() as such... Better calculate f(key) once, especially since we need its value to choose the hash chain in the first place. 9) pass tc_u_common to u32_set_parms() instead of tc_u_hnode 10) the tp_c argument of u32_set_parms() is always tp->data 11) get rid of hnode ->tp_c and tp_c argument of u32_set_parms() Massage that ends with getting rid of a redundant field. 12) keep track of knodes count in tc_u_common 13) simplify the hell out u32_delete() emptiness check Checking if a filter needs to be killed after u32_delete() can be done much easier - the test is equivalent to "filter doesn't have ->data shared with anyone else and it has no knodes left in it" and keeping track of the number of knodes is trivial.