diff options
Diffstat (limited to 'net/sched/cls_u32.c')
-rw-r--r-- | net/sched/cls_u32.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index c39b583ace32..70c0be8d0121 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/errno.h> | 38 | #include <linux/errno.h> |
39 | #include <linux/rtnetlink.h> | 39 | #include <linux/rtnetlink.h> |
40 | #include <linux/skbuff.h> | 40 | #include <linux/skbuff.h> |
41 | #include <linux/bitmap.h> | ||
41 | #include <net/netlink.h> | 42 | #include <net/netlink.h> |
42 | #include <net/act_api.h> | 43 | #include <net/act_api.h> |
43 | #include <net/pkt_cls.h> | 44 | #include <net/pkt_cls.h> |
@@ -460,17 +461,25 @@ static int u32_delete(struct tcf_proto *tp, unsigned long arg) | |||
460 | return 0; | 461 | return 0; |
461 | } | 462 | } |
462 | 463 | ||
464 | #define NR_U32_NODE (1<<12) | ||
463 | static u32 gen_new_kid(struct tc_u_hnode *ht, u32 handle) | 465 | static u32 gen_new_kid(struct tc_u_hnode *ht, u32 handle) |
464 | { | 466 | { |
465 | struct tc_u_knode *n; | 467 | struct tc_u_knode *n; |
466 | unsigned int i = 0x7FF; | 468 | unsigned long i; |
469 | unsigned long *bitmap = kzalloc(BITS_TO_LONGS(NR_U32_NODE) * sizeof(unsigned long), | ||
470 | GFP_KERNEL); | ||
471 | if (!bitmap) | ||
472 | return handle | 0xFFF; | ||
467 | 473 | ||
468 | for (n = ht->ht[TC_U32_HASH(handle)]; n; n = n->next) | 474 | for (n = ht->ht[TC_U32_HASH(handle)]; n; n = n->next) |
469 | if (i < TC_U32_NODE(n->handle)) | 475 | set_bit(TC_U32_NODE(n->handle), bitmap); |
470 | i = TC_U32_NODE(n->handle); | ||
471 | i++; | ||
472 | 476 | ||
473 | return handle | (i > 0xFFF ? 0xFFF : i); | 477 | i = find_next_zero_bit(bitmap, NR_U32_NODE, 0x800); |
478 | if (i >= NR_U32_NODE) | ||
479 | i = find_next_zero_bit(bitmap, NR_U32_NODE, 1); | ||
480 | |||
481 | kfree(bitmap); | ||
482 | return handle | (i >= NR_U32_NODE ? 0xFFF : i); | ||
474 | } | 483 | } |
475 | 484 | ||
476 | static const struct nla_policy u32_policy[TCA_U32_MAX + 1] = { | 485 | static const struct nla_policy u32_policy[TCA_U32_MAX + 1] = { |