cls_basic: Convert to use 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>
This commit is contained in:
Matthew Wilcox 2017-11-28 10:36:09 -05:00
parent 9ce75499ac
commit 05af0ebb08
1 changed files with 10 additions and 15 deletions

View File

@ -185,7 +185,6 @@ static int basic_change(struct net *net, struct sk_buff *in_skb,
struct nlattr *tb[TCA_BASIC_MAX + 1]; struct nlattr *tb[TCA_BASIC_MAX + 1];
struct basic_filter *fold = (struct basic_filter *) *arg; struct basic_filter *fold = (struct basic_filter *) *arg;
struct basic_filter *fnew; struct basic_filter *fnew;
unsigned long idr_index;
if (tca[TCA_OPTIONS] == NULL) if (tca[TCA_OPTIONS] == NULL)
return -EINVAL; return -EINVAL;
@ -208,21 +207,17 @@ static int basic_change(struct net *net, struct sk_buff *in_skb,
if (err < 0) if (err < 0)
goto errout; goto errout;
if (handle) { if (!handle) {
fnew->handle = handle; handle = 1;
if (!fold) { err = idr_alloc_u32(&head->handle_idr, fnew, &handle,
err = idr_alloc_ext(&head->handle_idr, fnew, &idr_index, INT_MAX, GFP_KERNEL);
handle, handle + 1, GFP_KERNEL); } else if (!fold) {
if (err) err = idr_alloc_u32(&head->handle_idr, fnew, &handle,
goto errout; handle, GFP_KERNEL);
}
} else {
err = idr_alloc_ext(&head->handle_idr, fnew, &idr_index,
1, 0x7FFFFFFF, GFP_KERNEL);
if (err)
goto errout;
fnew->handle = idr_index;
} }
if (err)
goto errout;
fnew->handle = handle;
err = basic_set_parms(net, tp, fnew, base, tb, tca[TCA_RATE], ovr, err = basic_set_parms(net, tp, fnew, base, tb, tca[TCA_RATE], ovr,
extack); extack);