Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 85bd0438 authored by Matthew Wilcox's avatar Matthew Wilcox
Browse files

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: default avatarMatthew Wilcox <mawilcox@microsoft.com>
parent 0b4ce8da
Loading
Loading
Loading
Loading
+10 −16
Original line number Diff line number Diff line
@@ -865,7 +865,6 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
	struct cls_fl_filter *fnew;
	struct nlattr **tb;
	struct fl_flow_mask mask = {};
	unsigned long idr_index;
	int err;

	if (!tca[TCA_OPTIONS])
@@ -896,21 +895,17 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
		goto errout;

	if (!handle) {
		err = idr_alloc_ext(&head->handle_idr, fnew, &idr_index,
				    1, 0x80000000, GFP_KERNEL);
		if (err)
			goto errout;
		fnew->handle = idr_index;
	}

		handle = 1;
		err = idr_alloc_u32(&head->handle_idr, fnew, &handle,
				    INT_MAX, GFP_KERNEL);
	} else if (!fold) {
		/* 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);
		err = idr_alloc_u32(&head->handle_idr, fnew, &handle,
				    handle, GFP_KERNEL);
	}
	if (err)
		goto errout;
		fnew->handle = idr_index;
	}
	fnew->handle = handle;

	if (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,
	*arg = fnew;

	if (fold) {
		fnew->handle = handle;
		idr_replace(&head->handle_idr, fnew, fnew->handle);
		list_replace_rcu(&fold->list, &fnew->list);
		tcf_unbind_filter(tp, &fold->res);