提交 85bd0438 编写于 作者: M Matthew Wilcox

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: NMatthew Wilcox <mawilcox@microsoft.com>
上级 0b4ce8da
...@@ -865,7 +865,6 @@ static int fl_change(struct net *net, struct sk_buff *in_skb, ...@@ -865,7 +865,6 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
struct cls_fl_filter *fnew; struct cls_fl_filter *fnew;
struct nlattr **tb; struct nlattr **tb;
struct fl_flow_mask mask = {}; struct fl_flow_mask mask = {};
unsigned long idr_index;
int err; int err;
if (!tca[TCA_OPTIONS]) if (!tca[TCA_OPTIONS])
...@@ -896,21 +895,17 @@ static int fl_change(struct net *net, struct sk_buff *in_skb, ...@@ -896,21 +895,17 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
goto errout; goto errout;
if (!handle) { if (!handle) {
err = idr_alloc_ext(&head->handle_idr, fnew, &idr_index, handle = 1;
1, 0x80000000, GFP_KERNEL); err = idr_alloc_u32(&head->handle_idr, fnew, &handle,
if (err) INT_MAX, GFP_KERNEL);
goto errout; } else if (!fold) {
fnew->handle = idr_index; /* user specifies a handle and it doesn't exist */
} err = idr_alloc_u32(&head->handle_idr, fnew, &handle,
handle, GFP_KERNEL);
/* user specifies a handle and it doesn't exist */
if (handle && !fold) {
err = idr_alloc_ext(&head->handle_idr, fnew, &idr_index,
handle, handle + 1, GFP_KERNEL);
if (err)
goto errout;
fnew->handle = idr_index;
} }
if (err)
goto errout;
fnew->handle = handle;
if (tb[TCA_FLOWER_FLAGS]) { if (tb[TCA_FLOWER_FLAGS]) {
fnew->flags = nla_get_u32(tb[TCA_FLOWER_FLAGS]); 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,7 +961,6 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
*arg = fnew; *arg = fnew;
if (fold) { if (fold) {
fnew->handle = handle;
idr_replace(&head->handle_idr, fnew, fnew->handle); idr_replace(&head->handle_idr, fnew, fnew->handle);
list_replace_rcu(&fold->list, &fnew->list); list_replace_rcu(&fold->list, &fnew->list);
tcf_unbind_filter(tp, &fold->res); tcf_unbind_filter(tp, &fold->res);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册