diff options
author | Matthew Wilcox <mawilcox@microsoft.com> | 2017-11-28 13:45:02 -0500 |
---|---|---|
committer | Matthew Wilcox <mawilcox@microsoft.com> | 2018-02-06 16:41:27 -0500 |
commit | f730cb93db8e640f95ba4acb339d5732e1721730 (patch) | |
tree | 61a9f3a4869bc9f757ec995bdc4c31a7be0b61c1 /net | |
parent | ffdc2d9e1afd20e9f9d205115661481e984542d6 (diff) |
cls_u32: Convert to idr_alloc_u32
No real benefit to this classifier, but since we're allocating a u32
anyway, we should use this function.
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/sched/cls_u32.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index d2805f24ddd3..82f85d6a245a 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c | |||
@@ -740,19 +740,17 @@ ret: | |||
740 | 740 | ||
741 | static u32 gen_new_kid(struct tc_u_hnode *ht, u32 htid) | 741 | static u32 gen_new_kid(struct tc_u_hnode *ht, u32 htid) |
742 | { | 742 | { |
743 | unsigned long idr_index; | 743 | u32 index = htid | 0x800; |
744 | u32 start = htid | 0x800; | ||
745 | u32 max = htid | 0xFFF; | 744 | u32 max = htid | 0xFFF; |
746 | u32 min = htid; | ||
747 | 745 | ||
748 | if (idr_alloc_ext(&ht->handle_idr, NULL, &idr_index, | 746 | if (idr_alloc_u32(&ht->handle_idr, NULL, &index, max, GFP_KERNEL)) { |
749 | start, max + 1, GFP_KERNEL)) { | 747 | index = htid + 1; |
750 | if (idr_alloc_ext(&ht->handle_idr, NULL, &idr_index, | 748 | if (idr_alloc_u32(&ht->handle_idr, NULL, &index, max, |
751 | min + 1, max + 1, GFP_KERNEL)) | 749 | GFP_KERNEL)) |
752 | return max; | 750 | index = max; |
753 | } | 751 | } |
754 | 752 | ||
755 | return (u32)idr_index; | 753 | return index; |
756 | } | 754 | } |
757 | 755 | ||
758 | static const struct nla_policy u32_policy[TCA_U32_MAX + 1] = { | 756 | static const struct nla_policy u32_policy[TCA_U32_MAX + 1] = { |
@@ -1003,8 +1001,8 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, | |||
1003 | return -ENOMEM; | 1001 | return -ENOMEM; |
1004 | } | 1002 | } |
1005 | } else { | 1003 | } else { |
1006 | err = idr_alloc_ext(&tp_c->handle_idr, ht, NULL, | 1004 | err = idr_alloc_u32(&tp_c->handle_idr, ht, &handle, |
1007 | handle, handle + 1, GFP_KERNEL); | 1005 | handle, GFP_KERNEL); |
1008 | if (err) { | 1006 | if (err) { |
1009 | kfree(ht); | 1007 | kfree(ht); |
1010 | return err; | 1008 | return err; |
@@ -1060,8 +1058,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, | |||
1060 | return -EINVAL; | 1058 | return -EINVAL; |
1061 | } | 1059 | } |
1062 | handle = htid | TC_U32_NODE(handle); | 1060 | handle = htid | TC_U32_NODE(handle); |
1063 | err = idr_alloc_ext(&ht->handle_idr, NULL, NULL, | 1061 | err = idr_alloc_u32(&ht->handle_idr, NULL, &handle, handle, |
1064 | handle, handle + 1, | ||
1065 | GFP_KERNEL); | 1062 | GFP_KERNEL); |
1066 | if (err) | 1063 | if (err) |
1067 | return err; | 1064 | return err; |