aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wilcox <mawilcox@microsoft.com>2017-11-28 10:53:03 -0500
committerMatthew Wilcox <mawilcox@microsoft.com>2018-02-06 16:41:26 -0500
commit85bd0438a249e7a7a0622e0b0b6663595fadcc27 (patch)
tree53120e72ee90b2540145b4079dd03da1044ca43b
parent0b4ce8da79d65f9773601619bfc90d096f0a170e (diff)
cls_flower: Convert to idr_alloc_u32
Use the new helper which saves a temporary variable and a few lines of code. Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
-rw-r--r--net/sched/cls_flower.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index 2162e1c1f382..7d0ce2c40f93 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -865,7 +865,6 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
865 struct cls_fl_filter *fnew; 865 struct cls_fl_filter *fnew;
866 struct nlattr **tb; 866 struct nlattr **tb;
867 struct fl_flow_mask mask = {}; 867 struct fl_flow_mask mask = {};
868 unsigned long idr_index;
869 int err; 868 int err;
870 869
871 if (!tca[TCA_OPTIONS]) 870 if (!tca[TCA_OPTIONS])
@@ -896,21 +895,17 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
896 goto errout; 895 goto errout;
897 896
898 if (!handle) { 897 if (!handle) {
899 err = idr_alloc_ext(&head->handle_idr, fnew, &idr_index, 898 handle = 1;
900 1, 0x80000000, GFP_KERNEL); 899 err = idr_alloc_u32(&head->handle_idr, fnew, &handle,
901 if (err) 900 INT_MAX, GFP_KERNEL);
902 goto errout; 901 } else if (!fold) {
903 fnew->handle = idr_index; 902 /* user specifies a handle and it doesn't exist */
904 } 903 err = idr_alloc_u32(&head->handle_idr, fnew, &handle,
905 904 handle, GFP_KERNEL);
906 /* user specifies a handle and it doesn't exist */
907 if (handle && !fold) {
908 err = idr_alloc_ext(&head->handle_idr, fnew, &idr_index,
909 handle, handle + 1, GFP_KERNEL);
910 if (err)
911 goto errout;
912 fnew->handle = idr_index;
913 } 905 }
906 if (err)
907 goto errout;
908 fnew->handle = handle;
914 909
915 if (tb[TCA_FLOWER_FLAGS]) { 910 if (tb[TCA_FLOWER_FLAGS]) {
916 fnew->flags = nla_get_u32(tb[TCA_FLOWER_FLAGS]); 911 fnew->flags = nla_get_u32(tb[TCA_FLOWER_FLAGS]);
@@ -966,7 +961,6 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
966 *arg = fnew; 961 *arg = fnew;
967 962
968 if (fold) { 963 if (fold) {
969 fnew->handle = handle;
970 idr_replace(&head->handle_idr, fnew, fnew->handle); 964 idr_replace(&head->handle_idr, fnew, fnew->handle);
971 list_replace_rcu(&fold->list, &fnew->list); 965 list_replace_rcu(&fold->list, &fnew->list);
972 tcf_unbind_filter(tp, &fold->res); 966 tcf_unbind_filter(tp, &fold->res);